AuthenticationIdentity authenticationIdentity)
throws RepositoryLoginException, RepositoryException {
String userLoginName =
IdentityUtil.getCanonicalUsername(authenticationIdentity);
if (userLoginName == null) {
return new AuthenticationResponse(false, "");
} else {
String userDomain = IdentityUtil.getDomain(authenticationIdentity);
String password = authenticationIdentity.getPassword();
ISessionManager sessionManagerUser;
boolean authenticate;
String userName;
try {
if (Strings.isNullOrEmpty(password)) {
sessionManagerUser =
getSessionManager(connector.getLogin(), connector.getPassword());
//check for user existence when null password
userName = getUserName(sessionManagerUser, userLoginName, userDomain);
authenticate = (userName != null);
} else {
// TODO(jlacey): We are using the raw username from the GSA
// here because we always have and no bugs have been reported.
sessionManagerUser =
getSessionManager(authenticationIdentity.getUsername(), password);
// Use getSession instead of authenticate, so we can get the
// authenticated user name.
ISession session = sessionManagerUser.getSession(docbase);
try {
userName = session.getLoginUserName();
} finally {
sessionManagerUser.release(session);
}
authenticate = true;
}
} catch (RepositoryLoginException e) {
LOGGER.finer(e.getMessage());
return new AuthenticationResponse(false, "");
}
if (authenticate) {
return new AuthenticationResponse(authenticate, "", getAllGroupsForUser(
sessionManagerUser, userName));
} else {
return new AuthenticationResponse(false, "");
}
}
}