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 */ 017 018 package org.apache.geronimo.util.asn1.x509; 019 020 import org.apache.geronimo.util.asn1.ASN1EncodableVector; 021 import org.apache.geronimo.util.asn1.ASN1Sequence; 022 import org.apache.geronimo.util.asn1.ASN1Encodable; 023 import org.apache.geronimo.util.asn1.DERObject; 024 import org.apache.geronimo.util.asn1.DERObjectIdentifier; 025 import org.apache.geronimo.util.asn1.DERSequence; 026 027 public class PolicyInformation 028 extends ASN1Encodable 029 { 030 private DERObjectIdentifier policyIdentifier; 031 private ASN1Sequence policyQualifiers; 032 033 public PolicyInformation( 034 ASN1Sequence seq) 035 { 036 policyIdentifier = (DERObjectIdentifier)seq.getObjectAt(0); 037 038 if (seq.size() > 1) 039 { 040 policyQualifiers = (ASN1Sequence)seq.getObjectAt(1); 041 } 042 } 043 044 public PolicyInformation( 045 DERObjectIdentifier policyIdentifier) 046 { 047 this.policyIdentifier = policyIdentifier; 048 } 049 050 public PolicyInformation( 051 DERObjectIdentifier policyIdentifier, 052 ASN1Sequence policyQualifiers) 053 { 054 this.policyIdentifier = policyIdentifier; 055 this.policyQualifiers = policyQualifiers; 056 } 057 058 public static PolicyInformation getInstance( 059 Object obj) 060 { 061 if (obj == null || obj instanceof PolicyInformation) 062 { 063 return (PolicyInformation)obj; 064 } 065 066 return new PolicyInformation(ASN1Sequence.getInstance(obj)); 067 } 068 069 public DERObjectIdentifier getPolicyIdentifier() 070 { 071 return policyIdentifier; 072 } 073 074 public ASN1Sequence getPolicyQualifiers() 075 { 076 return policyQualifiers; 077 } 078 079 /* 080 * PolicyInformation ::= SEQUENCE { 081 * policyIdentifier CertPolicyId, 082 * policyQualifiers SEQUENCE SIZE (1..MAX) OF 083 * PolicyQualifierInfo OPTIONAL } 084 */ 085 public DERObject toASN1Object() 086 { 087 ASN1EncodableVector v = new ASN1EncodableVector(); 088 089 v.add(policyIdentifier); 090 091 if (policyQualifiers != null) 092 { 093 v.add(policyQualifiers); 094 } 095 096 return new DERSequence(v); 097 } 098 }