KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > common > acl > AclInfo


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package org.lucane.common.acl;
20
21 import java.io.Serializable JavaDoc;
22
23 /**
24  * A ACL item
25  */

26 public class AclInfo implements Serializable JavaDoc
27 {
28     private String JavaDoc access;
29     private boolean allow;
30     private String JavaDoc group;
31     private String JavaDoc user;
32     
33     /**
34      * Constructor.
35      *
36      * @param access the logical name
37      * @param allow true to allow, false for deny
38      * @param group the group or null if applied to a user
39      * @param user the user or null if applied to a group
40      */

41     public AclInfo(String JavaDoc access, boolean allow, String JavaDoc group, String JavaDoc user)
42     {
43         this.access = access;
44         this.allow = allow;
45         this.group = group;
46         this.user = user;
47     }
48     
49     /**
50      * @return access logical name
51      */

52     public String JavaDoc getAccess() {
53         return access;
54     }
55     
56     /**
57      * @return true if the access in granted
58      */

59     public boolean isAllow() {
60         return allow;
61     }
62     
63     /**
64      * @return false if the access is denied
65      */

66     public boolean isDeny() {
67         return !allow;
68     }
69     
70     /**
71      * @return the group or null if it's applied to a user
72      */

73     public String JavaDoc getGroup() {
74         return group;
75     }
76     /**
77      * @return the user or null if it's applied to a group
78      */

79     public String JavaDoc getUser() {
80         return user;
81     }
82
83     public boolean equals(Object JavaDoc other)
84     {
85         if(other instanceof AclInfo)
86         {
87             AclInfo i = (AclInfo)other;
88             if(user != null && !user.equals(i.user))
89                 return false;
90             if(group != null && !group.equals(i.group))
91                 return false;
92             if(i.user != null && !i.user.equals(user))
93                 return false;
94             if(i.group != null && !i.group.equals(group))
95                 return false;
96
97             return access.equals(i.access) && allow == i.allow;
98         }
99
100         return false;
101     }
102 }
Popular Tags