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.modules;
 
 import java.util.Map;
 import java.util.Set;
 
 

Deprecated:
use *ServerAuthentication
Version:
$Rev: 4792 $ $Date: 2009-03-18 22:55:52 +0100 (Wed, 18 Mar 2009) $
 
 public class BaseAuthModule implements ServerAuthModuleServerAuthContext
 {
     private static final Class[] SUPPORTED_MESSAGE_TYPES = new Class[] { HttpServletRequest.classHttpServletResponse.class };
 
     protected static final String LOGIN_SERVICE_KEY = "org.eclipse.jetty.security.jaspi.modules.LoginService";
 
     protected CallbackHandler callbackHandler;
 
     public Class[] getSupportedMessageTypes()
     {
         return ;
     }
 
     public BaseAuthModule()
     {
     }
 
     public BaseAuthModule(CallbackHandler callbackHandler)
     {
         this. = callbackHandler;
     }
 
     public void initialize(MessagePolicy requestPolicyMessagePolicy responsePolicyCallbackHandler handlerMap optionsthrows AuthException
     {
         this. = handler;
     }
 
     public void cleanSubject(MessageInfo messageInfoSubject subjectthrows AuthException
     {
         // TODO apparently we either get the LoginCallback or the LoginService
         // but not both :-(
         // Set<LoginCallback> loginCallbacks =
         // subject.getPrivateCredentials(LoginCallback.class);
         // if (!loginCallbacks.isEmpty()) {
         // LoginCallback loginCallback = loginCallbacks.iterator().next();
         // }
         // try {
         // loginService.logout(subject);
         // } catch (ServerAuthException e) {
         // throw new AuthException(e.getMessage());
         // }
     }
 
     public AuthStatus secureResponse(MessageInfo messageInfoSubject serviceSubjectthrows AuthException
     {
         // servlets do not need secured responses
         return .;
     }
    public AuthStatus validateRequest(MessageInfo messageInfoSubject clientSubjectSubject serviceSubjectthrows AuthException
    {
        return .;
    }

    

Parameters:
messageInfo message info to examine for mandatory flag
Returns:
whether authentication is mandatory or optional
    protected boolean isMandatory(MessageInfo messageInfo)
    {
        String mandatory = (StringmessageInfo.getMap().get(.);
        if (mandatory == nullreturn false;
        return Boolean.valueOf(mandatory);
    }
    protected boolean login(Subject clientSubjectString credentials
                            String authMethodMessageInfo messageInfo
    {
        credentials = credentials.substring(credentials.indexOf(' ')+1);
        credentials = B64Code.decode(credentials,.);
        int i = credentials.indexOf(':');
        String userName = credentials.substring(0,i);
        String password = credentials.substring(i+1);
        return login(clientSubjectuserNamenew Password(password), authMethodmessageInfo);
    }
    protected boolean login(Subject clientSubjectString username
                            Credential credentialString authMethod
                            MessageInfo messageInfo
    {
        CredentialValidationCallback credValidationCallback = new CredentialValidationCallback(clientSubjectusernamecredential);
        .handle(new Callback[] { credValidationCallback });
        if (credValidationCallback.getResult())
        {
            Set<LoginCallbackImplloginCallbacks = clientSubject.getPrivateCredentials(LoginCallbackImpl.class);
            if (!loginCallbacks.isEmpty())
            {
                LoginCallbackImpl loginCallback = loginCallbacks.iterator().next();
                CallerPrincipalCallback callerPrincipalCallback = new CallerPrincipalCallback(clientSubjectloginCallback.getUserPrincipal());
                GroupPrincipalCallback groupPrincipalCallback = new GroupPrincipalCallback(clientSubjectloginCallback.getRoles());
                .handle(new Callback[] { callerPrincipalCallbackgroupPrincipalCallback });
            }
            messageInfo.getMap().put(.authMethod);
        }
        return credValidationCallback.getResult();
    }
New to GrepCode? Check out our FAQ X