* @return A new {@code TokenInfo} or {@code null} if the token could not
* be created.
*/
@Override
public TokenInfo createToken(Credentials credentials) {
SimpleCredentials sc = extractSimpleCredentials(credentials);
TokenInfo tokenInfo = null;
if (sc != null) {
String[] attrNames = sc.getAttributeNames();
Map<String, String> attributes = new HashMap<String, String>(attrNames.length);
for (String attrName : sc.getAttributeNames()) {
attributes.put(attrName, sc.getAttribute(attrName).toString());
}
tokenInfo = createToken(sc.getUserID(), attributes);
if (tokenInfo != null) {
// also set the new token to the simple credentials.
sc.setAttribute(TOKEN_ATTRIBUTE, tokenInfo.getToken());
}
}
return tokenInfo;
}