_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q158500
ActivityRecordSearchTerm.parseInt
train
private static int parseInt(String str, int defaultValue) { if (str == null) return defaultValue; return Integer.parseInt(str); }
java
{ "resource": "" }
q158501
ConnectionGroupService.getIdentifiersWithin
train
public Set<String> getIdentifiersWithin(ModeledAuthenticatedUser user, String identifier) throws GuacamoleException { // Bypass permission checks if the user is a system admin if (user.getUser().isAdministrator()) return connectionGroupMapper.selectIdentifiersWithin(...
java
{ "resource": "" }
q158502
TunnelRequestService.fireTunnelConnectEvent
train
private void fireTunnelConnectEvent(AuthenticatedUser authenticatedUser, Credentials credentials, GuacamoleTunnel tunnel) throws GuacamoleException { listenerService.handleEvent(new TunnelConnectEvent(authenticatedUser, credentials, tunnel)); }
java
{ "resource": "" }
q158503
TunnelRequestService.fireTunnelClosedEvent
train
private void fireTunnelClosedEvent(AuthenticatedUser authenticatedUser, Credentials credentials, GuacamoleTunnel tunnel) throws GuacamoleException { listenerService.handleEvent(new TunnelCloseEvent(authenticatedUser, credentials, tunnel)); }
java
{ "resource": "" }
q158504
TunnelRequestService.getClientInformation
train
protected GuacamoleClientInformation getClientInformation(TunnelRequest request) throws GuacamoleException { // Get client information GuacamoleClientInformation info = new GuacamoleClientInformation(); // Set width if provided Integer width = request.getWidth(); if (wi...
java
{ "resource": "" }
q158505
TunnelRequestService.createAssociatedTunnel
train
protected GuacamoleTunnel createAssociatedTunnel(final GuacamoleTunnel tunnel, final String authToken, final GuacamoleSession session, final UserContext context, final TunnelRequest.Type type, final String id) throws GuacamoleException { // Monitor tunnel closure and data ...
java
{ "resource": "" }
q158506
TunnelRequestService.createTunnel
train
public GuacamoleTunnel createTunnel(TunnelRequest request) throws GuacamoleException { // Parse request parameters String authToken = request.getAuthenticationToken(); String id = request.getIdentifier(); TunnelRequest.Type type =...
java
{ "resource": "" }
q158507
TunnelCollectionResource.getTunnel
train
@Path("{tunnel}") public TunnelResource getTunnel(@PathParam("tunnel") String tunnelUUID) throws GuacamoleException { Map<String, UserTunnel> tunnels = session.getTunnels(); // Pull tunnel with given UUID final UserTunnel tunnel = tunnels.get(tunnelUUID); if (tunnel == ...
java
{ "resource": "" }
q158508
ConnectionGroupTree.addConnections
train
private void addConnections(Collection<Connection> connections) throws GuacamoleException { // Add each connection to the tree for (Connection connection : connections) { // Retrieve the connection's parent group APIConnectionGroup parent = retrievedGroups.get(connectio...
java
{ "resource": "" }
q158509
ConnectionGroupTree.addConnectionGroups
train
private void addConnectionGroups(Collection<ConnectionGroup> connectionGroups) { // Add each connection group to the tree for (ConnectionGroup connectionGroup : connectionGroups) { // Retrieve the connection group's parent group APIConnectionGroup parent = retrievedGroups.get(c...
java
{ "resource": "" }
q158510
ConnectionGroupTree.addSharingProfiles
train
private void addSharingProfiles(Collection<SharingProfile> sharingProfiles) throws GuacamoleException { // Add each sharing profile to the tree for (SharingProfile sharingProfile : sharingProfiles) { // Retrieve the sharing profile's associated connection String primary...
java
{ "resource": "" }
q158511
ConnectionGroupTree.addConnectionGroupDescendants
train
private void addConnectionGroupDescendants(Collection<ConnectionGroup> parents, List<ObjectPermission.Type> permissions) throws GuacamoleException { // If no parents, nothing to do if (parents.isEmpty()) return; Collection<String> childConnectionIdentifiers = ne...
java
{ "resource": "" }
q158512
ConnectionGroupTree.addConnectionDescendants
train
private void addConnectionDescendants(Collection<Connection> connections, List<ObjectPermission.Type> permissions) throws GuacamoleException { // If no connections, nothing to do if (connections.isEmpty()) return; // Build lists of sharing profile identifiers fo...
java
{ "resource": "" }
q158513
TunnelRequest.getRequiredParameter
train
public String getRequiredParameter(String name) throws GuacamoleException { // Pull requested parameter, aborting if absent String value = getParameter(name); if (value == null) throw new GuacamoleClientException("Parameter \"" + name + "\" is required."); return value; ...
java
{ "resource": "" }
q158514
TunnelRequest.getIntegerParameter
train
public Integer getIntegerParameter(String name) throws GuacamoleException { // Pull requested parameter String value = getParameter(name); if (value == null) return null; // Attempt to parse as an integer try { return Integer.parseInt(value); } ...
java
{ "resource": "" }
q158515
TunnelRequest.getType
train
public Type getType() throws GuacamoleException { String type = getRequiredParameter(TYPE_PARAMETER); // For each possible object type for (Type possibleType : Type.values()) { // Match against defined parameter value if (type.equals(possibleType.PARAMETER_VALUE)) ...
java
{ "resource": "" }
q158516
PasswordPolicyService.matches
train
private boolean matches(String str, Pattern... patterns) { // Check given string against all provided patterns for (Pattern pattern : patterns) { // Fail overall test if any pattern fails to match Matcher matcher = pattern.matcher(str); if (!matcher.find()) ...
java
{ "resource": "" }
q158517
PasswordPolicyService.matchesPreviousPasswords
train
private boolean matchesPreviousPasswords(String password, String username, int historySize) { // No need to compare if no history is relevant if (historySize <= 0) return false; // Check password against all recorded hashes List<PasswordRecordModel> history = pa...
java
{ "resource": "" }
q158518
PasswordPolicyService.verifyPassword
train
public void verifyPassword(String username, String password) throws GuacamoleException { // Retrieve password policy from environment PasswordPolicy policy = environment.getPasswordPolicy(); // Enforce minimum password length if (password.length() < policy.getMinimumLength(...
java
{ "resource": "" }
q158519
PasswordPolicyService.getPasswordAge
train
private long getPasswordAge(ModeledUser user) { // If no password was set, then no time has elapsed PasswordRecordModel passwordRecord = user.getPasswordRecord(); if (passwordRecord == null) return 0; // Pull both current time and the time the password was last reset ...
java
{ "resource": "" }
q158520
PasswordPolicyService.verifyPasswordAge
train
public void verifyPasswordAge(ModeledUser user) throws GuacamoleException { // Retrieve password policy from environment PasswordPolicy policy = environment.getPasswordPolicy(); long minimumAge = policy.getMinimumAge(); long passwordAge = getPasswordAge(user); // Require that ...
java
{ "resource": "" }
q158521
PasswordPolicyService.isPasswordExpired
train
public boolean isPasswordExpired(ModeledUser user) throws GuacamoleException { // Retrieve password policy from environment PasswordPolicy policy = environment.getPasswordPolicy(); // There is no maximum password age if 0 int maxPasswordAge = policy.getMaximumAge(); ...
java
{ "resource": "" }
q158522
PasswordPolicyService.recordPassword
train
public void recordPassword(ModeledUser user) throws GuacamoleException { // Retrieve password policy from environment PasswordPolicy policy = environment.getPasswordPolicy(); // Nothing to do if history is not being recorded int historySize = policy.getHistorySize(); ...
java
{ "resource": "" }
q158523
SignedDuoCookie.sign
train
private static String sign(String key, String data) throws GuacamoleException { try { // Attempt to sign UTF-8 bytes of provided data Mac mac = Mac.getInstance(SIGNATURE_ALGORITHM); mac.init(new SecretKeySpec(key.getBytes("UTF-8"), SIGNATURE_ALGORITHM)); // Ret...
java
{ "resource": "" }
q158524
UserCredentials.setValue
train
public String setValue(String name, String value) { return values.put(name, value); }
java
{ "resource": "" }
q158525
UserCredentials.setValue
train
public String setValue(Field field, String value) { return setValue(field.getName(), value); }
java
{ "resource": "" }
q158526
ModeledPermissions.isAdministrator
train
public boolean isAdministrator() throws GuacamoleException { SystemPermissionSet systemPermissionSet = getEffective().getSystemPermissions(); return systemPermissionSet.hasPermission(SystemPermission.Type.ADMINISTER); }
java
{ "resource": "" }
q158527
ModeledPermissions.getEffective
train
public Permissions getEffective() { final ModeledAuthenticatedUser authenticatedUser = getCurrentUser(); final Set<String> effectiveGroups; // If this user is the currently-authenticated user, include any // additional effective groups declared by the authentication system if (...
java
{ "resource": "" }
q158528
RadiusConnectionService.createRadiusConnection
train
private RadiusClient createRadiusConnection() throws GuacamoleException { // Create the RADIUS client with the configuration parameters try { return new RadiusClient(InetAddress.getByName(confService.getRadiusServer()), confService.getRadiusShared...
java
{ "resource": "" }
q158529
RadiusConnectionService.setupRadiusAuthenticator
train
private RadiusAuthenticator setupRadiusAuthenticator(RadiusClient radiusClient) throws GuacamoleException { // If we don't have a radiusClient object, yet, don't go any further. if (radiusClient == null) { logger.error("RADIUS client hasn't been set up, yet."); logge...
java
{ "resource": "" }
q158530
RadiusConnectionService.authenticate
train
public RadiusPacket authenticate(String username, String secret, byte[] state) throws GuacamoleException { // If a username wasn't passed, we quit if (username == null || username.isEmpty()) { logger.warn("Anonymous access not allowed with RADIUS client."); return nu...
java
{ "resource": "" }
q158531
RadiusConnectionService.sendChallengeResponse
train
public RadiusPacket sendChallengeResponse(String username, String response, byte[] state) throws GuacamoleException { if (username == null || username.isEmpty()) { logger.error("Challenge/response to RADIUS requires a username."); return null; } if (state ==...
java
{ "resource": "" }
q158532
RelatedObjectSet.canAlterRelation
train
private boolean canAlterRelation(Collection<String> identifiers) throws GuacamoleException { // System administrators may alter any relations if (getCurrentUser().getUser().isAdministrator()) return true; // Non-admin users require UPDATE permission on the parent object...
java
{ "resource": "" }
q158533
RESTMethodMatcher.methodThrowsException
train
private boolean methodThrowsException(Method method, Class<? extends Exception> exceptionType) { // Check whether the method throws an exception of the specified type for (Class<?> thrownType : method.getExceptionTypes()) { if (exceptionType.isAssignableFrom(thrownType)) ...
java
{ "resource": "" }
q158534
GuacamoleHTTPTunnelMap.get
train
public GuacamoleHTTPTunnel get(String uuid) { // Update the last access time GuacamoleHTTPTunnel tunnel = tunnelMap.get(uuid); if (tunnel != null) tunnel.access(); // Return tunnel, if any return tunnel; }
java
{ "resource": "" }
q158535
GuacamoleHTTPTunnelMap.put
train
public void put(String uuid, GuacamoleTunnel tunnel) { tunnelMap.put(uuid, new GuacamoleHTTPTunnel(tunnel)); }
java
{ "resource": "" }
q158536
DirectoryObjectResource.updateObject
train
@PUT public void updateObject(ExternalType modifiedObject) throws GuacamoleException { // Validate that data was provided if (modifiedObject == null) throw new GuacamoleClientException("Data must be submitted when updating objects."); // Filter/sanitize object contents ...
java
{ "resource": "" }
q158537
ConfigurationService.getRadiusCAFile
train
public File getRadiusCAFile() throws GuacamoleException { return environment.getProperty( RadiusGuacamoleProperties.RADIUS_CA_FILE, new File(environment.getGuacamoleHome(), "ca.crt") ); }
java
{ "resource": "" }
q158538
ConfigurationService.getRadiusKeyFile
train
public File getRadiusKeyFile() throws GuacamoleException { return environment.getProperty( RadiusGuacamoleProperties.RADIUS_KEY_FILE, new File(environment.getGuacamoleHome(), "radius.key") ); }
java
{ "resource": "" }
q158539
ModeledDirectoryObjectService.hasObjectPermission
train
protected boolean hasObjectPermission(ModeledAuthenticatedUser user, String identifier, ObjectPermission.Type type) throws GuacamoleException { // Get object permissions ObjectPermissionSet permissionSet = getEffectivePermissionSet(user); // Return whether permi...
java
{ "resource": "" }
q158540
ModeledDirectoryObjectService.getObjectInstances
train
protected Collection<InternalType> getObjectInstances(ModeledAuthenticatedUser currentUser, Collection<ModelType> models) throws GuacamoleException { // Create new collection of objects by manually converting each model Collection<InternalType> objects = new ArrayList<InternalType>(models.s...
java
{ "resource": "" }
q158541
ModeledDirectoryObjectService.isValidIdentifier
train
protected boolean isValidIdentifier(String identifier) { // Empty identifiers are invalid if (identifier.isEmpty()) return false; // Identifier is invalid if any non-numeric characters are present for (int i = 0; i < identifier.length(); i++) { if (!Character.is...
java
{ "resource": "" }
q158542
ModeledDirectoryObjectService.filterIdentifiers
train
protected Collection<String> filterIdentifiers(Collection<String> identifiers) { // Obtain enough space for a full copy of the given identifiers Collection<String> validIdentifiers = new ArrayList<String>(identifiers.size()); // Add only valid identifiers to the copy for (String identi...
java
{ "resource": "" }
q158543
ModeledDirectoryObjectService.getImplicitPermissions
train
protected Collection<ObjectPermissionModel> getImplicitPermissions(ModeledAuthenticatedUser user, ModelType model) { // Build list of implicit permissions Collection<ObjectPermissionModel> implicitPermissions = new ArrayList<ObjectPermissionModel>(IMPLICIT_OBJECT_PER...
java
{ "resource": "" }
q158544
WebApplicationResource.getMimeType
train
private static String getMimeType(ServletContext context, String path) { // If mimetype is known, use defined mimetype String mimetype = context.getMimeType(path); if (mimetype != null) return mimetype; // Otherwise, default to application/octet-stream return "appli...
java
{ "resource": "" }
q158545
NonceService.sweepExpiredNonces
train
private void sweepExpiredNonces() { // Do not sweep until enough time has elapsed since the last sweep long currentTime = System.currentTimeMillis(); if (currentTime - lastSweep < SWEEP_INTERVAL) return; // Record time of sweep lastSweep = currentTime; // F...
java
{ "resource": "" }
q158546
NonceService.generate
train
public String generate(long maxAge) { // Sweep expired nonces if enough time has passed sweepExpiredNonces(); // Generate and store nonce, along with expiration timestamp String nonce = new BigInteger(130, random).toString(32); nonces.put(nonce, System.currentTimeMillis() + max...
java
{ "resource": "" }
q158547
NonceService.isValid
train
public boolean isValid(String nonce) { // Remove nonce, verifying whether it was present at all Long expires = nonces.remove(nonce); if (expires == null) return false; // Nonce is only valid if it hasn't expired return expires > System.currentTimeMillis(); }
java
{ "resource": "" }
q158548
ConnectionService.retrieveParameters
train
public Map<String, String> retrieveParameters(ModeledAuthenticatedUser user, String identifier) { Map<String, String> parameterMap = new HashMap<String, String>(); // Determine whether we have permission to read parameters boolean canRetrieveParameters; try { ca...
java
{ "resource": "" }
q158549
ConnectionService.getObjectInstances
train
protected List<ConnectionRecord> getObjectInstances(List<ConnectionRecordModel> models) { // Create new list of records by manually converting each model List<ConnectionRecord> objects = new ArrayList<ConnectionRecord>(models.size()); for (ConnectionRecordModel model : models) objec...
java
{ "resource": "" }
q158550
ConnectionService.retrieveHistory
train
public List<ConnectionRecord> retrieveHistory(ModeledAuthenticatedUser user, ModeledConnection connection) throws GuacamoleException { String identifier = connection.getIdentifier(); // Retrieve history only if READ permission is granted if (hasObjectPermission(user, identifier, Ob...
java
{ "resource": "" }
q158551
ConnectionService.connect
train
public GuacamoleTunnel connect(ModeledAuthenticatedUser user, ModeledConnection connection, GuacamoleClientInformation info, Map<String, String> tokens) throws GuacamoleException { // Connect only if READ permission is granted if (hasObjectPermission(user, connection.getIdentifi...
java
{ "resource": "" }
q158552
ModeledObjectPermissionService.canAlterPermissions
train
protected boolean canAlterPermissions(ModeledAuthenticatedUser user, ModeledPermissions<? extends EntityModel> targetEntity, Collection<ObjectPermission> permissions) throws GuacamoleException { // A system adminstrator can do anything if (user.getUser().isAdministra...
java
{ "resource": "" }
q158553
ConfigurationService.getUsernameAttributes
train
public List<String> getUsernameAttributes() throws GuacamoleException { return environment.getProperty( LDAPGuacamoleProperties.LDAP_USERNAME_ATTRIBUTE, Collections.singletonList("uid") ); }
java
{ "resource": "" }
q158554
ConfigurationService.getGroupNameAttributes
train
public List<String> getGroupNameAttributes() throws GuacamoleException { return environment.getProperty( LDAPGuacamoleProperties.LDAP_GROUP_NAME_ATTRIBUTE, Collections.singletonList("cn") ); }
java
{ "resource": "" }
q158555
ConfigurationService.getLDAPSearchConstraints
train
public LDAPSearchConstraints getLDAPSearchConstraints() throws GuacamoleException { LDAPSearchConstraints constraints = new LDAPSearchConstraints(); constraints.setMaxResults(getMaxResults()); constraints.setDereference(getDereferenceAliases().DEREF_VALUE); return constraints; }
java
{ "resource": "" }
q158556
ConfigurationService.getAttributes
train
public List<String> getAttributes() throws GuacamoleException { return environment.getProperty( LDAPGuacamoleProperties.LDAP_USER_ATTRIBUTES, Collections.<String>emptyList() ); }
java
{ "resource": "" }
q158557
StreamInterceptingFilter.interceptStream
train
public void interceptStream(int index, T stream) throws GuacamoleException { InterceptedStream<T> interceptedStream; String indexString = Integer.toString(index); // Atomically verify tunnel is open and add the given stream synchronized (tunnel) { // Do nothing if tunnel i...
java
{ "resource": "" }
q158558
DuoCookie.parseDuoCookie
train
public static DuoCookie parseDuoCookie(String str) throws GuacamoleException { // Attempt to decode data as base64 String data; try { data = new String(BaseEncoding.base64().decode(str), "UTF-8"); } // Bail if invalid base64 is provided catch (IllegalArgumen...
java
{ "resource": "" }
q158559
ModeledUser.init
train
public void init(ModeledAuthenticatedUser currentUser, UserModel model, boolean exposeRestrictedAttributes) { super.init(currentUser, model); this.exposeRestrictedAttributes = exposeRestrictedAttributes; }
java
{ "resource": "" }
q158560
ModeledUser.asCalendar
train
private Calendar asCalendar(Calendar base, Time time) { // Get calendar from given SQL time Calendar timeCalendar = Calendar.getInstance(); timeCalendar.setTime(time); // Apply given time to base calendar base.set(Calendar.HOUR_OF_DAY, timeCalendar.get(Calendar.HOUR_OF_DAY)); ...
java
{ "resource": "" }
q158561
ModeledUser.getAccessWindowStart
train
private Calendar getAccessWindowStart() { // Get window start time Time start = getModel().getAccessWindowStart(); if (start == null) return null; // Return within defined time zone, current day return asCalendar(Calendar.getInstance(getTimeZone()), start); }
java
{ "resource": "" }
q158562
ModeledUser.getAccessWindowEnd
train
private Calendar getAccessWindowEnd() { // Get window end time Time end = getModel().getAccessWindowEnd(); if (end == null) return null; // Return within defined time zone, current day return asCalendar(Calendar.getInstance(getTimeZone()), end); }
java
{ "resource": "" }
q158563
ModeledUser.getValidFrom
train
private Calendar getValidFrom() { // Get valid from date Date validFrom = getModel().getValidFrom(); if (validFrom == null) return null; // Convert to midnight within defined time zone Calendar validFromCalendar = Calendar.getInstance(getTimeZone()); validFr...
java
{ "resource": "" }
q158564
ModeledUser.isActive
train
private boolean isActive(Calendar activeStart, Calendar inactiveStart) { // If end occurs before start, convert to equivalent case where start // start is before end if (inactiveStart != null && activeStart != null && inactiveStart.before(activeStart)) return !isActive(inactiveStart...
java
{ "resource": "" }
q158565
ModeledConnectionGroup.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.getDefaultMaxGroupConnections(); // Otherwise use defined value ...
java
{ "resource": "" }
q158566
ModeledConnectionGroup.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.getDefaultMaxGroupConnectionsPerUser(); // O...
java
{ "resource": "" }
q158567
GuacamoleSession.getUserContext
train
public DecoratedUserContext getUserContext(String authProviderIdentifier) throws GuacamoleException { // Locate and return the UserContext associated with the // AuthenticationProvider having the given identifier, if any for (DecoratedUserContext userContext : getUserContexts()) { ...
java
{ "resource": "" }
q158568
GuacamoleSession.invalidate
train
public void invalidate() { // Close all associated tunnels, if possible for (GuacamoleTunnel tunnel : tunnels.values()) { try { tunnel.close(); } catch (GuacamoleException e) { logger.debug("Unable to close tunnel.", e); } ...
java
{ "resource": "" }
q158569
NumericField.parse
train
public static Integer parse(String str) throws NumberFormatException { // Return null if no value provided if (str == null || str.isEmpty()) return null; // Parse as integer return Integer.valueOf(str); }
java
{ "resource": "" }
q158570
GuacamoleHTTPTunnelServlet.sendError
train
protected void sendError(HttpServletResponse response, int guacamoleStatusCode, int guacamoleHttpCode, String message) throws ServletException { try { // If response not committed, send error code and message if (!response.isCommitted()) { respon...
java
{ "resource": "" }
q158571
GuacamoleHTTPTunnelServlet.handleTunnelRequest
train
protected void handleTunnelRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException { try { String query = request.getQueryString(); if (query == null) throw new GuacamoleClientException("No query string provided."); ...
java
{ "resource": "" }
q158572
GuacamoleHTTPTunnelServlet.doRead
train
protected void doRead(HttpServletRequest request, HttpServletResponse response, String tunnelUUID) throws GuacamoleException { // Get tunnel, ensure tunnel exists GuacamoleTunnel tunnel = getTunnel(tunnelUUID); // Ensure tunnel is open if (!tunnel.isOpen()) ...
java
{ "resource": "" }
q158573
GuacamoleHTTPTunnelServlet.doWrite
train
protected void doWrite(HttpServletRequest request, HttpServletResponse response, String tunnelUUID) throws GuacamoleException { GuacamoleTunnel tunnel = getTunnel(tunnelUUID); // We still need to set the content type to avoid the default of // text/html, as such a conte...
java
{ "resource": "" }
q158574
TextField.parse
train
public static String parse(String str) { // Return null if no value provided if (str == null || str.isEmpty()) return null; // Otherwise, return string unmodified return str; }
java
{ "resource": "" }
q158575
RelatedObjectSetPatch.apply
train
public void apply(RelatedObjectSet objects) throws GuacamoleException { // Add any added identifiers if (!addedObjects.isEmpty()) objects.addObjects(addedObjects); // Remove any removed identifiers if (!removedObjects.isEmpty()) objects.removeObjects(removedObje...
java
{ "resource": "" }
q158576
LDAPUserContext.init
train
public void init(AuthenticatedUser user, LDAPConnection ldapConnection) throws GuacamoleException { // Query all accessible users userDirectory = new SimpleDirectory<>( userService.getUsers(ldapConnection) ); // Query all accessible user groups userGroup...
java
{ "resource": "" }
q158577
AuthenticationCodeField.getKeyURI
train
@JsonProperty("keyUri") public URI getKeyURI() throws GuacamoleException { // Do not generate a key URI if no key is being exposed if (key == null) return null; // Format "otpauth" URL (see https://github.com/google/google-authenticator/wiki/Key-Uri-Format) String issue...
java
{ "resource": "" }
q158578
AuthenticationCodeField.getQRCode
train
@JsonProperty("qrCode") public String getQRCode() throws GuacamoleException { // Do not generate a QR code if no key is being exposed URI keyURI = getKeyURI(); if (keyURI == null) return null; ByteArrayOutputStream stream = new ByteArrayOutputStream(); try { ...
java
{ "resource": "" }
q158579
InputStreamInterceptingFilter.sendBlob
train
private void sendBlob(String index, byte[] blob) { // Send "blob" containing provided data sendInstruction(new GuacamoleInstruction("blob", index, BaseEncoding.base64().encode(blob))); }
java
{ "resource": "" }
q158580
InputStreamInterceptingFilter.readNextBlob
train
private void readNextBlob(InterceptedStream<InputStream> stream) { // Read blob from stream if it exists try { // Read raw data from input stream byte[] blob = new byte[6048]; int length = stream.getStream().read(blob); // End stream if no more data ...
java
{ "resource": "" }
q158581
InputStreamInterceptingFilter.handleAck
train
private void handleAck(GuacamoleInstruction instruction) { // Verify all required arguments are present List<String> args = instruction.getArgs(); if (args.size() < 3) return; // Pull associated stream String index = args.get(0); InterceptedStream<InputStrea...
java
{ "resource": "" }
q158582
ConfiguredGuacamoleSocket.expect
train
private GuacamoleInstruction expect(GuacamoleReader reader, String opcode) throws GuacamoleException { // Wait for an instruction GuacamoleInstruction instruction = reader.readInstruction(); if (instruction == null) throw new GuacamoleServerException("End of stream while wai...
java
{ "resource": "" }
q158583
ConnectionResource.getConnectionParameters
train
@GET @Path("parameters") public Map<String, String> getConnectionParameters() throws GuacamoleException { // Pull effective permissions Permissions effective = userContext.self().getEffectivePermissions(); // Retrieve permission sets SystemPermissionSet systemPermis...
java
{ "resource": "" }
q158584
QuickConnectDirectory.create
train
public String create(GuacamoleConfiguration config) throws GuacamoleException { // Get the next available connection identifier. String newConnectionId = Integer.toString(getNextConnectionID()); // Generate a name for the configuration. String name = QCParser.getName(config); ...
java
{ "resource": "" }
q158585
QuickConnectREST.create
train
@POST @Path("create") public Map<String, String> create(@FormParam("uri") String uri) throws GuacamoleException { return Collections.singletonMap("identifier", directory.create(QCParser.getConfiguration(uri))); }
java
{ "resource": "" }
q158586
UserContextResource.getSelfResource
train
@Path("self") public DirectoryObjectResource<User, APIUser> getSelfResource() throws GuacamoleException { return userResourceFactory.create(userContext, userContext.getUserDirectory(), userContext.self()); }
java
{ "resource": "" }
q158587
UserContextResource.getActiveConnectionDirectoryResource
train
@Path("activeConnections") public DirectoryResource<ActiveConnection, APIActiveConnection> getActiveConnectionDirectoryResource() throws GuacamoleException { return activeConnectionDirectoryResourceFactory.create(userContext, userContext.getActiveConnectionDirectory()); }
java
{ "resource": "" }
q158588
UserContextResource.getConnectionDirectoryResource
train
@Path("connections") public DirectoryResource<Connection, APIConnection> getConnectionDirectoryResource() throws GuacamoleException { return connectionDirectoryResourceFactory.create(userContext, userContext.getConnectionDirectory()); }
java
{ "resource": "" }
q158589
UserContextResource.getConnectionGroupDirectoryResource
train
@Path("connectionGroups") public DirectoryResource<ConnectionGroup, APIConnectionGroup> getConnectionGroupDirectoryResource() throws GuacamoleException { return connectionGroupDirectoryResourceFactory.create(userContext, userContext.getConnectionGroupDirectory()); }
java
{ "resource": "" }
q158590
UserContextResource.getSharingProfileDirectoryResource
train
@Path("sharingProfiles") public DirectoryResource<SharingProfile, APISharingProfile> getSharingProfileDirectoryResource() throws GuacamoleException { return sharingProfileDirectoryResourceFactory.create(userContext, userContext.getSharingProfileDirectory()); }
java
{ "resource": "" }
q158591
UserContextResource.getUserDirectoryResource
train
@Path("users") public DirectoryResource<User, APIUser> getUserDirectoryResource() throws GuacamoleException { return userDirectoryResourceFactory.create(userContext, userContext.getUserDirectory()); }
java
{ "resource": "" }
q158592
UserContextResource.getUserGroupDirectoryResource
train
@Path("userGroups") public DirectoryResource<UserGroup, APIUserGroup> getUserGroupDirectoryResource() throws GuacamoleException { return userGroupDirectoryResourceFactory.create(userContext, userContext.getUserGroupDirectory()); }
java
{ "resource": "" }
q158593
GuacamoleWebSocketTunnelServlet.closeConnection
train
private void closeConnection(WsOutbound outbound, int guacamoleStatusCode, int webSocketCode) { try { byte[] message = Integer.toString(guacamoleStatusCode).getBytes("UTF-8"); outbound.close(webSocketCode, ByteBuffer.wrap(message)); } catch (IOException e) { ...
java
{ "resource": "" }
q158594
ConnectionService.getConnections
train
public Map<String, Connection> getConnections(AuthenticatedUser user, LDAPConnection ldapConnection) throws GuacamoleException { // Do not return any connections if base DN is not specified String configurationBaseDN = confService.getConfigurationBaseDN(); if (configurationBaseDN ==...
java
{ "resource": "" }
q158595
AuthenticationProviderService.bindAs
train
private LDAPConnection bindAs(Credentials credentials) throws GuacamoleException { // Get username and password from credentials String username = credentials.getUsername(); String password = credentials.getPassword(); // Require username if (username == null || usernam...
java
{ "resource": "" }
q158596
AuthenticationProviderService.authenticateUser
train
public LDAPAuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException { // Attempt bind LDAPConnection ldapConnection; try { ldapConnection = bindAs(credentials); } catch (GuacamoleException e) { logger.error("Cannot...
java
{ "resource": "" }
q158597
AuthenticationProviderService.getAttributeTokens
train
private Map<String, String> getAttributeTokens(LDAPConnection ldapConnection, String username) throws GuacamoleException { // Get attributes from configuration information List<String> attrList = confService.getAttributes(); // If there are no attributes there is no reason to searc...
java
{ "resource": "" }
q158598
AuthenticationProviderService.getUserContext
train
public LDAPUserContext getUserContext(AuthenticatedUser authenticatedUser) throws GuacamoleException { // Bind using credentials associated with AuthenticatedUser Credentials credentials = authenticatedUser.getCredentials(); LDAPConnection ldapConnection = bindAs(credentials); ...
java
{ "resource": "" }
q158599
ObjectQueryService.getIdentifier
train
public String getIdentifier(LDAPEntry entry, Collection<String> attributes) { // Retrieve the first value of the highest priority identifier attribute for (String identifierAttribute : attributes) { LDAPAttribute identifier = entry.getAttribute(identifierAttribute); if (identifi...
java
{ "resource": "" }