Search in sources :

Example 1 with AuditManager

use of org.jboss.security.audit.AuditManager in project wildfly by wildfly.

the class SimpleSecurityManager method authenticate.

private boolean authenticate(SecurityContext context, Subject subject) {
    SecurityContextUtil util = context.getUtil();
    SubjectInfo subjectInfo = getSubjectInfo(context);
    if (subject == null) {
        subject = new Subject();
    }
    Principal principal = util.getUserPrincipal();
    Principal auditPrincipal = principal;
    Object credential = util.getCredential();
    Identity unauthenticatedIdentity = null;
    boolean authenticated = false;
    if (principal == null) {
        unauthenticatedIdentity = getUnauthenticatedIdentity();
        subjectInfo.addIdentity(unauthenticatedIdentity);
        auditPrincipal = unauthenticatedIdentity.asPrincipal();
        subject.getPrincipals().add(auditPrincipal);
        authenticated = true;
    } else {
        subject.getPrincipals().add(principal);
    }
    if (authenticated == false) {
        AuthenticationManager authenticationManager = context.getAuthenticationManager();
        authenticated = authenticationManager.isValid(principal, credential, subject);
    }
    if (authenticated == true) {
        subjectInfo.setAuthenticatedSubject(subject);
    }
    AuditManager auditManager = context.getAuditManager();
    if (auditManager != null) {
        audit(authenticated ? AuditLevel.SUCCESS : AuditLevel.FAILURE, auditManager, auditPrincipal);
    }
    return authenticated;
}
Also used : AuthenticationManager(org.jboss.security.AuthenticationManager) SecurityContextUtil(org.jboss.security.SecurityContextUtil) SubjectInfo(org.jboss.security.SubjectInfo) SecurityIdentity(org.wildfly.security.auth.server.SecurityIdentity) Identity(org.jboss.security.identity.Identity) SimpleIdentity(org.jboss.security.identity.plugins.SimpleIdentity) RunAsIdentity(org.jboss.security.RunAsIdentity) Subject(javax.security.auth.Subject) Principal(java.security.Principal) SimplePrincipal(org.jboss.security.SimplePrincipal) AuditManager(org.jboss.security.audit.AuditManager)

Example 2 with AuditManager

use of org.jboss.security.audit.AuditManager in project wildfly by wildfly.

the class UndertowDeploymentInfoService method handleIdentityManager.

private void handleIdentityManager(final DeploymentInfo deploymentInfo) {
    if (securityDomain != null) {
        SecurityDomainContext sdc = securityDomainContextValue.getValue();
        deploymentInfo.setIdentityManager(new JAASIdentityManagerImpl(sdc));
        AuditManager auditManager = sdc.getAuditManager();
        if (auditManager != null && !mergedMetaData.isDisableAudit()) {
            deploymentInfo.addNotificationReceiver(new AuditNotificationReceiver(auditManager));
        }
    }
}
Also used : JAASIdentityManagerImpl(org.wildfly.extension.undertow.security.JAASIdentityManagerImpl) AuditNotificationReceiver(org.wildfly.extension.undertow.security.AuditNotificationReceiver) SecurityDomainContext(org.jboss.as.security.plugins.SecurityDomainContext) AuditManager(org.jboss.security.audit.AuditManager)

Example 3 with AuditManager

use of org.jboss.security.audit.AuditManager in project wildfly by wildfly.

the class JNDIBasedSecurityManagement method getAuditManager.

/** {@inheritDoc} */
public AuditManager getAuditManager(String securityDomain) {
    AuditManager am = null;
    try {
        am = auditMgrMap.get(securityDomain);
        if (am == null) {
            am = (AuditManager) lookUpJNDI(securityDomain + "/auditMgr");
            auditMgrMap.put(securityDomain, am);
        }
    } catch (Exception e) {
        SecurityLogger.ROOT_LOGGER.tracef(e, "Exception getting AuditManager for domain=%s", securityDomain);
    }
    return am;
}
Also used : AuditManager(org.jboss.security.audit.AuditManager)

Aggregations

AuditManager (org.jboss.security.audit.AuditManager)3 Principal (java.security.Principal)1 Subject (javax.security.auth.Subject)1 SecurityDomainContext (org.jboss.as.security.plugins.SecurityDomainContext)1 AuthenticationManager (org.jboss.security.AuthenticationManager)1 RunAsIdentity (org.jboss.security.RunAsIdentity)1 SecurityContextUtil (org.jboss.security.SecurityContextUtil)1 SimplePrincipal (org.jboss.security.SimplePrincipal)1 SubjectInfo (org.jboss.security.SubjectInfo)1 Identity (org.jboss.security.identity.Identity)1 SimpleIdentity (org.jboss.security.identity.plugins.SimpleIdentity)1 AuditNotificationReceiver (org.wildfly.extension.undertow.security.AuditNotificationReceiver)1 JAASIdentityManagerImpl (org.wildfly.extension.undertow.security.JAASIdentityManagerImpl)1 SecurityIdentity (org.wildfly.security.auth.server.SecurityIdentity)1