use of org.jboss.security.AuthorizationManager in project wildfly by wildfly.
the class JAASIdentityManagerImpl method verifyCredential.
private Account verifyCredential(final AccountImpl account, final Object credential) {
final AuthenticationManager authenticationManager = securityDomainContext.getAuthenticationManager();
final AuthorizationManager authorizationManager = securityDomainContext.getAuthorizationManager();
final SecurityContext sc = SecurityActions.getSecurityContext();
Principal incomingPrincipal = account.getOriginalPrincipal();
Subject subject = new Subject();
try {
boolean isValid = authenticationManager.isValid(incomingPrincipal, credential, subject);
if (isValid) {
UndertowLogger.ROOT_LOGGER.tracef("User: %s is authenticated", incomingPrincipal);
if (sc == null) {
throw UndertowLogger.ROOT_LOGGER.noSecurityContext();
}
Principal userPrincipal = getPrincipal(subject);
sc.getUtil().createSubjectInfo(incomingPrincipal, credential, subject);
SecurityContextCallbackHandler scb = new SecurityContextCallbackHandler(sc);
RoleGroup roles = authorizationManager.getSubjectRoles(subject, scb);
Set<String> roleSet = new HashSet<>();
for (Role role : roles.getRoles()) {
roleSet.add(role.getRoleName());
}
return new AccountImpl(userPrincipal, roleSet, credential, account.getOriginalPrincipal());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return null;
}
use of org.jboss.security.AuthorizationManager in project wildfly by wildfly.
the class JNDIBasedSecurityManagement method getAuthorizationManager.
/** {@inheritDoc} */
public AuthorizationManager getAuthorizationManager(String securityDomain) {
AuthorizationManager am = null;
try {
am = authzMgrMap.get(securityDomain);
if (am == null) {
am = (AuthorizationManager) lookUpJNDI(securityDomain + "/authorizationMgr");
authzMgrMap.put(securityDomain, am);
}
} catch (Exception e) {
SecurityLogger.ROOT_LOGGER.tracef(e, "Exception getting AuthorizationManager for domain=%s", securityDomain);
}
return am;
}
Aggregations