01: package org.bouncycastle.asn1.x509;
02:
03: import java.util.Hashtable;
04: import java.util.Enumeration;
05:
06: import org.bouncycastle.asn1.ASN1Sequence;
07: import org.bouncycastle.asn1.ASN1Encodable;
08: import org.bouncycastle.asn1.ASN1EncodableVector;
09: import org.bouncycastle.asn1.DERObject;
10: import org.bouncycastle.asn1.DERObjectIdentifier;
11: import org.bouncycastle.asn1.DERSequence;
12:
13: /**
14: * PolicyMappings V3 extension, described in RFC3280.
15: * <pre>
16: * PolicyMappings ::= SEQUENCE SIZE (1..MAX) OF SEQUENCE {
17: * issuerDomainPolicy CertPolicyId,
18: * subjectDomainPolicy CertPolicyId }
19: * </pre>
20: *
21: * @see <a href="http://www.faqs.org/rfc/rfc3280.txt">RFC 3280, section 4.2.1.6</a>
22: */
23: public class PolicyMappings extends ASN1Encodable {
24: ASN1Sequence seq = null;
25:
26: /**
27: * Creates a new <code>PolicyMappings</code> instance.
28: *
29: * @param seq an <code>ASN1Sequence</code> constructed as specified
30: * in RFC 3280
31: */
32: public PolicyMappings(ASN1Sequence seq) {
33: this .seq = seq;
34: }
35:
36: /**
37: * Creates a new <code>PolicyMappings</code> instance.
38: *
39: * @param mappings a <code>HashMap</code> value that maps
40: * <code>String</code> oids
41: * to other <code>String</code> oids.
42: */
43: public PolicyMappings(Hashtable mappings) {
44: ASN1EncodableVector dev = new ASN1EncodableVector();
45: Enumeration it = mappings.keys();
46:
47: while (it.hasMoreElements()) {
48: String idp = (String) it.nextElement();
49: String sdp = (String) mappings.get(idp);
50: ASN1EncodableVector dv = new ASN1EncodableVector();
51: dv.add(new DERObjectIdentifier(idp));
52: dv.add(new DERObjectIdentifier(sdp));
53: dev.add(new DERSequence(dv));
54: }
55:
56: seq = new DERSequence(dev);
57: }
58:
59: public DERObject toASN1Object() {
60: return seq;
61: }
62: }
|