001: /*
002: * @(#)CertificatePolicyMap.java 1.16 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: *
026: */
027:
028: package sun.security.x509;
029:
030: import java.io.IOException;
031:
032: import sun.security.util.*;
033:
034: /**
035: * Represent the CertificatePolicyMap ASN.1 object.
036: *
037: * @author Amit Kapoor
038: * @author Hemma Prafullchandra
039: * @version 1.9
040: */
041: public class CertificatePolicyMap {
042: private CertificatePolicyId issuerDomain;
043: private CertificatePolicyId subjectDomain;
044:
045: /**
046: * Create a CertificatePolicyMap with the passed CertificatePolicyId's.
047: *
048: * @param issuer the CertificatePolicyId for the issuer CA.
049: * @param subject the CertificatePolicyId for the subject CA.
050: */
051: public CertificatePolicyMap(CertificatePolicyId issuer,
052: CertificatePolicyId subject) {
053: this .issuerDomain = issuer;
054: this .subjectDomain = subject;
055: }
056:
057: /**
058: * Create the CertificatePolicyMap from the DER encoded value.
059: *
060: * @param val the DER encoded value of the same.
061: */
062: public CertificatePolicyMap(DerValue val) throws IOException {
063: if (val.tag != DerValue.tag_Sequence) {
064: throw new IOException(
065: "Invalid encoding for CertificatePolicyMap");
066: }
067: issuerDomain = new CertificatePolicyId(val.data.getDerValue());
068: subjectDomain = new CertificatePolicyId(val.data.getDerValue());
069: }
070:
071: /**
072: * Return the issuer CA part of the policy map.
073: */
074: public CertificatePolicyId getIssuerIdentifier() {
075: return (issuerDomain);
076: }
077:
078: /**
079: * Return the subject CA part of the policy map.
080: */
081: public CertificatePolicyId getSubjectIdentifier() {
082: return (subjectDomain);
083: }
084:
085: /**
086: * Returns a printable representation of the CertificatePolicyId.
087: */
088: public String toString() {
089: String s = "CertificatePolicyMap: [\n" + "IssuerDomain:"
090: + issuerDomain.toString() + "SubjectDomain:"
091: + subjectDomain.toString() + "]\n";
092:
093: return (s);
094: }
095:
096: /**
097: * Write the CertificatePolicyMap to the DerOutputStream.
098: *
099: * @param out the DerOutputStream to write the object to.
100: * @exception IOException on errors.
101: */
102: public void encode(DerOutputStream out) throws IOException {
103: DerOutputStream tmp = new DerOutputStream();
104:
105: issuerDomain.encode(tmp);
106: subjectDomain.encode(tmp);
107: out.write(DerValue.tag_Sequence, tmp);
108: }
109: }
|