• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.bouncycastle.asn1.x509;
2 
3 import org.bouncycastle.asn1.ASN1EncodableVector;
4 import org.bouncycastle.asn1.ASN1Sequence;
5 import org.bouncycastle.asn1.ASN1Encodable;
6 import org.bouncycastle.asn1.DERObject;
7 import org.bouncycastle.asn1.DERObjectIdentifier;
8 import org.bouncycastle.asn1.DERSequence;
9 
10 public class PolicyInformation
11     extends ASN1Encodable
12 {
13     private DERObjectIdentifier   policyIdentifier;
14     private ASN1Sequence          policyQualifiers;
15 
PolicyInformation( ASN1Sequence seq)16     public PolicyInformation(
17         ASN1Sequence seq)
18     {
19         if (seq.size() < 1 || seq.size() > 2)
20         {
21             throw new IllegalArgumentException("Bad sequence size: "
22                     + seq.size());
23         }
24 
25         policyIdentifier = DERObjectIdentifier.getInstance(seq.getObjectAt(0));
26 
27         if (seq.size() > 1)
28         {
29             policyQualifiers = ASN1Sequence.getInstance(seq.getObjectAt(1));
30         }
31     }
32 
PolicyInformation( DERObjectIdentifier policyIdentifier)33     public PolicyInformation(
34         DERObjectIdentifier policyIdentifier)
35     {
36         this.policyIdentifier = policyIdentifier;
37     }
38 
PolicyInformation( DERObjectIdentifier policyIdentifier, ASN1Sequence policyQualifiers)39     public PolicyInformation(
40         DERObjectIdentifier policyIdentifier,
41         ASN1Sequence        policyQualifiers)
42     {
43         this.policyIdentifier = policyIdentifier;
44         this.policyQualifiers = policyQualifiers;
45     }
46 
getInstance( Object obj)47     public static PolicyInformation getInstance(
48         Object obj)
49     {
50         if (obj == null || obj instanceof PolicyInformation)
51         {
52             return (PolicyInformation)obj;
53         }
54 
55         return new PolicyInformation(ASN1Sequence.getInstance(obj));
56     }
57 
getPolicyIdentifier()58     public DERObjectIdentifier getPolicyIdentifier()
59     {
60         return policyIdentifier;
61     }
62 
getPolicyQualifiers()63     public ASN1Sequence getPolicyQualifiers()
64     {
65         return policyQualifiers;
66     }
67 
68     /*
69      * PolicyInformation ::= SEQUENCE {
70      *      policyIdentifier   CertPolicyId,
71      *      policyQualifiers   SEQUENCE SIZE (1..MAX) OF
72      *              PolicyQualifierInfo OPTIONAL }
73      */
toASN1Object()74     public DERObject toASN1Object()
75     {
76         ASN1EncodableVector v = new ASN1EncodableVector();
77 
78         v.add(policyIdentifier);
79 
80         if (policyQualifiers != null)
81         {
82             v.add(policyQualifiers);
83         }
84 
85         return new DERSequence(v);
86     }
87 }
88