Newer Version Available
TokenUtility Class
Namespace
Example
Call the generateToken() method to generate a single token for a specified Salesforce record ID:
1Individual individual = [SELECT Id FROM Individual LIMIT 1];
2String token = pref_center.TokenUtility.generateToken(individual.Id);
3// Do something with the token
4System.debug(token)Call the generateTokens() method to generate tokens in bulk when given a list of Salesforce record IDs:
1List<Id> individualIds = new List<Id>();
2// Get Ids of Individuals who have not opted out of tracking
3for (Individual individual : [SELECT Id FROM Individual WHERE HasOptedOutTracking = false]) {
4 individualIds.add(individual.Id);
5}
6// Generate tokens for the list of Individual record Ids
7Map<String, String> tokens = pref_center.TokenUtility.generateTokens(individualIds);
8String firstIndividualId = individualIds[0];
9// The returned Map has the input record Id as key and the corresponding token as value
10String tokenForFirstIndividual = tokens.get(firstIndividualId);
11// Do something with the token
12System.debug(tokenForFirstIndividual);TokenUtility Methods
The following are methods for TokenUtility.
generateToken(tokenValue, tokenType)
Signature
public static String generateToken(String tokenValue, pref_center.TokenType tokenType)
Parameters
- tokenValue
- Type: String
- The value passed to LoadParameters.getRecordId() and SubmitParameters.getRecordId(). Identifies the entity that the preference form is acting on.
- tokenType
- Type: pref_center.TokenType
- Specifies the type of the value to be encrypted with authentication tokens.
Return Value
Type: String
generateToken(tokenValue)
Returns the authentication token for the specified token value using
the default standard token type.
Signature
public static String generateToken(String tokenValue)
Parameters
- tokenValue
- Type: String
- Identifies the entity that the preference form is acting on. The value passed to LoadParameters.getRecordId() and SubmitParameters.getRecordId().
Return Value
Type: String
generateTokens(tokenValues, tokenType)
Returns the authentication tokens in the form of a map, where the map
key is the input value to be tokenized and the map value is the corresponding token. The given
token type is used to generate the tokens.
Signature
public static Map<String,String> generateTokens(List<String> tokenValues, pref_center.TokenType tokenType)
Parameters
- tokenValues
- Type: List<String>
- The values passed to LoadParameters.getRecordId() and SubmitParameters.getRecordId(). Identifies the entity that the preference form is acting on. Contains multiple values to be encrypted with authentication tokens.
- tokenType
- Type: pref_center.TokenType
- Specifies the type of the value to be encrypted with authentication tokens.