01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /**
19: * @author Alexander Y. Kleymenov
20: * @version $Revision$
21: */package org.apache.harmony.security.x501;
22:
23: import org.apache.harmony.security.asn1.ASN1Choice;
24: import org.apache.harmony.security.asn1.ASN1StringType;
25: import org.apache.harmony.security.asn1.ASN1Type;
26: import org.apache.harmony.security.asn1.BerInputStream;
27:
28: /**
29: * The class encapsulates the ASN.1 DER encoding/decoding work
30: * with the DirectoryString structure
31: * (as specified in RFC 3280 -
32: * Internet X.509 Public Key Infrastructure.
33: * Certificate and Certificate Revocation List (CRL) Profile.
34: * http://www.ietf.org/rfc/rfc3280.txt):
35: *
36: * <pre>
37: * DirectoryString ::= CHOICE {
38: * teletexString TeletexString (SIZE (1..MAX)),
39: * printableString PrintableString (SIZE (1..MAX)),
40: * universalString UniversalString (SIZE (1..MAX)),
41: * utf8String UTF8String (SIZE (1..MAX)),
42: * bmpString BMPString (SIZE (1..MAX))
43: * }
44: * </pre>
45: */
46: public class DirectoryString {
47:
48: public static final ASN1Choice ASN1 = new ASN1Choice(
49: new ASN1Type[] { ASN1StringType.TELETEXSTRING,
50: ASN1StringType.PRINTABLESTRING,
51: ASN1StringType.UNIVERSALSTRING,
52: ASN1StringType.UTF8STRING, ASN1StringType.BMPSTRING }) {
53:
54: public int getIndex(java.lang.Object object) {
55: return 1; // always code as ASN1 printableString
56: //return 4; // always code as ASN1 utf8String
57: }
58:
59: public Object getObjectToEncode(Object object) {
60: return /*(String)*/object;
61: }
62: };
63: }
|