Path: blob/master/src/java.base/share/classes/sun/security/x509/CertificatePolicyMap.java
41159 views
/*1* Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.security.x509;2627import java.io.IOException;2829import sun.security.util.*;3031/**32* Represent the CertificatePolicyMap ASN.1 object.33*34* @author Amit Kapoor35* @author Hemma Prafullchandra36*/37public class CertificatePolicyMap {38private CertificatePolicyId issuerDomain;39private CertificatePolicyId subjectDomain;4041/**42* Create a CertificatePolicyMap with the passed CertificatePolicyId's.43*44* @param issuer the CertificatePolicyId for the issuer CA.45* @param subject the CertificatePolicyId for the subject CA.46*/47public CertificatePolicyMap(CertificatePolicyId issuer,48CertificatePolicyId subject) {49this.issuerDomain = issuer;50this.subjectDomain = subject;51}5253/**54* Create the CertificatePolicyMap from the DER encoded value.55*56* @param val the DER encoded value of the same.57*/58public CertificatePolicyMap(DerValue val) throws IOException {59if (val.tag != DerValue.tag_Sequence) {60throw new IOException("Invalid encoding for CertificatePolicyMap");61}62issuerDomain = new CertificatePolicyId(val.data.getDerValue());63subjectDomain = new CertificatePolicyId(val.data.getDerValue());64}6566/**67* Return the issuer CA part of the policy map.68*/69public CertificatePolicyId getIssuerIdentifier() {70return (issuerDomain);71}7273/**74* Return the subject CA part of the policy map.75*/76public CertificatePolicyId getSubjectIdentifier() {77return (subjectDomain);78}7980/**81* Returns a printable representation of the CertificatePolicyId.82*/83public String toString() {84String s = "CertificatePolicyMap: [\n"85+ "IssuerDomain:" + issuerDomain.toString()86+ "SubjectDomain:" + subjectDomain.toString()87+ "]\n";8889return (s);90}9192/**93* Write the CertificatePolicyMap to the DerOutputStream.94*95* @param out the DerOutputStream to write the object to.96* @exception IOException on errors.97*/98public void encode(DerOutputStream out) throws IOException {99DerOutputStream tmp = new DerOutputStream();100101issuerDomain.encode(tmp);102subjectDomain.encode(tmp);103out.write(DerValue.tag_Sequence,tmp);104}105}106107108