KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > api > securitymgr > session > SecurityManagerFactory


1 /*
2  * SecurityManagerFactory.java
3  *
4  * Created on May 12, 2003, 2:57 PM
5  */

6
7 package com.raptus.owxv3.api.securitymgr.session;
8
9 import com.raptus.owxv3.*;
10 import com.raptus.owxv3.api.securitymgr.*;
11 import javax.servlet.http.*;
12
13 /**
14  *
15  * @author root
16  */

17 public class SecurityManagerFactory implements SecurityMgrFactoryIF
18 {
19     
20     public static final String JavaDoc SESS_SECURITY_MANAGER_KEY="SecurityManager";
21     
22     /** Creates a new instance of SecurityManagerFactory */
23     public SecurityManagerFactory()
24     {
25         LoggingManager.log(this.getClass().getName()+">1", this);
26         LoggingManager.log("Initialising session security manager factory!", this);
27         LoggingManager.log(this.getClass().getName()+"<1", this);
28     }
29     
30     /**
31      * Create a security manager, according to object param.
32      *
33      * All data related to security should be taken from param object
34      *
35      * As this security manager uses all security data from the request,
36      * the object is cached in user's session, and on each request, when a new
37      * security manager is requested, simply return the cached one, with updated
38      * servlet request param.
39      *
40      * @param param - the parameter containing all data related to security
41      * (like users, roles, etc)
42      */

43     public SecurityMgrIF createSecurityManager(Object JavaDoc param)
44     {
45         HttpServletRequest req = (HttpServletRequest)param;
46         
47         // check if we already cached a security manager for this user
48
SecurityManager JavaDoc sm = (SecurityManager JavaDoc)req.getSession().getAttribute(
49             SecurityManagerFactory.SESS_SECURITY_MANAGER_KEY);
50         
51         // nope, create a new one
52
if(sm == null)
53         {
54             sm = new com.raptus.owxv3.api.securitymgr.session.SecurityManager(req);
55         }
56         else
57         {
58             // yup, we have one. update variables
59
sm.setRequest(req);
60         }
61         LoggingManager.log(this.getClass().getName()+"<2", this);
62         return sm;
63     }
64     
65 }
66
Popular Tags