Code clean-up
- Fix the inspector warnings - Fix the infinite recursion in SslContext.newClientContext() - Fix Javadoc errors
This commit is contained in:
parent
56b8bb30b2
commit
8f3904f6dc
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.ssl;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -15,11 +15,10 @@
|
||||
*/
|
||||
package io.netty.handler.ssl;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
|
||||
/**
|
||||
* JDK extension methods to support {@link ApplicationProtocolNegotiator}
|
||||
*/
|
||||
@ -27,7 +26,7 @@ public interface JdkApplicationProtocolNegotiator extends ApplicationProtocolNeg
|
||||
/**
|
||||
* Abstract factory pattern for wrapping an {@link SSLEngine} object. This is useful for NPN/APLN JDK support.
|
||||
*/
|
||||
public interface SslEngineWrapperFactory {
|
||||
interface SslEngineWrapperFactory {
|
||||
/**
|
||||
* Abstract factory pattern for wrapping an {@link SSLEngine} object. This is useful for NPN/APLN support.
|
||||
*
|
||||
@ -48,7 +47,7 @@ public interface JdkApplicationProtocolNegotiator extends ApplicationProtocolNeg
|
||||
* {@link ProtocolSelector#unsupported()} OR {@link ProtocolSelector#select(List)} will be called for each SSL
|
||||
* handshake.
|
||||
*/
|
||||
public interface ProtocolSelector {
|
||||
interface ProtocolSelector {
|
||||
/**
|
||||
* Callback invoked to let the application know that the peer does not support this
|
||||
* {@link ApplicationProtocolNegotiator}.
|
||||
@ -72,7 +71,7 @@ public interface JdkApplicationProtocolNegotiator extends ApplicationProtocolNeg
|
||||
* {@link ProtocolSelectionListener#unsupported()} OR the {@link ProtocolSelectionListener#selected(String)} method
|
||||
* will be called for each SSL handshake.
|
||||
*/
|
||||
public interface ProtocolSelectionListener {
|
||||
interface ProtocolSelectionListener {
|
||||
/**
|
||||
* Callback invoked to let the application know that the peer does not support this
|
||||
* {@link ApplicationProtocolNegotiator}.
|
||||
@ -93,7 +92,7 @@ public interface JdkApplicationProtocolNegotiator extends ApplicationProtocolNeg
|
||||
/**
|
||||
* Factory interface for {@link ProtocolSelector} objects.
|
||||
*/
|
||||
public interface ProtocolSelectorFactory {
|
||||
interface ProtocolSelectorFactory {
|
||||
/**
|
||||
* Generate a new instance of {@link ProtocolSelector}.
|
||||
* @param engine The {@link SSLEngine} that the returned {@link ProtocolSelector} will be used to create an
|
||||
@ -107,7 +106,7 @@ public interface JdkApplicationProtocolNegotiator extends ApplicationProtocolNeg
|
||||
/**
|
||||
* Factory interface for {@link ProtocolSelectionListener} objects.
|
||||
*/
|
||||
public interface ProtocolSelectionListenerFactory {
|
||||
interface ProtocolSelectionListenerFactory {
|
||||
/**
|
||||
* Generate a new instance of {@link ProtocolSelectionListener}.
|
||||
* @param engine The {@link SSLEngine} that the returned {@link ProtocolSelectionListener} will be used to
|
||||
|
@ -16,13 +16,25 @@
|
||||
|
||||
package io.netty.handler.ssl;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.buffer.ByteBufInputStream;
|
||||
import io.netty.util.internal.EmptyArrays;
|
||||
import io.netty.util.internal.logging.InternalLogger;
|
||||
import io.netty.util.internal.logging.InternalLoggerFactory;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.EncryptedPrivateKeyInfo;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.PBEKeySpec;
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSessionContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
@ -48,18 +60,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.EncryptedPrivateKeyInfo;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.PBEKeySpec;
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLSessionContext;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
import static io.netty.util.internal.ObjectUtil.*;
|
||||
|
||||
/**
|
||||
* An {@link SslContext} which uses JDK's SSL/TLS implementation.
|
||||
@ -141,8 +142,7 @@ public abstract class JdkSslContext extends SslContext {
|
||||
}
|
||||
|
||||
private static void addIfSupported(Set<String> supported, List<String> enabled, String... names) {
|
||||
for (int i = 0; i < names.length; ++i) {
|
||||
String n = names[i];
|
||||
for (String n: names) {
|
||||
if (supported.contains(n)) {
|
||||
enabled.add(n);
|
||||
}
|
||||
@ -224,7 +224,7 @@ public abstract class JdkSslContext extends SslContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a {@link ApplicationProtocolConfiguration} object to a {@link JdkApplicationProtocolNegotiator} object.
|
||||
* Translate a {@link ApplicationProtocolConfig} object to a {@link JdkApplicationProtocolNegotiator} object.
|
||||
* @param config The configuration which defines the translation
|
||||
* @param isServer {@code true} if a server {@code false} otherwise.
|
||||
* @return The results of the translation
|
||||
@ -336,7 +336,7 @@ public abstract class JdkSslContext extends SslContext {
|
||||
byte[] encodedKey = new byte[encodedKeyBuf.readableBytes()];
|
||||
encodedKeyBuf.readBytes(encodedKey).release();
|
||||
|
||||
char[] keyPasswordChars = keyPassword == null ? new char[0] : keyPassword.toCharArray();
|
||||
char[] keyPasswordChars = keyPassword == null ? EmptyArrays.EMPTY_CHARS : keyPassword.toCharArray();
|
||||
PKCS8EncodedKeySpec encodedKeySpec = generateKeySpec(keyPasswordChars, encodedKey);
|
||||
|
||||
PrivateKey key;
|
||||
|
@ -15,22 +15,21 @@
|
||||
*/
|
||||
package io.netty.handler.ssl;
|
||||
|
||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.util.internal.logging.InternalLogger;
|
||||
import io.netty.util.internal.logging.InternalLoggerFactory;
|
||||
import org.apache.tomcat.jni.Pool;
|
||||
import org.apache.tomcat.jni.SSL;
|
||||
import org.apache.tomcat.jni.SSLContext;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLException;
|
||||
|
||||
import org.apache.tomcat.jni.Pool;
|
||||
import org.apache.tomcat.jni.SSL;
|
||||
import org.apache.tomcat.jni.SSLContext;
|
||||
import static io.netty.util.internal.ObjectUtil.*;
|
||||
|
||||
/**
|
||||
* A server-side {@link SslContext} which uses OpenSSL's SSL/TLS implementation.
|
||||
@ -293,6 +292,7 @@ public final class OpenSslServerContext extends SslContext {
|
||||
return sessionTimeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationProtocolNegotiator applicationProtocolNegotiator() {
|
||||
return apn;
|
||||
}
|
||||
@ -359,7 +359,7 @@ public final class OpenSslServerContext extends SslContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a {@link ApplicationProtocolConfiguration} object to a
|
||||
* Translate a {@link ApplicationProtocolConfig} object to a
|
||||
* {@link OpenSslApplicationProtocolNegotiator} object.
|
||||
* @param config The configuration which defines the translation
|
||||
* @param isServer {@code true} if a server {@code false} otherwise.
|
||||
|
@ -20,9 +20,6 @@ import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import javax.net.ssl.KeyManager;
|
||||
import javax.net.ssl.KeyManagerFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
@ -30,6 +27,8 @@ import javax.net.ssl.SSLEngine;
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A secure socket protocol implementation which acts as a factory for {@link SSLEngine} and {@link SslHandler}.
|
||||
@ -360,7 +359,7 @@ public abstract class SslContext {
|
||||
*/
|
||||
public static SslContext newClientContext(
|
||||
SslProvider provider, TrustManagerFactory trustManagerFactory) throws SSLException {
|
||||
return newClientContext(provider, trustManagerFactory);
|
||||
return newClientContext(provider, null, trustManagerFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.ssl;
|
||||
|
||||
import javax.net.ssl.SSLEngine;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
Loading…
Reference in New Issue
Block a user