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