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 java.util.Hashtable; 22 import java.util.Enumeration; 23 24 import org.apache.geronimo.util.asn1.ASN1Sequence; 25 import org.apache.geronimo.util.asn1.ASN1Encodable; 26 import org.apache.geronimo.util.asn1.ASN1EncodableVector; 27 import org.apache.geronimo.util.asn1.DERObject; 28 import org.apache.geronimo.util.asn1.DERObjectIdentifier; 29 import org.apache.geronimo.util.asn1.DERSequence; 30 31 /** 32 * PolicyMappings V3 extension, described in RFC3280. 33 * <pre> 34 * PolicyMappings ::= SEQUENCE SIZE (1..MAX) OF SEQUENCE { 35 * issuerDomainPolicy CertPolicyId, 36 * subjectDomainPolicy CertPolicyId } 37 * </pre> 38 * 39 * @see <a href="http://www.faqs.org/rfc/rfc3280.txt">RFC 3280, section 4.2.1.6</a> 40 */ 41 public class PolicyMappings 42 extends ASN1Encodable 43 { 44 ASN1Sequence seq = null; 45 46 /** 47 * Creates a new <code>PolicyMappings</code> instance. 48 * 49 * @param seq an <code>ASN1Sequence</code> constructed as specified 50 * in RFC 3280 51 */ 52 public PolicyMappings (ASN1Sequence seq) 53 { 54 this.seq = seq; 55 } 56 57 /** 58 * Creates a new <code>PolicyMappings</code> instance. 59 * 60 * @param mappings a <code>HashMap</code> value that maps 61 * <code>String</code> oids 62 * to other <code>String</code> oids. 63 */ 64 public PolicyMappings (Hashtable mappings) 65 { 66 ASN1EncodableVector dev = new ASN1EncodableVector(); 67 Enumeration it = mappings.keys(); 68 69 while (it.hasMoreElements()) { 70 String idp = (String) it.nextElement(); 71 String sdp = (String) mappings.get(idp); 72 ASN1EncodableVector dv = new ASN1EncodableVector(); 73 dv.add(new DERObjectIdentifier(idp)); 74 dv.add(new DERObjectIdentifier(sdp)); 75 dev.add(new DERSequence(dv)); 76 } 77 78 seq = new DERSequence(dev); 79 } 80 81 public DERObject toASN1Object() 82 { 83 return seq; 84 } 85 }