000025229 - How to use RSA ClearTrust Runtime API to get new token for user

Document created by RSA Customer Support Employee on Jun 16, 2016Last modified by RSA Customer Support Employee on Apr 21, 2017
Version 2Show Document
  • View in full screen mode

Article Content

Article Number000025229
Applies ToRSA ClearTrust 5.5.x Runtime API
IssueHow to use RSA ClearTrust Runtime API to get new token for user
Use Runtime API to get new token for user
ResolutionGenerally, using the authenticate( ) method to authenticate a user will result in a new, valid token being created. In the following code, userId is the username, password is the user's current, valid password, and proxy is an instance of a connected RuntimeAPI interface:

public String getToken( String userId, String password ) throws Exception
{
    Map userProps = new HashMap( ) ;
    userProps.put( UserConstants.SC_USER_ID, userId ) ;
    userProps.put( UserConstants.CREDENTIALS, password ) ;
    userProps.put( UserConstants.AUTHENTICATION_TYPE, AuthTypes.SC_BASIC ) ;

    Map result = proxy.authenticate( userProps ) ;
    String authResult = (String) result.get( ResultConstants.AUTHORIZATION_RESULT ) ;
    if( authResult.equals( ResultConstants.VALID_USER ) )
        return (String) result.SC_TOKEN ;
    else
        throw new Exception( "Auth failed: "
            + (String) ResultConstants.AUTHORIZATION_RESULT ) ;
}


After authenticating, it's not necessary to use the createToken( ) function to generate a token, and doing so will generate an invalid token since the token result has all authentication flags initialized to false.

Legacy Article IDa25494

Attachments

    Outcomes