_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q158400
PlacesSampleActivity.initializeDraggablePanel
train
private void initializeDraggablePanel() { draggablePanel.setFragmentManager(getSupportFragmentManager()); draggablePanel.setTopFragment(placeFragment); draggablePanel.setBottomFragment(mapFragment); TypedValue typedValue = new TypedValue(); getResources().getValue(R.dimen.x_scale_factor, typedValue,...
java
{ "resource": "" }
q158401
Transformer.setViewHeight
train
public void setViewHeight(int newHeight) { if (newHeight > 0) { originalHeight = newHeight; RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) view.getLayoutParams(); layoutParams.height = newHeight; view.setLayoutParams(layoutParams); } }
java
{ "resource": "" }
q158402
DraggablePanelApplication.onCreate
train
@Override public void onCreate() { super.onCreate(); MainModule mainModule = new MainModule(this); objectGraph = ObjectGraph.create(mainModule); objectGraph.inject(this); objectGraph.injectStatics(); }
java
{ "resource": "" }
q158403
ExtensionClassLoader.getInstance
train
public static ExtensionClassLoader getInstance(final File extension, final ClassLoader parent) throws GuacamoleException { try { // Attempt to create classloader which loads classes from the given // .jar file return AccessController.doPrivileged(new PrivilegedEx...
java
{ "resource": "" }
q158404
ExtensionClassLoader.getExtensionURL
train
private static URL getExtensionURL(File extension) throws GuacamoleException { // Validate extension file is indeed a file if (!extension.isFile()) throw new GuacamoleException(extension + " is not a file."); try { return extension.toURI().toURL(); }...
java
{ "resource": "" }
q158405
SessionResource.getUserContextResource
train
@Path("data/{dataSource}") public UserContextResource getUserContextResource( @PathParam("dataSource") String authProviderIdentifier) throws GuacamoleException { // Pull UserContext defined by the given auth provider identifier UserContext userContext = session.getUserContex...
java
{ "resource": "" }
q158406
SessionResource.getExtensionResource
train
@Path("ext/{dataSource}") public Object getExtensionResource( @PathParam("dataSource") String authProviderIdentifier) throws GuacamoleException { // Pull UserContext defined by the given auth provider identifier UserContext userContext = session.getUserContext(authProviderId...
java
{ "resource": "" }
q158407
PatchRESTService.readResourceAsString
train
private String readResourceAsString(Resource resource) throws IOException { StringBuilder contents = new StringBuilder(); // Read entire resource into StringBuilder one chunk at a time Reader reader = new InputStreamReader(resource.asStream(), "UTF-8"); try { char buffer[]...
java
{ "resource": "" }
q158408
PatchRESTService.getPatches
train
@GET public List<String> getPatches() throws GuacamoleException { try { // Allocate a list of equal size to the total number of patches List<Resource> resources = patchResourceService.getPatchResources(); List<String> patches = new ArrayList<String>(resources.size()); ...
java
{ "resource": "" }
q158409
ModeledChildDirectoryObject.getParentIdentifier
train
public String getParentIdentifier() { // Translate null parent to proper identifier String parentIdentifier = getModel().getParentIdentifier(); if (parentIdentifier == null) return RootConnectionGroup.IDENTIFIER; return parentIdentifier; }
java
{ "resource": "" }
q158410
ModeledChildDirectoryObject.setParentIdentifier
train
public void setParentIdentifier(String parentIdentifier) { // Translate root identifier back into null if (parentIdentifier != null && parentIdentifier.equals(RootConnectionGroup.IDENTIFIER)) parentIdentifier = null; getModel().setParentIdentifier(parentIdentifier);...
java
{ "resource": "" }
q158411
RelatedObjectSetResource.updateRelatedObjectSet
train
private void updateRelatedObjectSet(APIPatch.Operation operation, RelatedObjectSetPatch relatedObjectSetPatch, String identifier) throws GuacamoleException { // Add or remove object based on operation switch (operation) { // Add object case add: ...
java
{ "resource": "" }
q158412
DirectoryResource.getObjects
train
@GET public Map<String, ExternalType> getObjects( @QueryParam("permission") List<ObjectPermission.Type> permissions) throws GuacamoleException { // An admin user has access to all objects Permissions effective = userContext.self().getEffectivePermissions(); SystemPer...
java
{ "resource": "" }
q158413
DirectoryResource.createObject
train
@POST public ExternalType createObject(ExternalType object) throws GuacamoleException { // Validate that data was provided if (object == null) throw new GuacamoleClientException("Data must be submitted when creating objects."); // Filter/sanitize object contents ...
java
{ "resource": "" }
q158414
DirectoryResource.getObjectResource
train
@Path("{identifier}") public DirectoryObjectResource<InternalType, ExternalType> getObjectResource(@PathParam("identifier") String identifier) throws GuacamoleException { // Retrieve the object having the given identifier InternalType object = directory.get(identifier); ...
java
{ "resource": "" }
q158415
ActiveConnectionMultimap.put
train
public void put(String identifier, ActiveConnectionRecord record) { synchronized (records) { // Get set of active connection records, creating if necessary Set<ActiveConnectionRecord> connections = records.get(identifier); if (connections == null) { connectio...
java
{ "resource": "" }
q158416
ActiveConnectionMultimap.remove
train
public void remove(String identifier, ActiveConnectionRecord record) { synchronized (records) { // Get set of active connection records Set<ActiveConnectionRecord> connections = records.get(identifier); assert(connections != null); // Remove old record ...
java
{ "resource": "" }
q158417
ActiveConnectionMultimap.get
train
public Collection<ActiveConnectionRecord> get(String identifier) { synchronized (records) { // Get set of active connection records Collection<ActiveConnectionRecord> connections = records.get(identifier); if (connections != null) return Collections.unmodifia...
java
{ "resource": "" }
q158418
TrackedActiveConnection.init
train
public void init(ModeledAuthenticatedUser currentUser, ActiveConnectionRecord activeConnectionRecord, boolean includeSensitiveInformation) { super.init(currentUser); this.connectionRecord = activeConnectionRecord; // Copy all non-sensitive data from given record...
java
{ "resource": "" }
q158419
UserGroupService.getUserGroups
train
public Map<String, UserGroup> getUserGroups(LDAPConnection ldapConnection) throws GuacamoleException { // Do not return any user groups if base DN is not specified String groupBaseDN = confService.getGroupBaseDN(); if (groupBaseDN == null) return Collections.emptyMap(); ...
java
{ "resource": "" }
q158420
UserGroupService.getParentUserGroupEntries
train
public List<LDAPEntry> getParentUserGroupEntries(LDAPConnection ldapConnection, String userDN) throws GuacamoleException { // Do not return any user groups if base DN is not specified String groupBaseDN = confService.getGroupBaseDN(); if (groupBaseDN == null) return Coll...
java
{ "resource": "" }
q158421
UserGroupService.getParentUserGroupIdentifiers
train
public Set<String> getParentUserGroupIdentifiers(LDAPConnection ldapConnection, String userDN) throws GuacamoleException { Collection<String> attributes = confService.getGroupNameAttributes(); List<LDAPEntry> userGroups = getParentUserGroupEntries(ldapConnection, userDN); Set<Strin...
java
{ "resource": "" }
q158422
ExtensionRESTService.getAuthenticationProvider
train
private AuthenticationProvider getAuthenticationProvider(String identifier) { // Iterate through all installed AuthenticationProviders, searching for // the given identifier for (AuthenticationProvider authProvider : authProviders) { if (authProvider.getIdentifier().equals(identifie...
java
{ "resource": "" }
q158423
ExtensionRESTService.getExtensionResource
train
@Path("{identifier}") public Object getExtensionResource(@PathParam("identifier") String identifier) throws GuacamoleException { // Retrieve authentication provider having given identifier AuthenticationProvider authProvider = getAuthenticationProvider(identifier); if (authProvi...
java
{ "resource": "" }
q158424
SharedUserContext.init
train
public void init(AuthenticationProvider authProvider, RemoteAuthenticatedUser user) { // Associate the originating authentication provider this.authProvider = authProvider; // Provide access to all connections shared with the given user this.connectionDirectory.init(user); // ...
java
{ "resource": "" }
q158425
TokenValidationService.processUsername
train
public String processUsername(String token) throws GuacamoleException { // Validating the token requires a JWKS key resolver HttpsJwks jwks = new HttpsJwks(confService.getJWKSEndpoint().toString()); HttpsJwksVerificationKeyResolver resolver = new HttpsJwksVerificationKeyResolver(jwks); ...
java
{ "resource": "" }
q158426
UserService.getUsers
train
public Map<String, User> getUsers(LDAPConnection ldapConnection) throws GuacamoleException { // Retrieve all visible user objects Collection<String> attributes = confService.getUsernameAttributes(); List<LDAPEntry> results = queryService.search(ldapConnection, confSe...
java
{ "resource": "" }
q158427
UserService.getUserDNs
train
public List<String> getUserDNs(LDAPConnection ldapConnection, String username) throws GuacamoleException { // Retrieve user objects having a matching username List<LDAPEntry> results = queryService.search(ldapConnection, confService.getUserBaseDN(), confServi...
java
{ "resource": "" }
q158428
GuacamoleWebSocketTunnelServlet.closeConnection
train
private static void closeConnection(Connection connection, int guacamoleStatusCode, int webSocketCode) { connection.close(webSocketCode, Integer.toString(guacamoleStatusCode)); }
java
{ "resource": "" }
q158429
GuacamoleParser.append
train
public int append(char chunk[], int offset, int length) throws GuacamoleException { int charsParsed = 0; // Do not exceed maximum number of elements if (elementCount == INSTRUCTION_MAX_ELEMENTS && state != State.COMPLETE) { state = State.ERROR; throw new GuacamoleServer...
java
{ "resource": "" }
q158430
TOTPGenerator.getMacInstance
train
private static Mac getMacInstance(Mode mode, Key key) throws InvalidKeyException { try { Mac hmac = Mac.getInstance(mode.getAlgorithmName()); hmac.init(key); return hmac; } catch (NoSuchAlgorithmException e) { throw new UnsupportedOper...
java
{ "resource": "" }
q158431
TOTPGenerator.getHMAC
train
private byte[] getHMAC(byte[] message) { try { return getMacInstance(mode, key).doFinal(message); } catch (InvalidKeyException e) { // As the key is verified during construction of the TOTPGenerator, // this should never happen throw new IllegalS...
java
{ "resource": "" }
q158432
TimeZoneField.parse
train
public static String parse(String timeZone) { // Return null if no time zone provided if (timeZone == null || timeZone.isEmpty()) return null; // Otherwise, assume time zone is valid return timeZone; }
java
{ "resource": "" }
q158433
SharingProfileResource.getParameters
train
@GET @Path("parameters") public Map<String, String> getParameters() throws GuacamoleException { // Pull effective permissions Permissions effective = userContext.self().getEffectivePermissions(); // Retrieve permission sets SystemPermissionSet systemPermissions = ef...
java
{ "resource": "" }
q158434
CodeUsageTrackingService.useCode
train
public boolean useCode(String username, String code) throws GuacamoleException { // Repeatedly attempt to use the given code until an explicit success // or failure has occurred UsedCode usedCode = new UsedCode(username, code); for (;;) { // Explicitly invalidat...
java
{ "resource": "" }
q158435
FailoverGuacamoleSocket.handleUpstreamErrors
train
private static void handleUpstreamErrors(GuacamoleInstruction instruction) throws GuacamoleUpstreamException { // Ignore error instructions which are missing the status code List<String> args = instruction.getArgs(); if (args.size() < 2) { logger.debug("Received \"error\...
java
{ "resource": "" }
q158436
ActiveConnectionRecord.init
train
private void init(RemoteAuthenticatedUser user, ModeledConnectionGroup balancingGroup, ModeledConnection connection, ModeledSharingProfile sharingProfile) { this.user = user; this.balancingGroup = balancingGroup; this.connection = connection; this.shar...
java
{ "resource": "" }
q158437
ActiveConnectionRecord.init
train
public void init(RemoteAuthenticatedUser user, ModeledConnectionGroup balancingGroup, ModeledConnection connection) { init(user, balancingGroup, connection, null); }
java
{ "resource": "" }
q158438
ActiveConnectionRecord.init
train
public void init(RemoteAuthenticatedUser user, ActiveConnectionRecord activeConnection, ModeledSharingProfile sharingProfile) { init(user, null, activeConnection.getConnection(), sharingProfile); this.connectionID = activeConnection.getConnectionID(); }
java
{ "resource": "" }
q158439
ActiveConnectionRecord.assignGuacamoleTunnel
train
public GuacamoleTunnel assignGuacamoleTunnel(final GuacamoleSocket socket, String connectionID) { // Create tunnel with given socket this.tunnel = new AbstractGuacamoleTunnel() { @Override public GuacamoleSocket getSocket() { return socket; ...
java
{ "resource": "" }
q158440
TimeField.format
train
public static String format(Date time) { DateFormat timeFormat = new SimpleDateFormat(TimeField.FORMAT); return time == null ? null : timeFormat.format(time); }
java
{ "resource": "" }
q158441
ModeledUserGroup.init
train
public void init(ModeledAuthenticatedUser currentUser, UserGroupModel model, boolean exposeRestrictedAttributes) { super.init(currentUser, model); this.exposeRestrictedAttributes = exposeRestrictedAttributes; }
java
{ "resource": "" }
q158442
DuoService.createSignedRequest
train
public String createSignedRequest(AuthenticatedUser authenticatedUser) throws GuacamoleException { // Generate a cookie associating the username with the integration key DuoCookie cookie = new DuoCookie(authenticatedUser.getIdentifier(), confService.getIntegrationKey(), ...
java
{ "resource": "" }
q158443
RESTExceptionMapper.getAuthenticationToken
train
private String getAuthenticationToken() { String token = request.getParameter("token"); if (token != null && !token.isEmpty()) return token; return null; }
java
{ "resource": "" }
q158444
ObjectPermissionSet.init
train
public void init(ModeledAuthenticatedUser currentUser, ModeledPermissions<? extends EntityModel> entity, Set<String> effectiveGroups) { super.init(currentUser); this.entity = entity; this.effectiveGroups = effectiveGroups; }
java
{ "resource": "" }
q158445
AbstractGuacamoleTunnelService.getGuacamoleConfiguration
train
private GuacamoleConfiguration getGuacamoleConfiguration(RemoteAuthenticatedUser user, ModeledConnection connection) { // Generate configuration from available data GuacamoleConfiguration config = new GuacamoleConfiguration(); // Set protocol from connection ConnectionModel...
java
{ "resource": "" }
q158446
AbstractGuacamoleTunnelService.getGuacamoleConfiguration
train
private GuacamoleConfiguration getGuacamoleConfiguration(RemoteAuthenticatedUser user, ModeledSharingProfile sharingProfile, String connectionID) { // Generate configuration from available data GuacamoleConfiguration config = new GuacamoleConfiguration(); config.setConnectionID(conn...
java
{ "resource": "" }
q158447
AbstractGuacamoleTunnelService.saveConnectionRecord
train
private void saveConnectionRecord(ActiveConnectionRecord record) { // Get associated models ConnectionRecordModel recordModel = new ConnectionRecordModel(); // Copy user information and timestamps into new record recordModel.setUsername(record.getUsername()); recordModel.setCon...
java
{ "resource": "" }
q158448
AbstractGuacamoleTunnelService.getUnconfiguredGuacamoleSocket
train
private GuacamoleSocket getUnconfiguredGuacamoleSocket( GuacamoleProxyConfiguration proxyConfig, Runnable socketClosedCallback) throws GuacamoleException { // Select socket type depending on desired encryption switch (proxyConfig.getEncryptionMethod()) { // Use SSL ...
java
{ "resource": "" }
q158449
AbstractGuacamoleTunnelService.getPreferredConnections
train
private Collection<String> getPreferredConnections(ModeledAuthenticatedUser user, Collection<String> identifiers) { // Search provided identifiers for any preferred connections for (String identifier : identifiers) { // If at least one prefferred connection is found, assume it ...
java
{ "resource": "" }
q158450
AbstractGuacamoleTunnelService.getBalancedConnections
train
private List<ModeledConnection> getBalancedConnections(ModeledAuthenticatedUser user, ModeledConnectionGroup connectionGroup) { // If not a balancing group, there are no balanced connections if (connectionGroup.getType() != ConnectionGroup.Type.BALANCING) return Collections.<Mod...
java
{ "resource": "" }
q158451
LDAPAuthenticatedUser.init
train
public void init(Credentials credentials, Map<String, String> tokens, Set<String> effectiveGroups) { this.credentials = credentials; this.tokens = Collections.unmodifiableMap(tokens); this.effectiveGroups = effectiveGroups; setIdentifier(credentials.getUsername()); }
java
{ "resource": "" }
q158452
TokenName.fromAttribute
train
public static String fromAttribute(String name) { // If even one logical word grouping cannot be found, default to // simply converting the attribute to uppercase and adding the // prefix Matcher groupMatcher = LDAP_ATTRIBUTE_NAME_GROUPING.matcher(name); if (!groupMatcher.find()...
java
{ "resource": "" }
q158453
QCParser.getConfiguration
train
public static GuacamoleConfiguration getConfiguration(String uri) throws GuacamoleException { // Parse the provided String into a URI object. URI qcUri; try { qcUri = new URI(uri); if (!qcUri.isAbsolute()) throw new QuickConnectException("URI ...
java
{ "resource": "" }
q158454
QCParser.parseUserInfo
train
public static void parseUserInfo(String userInfo, GuacamoleConfiguration config) throws UnsupportedEncodingException { Matcher userinfoMatcher = userinfoPattern.matcher(userInfo); if (userinfoMatcher.matches()) { String username = userinfoMatcher.group(USERNAME_GRO...
java
{ "resource": "" }
q158455
QCParser.getName
train
public static String getName(GuacamoleConfiguration config) throws GuacamoleException { if (config == null) return null; String protocol = config.getProtocol(); String host = config.getParameter("hostname"); String port = config.getParameter("port"); Str...
java
{ "resource": "" }
q158456
UserVerificationService.verifyAuthenticatedUser
train
public void verifyAuthenticatedUser(AuthenticatedUser authenticatedUser) throws GuacamoleException { // Pull the original HTTP request used to authenticate Credentials credentials = authenticatedUser.getCredentials(); HttpServletRequest request = credentials.getRequest(); /...
java
{ "resource": "" }
q158457
Authorization.getHexString
train
private static String getHexString(byte[] bytes) { // If null byte array given, return null if (bytes == null) return null; // Create string builder for holding the hex representation, // pre-calculating the exact length StringBuilder hex = new StringBuilder(2 * byt...
java
{ "resource": "" }
q158458
ModeledChildDirectoryObjectService.canUpdateModifiedParents
train
protected boolean canUpdateModifiedParents(ModeledAuthenticatedUser user, String identifier, ModelType model) throws GuacamoleException { // If user is an administrator, no need to check if (user.getUser().isAdministrator()) return true; // Verify that we have p...
java
{ "resource": "" }
q158459
Extension.getClassPathResources
train
private Map<String, Resource> getClassPathResources(String mimetype, Collection<String> paths) { // If no paths are provided, just return an empty map if (paths == null) return Collections.<String, Resource>emptyMap(); // Add classpath resource for each path provided Map<S...
java
{ "resource": "" }
q158460
Extension.getClassPathResources
train
private Map<String, Resource> getClassPathResources(Map<String, String> resourceTypes) { // If no paths are provided, just return an empty map if (resourceTypes == null) return Collections.<String, Resource>emptyMap(); // Add classpath resource for each path/mimetype pair provided...
java
{ "resource": "" }
q158461
Extension.getAuthenticationProviderClass
train
@SuppressWarnings("unchecked") // We check this ourselves with isAssignableFrom() private Class<AuthenticationProvider> getAuthenticationProviderClass(String name) throws GuacamoleException { try { // Get authentication provider class Class<?> authenticationProviderClas...
java
{ "resource": "" }
q158462
Extension.getAuthenticationProviderClasses
train
private Collection<Class<AuthenticationProvider>> getAuthenticationProviderClasses(Collection<String> names) throws GuacamoleException { // If no classnames are provided, just return an empty list if (names == null) return Collections.<Class<AuthenticationProvider>>emptyList(); ...
java
{ "resource": "" }
q158463
Extension.getListenerClass
train
@SuppressWarnings("unchecked") // We check this ourselves with isAssignableFrom() private Class<Listener> getListenerClass(String name) throws GuacamoleException { try { // Get listener class Class<?> listenerClass = classLoader.loadClass(name); // Verify t...
java
{ "resource": "" }
q158464
Extension.getListenerClasses
train
private Collection<Class<?>> getListenerClasses(Collection<String> names) throws GuacamoleException { // If no classnames are provided, just return an empty list if (names == null) return Collections.<Class<?>>emptyList(); // Define all auth provider classes Col...
java
{ "resource": "" }
q158465
ActiveConnectionResource.getConnection
train
@Path("connection") public DirectoryObjectResource<Connection, APIConnection> getConnection() throws GuacamoleException { // Return the underlying connection as a resource return connectionDirectoryResourceFactory .create(userContext, userContext.getConnectionDirectory()...
java
{ "resource": "" }
q158466
GuacamoleWebSocketTunnelListener.closeConnection
train
private void closeConnection(Session session, int guacamoleStatusCode, int webSocketCode) { try { String message = Integer.toString(guacamoleStatusCode); session.close(new CloseStatus(webSocketCode, message)); } catch (IOException e) { logger.debu...
java
{ "resource": "" }
q158467
UserVerificationService.getKey
train
private UserTOTPKey getKey(UserContext context, String username) throws GuacamoleException { // Retrieve attributes from current user User self = context.self(); Map<String, String> attributes = context.self().getAttributes(); // If no key is defined, attempt to generate a ...
java
{ "resource": "" }
q158468
UserVerificationService.setKey
train
private boolean setKey(UserContext context, UserTOTPKey key) throws GuacamoleException { // Get mutable set of attributes User self = context.self(); Map<String, String> attributes = new HashMap<String, String>(); // Set/overwrite current TOTP key state attributes.p...
java
{ "resource": "" }
q158469
UserVerificationService.verifyIdentity
train
public void verifyIdentity(UserContext context, AuthenticatedUser authenticatedUser) throws GuacamoleException { // Ignore anonymous users String username = authenticatedUser.getIdentifier(); if (username.equals(AuthenticatedUser.ANONYMOUS_IDENTIFIER)) return; /...
java
{ "resource": "" }
q158470
OutputStreamInterceptingFilter.handleBlob
train
private GuacamoleInstruction handleBlob(GuacamoleInstruction instruction) { // Verify all required arguments are present List<String> args = instruction.getArgs(); if (args.size() < 2) return instruction; // Pull associated stream String index = args.get(0); ...
java
{ "resource": "" }
q158471
OutputStreamInterceptingFilter.handleEnd
train
private void handleEnd(GuacamoleInstruction instruction) { // Verify all required arguments are present List<String> args = instruction.getArgs(); if (args.size() < 1) return; // Terminate stream closeInterceptedStream(args.get(0)); }
java
{ "resource": "" }
q158472
SimpleObjectPermissionSet.createPermissions
train
private static Set<ObjectPermission> createPermissions(Collection<String> identifiers, Collection<ObjectPermission.Type> types) { // Add a permission of each type to the set for each identifier given Set<ObjectPermission> permissions = new HashSet<>(identifiers.size()); types.forEac...
java
{ "resource": "" }
q158473
APIPermissionSet.addSystemPermissions
train
private void addSystemPermissions(Set<SystemPermission.Type> permissions, SystemPermissionSet permSet) throws GuacamoleException { // Add all provided system permissions for (SystemPermission permission : permSet.getPermissions()) permissions.add(permission.getType()); }
java
{ "resource": "" }
q158474
APIPermissionSet.addObjectPermissions
train
private void addObjectPermissions(Map<String, Set<ObjectPermission.Type>> permissions, ObjectPermissionSet permSet) throws GuacamoleException { // Add all provided object permissions for (ObjectPermission permission : permSet.getPermissions()) { // Get associated set of permis...
java
{ "resource": "" }
q158475
ListenerFactory.createListenerAdapters
train
@SuppressWarnings("deprecation") private static List<Listener> createListenerAdapters(Object provider) { final List<Listener> listeners = new ArrayList<Listener>(); if (provider instanceof AuthenticationSuccessListener) { listeners.add(new AuthenticationSuccessListenerAdapter( ...
java
{ "resource": "" }
q158476
ConnectionSharingService.generateTemporaryCredentials
train
public UserCredentials generateTemporaryCredentials(ModeledAuthenticatedUser user, ActiveConnectionRecord activeConnection, String sharingProfileIdentifier) throws GuacamoleException { // Pull sharing profile (verifying access) ModeledSharingProfile sharingProfile = ...
java
{ "resource": "" }
q158477
ConnectionSharingService.getShareKey
train
public String getShareKey(Credentials credentials) { // Pull associated HTTP request HttpServletRequest request = credentials.getRequest(); if (request == null) return null; // Retrieve the share key from the request return request.getParameter(SHARE_KEY_NAME); ...
java
{ "resource": "" }
q158478
ConnectionSharingService.retrieveSharedConnectionUser
train
public SharedAuthenticatedUser retrieveSharedConnectionUser( AuthenticationProvider authProvider, Credentials credentials) { // Validate the share key String shareKey = getShareKey(credentials); if (shareKey == null || connectionMap.get(shareKey) == null) return null; ...
java
{ "resource": "" }
q158479
TokenFilter.setTokens
train
public void setTokens(Map<String, String> tokens) { tokenValues.clear(); tokenValues.putAll(tokens); }
java
{ "resource": "" }
q158480
TokenFilter.filter
train
public String filter(String input) { StringBuilder output = new StringBuilder(); Matcher tokenMatcher = tokenPattern.matcher(input); // Track last regex match int endOfLastMatch = 0; // For each possible token while (tokenMatcher.find()) { // Pull possible...
java
{ "resource": "" }
q158481
TokenFilter.filterValues
train
public void filterValues(Map<?, String> map) { // For each map entry for (Map.Entry<?, String> entry : map.entrySet()) { // If value is non-null, filter value through this TokenFilter String value = entry.getValue(); if (value != null) entry.setValue...
java
{ "resource": "" }
q158482
LanguageResourceService.getLanguageKey
train
public String getLanguageKey(String path) { // Parse language key from filename Matcher languageKeyMatcher = LANGUAGE_KEY_PATTERN.matcher(path); if (!languageKeyMatcher.matches()) return null; // Return parsed key return languageKeyMatcher.group(1); }
java
{ "resource": "" }
q158483
LanguageResourceService.mergeTranslations
train
private JsonNode mergeTranslations(JsonNode original, JsonNode overlay) { // If we are at a leaf node, the result of merging is simply the overlay if (!overlay.isObject() || original == null) return overlay; // Create mutable copy of original ObjectNode newNode = JsonNodeFa...
java
{ "resource": "" }
q158484
LanguageResourceService.parseLanguageResource
train
private JsonNode parseLanguageResource(Resource resource) throws IOException { // Get resource stream InputStream stream = resource.asStream(); if (stream == null) return null; // Parse JSON tree try { JsonNode tree = mapper.readTree(stream); ...
java
{ "resource": "" }
q158485
LanguageResourceService.addLanguageResource
train
public void addLanguageResource(String key, Resource resource) { // Skip loading of language if not allowed if (!isLanguageAllowed(key)) { logger.debug("OMITTING language: \"{}\"", key); return; } // Merge language resources if already defined Resource e...
java
{ "resource": "" }
q158486
RestrictedGuacamoleTunnelService.tryAdd
train
private <T> boolean tryAdd(ConcurrentHashMultiset<T> multiset, T value, int max) { // Repeatedly attempt to add a new value to the given multiset until we // explicitly succeed or explicitly fail while (true) { // Get current number of values int count = multiset.count(...
java
{ "resource": "" }
q158487
RestrictedGuacamoleTunnelService.tryIncrement
train
private boolean tryIncrement(AtomicInteger counter, int max) { // Repeatedly attempt to increment the given AtomicInteger until we // explicitly succeed or explicitly fail while (true) { // Get current value int count = counter.get(); // Bail out if the max...
java
{ "resource": "" }
q158488
DirectoryClassLoader.getInstance
train
public static DirectoryClassLoader getInstance(final File dir) throws GuacamoleException { try { // Attempt to create singleton classloader which loads classes from // all .jar's in the lib directory defined in guacamole.properties return AccessController.doPrivi...
java
{ "resource": "" }
q158489
DirectoryClassLoader.getJarURLs
train
private static URL[] getJarURLs(File dir) throws GuacamoleException { // Validate directory is indeed a directory if (!dir.isDirectory()) throw new GuacamoleException(dir + " is not a directory."); // Get list of URLs for all .jar's in the lib directory Collection<URL> jarU...
java
{ "resource": "" }
q158490
AuthenticationProviderFacade.warnAuthProviderSkipped
train
private void warnAuthProviderSkipped(Throwable e) { logger.warn("The \"{}\" authentication provider has been skipped due " + "to an internal error. If this is unexpected or you are the " + "developer of this authentication provider, you may wish to " + "enable de...
java
{ "resource": "" }
q158491
AuthenticationProviderFacade.warnAuthAborted
train
private void warnAuthAborted() { String identifier = getIdentifier(); logger.warn("The \"{}\" authentication provider has encountered an " + "internal error which will halt the authentication " + "process. If this is unexpected or you are the developer of " ...
java
{ "resource": "" }
q158492
ModeledConnection.getMaxConnections
train
public int getMaxConnections() throws GuacamoleException { // Pull default from environment if connection limit is unset Integer value = getModel().getMaxConnections(); if (value == null) return environment.getDefaultMaxConnections(); // Otherwise use defined value ...
java
{ "resource": "" }
q158493
ModeledConnection.getMaxConnectionsPerUser
train
public int getMaxConnectionsPerUser() throws GuacamoleException { // Pull default from environment if per-user connection limit is unset Integer value = getModel().getMaxConnectionsPerUser(); if (value == null) return environment.getDefaultMaxConnectionsPerUser(); // Otherw...
java
{ "resource": "" }
q158494
ModeledConnection.getGuacamoleProxyConfiguration
train
public GuacamoleProxyConfiguration getGuacamoleProxyConfiguration() throws GuacamoleException { // Retrieve default proxy configuration from environment GuacamoleProxyConfiguration defaultConfig = environment.getDefaultGuacamoleProxyConfiguration(); // Retrieve proxy configuration ...
java
{ "resource": "" }
q158495
ListenerService.handleEvent
train
@Override public void handleEvent(Object event) throws GuacamoleException { for (final Listener listener : listeners) { listener.handleEvent(event); } }
java
{ "resource": "" }
q158496
LocalEnvironment.readProtocols
train
private Map<String, ProtocolInfo> readProtocols() { // Map of all available protocols Map<String, ProtocolInfo> protocols = new HashMap<String, ProtocolInfo>(); // Get protcols directory File protocol_directory = new File(getGuacamoleHome(), "protocols"); // Read protocols fro...
java
{ "resource": "" }
q158497
LocalEnvironment.getPropertyValue
train
private String getPropertyValue(String name) { // Check for corresponding environment variable if overrides enabled if (environmentPropertiesEnabled) { // Transform the name according to common convention final String envName = name.replace('-', '_').toUpperCase(); ...
java
{ "resource": "" }
q158498
TokenRESTService.getCredentials
train
private Credentials getCredentials(HttpServletRequest request, String username, String password) { // If no username/password given, try Authorization header if (username == null && password == null) { String authorization = request.getHeader("Authorization"); if (a...
java
{ "resource": "" }
q158499
TokenRESTService.invalidateToken
train
@DELETE @Path("/{token}") public void invalidateToken(@PathParam("token") String authToken) throws GuacamoleException { // Invalidate session, if it exists if (!authenticationService.destroyGuacamoleSession(authToken)) throw new GuacamoleResourceNotFoundException("No suc...
java
{ "resource": "" }