private void setSsoTokenCredential ( Subject subject , String principalAccessId ) throws CredentialException { try { TokenManager tokenManager = tokenManagerRef . getService ( ) ; SingleSignonToken ssoToken = null ; Set < Token > tokens = subject . getPrivateCredentials ( Token . class ) ; if ( tokens . isEmpty ( ) == false ) { Token ssoLtpaToken = tokens . iterator ( ) . next ( ) ; subject . getPrivateCredentials ( ) . remove ( ssoLtpaToken ) ; ssoToken = tokenManager . createSSOToken ( ssoLtpaToken ) ; } else { Map < String , Object > tokenData = new HashMap < String , Object > ( ) ; tokenData . put ( "unique_id" , principalAccessId ) ; ssoToken = tokenManager . createSSOToken ( tokenData ) ; } subject . getPrivateCredentials ( ) . add ( ssoToken ) ; } catch ( TokenCreationFailedException e ) { throw new CredentialException ( e . getLocalizedMessage ( ) ) ; } }
Create an SSO token for the specified accessId .