Java Code Examples for io.undertow.security.api.SecurityContext#getIdentityManager()

The following examples show how to use io.undertow.security.api.SecurityContext#getIdentityManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JWTAuthMechanism.java    From thorntail with Apache License 2.0 5 votes vote down vote up
/**
 * Extract the Authorization header and validate the bearer token if it exists. If it does, and is validated, this
 * builds the org.jboss.security.SecurityContext authenticated Subject that drives the container APIs as well as
 * the authorization layers.
 *
 * @param exchange        - the http request exchange object
 * @param securityContext - the current security context that
 * @return one of AUTHENTICATED, NOT_AUTHENTICATED or NOT_ATTEMPTED depending on the header and authentication outcome.
 */
@SuppressWarnings("deprecation")
@Override
public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange, SecurityContext securityContext) {
    String jwtToken = new UndertowBearerTokenExtractor(authContextInfo, exchange).getBearerToken();
    if (jwtToken != null) {
        try {
            identityManager = securityContext.getIdentityManager();
            JWTCredential credential = new JWTCredential(jwtToken, authContextInfo);
            // Install the JWT principal as the caller
            Account account = identityManager.verify(credential.getName(), credential);
            if (account != null) {
                JsonWebToken jwtPrincipal = (JsonWebToken) account.getPrincipal();
                preparePrincipalProducer(jwtPrincipal);
                securityContext.authenticationComplete(account, "MP-JWT", false);
                // Workaround authenticated JWTPrincipal not being installed as user principal
                // https://issues.jboss.org/browse/WFLY-9212
                org.jboss.security.SecurityContext jbSC = SecurityContextAssociation.getSecurityContext();
                Subject subject = jbSC.getUtil().getSubject();
                jbSC.getUtil().createSubjectInfo(jwtPrincipal, jwtToken, subject);
                RoleGroup roles = extract(subject);
                jbSC.getUtil().setRoles(roles);
                UndertowLogger.SECURITY_LOGGER.debugf("Authenticated caller(%s) for path(%s) with roles: %s",
                        credential.getName(), exchange.getRequestPath(), account.getRoles());
                return AuthenticationMechanismOutcome.AUTHENTICATED;
            } else {
                UndertowLogger.SECURITY_LOGGER.info("Failed to authenticate JWT bearer token");
                return AuthenticationMechanismOutcome.NOT_AUTHENTICATED;
            }
        } catch (Exception e) {
            UndertowLogger.SECURITY_LOGGER.infof(e, "Failed to validate JWT bearer token");
            return AuthenticationMechanismOutcome.NOT_AUTHENTICATED;
        }
    }

    // No suitable header has been found in this request,
    return AuthenticationMechanismOutcome.NOT_ATTEMPTED;
}
 
Example 2
Source File: SingleSignOnAuthenticationMechanism.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 3
Source File: LightBasicAuthenticationMechanism.java    From light-oauth2 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 4
Source File: LightFormAuthenticationMechanism.java    From light-oauth2 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 5
Source File: LightGSSAPIAuthenticationMechanism.java    From light-oauth2 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 6
Source File: DigestAuthenticationMechanism.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 7
Source File: ClientCertAuthenticationMechanism.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 8
Source File: BasicAuthenticationMechanism.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 9
Source File: FormAuthenticationMechanism.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 10
Source File: GSSAPIAuthenticationMechanism.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 11
Source File: ExternalAuthenticationMechanism.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 12
Source File: ExternalAuthenticationMechanism.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 13
Source File: DatawaveAuthenticationMechanism.java    From datawave with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 14
Source File: DigestAuthenticationMechanism.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 15
Source File: ClientCertAuthenticationMechanism.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 16
Source File: BasicAuthenticationMechanism.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 17
Source File: FormAuthenticationMechanism.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 18
Source File: GSSAPIAuthenticationMechanism.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 19
Source File: CachedAuthenticatedSessionMechanism.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}
 
Example 20
Source File: SingleSignOnAuthenticationMechanism.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private IdentityManager getIdentityManager(SecurityContext securityContext) {
    return identityManager != null ? identityManager : securityContext.getIdentityManager();
}