/** * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#createAuthenticationMechanism(java.lang.String, java.util.Map, javax.security.auth.callback.CallbackHandler) */ @Override public HttpServerAuthenticationMechanism createAuthenticationMechanism(String mechanismName, Map<String, ?> properties, CallbackHandler callbackHandler) throws HttpAuthenticationException { HttpServerAuthenticationMechanism serverMechanism = delegate.createAuthenticationMechanism(mechanismName, properties, callbackHandler); return serverMechanism != null ? new PrivilegedServerMechanism(serverMechanism, accessControlContext) : null; }
/** * Obtain the list of available mechanism names after merging the properties. * * @param properties the initial set of properties to pass to the delegate to obtain the mechanism names. * @return the list of authentication mechanisms available form this factory. * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#getMechanismNames(java.util.Map) */ @Override public String[] getMechanismNames(Map<String, ?> properties) { return delegate.getMechanismNames(combine(properties, this.properties)); }
@Override public Object getNegotiatedProperty(String propertyName) { return SECURITY_IDENTITY.equals(propertyName) ? securityIdentityCallbackHandler.getSecurityIdentity() : delegate.getNegotiatedProperty(propertyName); }
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; }
/** * @see org.wildfly.security.http.HttpServerAuthenticationMechanism#evaluateRequest(org.wildfly.security.http.HttpServerRequest) */ @Override public void evaluateRequest(final HttpServerRequest request) throws HttpAuthenticationException { try { AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> { mechanism.evaluateRequest(new HttpServerRequestWrapper(request)); return null; }, accessControlContext); } catch (PrivilegedActionException pae) { try { throw pae.getCause(); } catch (HttpAuthenticationException | RuntimeException | Error e) { throw e; } catch (Throwable throwable) { throw new UndeclaredThrowableException(throwable); } } }
final String mechanismName = getMechanismName(); final String hostName = resolvedHostName; final String protocol = request.getRequestURI().getScheme();
/** * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#createAuthenticationMechanism(java.lang.String, java.util.Map, javax.security.auth.callback.CallbackHandler) */ @Override public HttpServerAuthenticationMechanism createAuthenticationMechanism(String mechanismName, Map<String, ?> properties, CallbackHandler callbackHandler) throws HttpAuthenticationException { SecurityIdentityCallbackHandler securityIdentityCallbackHandler = new SecurityIdentityCallbackHandler(callbackHandler); final HttpServerAuthenticationMechanism delegate = this.delegate.createAuthenticationMechanism(mechanismName, properties, securityIdentityCallbackHandler); if (delegate != null) { return new HttpServerAuthenticationMechanism() { @Override public String getMechanismName() { return delegate.getMechanismName(); } @Override public void evaluateRequest(HttpServerRequest request) throws HttpAuthenticationException { delegate.evaluateRequest(request); } @Override public Object getNegotiatedProperty(String propertyName) { return SECURITY_IDENTITY.equals(propertyName) ? securityIdentityCallbackHandler.getSecurityIdentity() : delegate.getNegotiatedProperty(propertyName); } }; } return null; }
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(); }
@Override public HttpServerAuthenticationMechanismFactory getValue() throws IllegalStateException, IllegalArgumentException { return new SetMechanismInformationMechanismFactory(this.httpAuthenticationFactory); }
/** * Create an instance of the requested {@link HttpServerAuthenticationMechanismFactory}. * * @param mechanismName the name of the mechanism being requested. * @param properties initial properties to be passed into the delegate factory. * @param callbackHandler the {@link CallbackHandler} to use for verification. * @return The newly created {@link HttpServerAuthenticationMechanismFactory}, or {@code null} if not availbale. * @throws HttpAuthenticationException * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#createAuthenticationMechanism(java.lang.String, * java.util.Map, javax.security.auth.callback.CallbackHandler) */ @Override public HttpServerAuthenticationMechanism createAuthenticationMechanism(String mechanismName, Map<String, ?> properties, CallbackHandler callbackHandler) throws HttpAuthenticationException { return delegate.createAuthenticationMechanism(mechanismName, combine(properties, this.properties), callbackHandler); }
/** * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#createAuthenticationMechanism(java.lang.String, java.util.Map, javax.security.auth.callback.CallbackHandler) */ @Override public HttpServerAuthenticationMechanism createAuthenticationMechanism(String mechanismName, Map<String, ?> properties, CallbackHandler callbackHandler) throws HttpAuthenticationException { HttpServerAuthenticationMechanism serverMechanism = delegate.createAuthenticationMechanism(mechanismName, properties, callbackHandler); return serverMechanism != null ? new PrivilegedServerMechanism(serverMechanism, accessControlContext) : null; }
@Override public Object getNegotiatedProperty(String propertyName) { return SECURITY_IDENTITY.equals(propertyName) ? securityIdentityCallbackHandler.getSecurityIdentity() : delegate.getNegotiatedProperty(propertyName); }
/** * Obtain the list of available mechanism names after merging the properties. * * @param properties the initial set of properties to pass to the delegate to obtain the mechanism names. * @return the list of authentication mechanisms available form this factory. * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#getMechanismNames(java.util.Map) */ @Override public String[] getMechanismNames(Map<String, ?> properties) { return delegate.getMechanismNames(combine(properties, this.properties)); }
/** * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#createAuthenticationMechanism(java.lang.String, java.util.Map, javax.security.auth.callback.CallbackHandler) */ @Override public HttpServerAuthenticationMechanism createAuthenticationMechanism(String mechanismName, Map<String, ?> properties, CallbackHandler callbackHandler) throws HttpAuthenticationException { HttpServerAuthenticationMechanism serverMechanism = delegate.createAuthenticationMechanism(mechanismName, properties, callbackHandler); return serverMechanism != null ? new PrivilegedServerMechanism(serverMechanism, accessControlContext) : null; }
/** * Obtain the list of available mechanism names after merging the properties. * * @param properties the initial set of properties to pass to the delegate to obtain the mechanism names. * @return the list of authentication mechanisms available form this factory. * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#getMechanismNames(java.util.Map) */ @Override public String[] getMechanismNames(Map<String, ?> properties) { return delegate.getMechanismNames(combine(properties, this.properties)); }
/** * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#createAuthenticationMechanism(java.lang.String, java.util.Map, javax.security.auth.callback.CallbackHandler) */ @Override public HttpServerAuthenticationMechanism createAuthenticationMechanism(String mechanismName, Map<String, ?> properties, CallbackHandler callbackHandler) throws HttpAuthenticationException { HttpServerAuthenticationMechanism serverMechanism = delegate.createAuthenticationMechanism(mechanismName, properties, callbackHandler); return serverMechanism != null ? new PrivilegedServerMechanism(serverMechanism, accessControlContext) : null; }
/** * Obtain the list of available mechanism names after merging the properties. * * @param properties the initial set of properties to pass to the delegate to obtain the mechanism names. * @return the list of authentication mechanisms available form this factory. * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#getMechanismNames(java.util.Map) */ @Override public String[] getMechanismNames(Map<String, ?> properties) { return delegate.getMechanismNames(combine(properties, this.properties)); }
/** * Create an instance of the requested {@link HttpServerAuthenticationMechanismFactory}. * * @param mechanismName the name of the mechanism being requested. * @param properties initial properties to be passed into the delegate factory. * @param callbackHandler the {@link CallbackHandler} to use for verification. * @return The newly created {@link HttpServerAuthenticationMechanismFactory}, or {@code null} if not availbale. * @throws HttpAuthenticationException * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#createAuthenticationMechanism(java.lang.String, * java.util.Map, javax.security.auth.callback.CallbackHandler) */ @Override public HttpServerAuthenticationMechanism createAuthenticationMechanism(String mechanismName, Map<String, ?> properties, CallbackHandler callbackHandler) throws HttpAuthenticationException { return delegate.createAuthenticationMechanism(mechanismName, combine(properties, this.properties), callbackHandler); }
/** * Create an instance of the requested {@link HttpServerAuthenticationMechanismFactory}. * * @param mechanismName the name of the mechanism being requested. * @param properties initial properties to be passed into the delegate factory. * @param callbackHandler the {@link CallbackHandler} to use for verification. * @return The newly created {@link HttpServerAuthenticationMechanismFactory}, or {@code null} if not availbale. * @throws HttpAuthenticationException * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#createAuthenticationMechanism(java.lang.String, * java.util.Map, javax.security.auth.callback.CallbackHandler) */ @Override public HttpServerAuthenticationMechanism createAuthenticationMechanism(String mechanismName, Map<String, ?> properties, CallbackHandler callbackHandler) throws HttpAuthenticationException { return delegate.createAuthenticationMechanism(mechanismName, combine(properties, this.properties), callbackHandler); }
/** * Create an instance of the requested {@link HttpServerAuthenticationMechanismFactory}. * * @param mechanismName the name of the mechanism being requested. * @param properties initial properties to be passed into the delegate factory. * @param callbackHandler the {@link CallbackHandler} to use for verification. * @return The newly created {@link HttpServerAuthenticationMechanismFactory}, or {@code null} if not availbale. * @throws HttpAuthenticationException * @see org.wildfly.security.http.HttpServerAuthenticationMechanismFactory#createAuthenticationMechanism(java.lang.String, * java.util.Map, javax.security.auth.callback.CallbackHandler) */ @Override public HttpServerAuthenticationMechanism createAuthenticationMechanism(String mechanismName, Map<String, ?> properties, CallbackHandler callbackHandler) throws HttpAuthenticationException { return delegate.createAuthenticationMechanism(mechanismName, combine(properties, this.properties), callbackHandler); }