Map<String, Boolean> userGlobalPermissionsMap = new HashMap<String, Boolean>();
boolean needsRegistration = false;
try {
// authenticate the credentials
SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
Subject subject = subjectManager.loginLocal(logonForm.getJ_username(), logonForm.getJ_password());
Integer sessionId = subject.getSessionId(); // this is the RHQ session ID, not related to the HTTP session
log.debug("Logged in as [" + logonForm.getJ_username() + "] with session id [" + sessionId + "]");
boolean hasPrincipal = true;
if (subject.getId() == 0) {
// Subject with a ID of 0 means the subject wasn't in the database but the login succeeded.
// This means the login method detected that LDAP authenticated the user and just gave us a dummy subject.
// Set the needs-registration flag so we can eventually steer the user to the LDAP registration workflow.
needsRegistration = true;
}
if (!needsRegistration) {
subject = subjectManager.loadUserConfiguration(subject.getId());
subject.setSessionId(sessionId); // put the transient data back into our new subject
if (subject.getUserConfiguration() == null) {
subject.setUserConfiguration((Configuration) ctx.getAttribute(Constants.DEF_USER_PREFS));
subject = subjectManager.updateSubject(subject, subject);
subject.setSessionId(sessionId); // put the transient data back into our new subject
}
// look up the user's permissions
Set<Permission> all_permissions = LookupUtil.getAuthorizationManager().getExplicitGlobalPermissions(