use of com.github.jh3nd3rs0n.jargyle.common.net.ssl.DtlsDatagramSocketFactory in project jargyle by jh3nd3rs0n.
the class DtlsDatagramSocketFactoryImpl method newDatagramSocket.
@Override
public DatagramSocket newDatagramSocket(final DatagramSocket datagramSocket, final String peerHost, final int peerPort) throws IOException {
synchronized (this) {
if (this.dtlsContext == null) {
this.dtlsContext = this.getDtlsContext();
}
}
DtlsDatagramSocketFactory factory = DtlsDatagramSocketFactory.newInstance(this.dtlsContext);
DtlsDatagramSocket dtlsDatagramSocket = (DtlsDatagramSocket) factory.newDatagramSocket(datagramSocket, peerHost, peerPort);
dtlsDatagramSocket.setUseClientMode(false);
Settings settings = this.configuration.getSettings();
Words enabledCipherSuites = settings.getLastValue(DtlsSettingSpecConstants.DTLS_ENABLED_CIPHER_SUITES);
String[] cipherSuites = enabledCipherSuites.toStringArray();
if (cipherSuites.length > 0) {
dtlsDatagramSocket.setEnabledCipherSuites(cipherSuites);
}
Words enabledProtocols = settings.getLastValue(DtlsSettingSpecConstants.DTLS_ENABLED_PROTOCOLS);
String[] protocols = enabledProtocols.toStringArray();
if (protocols.length > 0) {
dtlsDatagramSocket.setEnabledProtocols(protocols);
}
PositiveInteger maxPacketSize = settings.getLastValue(DtlsSettingSpecConstants.DTLS_MAX_PACKET_SIZE);
dtlsDatagramSocket.setMaximumPacketSize(maxPacketSize.intValue());
if (settings.getLastValue(DtlsSettingSpecConstants.DTLS_NEED_CLIENT_AUTH).booleanValue()) {
dtlsDatagramSocket.setNeedClientAuth(true);
}
if (settings.getLastValue(DtlsSettingSpecConstants.DTLS_WANT_CLIENT_AUTH).booleanValue()) {
dtlsDatagramSocket.setWantClientAuth(true);
}
return dtlsDatagramSocket;
}
use of com.github.jh3nd3rs0n.jargyle.common.net.ssl.DtlsDatagramSocketFactory in project jargyle by jh3nd3rs0n.
the class DtlsDatagramSocketFactoryImpl method newDatagramSocket.
@Override
public DatagramSocket newDatagramSocket(final DatagramSocket datagramSocket, final String peerHost, final int peerPort) throws IOException {
synchronized (this) {
if (this.dtlsContext == null) {
this.dtlsContext = this.getDtlsContext();
}
}
DtlsDatagramSocketFactory factory = DtlsDatagramSocketFactory.newInstance(this.dtlsContext);
DtlsDatagramSocket dtlsDatagramSocket = (DtlsDatagramSocket) factory.newDatagramSocket(datagramSocket, peerHost, peerPort);
dtlsDatagramSocket.setUseClientMode(true);
Properties properties = this.socksClient.getProperties();
Words enabledCipherSuites = properties.getValue(DtlsPropertySpecConstants.DTLS_ENABLED_CIPHER_SUITES);
String[] cipherSuites = enabledCipherSuites.toStringArray();
if (cipherSuites.length > 0) {
dtlsDatagramSocket.setEnabledCipherSuites(cipherSuites);
}
Words enabledProtocols = properties.getValue(DtlsPropertySpecConstants.DTLS_ENABLED_PROTOCOLS);
String[] protocols = enabledProtocols.toStringArray();
if (protocols.length > 0) {
dtlsDatagramSocket.setEnabledProtocols(protocols);
}
PositiveInteger maxPacketSize = properties.getValue(DtlsPropertySpecConstants.DTLS_MAX_PACKET_SIZE);
dtlsDatagramSocket.setMaximumPacketSize(maxPacketSize.intValue());
return dtlsDatagramSocket;
}
Aggregations