// A Unix user must have a name not null so check here.
if ((_username == null) || (_username.length() == 0)) {
throw new LoginException("Invalid Username");
}
UnixUser user = authenticate(_username, _password);
if (user == null) { // JAAS behavior
throw new LoginException("Failed Pam Login for " + _username);
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "PAM login succeeded for: " + _username);
}
/*
* Get the groups from the libpam4j UnixUser class that has been
* returned after a successful authentication.
*/
String[] grpList = null;
Set<String> groupSet = user.getGroups();
if (groupSet != null) {
grpList = new String[groupSet.size()];
user.getGroups().toArray(grpList);
}
else {
//Empty group list, create a zero-length group list
grpList = new String[0];
}