001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.crypto.asn1.x509;
017:
018: import org.apache.geronimo.crypto.asn1.ASN1Encodable;
019: import org.apache.geronimo.crypto.asn1.ASN1Sequence;
020: import org.apache.geronimo.crypto.asn1.ASN1TaggedObject;
021: import org.apache.geronimo.crypto.asn1.DERBoolean;
022: import org.apache.geronimo.crypto.asn1.DERObject;
023:
024: /**
025: * IssuingDistributionPoint ::= SEQUENCE {
026: * distributionPoint [0] DistributionPointName OPTIONAL,
027: * onlyContainsUserCerts [1] BOOLEAN DEFAULT FALSE,
028: * onlyContainsCACerts [2] BOOLEAN DEFAULT FALSE,
029: * onlySomeReasons [3] ReasonFlags OPTIONAL,
030: * indirectCRL [4] BOOLEAN DEFAULT FALSE,
031: * onlyContainsAttributeCerts [5] BOOLEAN DEFAULT FALSE }
032: */
033: public class IssuingDistributionPoint extends ASN1Encodable {
034: private boolean onlyContainsUserCerts;
035: private boolean onlyContainsCACerts;
036: private boolean indirectCRL;
037: private boolean onlyContainsAttributeCerts;
038:
039: private ASN1Sequence seq;
040:
041: public static IssuingDistributionPoint getInstance(
042: ASN1TaggedObject obj, boolean explicit) {
043: return getInstance(ASN1Sequence.getInstance(obj, explicit));
044: }
045:
046: public static IssuingDistributionPoint getInstance(Object obj) {
047: if (obj == null || obj instanceof IssuingDistributionPoint) {
048: return (IssuingDistributionPoint) obj;
049: } else if (obj instanceof ASN1Sequence) {
050: return new IssuingDistributionPoint((ASN1Sequence) obj);
051: }
052:
053: throw new IllegalArgumentException("unknown object in factory");
054: }
055:
056: /**
057: * Constructor from ASN1Sequence
058: */
059: public IssuingDistributionPoint(ASN1Sequence seq) {
060: this .seq = seq;
061:
062: for (int i = 0; i != seq.size(); i++) {
063: ASN1TaggedObject o = (ASN1TaggedObject) seq.getObjectAt(i);
064:
065: switch (o.getTagNo()) {
066: case 0:
067: break;
068: case 1:
069: onlyContainsUserCerts = DERBoolean
070: .getInstance(o, false).isTrue();
071: break;
072: case 2:
073: onlyContainsCACerts = DERBoolean.getInstance(o, false)
074: .isTrue();
075: break;
076: case 3:
077: break;
078: case 4:
079: indirectCRL = DERBoolean.getInstance(o, false).isTrue();
080: break;
081: case 5:
082: onlyContainsAttributeCerts = DERBoolean.getInstance(o,
083: false).isTrue();
084: break;
085: default:
086: throw new IllegalArgumentException(
087: "unknown tag in IssuingDistributionPoint");
088: }
089: }
090: }
091:
092: public boolean onlyContainsUserCerts() {
093: return onlyContainsUserCerts;
094: }
095:
096: public boolean onlyContainsCACerts() {
097: return onlyContainsCACerts;
098: }
099:
100: public boolean isIndirectCRL() {
101: return indirectCRL;
102: }
103:
104: public boolean onlyContainsAttributeCerts() {
105: return onlyContainsAttributeCerts;
106: }
107:
108: public DERObject toASN1Object() {
109: return seq;
110: }
111: }
|