Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/share/classes/sun/security/x509/CertificatePolicyId.java
41159 views
1
/*
2
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package sun.security.x509;
27
28
import java.io.IOException;
29
import sun.security.util.*;
30
31
32
/**
33
* Represent the CertificatePolicyId ASN.1 object.
34
*
35
* @author Amit Kapoor
36
* @author Hemma Prafullchandra
37
*/
38
public class CertificatePolicyId {
39
private ObjectIdentifier id;
40
41
/**
42
* Create a CertificatePolicyId with the ObjectIdentifier.
43
*
44
* @param id the ObjectIdentifier for the policy id.
45
*/
46
public CertificatePolicyId(ObjectIdentifier id) {
47
this.id = id;
48
}
49
50
/**
51
* Create the object from its Der encoded value.
52
*
53
* @param val the DER encoded value for the same.
54
*/
55
public CertificatePolicyId(DerValue val) throws IOException {
56
this.id = val.getOID();
57
}
58
59
/**
60
* Return the value of the CertificatePolicyId as an ObjectIdentifier.
61
*/
62
public ObjectIdentifier getIdentifier() {
63
return (id);
64
}
65
66
/**
67
* Returns a printable representation of the CertificatePolicyId.
68
*/
69
public String toString() {
70
String s = "CertificatePolicyId: ["
71
+ id.toString()
72
+ "]\n";
73
74
return (s);
75
}
76
77
/**
78
* Write the CertificatePolicyId to the DerOutputStream.
79
*
80
* @param out the DerOutputStream to write the object to.
81
* @exception IOException on errors.
82
*/
83
public void encode(DerOutputStream out) throws IOException {
84
out.putOID(id);
85
}
86
87
/**
88
* Compares this CertificatePolicyId with another, for
89
* equality. Uses ObjectIdentifier.equals() as test for
90
* equality.
91
*
92
* @return true iff the ids are identical.
93
*/
94
public boolean equals(Object other) {
95
if (other instanceof CertificatePolicyId)
96
return id.equals(((CertificatePolicyId) other).getIdentifier());
97
else
98
return false;
99
}
100
101
/**
102
* Returns a hash code value for this object.
103
*
104
* @return a hash code value
105
*/
106
public int hashCode() {
107
return id.hashCode();
108
}
109
}
110
111