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));

    }
public UserCredentials generateTemporaryCredentials ( ModeledAuthenticatedUser user , ActiveConnectionRecord activeConnection , String sharingProfileIdentifier ) throws GuacamoleException { ModeledSharingProfile sharingProfile = sharingProfileService . retrieveObject ( user , sharingProfileIdentifier ) ; String connectionIdentifier = activeConnection . getConnectionIdentifier ( ) ; if ( sharingProfile == null || ! sharingProfile . getPrimaryConnectionIdentifier ( ) . equals ( connectionIdentifier ) ) throw new GuacamoleSecurityException ( "Permission denied." ) ; String key = keyGenerator . getShareKey ( ) ; connectionMap . add ( new SharedConnectionDefinition ( activeConnection , sharingProfile , key ) ) ; activeConnection . registerShareKey ( key ) ; 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.

@param user
The user sharing the connection.

@param activeConnection
The active connection being shared.

@param sharingProfileIdentifier
The identifier of the sharing profile dictating the semantics or
restrictions applying to the shared session.

@return
A newly-generated set of temporary credentials which can be used to
connect to the given connection.

@throws GuacamoleException
If permission to share the given connection is denied.