Search in sources :

Example 1 with Authenticator

use of org.eclipse.jetty.security.Authenticator in project jetty.project by eclipse.

the class JaspiAuthenticatorFactory method getAuthenticator.

/* ------------------------------------------------------------ */
public Authenticator getAuthenticator(Server server, ServletContext context, AuthConfiguration configuration, IdentityService identityService, LoginService loginService) {
    Authenticator authenticator = null;
    try {
        AuthConfigFactory authConfigFactory = AuthConfigFactory.getFactory();
        RegistrationListener listener = new RegistrationListener() {

            public void notify(String layer, String appContext) {
            }
        };
        Subject serviceSubject = findServiceSubject(server);
        String serverName = findServerName(server, serviceSubject);
        String contextPath = context.getContextPath();
        if (contextPath == null || contextPath.length() == 0)
            contextPath = "/";
        String appContext = serverName + " " + context.getContextPath();
        AuthConfigProvider authConfigProvider = authConfigFactory.getConfigProvider(MESSAGE_LAYER, appContext, listener);
        if (authConfigProvider != null) {
            ServletCallbackHandler servletCallbackHandler = new ServletCallbackHandler(loginService);
            ServerAuthConfig serverAuthConfig = authConfigProvider.getServerAuthConfig(MESSAGE_LAYER, appContext, servletCallbackHandler);
            if (serverAuthConfig != null) {
                Map map = new HashMap();
                for (String key : configuration.getInitParameterNames()) map.put(key, configuration.getInitParameter(key));
                authenticator = new JaspiAuthenticator(serverAuthConfig, map, servletCallbackHandler, serviceSubject, true, identityService);
            }
        }
    } catch (AuthException e) {
        LOG.warn(e);
    }
    return authenticator;
}
Also used : RegistrationListener(javax.security.auth.message.config.RegistrationListener) AuthConfigProvider(javax.security.auth.message.config.AuthConfigProvider) HashMap(java.util.HashMap) AuthConfigFactory(javax.security.auth.message.config.AuthConfigFactory) AuthException(javax.security.auth.message.AuthException) HashMap(java.util.HashMap) Map(java.util.Map) Authenticator(org.eclipse.jetty.security.Authenticator) Subject(javax.security.auth.Subject) ServerAuthConfig(javax.security.auth.message.config.ServerAuthConfig)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 Subject (javax.security.auth.Subject)1 AuthException (javax.security.auth.message.AuthException)1 AuthConfigFactory (javax.security.auth.message.config.AuthConfigFactory)1 AuthConfigProvider (javax.security.auth.message.config.AuthConfigProvider)1 RegistrationListener (javax.security.auth.message.config.RegistrationListener)1 ServerAuthConfig (javax.security.auth.message.config.ServerAuthConfig)1 Authenticator (org.eclipse.jetty.security.Authenticator)1