Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/crypto/JceSecurity/MyX509CertImpl.java
41149 views
1
/*
2
* Copyright (c) 2006, 2007, 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.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* test
26
* @bug 6377058
27
* @summary SunJCE depends on sun.security.provider.SignatureImpl
28
* behaviour, BC can't load into 1st slot.
29
* @author Brad R. Wetmore
30
*/
31
32
33
import java.util.*;
34
import java.math.*;
35
import java.security.*;
36
import java.security.cert.*;
37
import javax.security.auth.x500.*;
38
39
public class MyX509CertImpl extends X509Certificate
40
implements X509Extension {
41
42
X509Certificate c;
43
44
protected MyX509CertImpl(X509Certificate cert) {
45
c = cert;
46
}
47
48
public void checkValidity() throws CertificateExpiredException,
49
CertificateNotYetValidException {
50
c.checkValidity();
51
}
52
53
54
public void checkValidity(Date date) throws CertificateExpiredException,
55
CertificateNotYetValidException {
56
c.checkValidity(date);
57
}
58
59
public int getVersion() {
60
return c.getVersion();
61
}
62
63
public BigInteger getSerialNumber() {
64
return c.getSerialNumber();
65
}
66
67
public Principal getIssuerDN() {
68
return c.getIssuerDN();
69
}
70
71
public X500Principal getIssuerX500Principal() {
72
return c.getIssuerX500Principal();
73
}
74
75
public Principal getSubjectDN() {
76
return c.getSubjectDN();
77
}
78
79
public X500Principal getSubjectX500Principal() {
80
return c.getSubjectX500Principal();
81
}
82
83
public Date getNotBefore() {
84
return c.getNotBefore();
85
}
86
87
public Date getNotAfter() {
88
return c.getNotAfter();
89
}
90
91
public byte[] getTBSCertificate()
92
throws CertificateEncodingException {
93
return c.getTBSCertificate();
94
}
95
96
public byte[] getSignature() {
97
return c.getSignature();
98
}
99
100
public String getSigAlgName() {
101
return c.getSigAlgName();
102
}
103
104
public String getSigAlgOID() {
105
return c.getSigAlgOID();
106
}
107
108
public byte[] getSigAlgParams() {
109
return c.getSigAlgParams();
110
}
111
112
public boolean[] getIssuerUniqueID() {
113
return c.getIssuerUniqueID();
114
}
115
116
public boolean[] getSubjectUniqueID() {
117
return c.getSubjectUniqueID();
118
}
119
120
public boolean[] getKeyUsage() {
121
return c.getKeyUsage();
122
}
123
124
public List<String> getExtendedKeyUsage()
125
throws CertificateParsingException {
126
return c.getExtendedKeyUsage();
127
}
128
129
public int getBasicConstraints() {
130
return c.getBasicConstraints();
131
}
132
133
public Collection<List<?>> getSubjectAlternativeNames()
134
throws CertificateParsingException {
135
return c.getSubjectAlternativeNames();
136
}
137
138
public Collection<List<?>> getIssuerAlternativeNames()
139
throws CertificateParsingException {
140
return c.getIssuerAlternativeNames();
141
}
142
143
/*
144
* The following are from X509Extension
145
*/
146
public boolean hasUnsupportedCriticalExtension() {
147
return c.hasUnsupportedCriticalExtension();
148
}
149
150
public Set<String> getCriticalExtensionOIDs() {
151
return c.getCriticalExtensionOIDs();
152
}
153
154
public Set<String> getNonCriticalExtensionOIDs() {
155
return c.getNonCriticalExtensionOIDs();
156
}
157
158
public byte[] getExtensionValue(String oid) {
159
return c.getExtensionValue(oid);
160
}
161
162
/*
163
* The rest are from Certificate
164
*/
165
public boolean equals(Object other) {
166
return c.equals(other);
167
}
168
169
public int hashCode() {
170
return c.hashCode();
171
}
172
173
public byte[] getEncoded()
174
throws CertificateEncodingException {
175
return c.getEncoded();
176
}
177
178
public void verify(PublicKey key)
179
throws CertificateException, NoSuchAlgorithmException,
180
InvalidKeyException, NoSuchProviderException,
181
SignatureException {
182
System.out.println("Trying a verify");
183
try {
184
c.verify(key);
185
} catch (SignatureException e) {
186
System.out.println("Rethrowing \"acceptable\" exception");
187
throw new InvalidKeyException(
188
"Rethrowing as a SignatureException", e);
189
}
190
}
191
192
public void verify(PublicKey key, String sigProvider)
193
throws CertificateException, NoSuchAlgorithmException,
194
InvalidKeyException, NoSuchProviderException,
195
SignatureException {
196
197
System.out.println("Trying a verify");
198
try {
199
c.verify(key, sigProvider);
200
} catch (SignatureException e) {
201
System.out.println("Rethrowing \"acceptable\" exception");
202
throw new InvalidKeyException(
203
"Rethrowing as a SignatureException", e);
204
}
205
}
206
207
public String toString() {
208
return c.toString();
209
}
210
211
public PublicKey getPublicKey() {
212
return c.getPublicKey();
213
}
214
}
215
216