The following example code shows how to use the readToken method:

Note:

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 
}