Path: blob/master/src/java.base/share/classes/sun/security/x509/CertificatePolicySet.java
41159 views
/*1* Copyright (c) 1997, 2008, 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;28import java.util.Vector;29import java.util.List;30import java.util.Collections;3132import sun.security.util.*;3334/**35* This class defines the certificate policy set ASN.1 object.36*37* @author Amit Kapoor38* @author Hemma Prafullchandra39*/40public class CertificatePolicySet {4142private final Vector<CertificatePolicyId> ids;4344/**45* The default constructor for this class.46*47* @param ids the sequence of CertificatePolicyId's.48*/49public CertificatePolicySet(Vector<CertificatePolicyId> ids) {50this.ids = ids;51}5253/**54* Create the object from the DerValue.55*56* @param in the passed DerInputStream.57* @exception IOException on decoding errors.58*/59public CertificatePolicySet(DerInputStream in) throws IOException {60ids = new Vector<>();61DerValue[] seq = in.getSequence(5);6263for (int i = 0; i < seq.length; i++) {64CertificatePolicyId id = new CertificatePolicyId(seq[i]);65ids.addElement(id);66}67}6869/**70* Return printable form of the object.71*/72public String toString() {73String s = "CertificatePolicySet:[\n"74+ ids.toString()75+ "]\n";7677return (s);78}7980/**81* Encode the policy set to the output stream.82*83* @param out the DerOutputStream to encode the data to.84*/85public void encode(DerOutputStream out) throws IOException {86DerOutputStream tmp = new DerOutputStream();8788for (int i = 0; i < ids.size(); i++) {89ids.elementAt(i).encode(tmp);90}91out.write(DerValue.tag_Sequence,tmp);92}9394/**95* Return the sequence of CertificatePolicyIds.96*97* @return A List containing the CertificatePolicyId objects.98*99*/100public List<CertificatePolicyId> getCertPolicyIds() {101return Collections.unmodifiableList(ids);102}103}104105106