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: */package org.apache.geronimo.crypto.asn1.x509;
17:
18: import org.apache.geronimo.crypto.asn1.ASN1Encodable;
19: import org.apache.geronimo.crypto.asn1.ASN1EncodableVector;
20: import org.apache.geronimo.crypto.asn1.ASN1Sequence;
21: import org.apache.geronimo.crypto.asn1.DERBitString;
22: import org.apache.geronimo.crypto.asn1.DERObject;
23: import org.apache.geronimo.crypto.asn1.DERSequence;
24:
25: public class AttributeCertificate extends ASN1Encodable {
26: AttributeCertificateInfo acinfo;
27: AlgorithmIdentifier signatureAlgorithm;
28: DERBitString signatureValue;
29:
30: /**
31: * @param obj
32: * @return an AttributeCertificate object
33: */
34: public static AttributeCertificate getInstance(Object obj) {
35: if (obj instanceof AttributeCertificate) {
36: return (AttributeCertificate) obj;
37: } else if (obj instanceof ASN1Sequence) {
38: return new AttributeCertificate((ASN1Sequence) obj);
39: }
40:
41: throw new IllegalArgumentException("unknown object in factory");
42: }
43:
44: public AttributeCertificate(AttributeCertificateInfo acinfo,
45: AlgorithmIdentifier signatureAlgorithm,
46: DERBitString signatureValue) {
47: this .acinfo = acinfo;
48: this .signatureAlgorithm = signatureAlgorithm;
49: this .signatureValue = signatureValue;
50: }
51:
52: public AttributeCertificate(ASN1Sequence seq) {
53: this .acinfo = AttributeCertificateInfo.getInstance(seq
54: .getObjectAt(0));
55: this .signatureAlgorithm = AlgorithmIdentifier.getInstance(seq
56: .getObjectAt(1));
57: this .signatureValue = DERBitString.getInstance(seq
58: .getObjectAt(2));
59: }
60:
61: public AttributeCertificateInfo getAcinfo() {
62: return acinfo;
63: }
64:
65: public AlgorithmIdentifier getSignatureAlgorithm() {
66: return signatureAlgorithm;
67: }
68:
69: public DERBitString getSignatureValue() {
70: return signatureValue;
71: }
72:
73: /**
74: * Produce an object suitable for an ASN1OutputStream.
75: * <pre>
76: * AttributeCertificate ::= SEQUENCE {
77: * acinfo AttributeCertificateInfo,
78: * signatureAlgorithm AlgorithmIdentifier,
79: * signatureValue BIT STRING
80: * }
81: * </pre>
82: */
83: public DERObject toASN1Object() {
84: ASN1EncodableVector v = new ASN1EncodableVector();
85:
86: v.add(acinfo);
87: v.add(signatureAlgorithm);
88: v.add(signatureValue);
89:
90: return new DERSequence(v);
91: }
92: }
|