X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Fconnect%2Futil%2FSslHandlerFactoryImpl.java;h=6165869eed50d6778befa6f59f6c387b9f1695b8;hb=241dc2063166c0eec1d8cf0647ecf0c97c445ae5;hp=5e8453373978cb2702de41e7b72aa46a31c4aaeb;hpb=c1e293e96525d44e3a3ba8bb1ebf0a755e3a8d4d;p=netconf.git diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/SslHandlerFactoryImpl.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/SslHandlerFactoryImpl.java index 5e84533739..6165869eed 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/SslHandlerFactoryImpl.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/util/SslHandlerFactoryImpl.java @@ -7,7 +7,6 @@ */ package org.opendaylight.netconf.sal.connect.util; -import static com.google.common.base.Preconditions.checkArgument; import static java.util.Objects.requireNonNull; import com.google.common.collect.Sets; @@ -15,7 +14,6 @@ import io.netty.handler.ssl.SslHandler; import java.io.IOException; import java.security.GeneralSecurityException; import java.security.KeyStore; -import java.util.Collections; import java.util.Set; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; @@ -42,11 +40,11 @@ public final class SslHandlerFactoryImpl implements SslHandlerFactory { @Override public SslHandler createSslHandler() { - return createSslHandler(Collections.emptySet()); + return createSslHandler(Set.of()); } @Override - public SslHandler createSslHandler(Set allowedKeys) { + public SslHandler createSslHandler(final Set allowedKeys) { try { final KeyStore keyStore = keystoreAdapter.getJavaKeyStore(allowedKeys); @@ -64,14 +62,14 @@ public final class SslHandlerFactoryImpl implements SslHandlerFactory { final String[] engineProtocols = engine.getSupportedProtocols(); final String[] enabledProtocols; - if (specification != null) { - checkArgument(specification instanceof TlsCase, "Cannot get TLS specification from: %s", specification); - + if (specification instanceof TlsCase tlsSpecification) { final Set protocols = Sets.newHashSet(engineProtocols); - protocols.removeAll(((TlsCase)specification).getTls().getExcludedVersions()); + protocols.removeAll(tlsSpecification.getTls().getExcludedVersions()); enabledProtocols = protocols.toArray(new String[0]); - } else { + } else if (specification == null) { enabledProtocols = engineProtocols; + } else { + throw new IllegalArgumentException("Cannot get TLS specification from: " + specification); } engine.setEnabledProtocols(enabledProtocols);