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.x509; 24 25 import org.apache.harmony.security.asn1.ASN1Sequence; 26 import org.apache.harmony.security.asn1.ASN1Type; 27 import org.apache.harmony.security.asn1.BerInputStream; 28 29 /** 30 * The class encapsulates the ASN.1 DER encoding/decoding work 31 * with the ORAddress structure which is a part of X.509 certificate: 32 * (as specified in RFC 3280 - 33 * Internet X.509 Public Key Infrastructure. 34 * Certificate and Certificate Revocation List (CRL) Profile. 35 * http://www.ietf.org/rfc/rfc3280.txt): 36 * 37 * <pre> 38 * ORAddress ::= SEQUENCE { 39 * built-in-standard-attributes BuiltInStandardAttributes, 40 * built-in-domain-defined-attributes 41 * BuiltInDomainDefinedAttributes OPTIONAL, 42 * extension-attributes ExtensionAttributes OPTIONAL 43 * } 44 * </pre> 45 * 46 * TODO: this class needs to be finished. 47 */ 48 public final class ORAddress { 49 50 /** the ASN.1 encoded form of ORAddress */ 51 private byte[] encoding; 52 53 /** 54 * Returns ASN.1 encoded form of this X.509 ORAddress value. 55 */ 56 public byte[] getEncoded() { 57 if (encoding == null) { 58 encoding = ASN1.encode(this); 59 } 60 return encoding; 61 } 62 63 /** 64 * ASN.1 DER X.509 ORAddress encoder/decoder class. 65 */ 66 public static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] { 67 new ASN1Sequence(new ASN1Type[] {}) { 68 @Override protected void getValues(Object object, Object[] values) {} 69 }}) { 70 71 @Override protected Object getDecodedObject(BerInputStream in) { 72 return new ORAddress(); 73 } 74 75 private final Object foo = new Object(); 76 77 @Override protected void getValues(Object object, Object[] values) { 78 values[0] = foo; 79 } 80 }; 81 } 82 83