user.getAuthenticationStatus().reset();
DirContext dirContext = getConnectedContext();
// ensure an authenticated DN
if (sAuthenticatedDN.length() == 0) {
throw new AuthenticationException("Invalid credentials.");
}
// populate profile information
user.setDistinguishedName(sAuthenticatedDN);
user.setKey(user.getDistinguishedName());
getQueryFunctions().readUserProfile(dirContext,user);
user.setName(user.getProfile().getUsername());
// read groups, set authenticated roles
getQueryFunctions().readUserGroups(dirContext,user);
Groups userGroups = user.getGroups();
Roles configuredRoles = getConfiguration().getIdentityConfiguration().getConfiguredRoles();
RoleSet authenticatedRoles = user.getAuthenticationStatus().getAuthenticatedRoles();
for (Role role: configuredRoles.values()) {
if (userGroups.containsKey(role.getDistinguishedName())) {
authenticatedRoles.addAll(role.getFullRoleSet());
}
}
user.getAuthenticationStatus().setWasAuthenticated(true);
// ensure membership if a targeted metadata management group was specified
if (targetedGroupDN.length() > 0) {
if (!userGroups.containsKey(targetedGroupDN)) {
user.getAuthenticationStatus().reset();
throw new AuthenticationException("Invalid credentials, not a member of the supplied group.");
}
}
// ensure a local reference for the user
LocalDao localDao = new LocalDao(requestContext);