Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.apache.catalina.authenticator;
 
 
 
A class that represents entries in the cache of authenticated users. This is necessary to make it available to AuthenticatorBase subclasses that need it in order to perform reauthentications when SingleSignOn is in use.

Author(s):
B Stansberry, based on work by Craig R. McClanahan
Version:
$Revision: 1570 $
See also:
SingleSignOn
AuthenticatorBase.reauthenticateFromSSO(java.lang.String,org.apache.catalina.connector.Request)
 
 public class SingleSignOnEntry
 {
     // ------------------------------------------------------  Instance Fields
 
     protected String authType = null;
 
     protected String password = null;
 
     protected Principal principal = null;
 
     protected Session sessions[] = new Session[0];
 
     protected String username = null;
 
     protected boolean canReauthenticate = false;
 
     // ---------------------------------------------------------  Constructors
 
    
Creates a new SingleSignOnEntry

Parameters:
principal the Principal returned by the latest call to Realm.authenticate.
authType the type of authenticator used (BASIC, CLIENT_CERT, DIGEST or FORM)
username the username (if any) used for the authentication
password the password (if any) used for the authentication
 
     public SingleSignOnEntry(Principal principalString authType,
                              String usernameString password) {
         super();
         updateCredentials(principalauthTypeusernamepassword);
     }
 
     public SingleSignOnEntry() {
     }
 
     // ------------------------------------------------------- Package Methods
 
    
Adds a Session to the list of those associated with this SSO.

Parameters:
sso The SingleSignOn valve that is managing the SSO session.
session The Session being associated with the SSO.
 
     public synchronized void addSession(SingleSignOn ssoSession session) {
         for (int i = 0; i < .i++) {
             if (session == [i])
                 return;
         }
         Session results[] = new Session[. + 1];
         System.arraycopy(, 0, results, 0, .);
         results[.] = session;
          = results;
         session.addSessionListener(sso);
     }

    
Removes the given Session from the list of those associated with this SSO.

Parameters:
session the Session to remove.
    public synchronized void removeSession(Session session) {
        Session[] nsessions = new Session[. - 1];
        for (int i = 0, j = 0; i < .i++) {
            if (session == [i])
                continue;
            nsessions[j++] = [i];
        }
         = nsessions;
    }

    
Returns the Sessions associated with this SSO.
    public synchronized Session[] findSessions() {
        return (this.);
    }

    
Gets the name of the authentication type originally used to authenticate the user associated with the SSO.

Returns:
"BASIC", "CLIENT_CERT", "DIGEST", "FORM" or "NONE"
    public String getAuthType() {
        return (this.);
    }

    
Gets whether the authentication type associated with the original authentication supports reauthentication.

Returns:
true if getAuthType returns "BASIC" or "FORM", false otherwise.
    public boolean getCanReauthenticate() {
        return (this.);
    }

    
Gets the password credential (if any) associated with the SSO.

Returns:
the password credential associated with the SSO, or null if the original authentication type does not involve a password.
    public String getPassword() {
        return (this.);
    }

    
Gets the Principal that has been authenticated by the SSO.
    public Principal getPrincipal() {
        return (this.);
    }

    
Gets the username provided by the user as part of the authentication process.
    public String getUsername() {
        return (this.);
    }


    
Updates the SingleSignOnEntry to reflect the latest security information associated with the caller.

Parameters:
principal the Principal returned by the latest call to Realm.authenticate.
authType the type of authenticator used (BASIC, CLIENT_CERT, DIGEST or FORM)
username the username (if any) used for the authentication
password the password (if any) used for the authentication
    public void updateCredentials(Principal principalString authType,
                                  String usernameString password) {
        this. = principal;
        this. = authType;
        this. = username;
        this. = password;
        this. =
            (..equals(authType)
                || ..equals(authType)
                || ..equals(authType));
    }
New to GrepCode? Check out our FAQ X