001 /** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package org.apache.geronimo.util.asn1.x509; 020 021 import org.apache.geronimo.util.asn1.ASN1Encodable; 022 import org.apache.geronimo.util.asn1.ASN1EncodableVector; 023 import org.apache.geronimo.util.asn1.ASN1Sequence; 024 import org.apache.geronimo.util.asn1.ASN1TaggedObject; 025 import org.apache.geronimo.util.asn1.DERObject; 026 import org.apache.geronimo.util.asn1.DERSequence; 027 028 public class CRLDistPoint 029 extends ASN1Encodable 030 { 031 ASN1Sequence seq = null; 032 033 public static CRLDistPoint getInstance( 034 ASN1TaggedObject obj, 035 boolean explicit) 036 { 037 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 038 } 039 040 public static CRLDistPoint getInstance( 041 Object obj) 042 { 043 if (obj instanceof CRLDistPoint) 044 { 045 return (CRLDistPoint)obj; 046 } 047 else if (obj instanceof ASN1Sequence) 048 { 049 return new CRLDistPoint((ASN1Sequence)obj); 050 } 051 052 throw new IllegalArgumentException("unknown object in factory"); 053 } 054 055 public CRLDistPoint( 056 ASN1Sequence seq) 057 { 058 this.seq = seq; 059 } 060 061 public CRLDistPoint( 062 DistributionPoint[] points) 063 { 064 ASN1EncodableVector v = new ASN1EncodableVector(); 065 066 for (int i = 0; i != points.length; i++) 067 { 068 v.add(points[i]); 069 } 070 071 seq = new DERSequence(v); 072 } 073 074 /** 075 * Return the distribution points making up the sequence. 076 * 077 * @return DistributionPoint[] 078 */ 079 public DistributionPoint[] getDistributionPoints() 080 { 081 DistributionPoint[] dp = new DistributionPoint[seq.size()]; 082 083 for (int i = 0; i != seq.size(); i++) 084 { 085 dp[i] = DistributionPoint.getInstance(seq.getObjectAt(i)); 086 } 087 088 return dp; 089 } 090 091 /** 092 * Produce an object suitable for an ASN1OutputStream. 093 * <pre> 094 * CRLDistPoint ::= SEQUENCE SIZE {1..MAX} OF DistributionPoint 095 * </pre> 096 */ 097 public DERObject toASN1Object() 098 { 099 return seq; 100 } 101 }