1 23 24 package com.sun.enterprise.security.web; 25 26 import java.io.IOException ; 27 import java.security.Principal ; 28 import java.util.HashMap ; 29 import java.util.Iterator ; 30 import java.util.ArrayList ; 31 import java.util.logging.Logger ; 32 import java.util.logging.Level ; 33 34 import javax.servlet.ServletException ; 35 import javax.servlet.http.Cookie ; 36 import javax.servlet.http.HttpServletRequest ; 37 import javax.servlet.http.HttpServletResponse ; 38 39 import org.apache.catalina.Container; 40 import org.apache.catalina.HttpRequest; 41 import org.apache.catalina.HttpResponse; 42 import org.apache.catalina.Lifecycle; 43 import org.apache.catalina.LifecycleException; 44 import org.apache.catalina.Request; 45 import org.apache.catalina.Response; 46 import org.apache.catalina.Session; 47 import org.apache.catalina.SessionEvent; 48 import org.apache.catalina.SessionListener; 49 import org.apache.catalina.ValveContext; 50 import org.apache.catalina.authenticator.Constants; 51 import org.apache.catalina.Realm; 52 53 56 public class SingleSignOnEntry { 57 58 public String authType = null; 59 60 public String password = null; 61 62 public Principal principal = null; 63 64 public Session sessions[] = new Session[0]; 65 66 public String username = null; 67 68 public String realmName = null; 69 70 public long lastAccessTime; 71 72 public SingleSignOnEntry(Principal principal, String authType, 73 String username, String password, String realmName) { 74 super(); 75 this.principal = principal; 76 this.authType = authType; 77 this.username = username; 78 this.password = password; 79 this.realmName = realmName; 80 this.lastAccessTime = System.currentTimeMillis(); 81 } 82 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 public synchronized void removeSession(Session session) { 96 Session[] nsessions = new Session[sessions.length - 1]; 97 for (int i = 0, j = 0; i < sessions.length; i++) { 98 if (session == sessions[i]) 99 continue; 100 nsessions[j++] = sessions[i]; 101 } 102 sessions = nsessions; 103 } 104 105 public synchronized Session[] findSessions() { 106 return (this.sessions); 107 } 108 109 } 110 | Popular Tags |