KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > policyframework > AccessRight


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.policyframework;
21
22 import java.io.Serializable JavaDoc;
23
24
25 /**
26  * Every {@link com.sslexplorer.policyframework.AccessRights} contains
27  * of at least one AccessRight. This provides the
28  * {@link com.sslexplorer.policyframework.ResourceType} and
29  * {@link com.sslexplorer.policyframework.Permission} that
30  * make up a single permission.
31  * <p>
32  * See {@link com.sslexplorer.policyframework.PolicyConstants} for a bunch
33  * of constants for resource types and permission.
34  *
35  * @author Brett Smith <brett@3sp.com>
36  * @see com.sslexplorer.policyframework.PolicyConstants
37  */

38 public class AccessRight implements Serializable JavaDoc {
39     
40     // Private instance variables
41

42     private ResourceType resourceType;
43     private Permission permission;
44
45     /**
46      * Constructor
47      *
48      * @param resourceType resource type
49      * @param permission resource permission
50      */

51     public AccessRight(ResourceType resourceType, Permission permission) {
52         if (resourceType == null) {
53             throw new IllegalArgumentException JavaDoc("Null resource type.");
54         }
55         if (permission == null) {
56             throw new IllegalArgumentException JavaDoc("Null permission.");
57         }
58         this.resourceType = resourceType;
59         this.permission = permission;
60     }
61
62     /* (non-Javadoc)
63      * @see java.lang.Object#equals(java.lang.Object)
64      */

65     public boolean equals(Object JavaDoc o) {
66         return o instanceof AccessRight ? getPermission().equals(
67             ((AccessRight) o).getPermission())
68                         && getResourceType().equals(((AccessRight) o).getResourceType()) : false;
69     }
70
71     /**
72      * Get the resource permission.
73      *
74      * @return returns the permission.
75      */

76     public Permission getPermission() {
77         return permission;
78     }
79
80     /**
81      * Set the resource permission.
82      *
83      * @param permission The permission to set.
84      */

85     public void setPermission(Permission permission) {
86         this.permission = permission;
87     }
88
89     /**
90      * Get the resource type. See {@link PolicyConstants} for a list
91      * of resource types.
92      *
93      * @return returns the resourceType.
94      */

95     public ResourceType getResourceType() {
96         return resourceType;
97     }
98
99     /**
100      * Set the resource type. See {@link PolicyConstants} for a list
101      * of resource types.
102      *
103      * @param resourceType The resourceType to set.
104      */

105     public void setResourceType(ResourceType resourceType) {
106         this.resourceType = resourceType;
107     }
108 }
109
Popular Tags