1 17 package org.apache.catalina.authenticator; 18 19 import java.security.Principal ; 20 21 import org.apache.catalina.Session; 22 import org.apache.catalina.authenticator.Constants; 23 24 36 public class SingleSignOnEntry 37 { 38 40 protected String authType = null; 41 42 protected String password = null; 43 44 protected Principal principal = null; 45 46 protected Session sessions[] = new Session[0]; 47 48 protected String username = null; 49 50 protected boolean canReauthenticate = false; 51 52 54 64 public SingleSignOnEntry(Principal principal, String authType, 65 String username, String password) { 66 super(); 67 updateCredentials(principal, authType, username, password); 68 } 69 70 public SingleSignOnEntry() { 71 } 72 73 75 83 public synchronized void addSession(SingleSignOn sso, Session session) { 84 for (int i = 0; i < sessions.length; i++) { 85 if (session == sessions[i]) 86 return; 87 } 88 Session results[] = new Session[sessions.length + 1]; 89 System.arraycopy(sessions, 0, results, 0, sessions.length); 90 results[sessions.length] = session; 91 sessions = results; 92 session.addSessionListener(sso); 93 } 94 95 101 public synchronized void removeSession(Session session) { 102 Session[] nsessions = new Session[sessions.length - 1]; 103 for (int i = 0, j = 0; i < sessions.length; i++) { 104 if (session == sessions[i]) 105 continue; 106 nsessions[j++] = sessions[i]; 107 } 108 sessions = nsessions; 109 } 110 111 114 public synchronized Session[] findSessions() { 115 return (this.sessions); 116 } 117 118 124 public String getAuthType() { 125 return (this.authType); 126 } 127 128 135 public boolean getCanReauthenticate() { 136 return (this.canReauthenticate); 137 } 138 139 146 public String getPassword() { 147 return (this.password); 148 } 149 150 154 public Principal getPrincipal() { 155 return (this.principal); 156 } 157 158 162 public String getUsername() { 163 return (this.username); 164 } 165 166 167 178 public void updateCredentials(Principal principal, String authType, 179 String username, String password) { 180 181 this.principal = principal; 182 this.authType = authType; 183 this.username = username; 184 this.password = password; 185 this.canReauthenticate = 186 (Constants.BASIC_METHOD.equals(authType) 187 || Constants.FORM_METHOD.equals(authType)); 188 } 189 190 } 191 | Popular Tags |