KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > util > asn1 > x509 > AttributeCertificate


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 package org.apache.geronimo.util.asn1.x509;
19
20 import org.apache.geronimo.util.asn1.ASN1Encodable;
21 import org.apache.geronimo.util.asn1.ASN1EncodableVector;
22 import org.apache.geronimo.util.asn1.ASN1Sequence;
23 import org.apache.geronimo.util.asn1.DERBitString;
24 import org.apache.geronimo.util.asn1.DERObject;
25 import org.apache.geronimo.util.asn1.DERSequence;
26
27 public class AttributeCertificate
28     extends ASN1Encodable
29 {
30     AttributeCertificateInfo acinfo;
31     AlgorithmIdentifier signatureAlgorithm;
32     DERBitString signatureValue;
33
34     /**
35      * @param obj
36      * @return an AttributeCertificate object
37      */

38     public static AttributeCertificate getInstance(Object JavaDoc obj)
39     {
40         if (obj instanceof AttributeCertificate)
41         {
42             return (AttributeCertificate)obj;
43         }
44         else if (obj instanceof ASN1Sequence)
45         {
46             return new AttributeCertificate((ASN1Sequence)obj);
47         }
48
49         throw new IllegalArgumentException JavaDoc("unknown object in factory");
50     }
51
52     public AttributeCertificate(
53         AttributeCertificateInfo acinfo,
54         AlgorithmIdentifier signatureAlgorithm,
55         DERBitString signatureValue)
56     {
57         this.acinfo = acinfo;
58         this.signatureAlgorithm = signatureAlgorithm;
59         this.signatureValue = signatureValue;
60     }
61
62     public AttributeCertificate(
63         ASN1Sequence seq)
64     {
65         this.acinfo = AttributeCertificateInfo.getInstance(seq.getObjectAt(0));
66         this.signatureAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(1));
67         this.signatureValue = DERBitString.getInstance(seq.getObjectAt(2));
68     }
69
70     public AttributeCertificateInfo getAcinfo()
71     {
72         return acinfo;
73     }
74
75     public AlgorithmIdentifier getSignatureAlgorithm()
76     {
77         return signatureAlgorithm;
78     }
79
80     public DERBitString getSignatureValue()
81     {
82         return signatureValue;
83     }
84
85     /**
86      * Produce an object suitable for an ASN1OutputStream.
87      * <pre>
88      * AttributeCertificate ::= SEQUENCE {
89      * acinfo AttributeCertificateInfo,
90      * signatureAlgorithm AlgorithmIdentifier,
91      * signatureValue BIT STRING
92      * }
93      * </pre>
94      */

95     public DERObject toASN1Object()
96     {
97         ASN1EncodableVector v = new ASN1EncodableVector();
98
99         v.add(acinfo);
100         v.add(signatureAlgorithm);
101         v.add(signatureValue);
102
103         return new DERSequence(v);
104     }
105 }
106
Popular Tags