Path: blob/master/src/java.base/share/classes/sun/security/x509/CertificatePolicyId.java
41159 views
/*1* Copyright (c) 1997, 2015, 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 sun.security.util.*;293031/**32* Represent the CertificatePolicyId ASN.1 object.33*34* @author Amit Kapoor35* @author Hemma Prafullchandra36*/37public class CertificatePolicyId {38private ObjectIdentifier id;3940/**41* Create a CertificatePolicyId with the ObjectIdentifier.42*43* @param id the ObjectIdentifier for the policy id.44*/45public CertificatePolicyId(ObjectIdentifier id) {46this.id = id;47}4849/**50* Create the object from its Der encoded value.51*52* @param val the DER encoded value for the same.53*/54public CertificatePolicyId(DerValue val) throws IOException {55this.id = val.getOID();56}5758/**59* Return the value of the CertificatePolicyId as an ObjectIdentifier.60*/61public ObjectIdentifier getIdentifier() {62return (id);63}6465/**66* Returns a printable representation of the CertificatePolicyId.67*/68public String toString() {69String s = "CertificatePolicyId: ["70+ id.toString()71+ "]\n";7273return (s);74}7576/**77* Write the CertificatePolicyId to the DerOutputStream.78*79* @param out the DerOutputStream to write the object to.80* @exception IOException on errors.81*/82public void encode(DerOutputStream out) throws IOException {83out.putOID(id);84}8586/**87* Compares this CertificatePolicyId with another, for88* equality. Uses ObjectIdentifier.equals() as test for89* equality.90*91* @return true iff the ids are identical.92*/93public boolean equals(Object other) {94if (other instanceof CertificatePolicyId)95return id.equals(((CertificatePolicyId) other).getIdentifier());96else97return false;98}99100/**101* Returns a hash code value for this object.102*103* @return a hash code value104*/105public int hashCode() {106return id.hashCode();107}108}109110111