mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8265426: Update java.security to use instanceof pattern variable
Reviewed-by: rriggs, weijun, dfuchs
This commit is contained in:
parent
3fcdc50e44
commit
86b8dc9f5b
23 changed files with 85 additions and 165 deletions
|
@ -333,7 +333,7 @@ public abstract class Signature extends SignatureSpi {
|
|||
// so it is a "real" Spi if it is an
|
||||
// instance of SignatureSpi but not Signature
|
||||
boolean r = (instance instanceof SignatureSpi)
|
||||
&& (instance instanceof Signature == false);
|
||||
&& (!(instance instanceof Signature));
|
||||
if ((debug != null) && (r == false)) {
|
||||
debug.println("Not a SignatureSpi " + className);
|
||||
debug.println("Delayed provider selection may not be "
|
||||
|
@ -541,16 +541,15 @@ public abstract class Signature extends SignatureSpi {
|
|||
// we should check whether it has a Key Usage
|
||||
// extension marked as critical.
|
||||
//if (cert instanceof java.security.cert.X509Certificate) {
|
||||
if (cert instanceof X509Certificate) {
|
||||
if (cert instanceof X509Certificate xcert) {
|
||||
// Check whether the cert has a key usage extension
|
||||
// marked as a critical extension.
|
||||
// The OID for KeyUsage extension is 2.5.29.15.
|
||||
X509Certificate c = (X509Certificate)cert;
|
||||
Set<String> critSet = c.getCriticalExtensionOIDs();
|
||||
Set<String> critSet = xcert.getCriticalExtensionOIDs();
|
||||
|
||||
if (critSet != null && !critSet.isEmpty()
|
||||
&& critSet.contains(KnownOIDs.KeyUsage.value())) {
|
||||
boolean[] keyUsageInfo = c.getKeyUsage();
|
||||
boolean[] keyUsageInfo = xcert.getKeyUsage();
|
||||
// keyUsageInfo[0] is for digitalSignature.
|
||||
if ((keyUsageInfo != null) && (keyUsageInfo[0] == false))
|
||||
throw new InvalidKeyException("Wrong key usage");
|
||||
|
@ -1178,7 +1177,7 @@ public abstract class Signature extends SignatureSpi {
|
|||
}
|
||||
} else {
|
||||
Object o = s.newInstance(null);
|
||||
if (o instanceof SignatureSpi == false) {
|
||||
if (!(o instanceof SignatureSpi)) {
|
||||
throw new NoSuchAlgorithmException
|
||||
("Not a SignatureSpi: " + o.getClass().getName());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue