Home | History | Annotate | Download | only in x501
      1 /*
      2  *  Licensed to the Apache Software Foundation (ASF) under one or more
      3  *  contributor license agreements.  See the NOTICE file distributed with
      4  *  this work for additional information regarding copyright ownership.
      5  *  The ASF licenses this file to You under the Apache License, Version 2.0
      6  *  (the "License"); you may not use this file except in compliance with
      7  *  the License.  You may obtain a copy of the License at
      8  *
      9  *     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 */
     22 
     23 package org.apache.harmony.security.x501;
     24 
     25 import org.apache.harmony.security.asn1.ASN1Choice;
     26 import org.apache.harmony.security.asn1.ASN1StringType;
     27 import org.apache.harmony.security.asn1.ASN1Type;
     28 
     29 
     30 /**
     31  * The class encapsulates the ASN.1 DER encoding/decoding work
     32  * with the DirectoryString structure
     33  * (as specified in RFC 3280 -
     34  *  Internet X.509 Public Key Infrastructure.
     35  *  Certificate and Certificate Revocation List (CRL) Profile.
     36  *  http://www.ietf.org/rfc/rfc3280.txt):
     37  *
     38  * <pre>
     39  *   DirectoryString ::= CHOICE {
     40  *        teletexString             TeletexString   (SIZE (1..MAX)),
     41  *        printableString           PrintableString (SIZE (1..MAX)),
     42  *        universalString           UniversalString (SIZE (1..MAX)),
     43  *        utf8String              UTF8String      (SIZE (1..MAX)),
     44  *        bmpString               BMPString       (SIZE (1..MAX))
     45  *   }
     46  * </pre>
     47  */
     48 public final class DirectoryString {
     49 
     50     public static final ASN1Choice ASN1 = new ASN1Choice(new ASN1Type[] {
     51            ASN1StringType.TELETEXSTRING,
     52            ASN1StringType.PRINTABLESTRING,
     53            ASN1StringType.UNIVERSALSTRING,
     54            ASN1StringType.UTF8STRING,
     55            ASN1StringType.BMPSTRING }) {
     56 
     57         public int getIndex(java.lang.Object object) {
     58             return 1; // always code as ASN1 printableString
     59             //return 4; // always code as ASN1 utf8String
     60         }
     61 
     62         public Object getObjectToEncode(Object object) {
     63             return /*(String)*/ object;
     64         }
     65     };
     66 }
     67 
     68