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.crypto.asn1.x509; 019 020 import java.util.Hashtable; 021 import java.util.Enumeration; 022 023 import org.apache.geronimo.crypto.asn1.ASN1Sequence; 024 import org.apache.geronimo.crypto.asn1.ASN1Encodable; 025 import org.apache.geronimo.crypto.asn1.ASN1EncodableVector; 026 import org.apache.geronimo.crypto.asn1.DERObject; 027 import org.apache.geronimo.crypto.asn1.DERObjectIdentifier; 028 import org.apache.geronimo.crypto.asn1.DERSequence; 029 030 /** 031 * PolicyMappings V3 extension, described in RFC3280. 032 * <pre> 033 * PolicyMappings ::= SEQUENCE SIZE (1..MAX) OF SEQUENCE { 034 * issuerDomainPolicy CertPolicyId, 035 * subjectDomainPolicy CertPolicyId } 036 * </pre> 037 * 038 * @see <a href="http://www.faqs.org/rfc/rfc3280.txt">RFC 3280, section 4.2.1.6</a> 039 */ 040 public class PolicyMappings 041 extends ASN1Encodable 042 { 043 ASN1Sequence seq = null; 044 045 /** 046 * Creates a new <code>PolicyMappings</code> instance. 047 * 048 * @param seq an <code>ASN1Sequence</code> constructed as specified 049 * in RFC 3280 050 */ 051 public PolicyMappings (ASN1Sequence seq) 052 { 053 this.seq = seq; 054 } 055 056 /** 057 * Creates a new <code>PolicyMappings</code> instance. 058 * 059 * @param mappings a <code>HashMap</code> value that maps 060 * <code>String</code> oids 061 * to other <code>String</code> oids. 062 */ 063 public PolicyMappings (Hashtable mappings) 064 { 065 ASN1EncodableVector dev = new ASN1EncodableVector(); 066 Enumeration it = mappings.keys(); 067 068 while (it.hasMoreElements()) { 069 String idp = (String) it.nextElement(); 070 String sdp = (String) mappings.get(idp); 071 ASN1EncodableVector dv = new ASN1EncodableVector(); 072 dv.add(new DERObjectIdentifier(idp)); 073 dv.add(new DERObjectIdentifier(sdp)); 074 dev.add(new DERSequence(dv)); 075 } 076 077 seq = new DERSequence(dev); 078 } 079 080 public DERObject toASN1Object() 081 { 082 return seq; 083 } 084 }