KickJava   Java API By Example, From Geeks To Geeks.

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


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

6
7 package com.raptus.owxv3.api.securitymgr.tomcat;
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     }
26     
27     /**
28      * Create a security manager, according to object param.
29      *
30      * All data related to security should be taken from param object
31      *
32      * As this security manager uses all security data from the request,
33      * the object is cached in user's session, and on each request, when a new
34      * security manager is requested, simply return the cached one, with updated
35      * servlet request param.
36      *
37      * @param param - the parameter containing all data related to security
38      * (like users, roles, etc)
39      */

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