Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  //
  //  ========================================================================
  //  Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
  //  ------------------------------------------------------------------------
  //  All rights reserved. This program and the accompanying materials
  //  are made available under the terms of the Eclipse Public License v1.0
  //  and Apache License v2.0 which accompanies this distribution.
  //
  //      The Eclipse Public License is available at
 //      http://www.eclipse.org/legal/epl-v10.html
 //
 //      The Apache License v2.0 is available at
 //      http://www.opensource.org/licenses/apache2.0.php
 //
 //  You may elect to redistribute this code under either of these licenses.
 //  ========================================================================
 //
 
 package org.eclipse.jetty.security.jaspi;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 
 
 {
     private static final Logger LOG = Log.getLogger(JaspiAuthenticatorFactory.class);
 
     private static String MESSAGE_LAYER = "HTTP";
     
     private Subject _serviceSubject;
     private String _serverName;
     
 
     /* ------------------------------------------------------------ */
    

Returns:
the serviceSubject
 
     public Subject getServiceSubject()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
serviceSubject the serviceSubject to set
 
     public void setServiceSubject(Subject serviceSubject)
     {
          = serviceSubject;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
the serverName
 
     public String getServerName()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
serverName the serverName to set
 
     public void setServerName(String serverName)
     {
          = serverName;
     }
 
     /* ------------------------------------------------------------ */
     public Authenticator getAuthenticator(Server serverServletContext contextAuthConfiguration configurationIdentityService identityServiceLoginService loginService)
     {
         Authenticator authenticator=null;
         try 
         {
             AuthConfigFactory authConfigFactory = AuthConfigFactory.getFactory();
             RegistrationListener listener = new RegistrationListener()
             {
                 public void notify(String layerString appContext)
                {}
            };
            Subject serviceSubject=findServiceSubject(server);
            String serverName=findServerName(server,serviceSubject);
            String appContext = serverName + " " + context.getContextPath();
            
            AuthConfigProvider authConfigProvider = authConfigFactory.getConfigProvider(,appContext,listener);
  
            if (authConfigProvider != null)
            {
                ServletCallbackHandler servletCallbackHandler = new ServletCallbackHandler(loginService);
                ServerAuthConfig serverAuthConfig = authConfigProvider.getServerAuthConfig(,appContext,servletCallbackHandler);
                if (serverAuthConfig != null)
                {
                    Map map = new HashMap();
                    for (String key : configuration.getInitParameterNames())
                        map.put(key,configuration.getInitParameter(key));
                    authenticatornew JaspiAuthenticator(serverAuthConfig,map,servletCallbackHandler,
                                serviceSubject,trueidentityService);
                }
            }
        } 
        catch (AuthException e
        {
            .warn(e);
        }
        return authenticator;
    }
    /* ------------------------------------------------------------ */
    
Find a service Subject. If setServiceSubject(javax.security.auth.Subject) has not been used to set a subject, then the org.eclipse.jetty.util.component.ContainerLifeCycle.getBeans(java.lang.Class) method is used to look for a Subject.
    protected Subject findServiceSubject(Server server)
    {
        if (!=null)
            return ;
        List<Subjectsubjects = (List<Subject>)server.getBeans(Subject.class);
        if (subjects.size()>0)
            return (Subject)subjects.get(0);
        return null;
    }
    /* ------------------------------------------------------------ */
    
Find a servername. If setServerName(java.lang.String) has not been called, then use the name of the a principal in the service subject. If not found, return "server".
    protected String findServerName(Server serverSubject subject)
    {
        if (!=null)
            return ;
        if (subject!=null)
        {
            Set<Principalprincipals = subject.getPrincipals();
            if (principals!=null && !principals.isEmpty())
                return principals.iterator().next().getName();
        }
        
        return "server";
    }
New to GrepCode? Check out our FAQ X