public UserCredentials generateTemporaryCredentials ( ModeledAuthenticatedUser user , ActiveConnectionRecord activeConnection , String sharingProfileIdentifier ) throws GuacamoleException { // Pull sharing profile (verifying access) ModeledSharingProfile sharingProfile = sharingProfileService . retrieveObject ( user , sharingProfileIdentifier ) ; // Verify that this profile is indeed a sharing profile for the // requested connection String connectionIdentifier = activeConnection . getConnectionIdentifier ( ) ; if ( sharingProfile == null || ! sharingProfile . getPrimaryConnectionIdentifier ( ) . equals ( connectionIdentifier ) ) throw new GuacamoleSecurityException ( "Permission denied." ) ; // Generate a share key for the requested connection String key = keyGenerator . getShareKey ( ) ; connectionMap . add ( new SharedConnectionDefinition ( activeConnection , sharingProfile , key ) ) ; // Ensure the share key is properly invalidated when the original // connection is closed activeConnection . registerShareKey ( key ) ; // Return credentials defining a single expected parameter return new UserCredentials ( SHARE_KEY , Collections . singletonMap ( SHARE_KEY_NAME , key ) ) ; }
Generates a set of temporary credentials which can be used to connect to the given connection using the given sharing profile . If the user does not have permission to share the connection via the given sharing profile permission will be denied .