|
|
|
@ -40,7 +40,7 @@ public interface SslOptions {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return if any SSL options have been specified.
|
|
|
|
|
* @return {@true} if SSL options have been specified
|
|
|
|
|
* @return {@code true} if SSL options have been specified
|
|
|
|
|
*/
|
|
|
|
|
default boolean isSpecified() {
|
|
|
|
|
return (getCiphers() != null) && (getEnabledProtocols() != null);
|
|
|
|
@ -52,7 +52,7 @@ public interface SslOptions {
|
|
|
|
|
* {@link SSLEngine#getSupportedCipherSuites()}.
|
|
|
|
|
* @return the ciphers that can be used or {@code null}
|
|
|
|
|
*/
|
|
|
|
|
Set<String> getCiphers();
|
|
|
|
|
String[] getCiphers();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the protocols that should be enabled or an empty set. The protocols names in
|
|
|
|
@ -60,7 +60,7 @@ public interface SslOptions {
|
|
|
|
|
* {@link SSLEngine#getSupportedProtocols()}.
|
|
|
|
|
* @return the protocols to enable or {@code null}
|
|
|
|
|
*/
|
|
|
|
|
Set<String> getEnabledProtocols();
|
|
|
|
|
String[] getEnabledProtocols();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Factory method to create a new {@link SslOptions} instance.
|
|
|
|
@ -69,44 +69,43 @@ public interface SslOptions {
|
|
|
|
|
* @return a new {@link SslOptions} instance
|
|
|
|
|
*/
|
|
|
|
|
static SslOptions of(String[] ciphers, String[] enabledProtocols) {
|
|
|
|
|
return of(asSet(ciphers), asSet(enabledProtocols));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Factory method to create a new {@link SslOptions} instance.
|
|
|
|
|
* @param ciphers the ciphers
|
|
|
|
|
* @param enabledProtocols the enabled protocols
|
|
|
|
|
* @return a new {@link SslOptions} instance
|
|
|
|
|
*/
|
|
|
|
|
static SslOptions of(Set<String> ciphers, Set<String> enabledProtocols) {
|
|
|
|
|
return new SslOptions() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Set<String> getCiphers() {
|
|
|
|
|
public String[] getCiphers() {
|
|
|
|
|
return ciphers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Set<String> getEnabledProtocols() {
|
|
|
|
|
public String[] getEnabledProtocols() {
|
|
|
|
|
return enabledProtocols;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper method that provides a null-safe way to convert a {@link Collection} to a
|
|
|
|
|
* {@code String[]} for client libraries to use.
|
|
|
|
|
* @param collection the collection to convert
|
|
|
|
|
* @return a string array or {@code null}
|
|
|
|
|
* Factory method to create a new {@link SslOptions} instance.
|
|
|
|
|
* @param ciphers the ciphers
|
|
|
|
|
* @param enabledProtocols the enabled protocols
|
|
|
|
|
* @return a new {@link SslOptions} instance
|
|
|
|
|
*/
|
|
|
|
|
static String[] toArray(Collection<String> collection) {
|
|
|
|
|
return (collection != null) ? collection.toArray(String[]::new) : null;
|
|
|
|
|
static SslOptions of(Set<String> ciphers, Set<String> enabledProtocols) {
|
|
|
|
|
return of(toArray(ciphers), toArray(enabledProtocols));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Set<String> asSet(String[] array) {
|
|
|
|
|
/**
|
|
|
|
|
* Helper method that provides a null-safe way to convert a {@code String[]} to a
|
|
|
|
|
* {@link Collection} for client libraries to use.
|
|
|
|
|
* @param array the array to convert
|
|
|
|
|
* @return a collection or {@code null}
|
|
|
|
|
*/
|
|
|
|
|
static Set<String> asSet(String[] array) {
|
|
|
|
|
return (array != null) ? Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(array))) : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String[] toArray(Collection<String> collection) {
|
|
|
|
|
return (collection != null) ? collection.toArray(String[]::new) : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|