![JAR search and dependency download from the Maven repository](/logo.png)
com.viaoa.comm.ssl.OASslServer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of oa-core Show documentation
Show all versions of oa-core Show documentation
Object Automation library
The newest version!
/* Copyright 1999 Vince Via [email protected]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.viaoa.comm.ssl;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyStore;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLServerSocketFactory;
/**
* SSLServer used to encrypt data
* @author vvia
*
*/
public abstract class OASslServer extends OASslBase {
public OASslServer(String host, int port) {
super(host, port);
}
protected SSLContext createSSLContext() throws Exception {
// 20171118
SSLContext sslContext = SSLContext.getInstance("TLS");
// SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
//was: SSLContext sslContext = SSLContext.getInstance("SSLv3");
KeyStore keystore = KeyStore.getInstance("JKS");
// see keystore.txt
InputStream is = OASslServer.class.getResourceAsStream("sslserver.jks");
if (is == null) throw new IOException("sslserver.jks not found");
keystore.load(is, "vince1".toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(keystore, "vince1".toCharArray());
sslContext.init(kmf.getKeyManagers(), null, null);
return sslContext;
}
protected SSLEngine createSSLEngine() throws Exception {
SSLEngine sslEngine = getSSLContext().createSSLEngine(host, port);
sslEngine.setUseClientMode(false);
sslEngine.setNeedClientAuth(false);
return sslEngine;
}
@Override
protected void log(String msg) {
System.out.println("SERVER: "+msg);
}
public static void main(String[] args) throws Exception {
SSLServerSocketFactory ssf = (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
String[] defaultCiphers = ssf.getDefaultCipherSuites();
String[] availableCiphers = ssf.getSupportedCipherSuites();
int xx = 4;
xx++;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy