Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/security/provider/certpath/CertPathConstraintsParameters.java
38923 views
1
/*
2
* Copyright (c) 2020, 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.provider.certpath;
27
28
import java.security.Key;
29
import java.security.cert.TrustAnchor;
30
import java.security.cert.X509Certificate;
31
import java.util.Date;
32
import java.util.Set;
33
import java.util.Collections;
34
35
import sun.security.util.ConstraintsParameters;
36
import sun.security.validator.Validator;
37
38
/**
39
* This class contains parameters for checking certificates against
40
* constraints specified in the jdk.certpath.disabledAlgorithms security
41
* property.
42
*/
43
class CertPathConstraintsParameters implements ConstraintsParameters {
44
// The public key of the certificate
45
private final Key key;
46
// The certificate's trust anchor which will be checked against the
47
// jdkCA constraint, if specified.
48
private final TrustAnchor anchor;
49
// The PKIXParameter validity date or the timestamp of the signed JAR
50
// file, if this chain is associated with a timestamped signed JAR.
51
private final Date date;
52
// The variant or usage of this certificate
53
private final String variant;
54
// The certificate being checked (may be null if a CRL or OCSPResponse is
55
// being checked)
56
private final X509Certificate cert;
57
58
public CertPathConstraintsParameters(X509Certificate cert,
59
String variant, TrustAnchor anchor, Date date) {
60
this(cert.getPublicKey(), variant, anchor, date, cert);
61
}
62
63
public CertPathConstraintsParameters(Key key, String variant,
64
TrustAnchor anchor) {
65
this(key, variant, anchor, null, null);
66
}
67
68
private CertPathConstraintsParameters(Key key, String variant,
69
TrustAnchor anchor, Date date, X509Certificate cert) {
70
this.key = key;
71
this.variant = (variant == null ? Validator.VAR_GENERIC : variant);
72
this.anchor = anchor;
73
this.date = date;
74
this.cert = cert;
75
}
76
77
@Override
78
public boolean anchorIsJdkCA() {
79
return CertPathHelper.isJdkCA(anchor);
80
}
81
82
@Override
83
public Set<Key> getKeys() {
84
return (key == null) ? Collections.emptySet()
85
: Collections.singleton(key);
86
}
87
88
@Override
89
public Date getDate() {
90
return date;
91
}
92
93
@Override
94
public String getVariant() {
95
return variant;
96
}
97
98
@Override
99
public String extendedExceptionMsg() {
100
return (cert == null ? "."
101
: " used with certificate: " +
102
cert.getSubjectX500Principal());
103
}
104
105
@Override
106
public String toString() {
107
StringBuilder sb = new StringBuilder("[\n");
108
sb.append("\n Variant: ").append(variant);
109
if (anchor != null) {
110
sb.append("\n Anchor: ").append(anchor);
111
}
112
if (cert != null) {
113
sb.append("\n Cert Issuer: ")
114
.append(cert.getIssuerX500Principal());
115
sb.append("\n Cert Subject: ")
116
.append(cert.getSubjectX500Principal());
117
}
118
if (key != null) {
119
sb.append("\n Key: ").append(key.getAlgorithm());
120
}
121
if (date != null) {
122
sb.append("\n Date: ").append(date);
123
}
124
sb.append("\n]");
125
return sb.toString();
126
}
127
}
128
129