if (!(credentials instanceof NamePasswordCredentials)) {
throw new CredentialException("Wrong credential class: " +
credentials.getClass().getName());
}
NamePasswordCredentials npc = (NamePasswordCredentials) credentials;
// make sure the name is specified
if (npc.getName() == null) {
logger.warning("No name specified");
throw new CredentialException("Invalid username");
}
logger.warning("Auth token: " + npc.getName());
// unpack the components of the id
try {
String username = null;
String fullname = null;
String email = null;
Attributes attrs = auth.getAttributes(npc.getName(), "uid", "cn", "mail");
Attribute usernameAttr = attrs.get("uid");
if (usernameAttr != null) {
username = (String) usernameAttr.get();
}