Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8259223: Simplify boolean expression in the SunJSSE provider
Reviewed-by: mullan
  • Loading branch information
XueleiFan committed Jan 5, 2021
1 parent 1b60acd commit 4d3d59912d71a05865b87bb2579571fbda74b668
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 35 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -890,7 +890,7 @@ private CipherSuite(int id, boolean isDefaultEnabled,
this.macAlg = macAlg;
this.hashAlg = hashAlg;

this.exportable = (cipher == null ? false : cipher.exportable);
this.exportable = (cipher != null && cipher.exportable);
}

static CipherSuite nameOf(String ciperSuiteName) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -128,7 +128,7 @@ private boolean isValid() {
* Return the KeyPair or null if it is invalid.
*/
private KeyPair getKeyPair() {
if (isValid() == false) {
if (!isValid()) {
keyPair = null;
return null;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -325,7 +325,7 @@ public byte[] createVerifyData(HandshakeContext context,
}
}

// TLS 1.2
// TLS 1.3
private static final
class T13VerifyDataGenerator implements VerifyDataGenerator {
private static final byte[] hkdfLabel = "tls13 finished".getBytes();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -576,7 +576,7 @@ private static boolean isActivatable(CipherSuite suite,

retval |= groupAvailable;
} else {
retval |= true;
retval = true;
}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -99,7 +99,7 @@ protected void engineInit(KeyStore ks, char[] password) throws
@Override
protected void engineInit(ManagerFactoryParameters params) throws
InvalidAlgorithmParameterException {
if (params instanceof KeyStoreBuilderParameters == false) {
if (!(params instanceof KeyStoreBuilderParameters)) {
throw new InvalidAlgorithmParameterException(
"Parameters must be instance of KeyStoreBuilderParameters");
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -356,23 +356,23 @@ boolean useTLS12PlusSpec() {
* TLS 1.1/DTLS 1.0 or newer version.
*/
boolean useTLS11PlusSpec() {
return isDTLS ? true : (this.id >= TLS11.id);
return isDTLS || (this.id >= TLS11.id);
}

/**
* Return true if this ProtocolVersion object is of TLS 1.0 or
* newer version.
*/
boolean useTLS10PlusSpec() {
return isDTLS ? true : (this.id >= TLS10.id);
return isDTLS || (this.id >= TLS10.id);
}

/**
* Return true if this ProtocolVersion object is of TLS 1.0 or
* newer version.
*/
static boolean useTLS10PlusSpec(int id, boolean isDTLS) {
return isDTLS ? true : (id >= TLS10.id);
return isDTLS || (id >= TLS10.id);
}

/**
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -837,7 +837,7 @@ private void shutdownInput(
@Override
public boolean isInputShutdown() {
return conContext.isInboundClosed() &&
((autoClose || !isLayered()) ? super.isInputShutdown(): true);
(!autoClose && isLayered() || super.isInputShutdown());
}

// Please don't synchronized this method. Otherwise, the read and close
@@ -861,7 +861,7 @@ public void shutdownOutput() throws IOException {
@Override
public boolean isOutputShutdown() {
return conContext.isOutboundClosed() &&
((autoClose || !isLayered()) ? super.isOutputShutdown(): true);
(!autoClose && isLayered() || super.isOutputShutdown());
}

@Override
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -364,8 +364,8 @@ private boolean isPermitted(AlgorithmConstraints constraints) {
constraints.permits(SIGNATURE_PRIMITIVE_SET,
this.algorithm, (signAlgParams != null ?
signAlgParams.parameters : null)) &&
(namedGroup != null ?
namedGroup.isPermitted(constraints) : true);
(namedGroup == null ||
namedGroup.isPermitted(constraints));
}

// Get local supported algorithm collection complying to algorithm
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -139,7 +139,7 @@ Set<X500Principal> getIssuerX500Principals() {
continue;
}
Key key = ks.getKey(alias, password);
if (key instanceof PrivateKey == false) {
if (!(key instanceof PrivateKey)) {
continue;
}
Certificate[] certs = ks.getCertificateChain(alias);
@@ -334,7 +334,7 @@ private String[] getAliases(String keyType, Principal[] issuers) {
if (issuers == null) {
issuers = new X500Principal[0];
}
if (issuers instanceof X500Principal[] == false) {
if (!(issuers instanceof X500Principal[])) {
// normally, this will never happen but try to recover if it does
issuers = convertPrincipals(issuers);
}
@@ -375,7 +375,7 @@ private String[] getAliases(String keyType, Principal[] issuers) {
certs[0].getSigAlgName().toUpperCase(Locale.ENGLISH);
String pattern = "WITH" +
sigType.toUpperCase(Locale.ENGLISH);
if (sigAlgName.contains(pattern) == false) {
if (!sigAlgName.contains(pattern)) {
continue;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -155,13 +155,13 @@ X509TrustManager getInstance(
@Override
X509TrustManager getInstance(ManagerFactoryParameters spec)
throws InvalidAlgorithmParameterException {
if (spec instanceof CertPathTrustManagerParameters == false) {
if (!(spec instanceof CertPathTrustManagerParameters)) {
throw new InvalidAlgorithmParameterException
("Parameters must be CertPathTrustManagerParameters");
}
CertPathParameters params =
((CertPathTrustManagerParameters)spec).getParameters();
if (params instanceof PKIXBuilderParameters == false) {
if (!(params instanceof PKIXBuilderParameters)) {
throw new InvalidAlgorithmParameterException
("Encapsulated parameters must be PKIXBuilderParameters");
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -271,7 +271,7 @@ private PrivateKeyEntry getEntry(String alias) {
KeyStore ks = builder.getKeyStore();
Entry newEntry = ks.getEntry
(keyStoreAlias, builder.getProtectionParameter(alias));
if (newEntry instanceof PrivateKeyEntry == false) {
if (!(newEntry instanceof PrivateKeyEntry)) {
// unexpected type of entry
return null;
}
@@ -581,7 +581,7 @@ CheckResult check(X509Certificate cert, Date date,
// require either signature bit
// or if server also allow key encipherment bit
if (!supportsDigitalSignature) {
if (this == CLIENT || getBit(ku, 2) == false) {
if (this == CLIENT || !getBit(ku, 2)) {
return CheckResult.EXTENSION_MISMATCH;
}
}
@@ -599,7 +599,7 @@ CheckResult check(X509Certificate cert, Date date,
break;
case "DH":
// require keyagreement bit
if (getBit(ku, 4) == false) {
if (!getBit(ku, 4)) {
return CheckResult.EXTENSION_MISMATCH;
}
break;
@@ -614,7 +614,7 @@ CheckResult check(X509Certificate cert, Date date,
// exchange and not ephemeral ECDH. We leave it in
// for now until there are signs that this check
// causes problems for real world EC certificates.
if ((this == SERVER) && (getBit(ku, 4) == false)) {
if (this == SERVER && !getBit(ku, 4)) {
return CheckResult.EXTENSION_MISMATCH;
}
break;
@@ -748,7 +748,7 @@ private List<EntryStatus> getAliases(int builderIndex,

boolean incompatible = false;
for (Certificate cert : chain) {
if (cert instanceof X509Certificate == false) {
if (!(cert instanceof X509Certificate)) {
// not an X509Certificate, ignore this alias
incompatible = true;
break;
@@ -785,7 +785,7 @@ private List<EntryStatus> getAliases(int builderIndex,
break;
}
}
if (found == false) {
if (!found) {
if (SSLLogger.isOn && SSLLogger.isOn("keymanager")) {
SSLLogger.fine(
"Ignore alias " + alias
@@ -820,7 +820,7 @@ private List<EntryStatus> getAliases(int builderIndex,
if (!preferred && checkResult == CheckResult.OK && keyIndex == 0) {
preferred = true;
}
if (preferred && (findAll == false)) {
if (preferred && !findAll) {
// if we have a good match and do not need all matches,
// return immediately
return Collections.singletonList(status);

0 comments on commit 4d3d599

Please sign in to comment.