OAuth 2.0 mapping rule methods

Methods are available for you to use in the PreTokenGeneration and PostTokenGeneration mapping rules.

Sample mapping rules are in Manage System Settings > Secure Settings > File Downloads > mga > example > demo > demo_rules.

The following limitations affect the attribute keys and values that are associated with the state_id by using the OAuthMappingExtUtils class:
  • Keys cannot be null or empty.
  • Values cannot be null but can be empty.
  • Key-value pairs that are associated are read and write-allowed and not-sensitive.
  • Some keys are reserved for system use and cannot be modified by this utility. For example, the keys and values for the API PIN protection.
associate
public static boolean associate(
   String stateID,
   String attrKey, 
   String attrValue
)
This method associates the attribute key-value pair to the authorization grant state ID. Use the following parameters:
  • stateID - The state ID of the authorization grant. This parameter cannot be null or empty.
  • attrKey - The attribute key. This parameter cannot be null or empty. The maximum length is 256 characters.
  • attrValue - The attribute value. This parameter cannot be null. The maximum length is 256 characters.
These responses come from the runtime after association.
  • True if successful.
  • False if not successful.
disassociate
public static String disassociate( 
   String stateID, 
   String attrKey
)
This method disassociates the attribute key-value pair from the authorization grant state ID. Use the following parameters:
  • stateID - The state ID of the authorization grant. This parameter cannot be null or empty.
  • attrKey - The attribute key to disassociate. This parameter cannot be null or empty.
These responses come from the runtime after disassociation.
  • The previous string value that is associated with the state ID and attribute key if successful.
  • Null if not successful. For example, when association is never made.
getAssociationKeys
public static String[] getAssociationKeys(
   String stateID
)
This method gets all the attribute keys that are associated with the authorization grant state ID. Use the following parameter:
  • stateID - The state ID of the authorization grant. This parameter cannot be null or empty.
These responses come from the runtime after it gets the association keys.
  • A string array of all attribute keys that are associated with the authorization grant state ID if successful.
  • Null if state ID is wrong, if there are problems during retrieval from the token cache, or there are no associated attributes.
getAssociation
public static String getAssociation( 
   String stateID, 
   String attrKey
)
This method gets the attribute value from the authorization grant state ID and attribute key. Use the following parameters:
  • stateID - The state ID of the authorization grant. This parameter cannot be null or empty.
  • attrKey - The attribute key value that you want to be returned. This parameter cannot be null or empty.
These responses come from the runtime after it gets the association keys.
  • The string value that is associated with the state ID and attribute key if successful.
  • Null if not successful. For example, when the association is never made.
throwSTSException
public static void throwSTSException( 
   String message
)
This method returns an STSException. Use the following parameter:
  • message - The message to be printed along with the stack trace in the application log. A generic response is returned to the client. The input message that is passed can only be logged and is not visible to the client.
throwSTSUserMessageException
public static void throwSTSUserMessageException( 
   String message
)
This method returns an STSUserMessageException. Use the following parameter:
  • message - The message to be printed along with the stack trace in the application log and returned in the response to the client. The input message is logged and visible to the client.
HTTP GET
public static HttpResponse httpGet(
   String url, 
)
This method sends a HTTP GET request. Use the following parameters:
  • url - The URL to send the GET request.
This request returns an HttpResponse. The request becomes null when there is no response or when it contains wrong parameters.
HTTP GET
public static HttpResponse httpGet(
   String url,
   Map headers,
   String httpsTrustStore,
   String basicAuthUsername,
   String basicAuthPassword,
   String clientKeyStore,
   String clientKeyAlias
)
This method sends a HTTP GET request. Use the following parameters:
  • url - The URL to send the GET request.
  • headers - A map of the headers.
  • httpsTrustStore - The truststore name. If this parameter is null and SSL connection is required, use the default truststore.
  • basicAuthUsername - The user name for basic authentication. If this parameter is null, the basic authentication is not enabled.
  • basicAuthPassword - The password that is used for basic authentication. If null, basic authentication is not enabled.
  • clientKeyStore - The client keystore name. If this parameter is null, client certificate authentication is not enabled.
  • clientKeyAlias - The client key alias. If this parameter is null, client certificate authentication is not enabled.
This request returns an HttpResponse. The request becomes null when there is no response or when it contains wrong parameters.
HTTP POST
public static HttpResponse httpPost(
   String url,
   Map params
)
This method sends a HTTP POST request. Use the following parameters:
  • url - The URL to send the POST request.
  • params- A map of the parameters.
This request returns an HttpResponse. The request becomes null when there is no response or when it contains wrong parameters.
HTTP POST
public static HttpResponse httpPost(
   String url,
   Map headers,
   Map params,
   String httpsTrustStore,
   String basicAuthUsername,
   String basicAuthPassword,
   String clientKeyStore,
   String clientKeyAlias
)
This method sends a HTTP POST request. Use the following parameters:
  • url - The URL to send the GET request.
  • headers - A map of the headers.
  • httpsTrustStore - The truststore name. If this parameter is null and SSL connection is required, use the default truststore.
  • basicAuthUsername - The user name for basic authentication. If this parameter is null, the basic authentication is not enabled.
  • basicAuthPassword - The password that is used for basic authentication. If null, basic authentication is not enabled.
  • clientKeyStore - The client keystore name. If this parameter is null, client certificate authentication is not enabled.
  • clientKeyAlias - The client key alias. If this parameter is null, client certificate authentication is not enabled.
This request returns an HttpResponse. The request becomes null when there is no response or when it contains wrong parameters.
HTTPResponse
public int getCode()
This method gets the HTTP response code.
This method returns the HttpResponse code. The method returns -1 if the response code is not set.
HTTPResponse
public String getBody()
This method gets the HTTP response body.
This method returns the HTTP response body. The method returns an empty string if the response body is not set.
HTTPResponse
public String[] getHeaderKeys()
This method gets the HTTP response header keys.
This method returns a string array of the HTTP response header keys. This method returns an empty array if there are no headers.
HTTPResponse
public String[] getHeaderValues(
   String key
)
This method gets the HTTP response header values for the key.
This method returns a string array of the HTTP response header values for the key. This method returns an empty array if there is no value for the header key.

For more information, see the Javadoc in Manage System Settings > Secure Settings > File Downloads > mga > doc.

tokenID
public static Boolean deleteToken (

      String tokenID

)
This method deletes the token from the token cache. Use the following parameter:
  • tokenID - The token ID of the token to be deleted. This parameter cannot be null or empty.