001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.harmony.jndi.provider.ldap.asn1;
019:
020: import org.apache.harmony.security.asn1.ASN1Boolean;
021: import org.apache.harmony.security.asn1.ASN1Constants;
022: import org.apache.harmony.security.asn1.ASN1Enumerated;
023: import org.apache.harmony.security.asn1.ASN1Implicit;
024: import org.apache.harmony.security.asn1.ASN1Integer;
025: import org.apache.harmony.security.asn1.ASN1OctetString;
026: import org.apache.harmony.security.asn1.ASN1Sequence;
027: import org.apache.harmony.security.asn1.ASN1SequenceOf;
028: import org.apache.harmony.security.asn1.ASN1SetOf;
029: import org.apache.harmony.security.asn1.ASN1Type;
030:
031: /**
032: * This class contains all ASN.1 type defined in RFC 2251.
033: */
034: public class LdapASN1Constant {
035:
036: public static final int OP_BIND_REQUEST = 0;
037:
038: public static final int OP_BIND_RESPONSE = 1;
039:
040: public static final int OP_UNBIND_REQUEST = 2;
041:
042: public static final int OP_SEARCH_REQUEST = 3;
043:
044: public static final int OP_SEARCH_RESULT_ENTRY = 4;
045:
046: public static final int OP_SEARCH_RESULT_DONE = 5;
047:
048: public static final int OP_SEARCH_RESULT_REF = 6;
049:
050: public static final int OP_MODIFY_REQUEST = 7;
051:
052: public static final int OP_MODIFY_RESPONSE = 8;
053:
054: public static final int OP_ADD_REQUEST = 9;
055:
056: public static final int OP_ADD_RESPONSE = 10;
057:
058: public static final int OP_DEL_REQUEST = 11;
059:
060: public static final int OP_DEL_RESPONSE = 12;
061:
062: public static final int OP_MODIFY_DN_REQUEST = 13;
063:
064: public static final int OP_MODIFY_DN_RESPONSE = 14;
065:
066: public static final int OP_COMPARE_REQUEST = 15;
067:
068: public static final int OP_COMPARE_RESPONSE = 16;
069:
070: public static final int OP_ABANDON_REQUEST = 17;
071:
072: public static final int OP_EXTENDED_REQUEST = 18;
073:
074: public static final int OP_EXTENDED_RESPONSE = 19;
075:
076: public static final ASN1Type Attribute = new ASN1SequenceWrap(
077: new ASN1Type[] { ASN1OctetString.getInstance(), // type
078: new ASN1SetOf(ASN1OctetString.getInstance()) }); // vals
079:
080: public static final ASN1Type AttributeList = new ASN1SequenceOf(
081: new ASN1SequenceWrap(new ASN1Type[] {
082: ASN1OctetString.getInstance(), // type
083: new ASN1SetOf(ASN1OctetString.getInstance()) })); // values
084:
085: public static final ASN1Type AddRequest = new ASN1Implicit(
086: ASN1Constants.CLASS_APPLICATION, 8, new ASN1SequenceWrap(
087: new ASN1Type[] { ASN1OctetString.getInstance(), // entry
088: AttributeList })); // attributes
089:
090: public static final ASN1Type SaslCredentials = new ASN1SequenceWrap(
091: new ASN1Type[] { ASN1OctetString.getInstance(), // mechanism
092: ASN1OctetString.getInstance() }) { // credentials
093: {
094: setOptional(1); // credentials is optional
095: }
096: };
097:
098: public static final ASN1Type AuthenticationChoice = new ASN1ChoiceWrap(
099: new ASN1Type[] {
100: new ASN1Implicit(
101: ASN1Constants.CLASS_CONTEXTSPECIFIC, 0, // simple
102: ASN1OctetString.getInstance()),
103: new ASN1Implicit(
104: ASN1Constants.CLASS_CONTEXTSPECIFIC, 3, // sasl
105: SaslCredentials) });
106:
107: public static final ASN1Type LDAPResult = new ASN1SequenceWrap(
108: new ASN1Type[] {
109: ASN1Enumerated.getInstance(), // resultCode
110: ASN1OctetString.getInstance(), // matchedDN
111: ASN1OctetString.getInstance(), // errorMessage
112: new ASN1Implicit(
113: ASN1Constants.CLASS_CONTEXTSPECIFIC, 3, // referral
114: new ASN1SequenceOf(ASN1OctetString
115: .getInstance())) }) {
116: {
117: setOptional(3); // referral is optional
118: }
119: };
120:
121: public static final ASN1Type AddResponse = new ASN1Implicit(
122: ASN1Constants.CLASS_APPLICATION, 9, LDAPResult);
123:
124: public static final ASN1Type Control = new ASN1SequenceWrap(
125: new ASN1Type[] { ASN1OctetString.getInstance(), // controlType
126: ASN1Boolean.getInstance(), // criticality
127: ASN1OctetString.getInstance() }) { // controlValue
128: {
129: setDefault(Boolean.FALSE, 1); // criticality default false
130: setOptional(2); // controlValue is optional
131: }
132: };
133:
134: public static final ASN1Type BindRequest = new ASN1Implicit(
135: ASN1Constants.CLASS_APPLICATION, 0, new ASN1SequenceWrap(
136: new ASN1Type[] { ASN1Integer.getInstance(), // version
137: ASN1OctetString.getInstance(), // name
138: AuthenticationChoice })); // authentication
139:
140: public static final ASN1Type BindResponse = new ASN1Implicit(
141: ASN1Constants.CLASS_APPLICATION,
142: 1,
143: Utils
144: .conjoinSequence(
145: (ASN1Sequence) LDAPResult, // result
146: new ASN1SequenceWrap(
147: new ASN1Type[] { new ASN1Implicit(
148: ASN1Constants.CLASS_CONTEXTSPECIFIC,
149: 7, // serverSaslCreds
150: ASN1OctetString
151: .getInstance()) }) {
152: {
153: setOptional(0); // serverSaslCreds is optional
154: }
155: }));
156:
157: public static final ASN1Type UnbindRequest = new ASN1Implicit(
158: ASN1Constants.CLASS_APPLICATION, 2, ASN1Null.getInstance());
159:
160: public static final ASN1Type AttributeValueAssertion = new ASN1SequenceWrap(
161: new ASN1Type[] { ASN1OctetString.getInstance(), // attributeDesc
162: ASN1OctetString.getInstance() }); // assertionValue
163:
164: public static final ASN1Type AbandonRequest = new ASN1Implicit(
165: ASN1Constants.CLASS_APPLICATION, 16, ASN1Integer
166: .getInstance());
167:
168: public static final ASN1Type CompareRequest = new ASN1Implicit(
169: ASN1Constants.CLASS_APPLICATION, 14, new ASN1SequenceWrap(
170: new ASN1Type[] { ASN1OctetString.getInstance(), // entry
171: AttributeValueAssertion })); // ava
172:
173: public static final ASN1Type CompareResponse = new ASN1Implicit(
174: ASN1Constants.CLASS_APPLICATION, 15, LDAPResult);
175:
176: public static final ASN1Type DelRequest = new ASN1Implicit(
177: ASN1Constants.CLASS_APPLICATION, 10, ASN1OctetString
178: .getInstance());
179:
180: public static final ASN1Type DelResponse = new ASN1Implicit(
181: ASN1Constants.CLASS_APPLICATION, 11, LDAPResult);
182:
183: public static final ASN1Type ExtendedRequest = new ASN1Implicit(
184: ASN1Constants.CLASS_APPLICATION, 23,
185: new ASN1SequenceWrap(new ASN1Type[] {
186: new ASN1Implicit(
187: ASN1Constants.CLASS_CONTEXTSPECIFIC, 0, // requestName
188: ASN1OctetString.getInstance()),
189: new ASN1Implicit(
190: ASN1Constants.CLASS_CONTEXTSPECIFIC, 1, // requestValue
191: ASN1OctetString.getInstance()) }) {
192: {
193: setOptional(1); // requestValue is optional
194: }
195: });
196:
197: public static final ASN1Type ExtendedResponse = new ASN1Implicit(
198: ASN1Constants.CLASS_APPLICATION,
199: 24,
200: Utils
201: .conjoinSequence(
202: (ASN1Sequence) LDAPResult, // LDAPResult
203: new ASN1SequenceWrap(
204: new ASN1Type[] {
205: new ASN1Implicit(
206: ASN1Constants.CLASS_CONTEXTSPECIFIC,
207: 10, // responseName
208: ASN1OctetString
209: .getInstance()),
210: new ASN1Implicit(
211: ASN1Constants.CLASS_CONTEXTSPECIFIC,
212: 11, // response
213: ASN1OctetString
214: .getInstance()) }) {
215: {
216: setOptional(0);
217: setOptional(1);
218: }
219: }));
220:
221: public static final ASN1Type ModifyDNRequest = new ASN1Implicit(
222: ASN1Constants.CLASS_APPLICATION, 12,
223: new ASN1SequenceWrap(new ASN1Type[] {
224: ASN1OctetString.getInstance(), // entry
225: ASN1OctetString.getInstance(), // newrdn
226: ASN1Boolean.getInstance(), // deleteoldrdn
227: new ASN1Implicit(
228: ASN1Constants.CLASS_CONTEXTSPECIFIC, 0,
229: ASN1OctetString.getInstance()) }) { // newSuperior
230: {
231: setOptional(3);
232: }
233: });
234:
235: public static final ASN1Type ModifyDNResponse = new ASN1Implicit(
236: ASN1Constants.CLASS_APPLICATION, 13, LDAPResult);
237:
238: public static final ASN1Type AttributeTypeAndValues = new ASN1SequenceWrap(
239: new ASN1Type[] { ASN1OctetString.getInstance(), // type
240: new ASN1SetOf(ASN1OctetString.getInstance()) }); // vals
241:
242: public static final ASN1Type ModifyRequest = new ASN1Implicit(
243: ASN1Constants.CLASS_APPLICATION, 6,
244: new ASN1SequenceWrap(new ASN1Type[] {
245: ASN1OctetString.getInstance(), // object
246: new ASN1SequenceOf(new ASN1SequenceWrap( // modification
247: new ASN1Type[] {
248: ASN1Enumerated.getInstance(), // operation
249: AttributeTypeAndValues })) })); // modification
250:
251: public static final ASN1Type ModifyResponse = new ASN1Implicit(
252: ASN1Constants.CLASS_APPLICATION, 7, LDAPResult);
253:
254: public static final ASN1Type SubstringFilter = new ASN1SequenceWrap(
255: new ASN1Type[] {
256: ASN1OctetString.getInstance(), // type
257: new ASN1SequenceOf(
258: new ASN1ChoiceWrap(new ASN1Type[] { // substrings
259: new ASN1Implicit(
260: // initial
261: ASN1Constants.CLASS_CONTEXTSPECIFIC,
262: 0,
263: ASN1OctetString
264: .getInstance()),
265: new ASN1Implicit(
266: // any
267: ASN1Constants.CLASS_CONTEXTSPECIFIC,
268: 1,
269: ASN1OctetString
270: .getInstance()),
271: new ASN1Implicit(
272: // final
273: ASN1Constants.CLASS_CONTEXTSPECIFIC,
274: 2,
275: ASN1OctetString
276: .getInstance()) })) });
277:
278: public static final ASN1Type MatchingRuleAssertion = new ASN1SequenceWrap(
279: new ASN1Type[] {
280: new ASN1Implicit(
281: ASN1Constants.CLASS_CONTEXTSPECIFIC, 1, // matchingRule
282: ASN1OctetString.getInstance()),
283: new ASN1Implicit(
284: ASN1Constants.CLASS_CONTEXTSPECIFIC, 2, // type
285: ASN1OctetString.getInstance()),
286: new ASN1Implicit(
287: ASN1Constants.CLASS_CONTEXTSPECIFIC, 3, // matchValue
288: ASN1OctetString.getInstance()),
289: new ASN1Implicit(
290: ASN1Constants.CLASS_CONTEXTSPECIFIC, 4, // dnAttributes
291: ASN1Boolean.getInstance()) }) {
292: {
293: setOptional(0);
294: setOptional(1);
295: setDefault(Boolean.FALSE, 3);
296: }
297: };
298:
299: public static final ASN1Type Filter = new ASN1ChoiceWrap(
300: new ASN1Type[] {
301: new ASN1Implicit(
302: ASN1Constants.CLASS_CONTEXTSPECIFIC, 0,
303: new ASN1SetOf(new ASN1LdapFilter())),
304: new ASN1Implicit(
305: ASN1Constants.CLASS_CONTEXTSPECIFIC, 1,
306: new ASN1SetOf(new ASN1LdapFilter())),
307: new ASN1Implicit(
308: ASN1Constants.CLASS_CONTEXTSPECIFIC, 2,
309: new ASN1LdapFilter()),
310: new ASN1Implicit(
311: ASN1Constants.CLASS_CONTEXTSPECIFIC, 3,
312: AttributeValueAssertion),
313: new ASN1Implicit(
314: ASN1Constants.CLASS_CONTEXTSPECIFIC, 4,
315: SubstringFilter),
316: new ASN1Implicit(
317: ASN1Constants.CLASS_CONTEXTSPECIFIC, 5,
318: AttributeValueAssertion),
319: new ASN1Implicit(
320: ASN1Constants.CLASS_CONTEXTSPECIFIC, 6,
321: AttributeValueAssertion),
322: new ASN1Implicit(
323: ASN1Constants.CLASS_CONTEXTSPECIFIC, 7,
324: ASN1OctetString.getInstance()),
325: new ASN1Implicit(
326: ASN1Constants.CLASS_CONTEXTSPECIFIC, 8,
327: AttributeValueAssertion),
328: new ASN1Implicit(
329: ASN1Constants.CLASS_CONTEXTSPECIFIC, 9,
330: MatchingRuleAssertion) });
331:
332: public static final ASN1Type SearchRequest = new ASN1Implicit(
333: ASN1Constants.CLASS_APPLICATION, 3, new ASN1SequenceWrap(
334: new ASN1Type[] {
335: ASN1OctetString.getInstance(), // baseObject
336: ASN1Enumerated.getInstance(), // scope
337: ASN1Enumerated.getInstance(), // derefAliases
338: ASN1Integer.getInstance(), // sizeLimit
339: ASN1Integer.getInstance(), // timeLimit
340: ASN1Boolean.getInstance(), // typesonly
341: Filter, // Filter
342: new ASN1SequenceOf(ASN1OctetString
343: .getInstance()) })); // attributes
344:
345: public static final ASN1Type PartialAttributeList = new ASN1SequenceOf(
346: new ASN1SequenceWrap(new ASN1Type[] {
347: ASN1OctetString.getInstance(), // type
348: new ASN1SetOf(ASN1OctetString.getInstance()) })); // vals
349:
350: public static final ASN1Type SearchResultEntry = new ASN1Implicit(
351: ASN1Constants.CLASS_APPLICATION, 4, new ASN1SequenceWrap(
352: new ASN1Type[] { ASN1OctetString.getInstance(), // objectName
353: PartialAttributeList })); // attributes
354:
355: public static final ASN1Type SearchResultReference = new ASN1Implicit(
356: ASN1Constants.CLASS_APPLICATION, 19, new ASN1SequenceOf(
357: ASN1OctetString.getInstance()));
358:
359: public static final ASN1Type SearchResultDone = new ASN1Implicit(
360: ASN1Constants.CLASS_APPLICATION, 5, LDAPResult);
361:
362: public static final ASN1Type LDAPMessage = new ASN1SequenceWrap(
363: new ASN1Type[] {
364: ASN1Integer.getInstance(),
365: new ASN1ChoiceWrap(new ASN1Type[] { BindRequest,
366: BindResponse, UnbindRequest, SearchRequest,
367: SearchResultEntry, SearchResultDone,
368: SearchResultReference, ModifyRequest,
369: ModifyResponse, AddRequest, AddResponse,
370: DelRequest, DelResponse, ModifyDNRequest,
371: ModifyDNResponse, CompareRequest,
372: CompareResponse, AbandonRequest,
373: ExtendedRequest, ExtendedResponse }),
374: new ASN1Implicit(
375: ASN1Constants.CLASS_CONTEXTSPECIFIC, 0,
376: new ASN1SequenceOf(Control)) }) {
377: {
378: setOptional(2);
379: }
380: };
381:
382: public static final ASN1Type PersistentSearchControl = new ASN1SequenceWrap(
383: new ASN1Type[] { new ASN1Integer(), // changeTypes
384: new ASN1Boolean(), // changesOnly
385: new ASN1Boolean() }); // returnECs
386:
387: public static final ASN1Type EntryChangeNotificationControl = new ASN1SequenceWrap(
388: new ASN1Type[] { new ASN1Enumerated(), // changeType
389: new ASN1OctetString(), // previousDN
390: new ASN1Integer() }) { // changeNumber
391: {
392: setOptional(1);
393: setOptional(2);
394: }
395: };
396: }
|