View Javadoc

1   /**
2    *
3    *  Licensed to the Apache Software Foundation (ASF) under one or more
4    *  contributor license agreements.  See the NOTICE file distributed with
5    *  this work for additional information regarding copyright ownership.
6    *  The ASF licenses this file to You under the Apache License, Version 2.0
7    *  (the "License"); you may not use this file except in compliance with
8    *  the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing, software
13   *  distributed under the License is distributed on an "AS IS" BASIS,
14   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *  See the License for the specific language governing permissions and
16   *  limitations under the License.
17   */
18  
19  package org.apache.geronimo.util.asn1.x509;
20  
21  import org.apache.geronimo.util.asn1.ASN1Encodable;
22  import org.apache.geronimo.util.asn1.ASN1Sequence;
23  import org.apache.geronimo.util.asn1.ASN1TaggedObject;
24  import org.apache.geronimo.util.asn1.DERBoolean;
25  import org.apache.geronimo.util.asn1.DERObject;
26  
27  /**
28   * IssuingDistributionPoint ::= SEQUENCE {
29   *      distributionPoint          [0] DistributionPointName OPTIONAL,
30   *      onlyContainsUserCerts      [1] BOOLEAN DEFAULT FALSE,
31   *      onlyContainsCACerts        [2] BOOLEAN DEFAULT FALSE,
32   *      onlySomeReasons            [3] ReasonFlags OPTIONAL,
33   *      indirectCRL                [4] BOOLEAN DEFAULT FALSE,
34   *      onlyContainsAttributeCerts [5] BOOLEAN DEFAULT FALSE }
35   */
36  public class IssuingDistributionPoint
37      extends ASN1Encodable
38  {
39      private boolean         onlyContainsUserCerts;
40      private boolean         onlyContainsCACerts;
41      private boolean         indirectCRL;
42      private boolean         onlyContainsAttributeCerts;
43  
44      private ASN1Sequence    seq;
45  
46      public static IssuingDistributionPoint getInstance(
47          ASN1TaggedObject obj,
48          boolean          explicit)
49      {
50          return getInstance(ASN1Sequence.getInstance(obj, explicit));
51      }
52  
53      public static IssuingDistributionPoint getInstance(
54          Object  obj)
55      {
56          if (obj == null || obj instanceof IssuingDistributionPoint)
57          {
58              return (IssuingDistributionPoint)obj;
59          }
60          else if (obj instanceof ASN1Sequence)
61          {
62              return new IssuingDistributionPoint((ASN1Sequence)obj);
63          }
64  
65          throw new IllegalArgumentException("unknown object in factory");
66      }
67  
68      /**
69       * Constructor from ASN1Sequence
70       */
71      public IssuingDistributionPoint(
72          ASN1Sequence  seq)
73      {
74          this.seq = seq;
75  
76          for (int i = 0; i != seq.size(); i++)
77          {
78              ASN1TaggedObject  o = (ASN1TaggedObject)seq.getObjectAt(i);
79  
80              switch (o.getTagNo())
81              {
82              case 0:
83                  break;
84              case 1:
85                  onlyContainsUserCerts = DERBoolean.getInstance(o, false).isTrue();
86                  break;
87              case 2:
88                  onlyContainsCACerts = DERBoolean.getInstance(o, false).isTrue();
89                  break;
90              case 3:
91                  break;
92              case 4:
93                  indirectCRL = DERBoolean.getInstance(o, false).isTrue();
94                  break;
95              case 5:
96                  onlyContainsAttributeCerts = DERBoolean.getInstance(o, false).isTrue();
97                  break;
98              default:
99                  throw new IllegalArgumentException("unknown tag in IssuingDistributionPoint");
100             }
101         }
102     }
103 
104     public boolean onlyContainsUserCerts()
105     {
106         return onlyContainsUserCerts;
107     }
108 
109     public boolean onlyContainsCACerts()
110     {
111         return onlyContainsCACerts;
112     }
113 
114     public boolean isIndirectCRL()
115     {
116         return indirectCRL;
117     }
118 
119     public boolean onlyContainsAttributeCerts()
120     {
121         return onlyContainsAttributeCerts;
122     }
123 
124     public DERObject toASN1Object()
125     {
126         return seq;
127     }
128 }