Search in sources :

Example 1 with HttpAuthenticationFactory

use of org.wildfly.security.auth.server.HttpAuthenticationFactory in project wildfly by wildfly.

the class HttpInvokerHostService method secureAccess.

private static HttpHandler secureAccess(HttpHandler domainHandler, final HttpAuthenticationFactory httpAuthenticationFactory) {
    domainHandler = new AuthenticationCallHandler(domainHandler);
    domainHandler = new AuthenticationConstraintHandler(domainHandler);
    Supplier<List<HttpServerAuthenticationMechanism>> mechanismSupplier = () -> httpAuthenticationFactory.getMechanismNames().stream().map(s -> {
        try {
            return httpAuthenticationFactory.createMechanism(s);
        } catch (Exception e) {
            return null;
        }
    }).collect(Collectors.toList());
    domainHandler = ElytronContextAssociationHandler.builder().setNext(domainHandler).setMechanismSupplier(mechanismSupplier).setHttpExchangeSupplier(h -> new ElytronHttpExchange(h) {

        @Override
        public void authenticationComplete(SecurityIdentity securityIdentity, String mechanismName) {
            super.authenticationComplete(securityIdentity, mechanismName);
            h.putAttachment(ElytronIdentityHandler.IDENTITY_KEY, securityIdentity);
        }
    }).build();
    return domainHandler;
}
Also used : Service(org.jboss.msc.service.Service) StopContext(org.jboss.msc.service.StopContext) HttpServerExchange(io.undertow.server.HttpServerExchange) AuthenticationConstraintHandler(io.undertow.security.handlers.AuthenticationConstraintHandler) AttachmentKey(io.undertow.util.AttachmentKey) StartContext(org.jboss.msc.service.StartContext) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) HttpAuthenticationFactory(org.wildfly.security.auth.server.HttpAuthenticationFactory) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) HttpHandler(io.undertow.server.HttpHandler) List(java.util.List) PathHandler(io.undertow.server.handlers.PathHandler) ElytronContextAssociationHandler(org.wildfly.elytron.web.undertow.server.ElytronContextAssociationHandler) HttpServerAuthenticationMechanism(org.wildfly.security.http.HttpServerAuthenticationMechanism) ElytronHttpExchange(org.wildfly.elytron.web.undertow.server.ElytronHttpExchange) AuthenticationCallHandler(io.undertow.security.handlers.AuthenticationCallHandler) SecurityIdentity(org.wildfly.security.auth.server.SecurityIdentity) InjectedValue(org.jboss.msc.value.InjectedValue) StartException(org.jboss.msc.service.StartException) ElytronHttpExchange(org.wildfly.elytron.web.undertow.server.ElytronHttpExchange) SecurityIdentity(org.wildfly.security.auth.server.SecurityIdentity) AuthenticationConstraintHandler(io.undertow.security.handlers.AuthenticationConstraintHandler) AuthenticationCallHandler(io.undertow.security.handlers.AuthenticationCallHandler) List(java.util.List) StartException(org.jboss.msc.service.StartException)

Aggregations

AuthenticationCallHandler (io.undertow.security.handlers.AuthenticationCallHandler)1 AuthenticationConstraintHandler (io.undertow.security.handlers.AuthenticationConstraintHandler)1 HttpHandler (io.undertow.server.HttpHandler)1 HttpServerExchange (io.undertow.server.HttpServerExchange)1 PathHandler (io.undertow.server.handlers.PathHandler)1 AttachmentKey (io.undertow.util.AttachmentKey)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 List (java.util.List)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 Service (org.jboss.msc.service.Service)1 StartContext (org.jboss.msc.service.StartContext)1 StartException (org.jboss.msc.service.StartException)1 StopContext (org.jboss.msc.service.StopContext)1 InjectedValue (org.jboss.msc.value.InjectedValue)1 ElytronContextAssociationHandler (org.wildfly.elytron.web.undertow.server.ElytronContextAssociationHandler)1 ElytronHttpExchange (org.wildfly.elytron.web.undertow.server.ElytronHttpExchange)1 HttpAuthenticationFactory (org.wildfly.security.auth.server.HttpAuthenticationFactory)1 SecurityIdentity (org.wildfly.security.auth.server.SecurityIdentity)1 HttpServerAuthenticationMechanism (org.wildfly.security.http.HttpServerAuthenticationMechanism)1