KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > core > plugins > security > AccessController


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.core.plugins.security;
10
11 import org.jboss.portal.core.metadata.AccessControllerMetaData;
12 import org.jboss.portal.common.metadata.MetaData;
13 import org.jboss.portal.common.plugin.Plugin;
14 import org.jboss.portal.server.plugins.PluginService;
15
16 import java.util.Set JavaDoc;
17 import java.util.HashSet JavaDoc;
18 import java.util.Collections JavaDoc;
19
20 /**
21  * Maintain the authorization state.
22  *
23  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
24  * @version $Revision: 1.1 $
25  */

26 public class AccessController
27    extends PluginService
28    implements Plugin
29 {
30
31    /** Our meta data. */
32    private AccessControllerMetaData metaData;
33    
34    /** True if no check should be done. */
35    private boolean unchecked;
36
37    /** The set of authorized roles. */
38    private Set JavaDoc roles;
39    
40    public AccessController()
41    {
42       this.metaData = null;
43       this.unchecked = false;
44       this.roles = Collections.EMPTY_SET;
45    }
46    
47    public void setMetaData(MetaData metaData)
48    {
49       this.metaData = (AccessControllerMetaData)metaData;
50    }
51    
52    public MetaData getMetaData()
53    {
54       return metaData;
55    }
56    
57    public void create()
58    {
59       unchecked = metaData.isUnchecked();
60       roles = Collections.unmodifiableSet(new HashSet JavaDoc(metaData.getRoles()));
61    }
62    
63    public boolean isUnchecked()
64    {
65       return unchecked;
66    }
67    
68    public Set JavaDoc getRoles()
69    {
70       return roles;
71    }
72 }
73
Popular Tags