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; }
private static String[] getAvailableHttpMechanisms(OperationContext context) { RuntimeCapability<Void> runtimeCapability = HTTP_AUTHENTICATION_FACTORY_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName securityDomainHttpConfigurationName = runtimeCapability.getCapabilityServiceName(HttpAuthenticationFactory.class); ServiceController<HttpAuthenticationFactory> serviceContainer = getRequiredService(context.getServiceRegistry(false), securityDomainHttpConfigurationName, HttpAuthenticationFactory.class); if (serviceContainer.getState() != State.UP) { return null; } Collection<String> mechanismNames = serviceContainer.getValue().getMechanismNames(); return mechanismNames.toArray(new String[mechanismNames.size()]); }
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; }
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; }
private static HttpHandler secureDomainAccess(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; }
final Collection<String> availableMechanisms; if (httpAuthenticationFactory != null) { availableMechanisms = builder.httpAuthenticationFactory.getMechanismNames(); if (availableMechanisms.isEmpty()) { throw new IllegalStateException("There are no mechanisms available from the HttpAuthenticationFactory.");