Decoding attributes
The readToken method inspects the cookie (or query parameters, depending on the configuration of the agent instance) and decodes the OpenToken, returning a Collection of attributes or null if no token is found or an error is encountered. In the case of an error, a TokenException is thrown.
The following example code shows how to use the readToken method:
|
This code is the same for both the Java native and Apache commons multimap methods described in Reading and writing OpenTokens. |
Sample code
try {
//See the "Reading and writing OpenTokens" topic for sample code
//that instantiates and configures an Agent instance
Map userInfo = agent.readToken(request);
if(userInfo != null) {
String username = (String)userInfo.get(Agent.TOKEN_SUBJECT);
}
}
catch(TokenException e) {
// Handle exception
}