Search in sources :

Example 11 with FormAuthenticator

use of org.eclipse.jetty.security.authentication.FormAuthenticator in project jetty.project by eclipse.

the class DefaultAuthenticatorFactory method getAuthenticator.

public Authenticator getAuthenticator(Server server, ServletContext context, AuthConfiguration configuration, IdentityService identityService, LoginService loginService) {
    String auth = configuration.getAuthMethod();
    Authenticator authenticator = null;
    if (auth == null || Constraint.__BASIC_AUTH.equalsIgnoreCase(auth))
        authenticator = new BasicAuthenticator();
    else if (Constraint.__DIGEST_AUTH.equalsIgnoreCase(auth))
        authenticator = new DigestAuthenticator();
    else if (Constraint.__FORM_AUTH.equalsIgnoreCase(auth))
        authenticator = new FormAuthenticator();
    else if (Constraint.__SPNEGO_AUTH.equalsIgnoreCase(auth))
        authenticator = new SpnegoAuthenticator();
    else if (// see Bug #377076
    Constraint.__NEGOTIATE_AUTH.equalsIgnoreCase(auth))
        authenticator = new SpnegoAuthenticator(Constraint.__NEGOTIATE_AUTH);
    if (Constraint.__CERT_AUTH.equalsIgnoreCase(auth) || Constraint.__CERT_AUTH2.equalsIgnoreCase(auth))
        authenticator = new ClientCertAuthenticator();
    return authenticator;
}
Also used : BasicAuthenticator(org.eclipse.jetty.security.authentication.BasicAuthenticator) ClientCertAuthenticator(org.eclipse.jetty.security.authentication.ClientCertAuthenticator) DigestAuthenticator(org.eclipse.jetty.security.authentication.DigestAuthenticator) FormAuthenticator(org.eclipse.jetty.security.authentication.FormAuthenticator) SpnegoAuthenticator(org.eclipse.jetty.security.authentication.SpnegoAuthenticator) SpnegoAuthenticator(org.eclipse.jetty.security.authentication.SpnegoAuthenticator) ClientCertAuthenticator(org.eclipse.jetty.security.authentication.ClientCertAuthenticator) DigestAuthenticator(org.eclipse.jetty.security.authentication.DigestAuthenticator) FormAuthenticator(org.eclipse.jetty.security.authentication.FormAuthenticator) BasicAuthenticator(org.eclipse.jetty.security.authentication.BasicAuthenticator)

Example 12 with FormAuthenticator

use of org.eclipse.jetty.security.authentication.FormAuthenticator in project drill by axbaretto.

the class WebServer method createSecurityHandler.

/**
 * @return {@link SecurityHandler} with appropriate {@link LoginService}, {@link Authenticator} and constraints.
 */
private ConstraintSecurityHandler createSecurityHandler() {
    ConstraintSecurityHandler security = new ConstraintSecurityHandler();
    Set<String> knownRoles = ImmutableSet.of(AUTHENTICATED_ROLE, ADMIN_ROLE);
    security.setConstraintMappings(Collections.<ConstraintMapping>emptyList(), knownRoles);
    security.setAuthenticator(new FormAuthenticator("/login", "/login", true));
    security.setLoginService(new DrillRestLoginService(workManager.getContext()));
    return security;
}
Also used : ConstraintSecurityHandler(org.eclipse.jetty.security.ConstraintSecurityHandler) FormAuthenticator(org.eclipse.jetty.security.authentication.FormAuthenticator) DrillRestLoginService(org.apache.drill.exec.server.rest.auth.DrillRestLoginService)

Example 13 with FormAuthenticator

use of org.eclipse.jetty.security.authentication.FormAuthenticator in project drill by apache.

the class WebServer method createSecurityHandler.

/**
 * It creates handler with security constraint combinations for runtime efficiency
 * @see <a href="http://www.eclipse.org/jetty/documentation/current/embedded-examples.html">Eclipse Jetty Documentation</a>
 *
 * @return security handler with precomputed constraint combinations
 */
private ConstraintSecurityHandler createSecurityHandler() {
    ConstraintSecurityHandler security = new ConstraintSecurityHandler();
    Set<String> knownRoles = ImmutableSet.of(ADMIN_ROLE);
    security.setConstraintMappings(Collections.emptyList(), knownRoles);
    security.setAuthenticator(new FormAuthenticator("/login", "/login", true));
    security.setLoginService(new AmLoginService(AMSecurityManagerImpl.instance()));
    return security;
}
Also used : ConstraintSecurityHandler(org.eclipse.jetty.security.ConstraintSecurityHandler) FormAuthenticator(org.eclipse.jetty.security.authentication.FormAuthenticator)

Aggregations

FormAuthenticator (org.eclipse.jetty.security.authentication.FormAuthenticator)13 Test (org.junit.Test)6 ConstraintSecurityHandler (org.eclipse.jetty.security.ConstraintSecurityHandler)4 DrillRestLoginService (org.apache.drill.exec.server.rest.auth.DrillRestLoginService)2 BasicAuthenticator (org.eclipse.jetty.security.authentication.BasicAuthenticator)2 ClientCertAuthenticator (org.eclipse.jetty.security.authentication.ClientCertAuthenticator)2 DigestAuthenticator (org.eclipse.jetty.security.authentication.DigestAuthenticator)2 SpnegoAuthenticator (org.eclipse.jetty.security.authentication.SpnegoAuthenticator)2 Constraint (org.eclipse.jetty.util.security.Constraint)1