KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > coi > tools > os > win > AccessControlList


1 /*
2  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
3  *
4  * http://www.izforge.com/izpack/
5  * http://developer.berlios.de/projects/izpack/
6  *
7  * Copyright 2006 Klaus Bartz
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package com.coi.tools.os.win;
23
24 import java.util.ArrayList JavaDoc;
25
26 /**
27  * Data container for access control lists used by the registry stuff in the java and in the native
28  * part. DO NOT CHANGE METHODE SIGNATURES etc. without addapt the native methods
29  * RegistryImpl.modifyKeyACL and RegistryImpl.getKeyACL.
30  *
31  * @author Klaus Bartz
32  *
33  */

34 public class AccessControlList extends java.util.ArrayList JavaDoc
35 {
36
37     private ArrayList JavaDoc permissions = new ArrayList JavaDoc();
38
39     /**
40      * Default constructor.
41      */

42     public AccessControlList()
43     {
44         super();
45     }
46
47     /**
48      * Creates an ACE entry in the permission array with the given values.
49      *
50      * @param owner owner of the ACE
51      * @param allowed access allowed mask
52      * @param denied access denied mask
53      */

54     public void setACE(String JavaDoc owner, int allowed, int denied)
55     {
56         AccessControlEntry ace = new AccessControlEntry(owner, allowed, denied);
57         permissions.add(ace);
58     }
59
60     /**
61      * Returns the access control entry related to the given id.
62      *
63      * @param num id in the internal permisson array.
64      * @return the access control entry for the given id
65      */

66     public AccessControlEntry getACE(int num)
67     {
68         return ((AccessControlEntry) (((AccessControlEntry) permissions.get(num)).clone()));
69     }
70
71     /**
72      * Returns number of access control entries.
73      *
74      * @return number of access control entries
75      */

76     public int getACECount()
77     {
78         return (permissions.size());
79     }
80
81     /**
82      * This class holds a representation of MS Windows ACEs.
83      *
84      * @author Klaus Bartz
85      *
86      */

87     public static class AccessControlEntry implements Cloneable JavaDoc
88     {
89
90         private String JavaDoc owner;
91
92         private int accessAllowdMask;
93
94         private int accessDeniedMask;
95
96         /**
97          * Default constructor.
98          */

99         public AccessControlEntry()
100         {
101             super();
102         }
103
104         /**
105          * Creates an ACE with the given parameter.
106          *
107          * @param owner2 owner of the ACE
108          * @param allowed access allowed mask
109          * @param denied access denied mask
110          */

111         public AccessControlEntry(String JavaDoc owner2, int allowed, int denied)
112         {
113             owner = owner2;
114             accessAllowdMask = allowed;
115             accessDeniedMask = denied;
116         }
117
118         /**
119          * Returns the owner.
120          *
121          * @return the owner
122          */

123         public String JavaDoc getOwner()
124         {
125             return owner;
126         }
127
128         /**
129          * Sets owner to the given value.
130          *
131          * @param owner The owner to set.
132          */

133         public void setOwner(String JavaDoc owner)
134         {
135             this.owner = owner;
136         }
137
138         /**
139          * Returns the accessAllowdMask.
140          *
141          * @return the accessAllowdMask
142          */

143         public int getAccessAllowdMask()
144         {
145             return accessAllowdMask;
146         }
147
148         /**
149          * Sets accessAllowdMask to the given value.
150          *
151          * @param accessAllowdMask The accessAllowdMask to set.
152          */

153         public void setAccessAllowdMask(int accessAllowdMask)
154         {
155             this.accessAllowdMask = accessAllowdMask;
156         }
157
158         /**
159          * Returns the accessDeniedMask.
160          *
161          * @return the accessDeniedMask
162          */

163         public int getAccessDeniedMask()
164         {
165             return accessDeniedMask;
166         }
167
168         /**
169          * Sets accessDeniedMask to the given value.
170          *
171          * @param accessDeniedMask The accessDeniedMask to set.
172          */

173         public void setAccessDeniedMask(int accessDeniedMask)
174         {
175             this.accessDeniedMask = accessDeniedMask;
176         }
177
178         /*
179          * (non-Javadoc)
180          *
181          * @see java.lang.Object#clone()
182          */

183         public Object JavaDoc clone()
184         {
185             try
186             {
187                 return (super.clone());
188             }
189             catch (CloneNotSupportedException JavaDoc e)
190             {
191                 e.printStackTrace();
192             }
193             return (null);
194         }
195     }
196
197 }
198
Popular Tags