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; }
public HttpAuthenticationFactory build() { return new HttpAuthenticationFactory(getSecurityDomain(), getMechanismConfigurationSelector(), getFactory()); } }
private static Function<String, HttpAuthenticationFactory> toHttpAuthenticationFactoryFunction(final Supplier<SecurityDomain> securityDomainSupplier) { final HttpServerAuthenticationMechanismFactory mechanismFactory = new FilterServerMechanismFactory(new ServerMechanismFactoryImpl(), SERVLET_MECHANISM); return (realmName) -> HttpAuthenticationFactory.builder().setFactory(mechanismFactory) .setSecurityDomain(securityDomainSupplier.get()) .setMechanismConfigurationSelector( MechanismConfigurationSelector.constantSelector(realmName == null ? MechanismConfiguration.EMPTY : MechanismConfiguration.builder() .addMechanismRealm( MechanismRealmConfiguration.builder().setRealmName(realmName).build()) .build())) .build(); }
Collection<String> getAllSupportedMechNames() { return asList(getFactory().getMechanismNames(Collections.emptyMap())); }
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 List<HttpServerAuthenticationMechanism> getAuthenticationMechanisms(Map<String, Map<String, String>> selectedMechanisms) { List<HttpServerAuthenticationMechanism> mechanisms = new ArrayList<>(selectedMechanisms.size()); UnaryOperator<HttpServerAuthenticationMechanismFactory> singleSignOnTransformer = builder.httpAuthenticationFactoryTransformer; for (Entry<String, Map<String, String>> entry : selectedMechanisms.entrySet()) { try { UnaryOperator<HttpServerAuthenticationMechanismFactory> factoryTransformation = f -> { HttpServerAuthenticationMechanismFactory factory = new PropertiesServerMechanismFactory(f, entry.getValue()); return (singleSignOnTransformer != null) ? singleSignOnTransformer.apply(factory) : factory; }; HttpServerAuthenticationMechanism mechanism = builder.httpAuthenticationFactory.createMechanism(entry.getKey(), factoryTransformation); if (mechanism != null) mechanisms.add(mechanism); } catch (HttpAuthenticationException e) { throw new IllegalStateException(e); } } return mechanisms; }
final SecurityDomain securityDomain = httpAuthenticationFactory != null ? httpAuthenticationFactory.getSecurityDomain() : builder.securityDomain;
HttpServerAuthenticationMechanism doCreate(final String name, final CallbackHandler callbackHandler, final UnaryOperator<HttpServerAuthenticationMechanismFactory> factoryTransformation) throws HttpAuthenticationException { HttpServerAuthenticationMechanism server = new SecurityIdentityServerMechanismFactory(factoryTransformation.apply(getFactory())).createAuthenticationMechanism(name, Collections.emptyMap(), callbackHandler); log.tracef("Created HttpServerAuthenticationMechanism [%s] for mechanism [%s]", server, name); return server; }
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.");
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; }
Collection<String> getAllSupportedMechNames() { return asList(getFactory().getMechanismNames(Collections.emptyMap())); }
HttpAuthenticationFactory.Builder builder = HttpAuthenticationFactory.builder() .setSecurityDomain(securityDomainInjector.getValue()) .setFactory(serverFactory);
public HttpAuthenticationFactory build() { return new HttpAuthenticationFactory(getSecurityDomain(), getMechanismConfigurationSelector(), getFactory()); } }
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; }
Collection<String> getAllSupportedMechNames() { return asList(getFactory().getMechanismNames(Collections.emptyMap())); }
private static Function<String, HttpAuthenticationFactory> toHttpAuthenticationFactoryFunction(final Supplier<SecurityDomain> securityDomainSupplier) { final HttpServerAuthenticationMechanismFactory mechanismFactory = new FilterServerMechanismFactory(new ServerMechanismFactoryImpl(), SERVLET_MECHANISM); return (realmName) -> HttpAuthenticationFactory.builder().setFactory(mechanismFactory) .setSecurityDomain(securityDomainSupplier.get()) .setMechanismConfigurationSelector( MechanismConfigurationSelector.constantSelector(realmName == null ? MechanismConfiguration.EMPTY : MechanismConfiguration.builder() .addMechanismRealm( MechanismRealmConfiguration.builder().setRealmName(realmName).build()) .build())) .build(); }
public HttpAuthenticationFactory build() { return new HttpAuthenticationFactory(getSecurityDomain(), getMechanismConfigurationSelector(), getFactory()); } }
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; }
protected Collection<String> getAllSupportedMechNames() { return asList(getFactory().getMechanismNames(Collections.emptyMap())); }
private static Function<String, HttpAuthenticationFactory> toHttpAuthenticationFactoryFunction(final Supplier<SecurityDomain> securityDomainSupplier) { final HttpServerAuthenticationMechanismFactory mechanismFactory = new FilterServerMechanismFactory(new ServerMechanismFactoryImpl(), SERVLET_MECHANISM); return (realmName) -> HttpAuthenticationFactory.builder().setFactory(mechanismFactory) .setSecurityDomain(securityDomainSupplier.get()) .setMechanismConfigurationSelector( MechanismConfigurationSelector.constantSelector(realmName == null ? MechanismConfiguration.EMPTY : MechanismConfiguration.builder() .addMechanismRealm( MechanismRealmConfiguration.builder().setRealmName(realmName).build()) .build())) .build(); }