1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.ldap.server.authz.support;
20
21 import java.util.ArrayList;
22 import java.util.Iterator;
23
24 import javax.naming.NamingException;
25
26 import org.apache.ldap.common.schema.AttributeType;
27 import org.apache.ldap.common.schema.MatchingRule;
28 import org.apache.ldap.common.schema.Syntax;
29 import org.apache.ldap.common.schema.UsageEnum;
30 import org.apache.ldap.server.schema.AttributeTypeRegistry;
31
32 /***
33 * A mock {@link AttributeTypeRegistry} to test {@link ACITupleFilter} implementations.
34 *
35 * @author The Apache Directory Project
36 * @version $Rev: 292669 $, $Date: 2005-09-30 03:58:31 -0400 (Fri, 30 Sep 2005) $
37 *
38 */
39 public class DummyAttributeTypeRegistry implements AttributeTypeRegistry
40 {
41 private final boolean returnOperational;
42
43 public DummyAttributeTypeRegistry( boolean returnOperational )
44 {
45 this.returnOperational = returnOperational;
46 }
47
48 public void register( String schema, AttributeType attributeType ) throws NamingException
49 {
50 }
51
52 public AttributeType lookup( final String id ) throws NamingException
53 {
54 if( returnOperational )
55 {
56 return new AttributeType()
57 {
58 public boolean isSingleValue()
59 {
60 return false;
61 }
62
63 public boolean isCanUserModify()
64 {
65 return false;
66 }
67
68 public boolean isCollective()
69 {
70 return false;
71 }
72
73 public UsageEnum getUsage()
74 {
75 return null;
76 }
77
78 public AttributeType getSuperior() throws NamingException
79 {
80 return null;
81 }
82
83 public Syntax getSyntax() throws NamingException
84 {
85 return null;
86 }
87
88 public int getLength()
89 {
90 return 0;
91 }
92
93 public MatchingRule getEquality() throws NamingException
94 {
95 return null;
96 }
97
98 public MatchingRule getOrdering() throws NamingException
99 {
100 return null;
101 }
102
103 public MatchingRule getSubstr() throws NamingException
104 {
105 return null;
106 }
107
108 public boolean isObsolete()
109 {
110 return false;
111 }
112
113 public String getOid()
114 {
115 return String.valueOf( id.hashCode() );
116 }
117
118 public String[] getNames()
119 {
120 return new String[] { id };
121 }
122
123 public String getName()
124 {
125 return id;
126 }
127
128 public String getDescription()
129 {
130 return id;
131 }
132 };
133 }
134 else
135 {
136 return new AttributeType()
137 {
138 public boolean isSingleValue()
139 {
140 return false;
141 }
142
143 public boolean isCanUserModify()
144 {
145 return true;
146 }
147
148 public boolean isCollective()
149 {
150 return false;
151 }
152
153 public UsageEnum getUsage()
154 {
155 return null;
156 }
157
158 public AttributeType getSuperior() throws NamingException
159 {
160 return null;
161 }
162
163 public Syntax getSyntax() throws NamingException
164 {
165 return null;
166 }
167
168 public int getLength()
169 {
170 return 0;
171 }
172
173 public MatchingRule getEquality() throws NamingException
174 {
175 return null;
176 }
177
178 public MatchingRule getOrdering() throws NamingException
179 {
180 return null;
181 }
182
183 public MatchingRule getSubstr() throws NamingException
184 {
185 return null;
186 }
187
188 public boolean isObsolete()
189 {
190 return false;
191 }
192
193 public String getOid()
194 {
195 return String.valueOf( id.hashCode() );
196 }
197
198 public String[] getNames()
199 {
200 return new String[] { id };
201 }
202
203 public String getName()
204 {
205 return id;
206 }
207
208 public String getDescription()
209 {
210 return id;
211 }
212 };
213 }
214 }
215
216 public String getSchemaName( String id ) throws NamingException
217 {
218 return "dummy";
219 }
220
221 public boolean hasAttributeType( String id )
222 {
223 return true;
224 }
225
226 public Iterator list()
227 {
228 return new ArrayList().iterator();
229 }
230
231 }