org.eclipse.serializer.communication.tls.TLSParametersProvider Maven / Gradle / Ivy
package org.eclipse.serializer.communication.tls;
/*-
* #%L
* Eclipse Serializer Communication Binary
* %%
* Copyright (C) 2023 MicroStream Software
* %%
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
* #L%
*/
import javax.net.ssl.SSLParameters;
public interface TLSParametersProvider
{
/**
* Provides the SSLParameters Object for the SSLEngine
*
* @return SSLParameters
*/
SSLParameters getSSLParameters();
/**
* provide the SSL protocol as defined in Standard Algorithm Name Documentation
*
* @return SSL protocol
*/
String getSSLProtocol();
/**
* Timeout for read operations during the TLS handshake in milliseconds
*
* @return returns the timeout for the TLS handshake
*/
int getHandshakeReadTimeOut();
/**
*
* Provides a nearly empty SSLParameters object.
*
* all configuration values are null except
*
* needClientAuth = true
*
*/
public final class Default implements TLSParametersProvider
{
///////////////////////////////////////////////////////////////////////////
// constants //
//////////////
private static final String TLS_PROTOCOL_STRING = "TLSv1.2";
private static final int SSL_HANDSHAKE_READ_TIMEOUT = 1000;
///////////////////////////////////////////////////////////////////////////
// constructors //
/////////////////
public Default()
{
super();
}
///////////////////////////////////////////////////////////////////////////
// methods //
////////////
@Override
public SSLParameters getSSLParameters()
{
final SSLParameters sslParameters = new SSLParameters();
sslParameters.setNeedClientAuth(true);
return sslParameters;
}
@Override
public String getSSLProtocol()
{
return Default.TLS_PROTOCOL_STRING;
}
@Override
public int getHandshakeReadTimeOut()
{
return SSL_HANDSHAKE_READ_TIMEOUT;
}
}
}