本文整理汇总了Java中javax.net.ssl.SSLServerSocket.setEnabledCipherSuites方法的典型用法代码示例。如果您正苦于以下问题:Java SSLServerSocket.setEnabledCipherSuites方法的具体用法?Java SSLServerSocket.setEnabledCipherSuites怎么用?Java SSLServerSocket.setEnabledCipherSuites使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.net.ssl.SSLServerSocket
的用法示例。
在下文中一共展示了SSLServerSocket.setEnabledCipherSuites方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Configures the given SSL server socket with the requested cipher suites,
* protocol versions, and need for client authentication
*/
private void initServerSocket(ServerSocket ssocket) {
SSLServerSocket socket = (SSLServerSocket) ssocket;
if (enabledCiphers != null) {
socket.setEnabledCipherSuites(enabledCiphers);
}
String requestedProtocols = (String) attributes.get("protocols");
setEnabledProtocols(socket, getEnabledProtocols(socket,
requestedProtocols));
// we don't know if client auth is needed -
// after parsing the request we may re-handshake
configureClientAuth(socket);
}
示例2: finishServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Configure the SSLServerSocket based on this SocketCreator's settings.
*/
private void finishServerSocket(SSLServerSocket serverSocket) throws IOException {
serverSocket.setUseClientMode(false);
if (this.sslConfig.isRequireAuth()) {
// serverSocket.setWantClientAuth( true );
serverSocket.setNeedClientAuth(true);
}
serverSocket.setEnableSessionCreation(true);
// restrict protocols
String[] protocols = this.sslConfig.getProtocolsAsStringArray();
if (!"any".equalsIgnoreCase(protocols[0])) {
serverSocket.setEnabledProtocols(protocols);
}
// restrict ciphers
String[] ciphers = this.sslConfig.getCiphersAsStringArray();
if (!"any".equalsIgnoreCase(ciphers[0])) {
serverSocket.setEnabledCipherSuites(ciphers);
}
}
示例3: configureServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Set the server socket configuration to our required
* QOS values.
*
* A small experiment shows that setting either (want, need) parameter to either true or false sets the
* other parameter to false.
*
* @param serverSocket
* The newly created SSLServerSocket.
*
* @throws IOException if server socket can't be configured
*/
private void configureServerSocket(SSLServerSocket serverSocket) throws IOException {
// set the authentication value and cipher suite info.
serverSocket.setEnabledCipherSuites(cipherSuites);
if (clientAuthRequired) {
serverSocket.setNeedClientAuth(true);
} else if (clientAuthSupported) {
serverSocket.setWantClientAuth(true);
} else {
serverSocket.setNeedClientAuth(false); //could set want with the same effect
}
serverSocket.setSoTimeout(SOCKET_TIMEOUT_MS);
if (log.isDebugEnabled()) {
log.debug("Created SSL server socket on port " + serverSocket.getLocalPort());
log.debug(" client authentication " + (clientAuthSupported ? "SUPPORTED" : "UNSUPPORTED"));
log.debug(" client authentication " + (clientAuthRequired ? "REQUIRED" : "OPTIONAL"));
log.debug(" cipher suites:");
for (int i = 0; i < cipherSuites.length; i++) {
log.debug(" " + cipherSuites[i]);
}
}
}
示例4: JSSEServer
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
JSSEServer(CipherTestUtils cipherTest, int serverPort,
String protocol, String cipherSuite) throws Exception {
super(cipherTest);
this.serverPort = serverPort;
SSLContext serverContext = SSLContext.getInstance("TLS");
serverContext.init(new KeyManager[]{cipherTest.getServerKeyManager()},
new TrustManager[]{cipherTest.getServerTrustManager()},
CipherTestUtils.secureRandom);
SSLServerSocketFactory factory =
(SSLServerSocketFactory)serverContext.getServerSocketFactory();
serverSocket =
(SSLServerSocket) factory.createServerSocket(serverPort);
serverSocket.setEnabledProtocols(protocol.split(","));
serverSocket.setEnabledCipherSuites(cipherSuite.split(","));
CipherTestUtils.printInfo(serverSocket);
}
示例5: initSecure
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
final ServerSocket initSecure(int port) throws Exception {
ServerSocketFactory fac;
if (sslContext != null) {
fac = sslContext.getServerSocketFactory();
} else {
fac = SSLServerSocketFactory.getDefault();
}
SSLServerSocket se = (SSLServerSocket) fac.createServerSocket(port);
SSLParameters sslp = se.getSSLParameters();
sslp.setApplicationProtocols(new String[]{"h2"});
se.setSSLParameters(sslp);
se.setEnabledCipherSuites(se.getSupportedCipherSuites());
se.setEnabledProtocols(se.getSupportedProtocols());
// other initialisation here
return se;
}
示例6: JSSEServer
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
JSSEServer(CipherTestUtils cipherTest, int serverPort,
String protocol, String cipherSuite) throws Exception {
super(cipherTest);
SSLContext serverContext = SSLContext.getInstance("TLS");
serverContext.init(new KeyManager[]{cipherTest.getServerKeyManager()},
new TrustManager[]{cipherTest.getServerTrustManager()},
CipherTestUtils.secureRandom);
SSLServerSocketFactory factory =
(SSLServerSocketFactory)serverContext.getServerSocketFactory();
serverSocket =
(SSLServerSocket) factory.createServerSocket(serverPort);
serverSocket.setEnabledProtocols(protocol.split(","));
serverSocket.setEnabledCipherSuites(cipherSuite.split(","));
CipherTestUtils.printInfo(serverSocket);
}
示例7: newSslServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public SSLServerSocket newSslServerSocket(String host,int port,int backlog) throws IOException {
SSLServerSocketFactory factory = sslContext.getServerSocketFactory();
SSLServerSocket socket =
(SSLServerSocket) (host==null ?
factory.createServerSocket(port, backlog):
factory.createServerSocket(port, backlog, InetAddress.getByName(host)));
if (sslConfig.getWantClientAuth())
socket.setWantClientAuth(sslConfig.getWantClientAuth());
if (sslConfig.getNeedClientAuth())
socket.setNeedClientAuth(sslConfig.getNeedClientAuth());
socket.setEnabledCipherSuites(selectCipherSuites(socket.getEnabledCipherSuites(),
socket.getSupportedCipherSuites()));
socket.setEnabledProtocols(selectProtocols(socket.getEnabledProtocols(),socket.getSupportedProtocols()));
return socket;
}
示例8: createServer
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
private static GfxdTSSLServerSocket createServer(
SSLServerSocketFactory factory, InetSocketAddress bindAddress,
SocketParameters params) throws TTransportException {
try {
SSLServerSocket serverSocket = (SSLServerSocket)factory
.createServerSocket(bindAddress.getPort(), 100,
bindAddress.getAddress());
if (params != null) {
if (params.getSSLEnabledProtocols() != null) {
serverSocket.setEnabledProtocols(params.getSSLEnabledProtocols());
}
if (params.getSSLCipherSuites() != null) {
serverSocket.setEnabledCipherSuites(params.getSSLCipherSuites());
}
serverSocket.setNeedClientAuth(params.getSSLClientAuth());
}
return new GfxdTSSLServerSocket(serverSocket, bindAddress, params);
} catch (Exception e) {
throw new TTransportException(TTransportException.NOT_OPEN,
"Could not bind to host:port " + bindAddress.toString(), e);
}
}
示例9: initSslServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Initializes the SSL server socket. Configures the certificate request
* (need or want) and the enabled cipher suites.
*
* @param sslServerSocket
* The server socket to initialize.
* @return The initialized server socket.
*/
protected SSLServerSocket initSslServerSocket(
SSLServerSocket sslServerSocket) {
if (getContextFactory().isNeedClientAuthentication()) {
sslServerSocket.setNeedClientAuth(true);
} else if (getContextFactory().isWantClientAuthentication()) {
sslServerSocket.setWantClientAuth(true);
}
if ((getContextFactory().getEnabledCipherSuites() != null)
|| (getContextFactory().getDisabledCipherSuites() != null)) {
sslServerSocket.setEnabledCipherSuites(getContextFactory()
.getSelectedCipherSuites(
sslServerSocket.getSupportedCipherSuites()));
}
if ((getContextFactory().getEnabledProtocols() != null)
|| (getContextFactory().getDisabledProtocols() != null)) {
sslServerSocket.setEnabledProtocols(getContextFactory()
.getSelectedSslProtocols(
sslServerSocket.getSupportedProtocols()));
}
return sslServerSocket;
}
示例10: BlockingServletEngine
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
BlockingServletEngine(FilterChain dispatcher, ServletEngineConfiguration config)
throws InterruptedException, IOException {
this.config = config;
if (config.isSecure()) {
SSLServerSocketFactory factory = (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
SSLServerSocket sslServerSocket = (SSLServerSocket)factory.createServerSocket(config.getPort());
sslServerSocket.setEnabledCipherSuites(config.getEnabledCipherSuites());
serverSocket = sslServerSocket;
} else {
serverSocket = new ServerSocket(config.getPort());
}
int nthreads = config.getMaxThreads();
queue = new DispatchQueueImpl(nthreads);
handler = new HttpRequestHandlerAdapter(dispatcher);
socketHandler = new HttpSocketHandler(handler);
for (int i = 0; i < nthreads; ++i) {
queue.addRunnable(new AcceptSocketAndHandleRequest(socketHandler, serverSocket));
}
}
示例11: createSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Create a ServerSocket. If the 'useSSL' has been specified as true, it
* will create a SSLServerSocket without certification ("ANON" Cypher Suites).
*
* @param port Port of the ServerSocket
* @return ServerSocket / SSLServerSocket
* @throws IOException
*/
private ServerSocket createSocket(int port) throws IOException
{
if(useSSL)
{
if(factory == null)
{
factory = (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
cipherSuites = Stream.of(factory.getSupportedCipherSuites())
.filter(c -> c.toLowerCase().contains("anon"))
.toArray(String[]::new);
}
SSLServerSocket socket = (SSLServerSocket)factory.createServerSocket(port);
socket.setEnabledCipherSuites(cipherSuites);
return socket;
}
else
return new ServerSocket(port);
}
示例12: newSslServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public SSLServerSocket newSslServerSocket(String host,int port,int backlog) throws IOException
{
SSLServerSocketFactory factory = _context.getServerSocketFactory();
SSLServerSocket socket =
(SSLServerSocket) (host==null ?
factory.createServerSocket(port,backlog):
factory.createServerSocket(port,backlog,InetAddress.getByName(host)));
if (getWantClientAuth())
socket.setWantClientAuth(getWantClientAuth());
if (getNeedClientAuth())
socket.setNeedClientAuth(getNeedClientAuth());
socket.setEnabledCipherSuites(selectCipherSuites(
socket.getEnabledCipherSuites(),
socket.getSupportedCipherSuites()));
socket.setEnabledProtocols(selectProtocols(socket.getEnabledProtocols(),socket.getSupportedProtocols()));
return socket;
}
示例13: open
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
private void open() {
try {
if (debugSettings.isUseSsslEncryption()) {
SSLServerSocket sslServerSocket =
(SSLServerSocket)
SSLServerSocketFactory.getDefault()
.createServerSocket(debugSettings.getDebugPort());
sslServerSocket.setEnabledCipherSuites(sslServerSocket.getSupportedCipherSuites());
this.debugSocket = sslServerSocket;
} else {
this.debugSocket = new ServerSocket(debugSettings.getDebugPort());
}
} catch (Exception e) {
ZendDebugger.LOG.error(e.getMessage(), e);
}
}
示例14: createServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
@Override
public ServerSocket createServerSocket(int port) throws IOException {
SSLServerSocket sslServerSocket =
(SSLServerSocket) sslServerSocketFactory.createServerSocket(port, 0, bindAddress);
if (getEnabledCipherSuites() != null) {
sslServerSocket.setEnabledCipherSuites(getEnabledCipherSuites());
}
if (getEnabledProtocols() == null) {
sslServerSocket.setEnabledProtocols(defaultProtocols);
} else {
sslServerSocket.setEnabledProtocols(getEnabledProtocols());
}
sslServerSocket.setNeedClientAuth(getNeedClientAuth());
return sslServerSocket;
}
示例15: initServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Configures the given SSL server socket with the requested cipher suites,
* protocol versions, and need for client authentication
*/
private void initServerSocket(ServerSocket ssocket) {
SSLServerSocket socket = (SSLServerSocket) ssocket;
socket.setEnabledCipherSuites(enabledCiphers);
socket.setEnabledProtocols(enabledProtocols);
// we don't know if client auth is needed -
// after parsing the request we may re-handshake
configureClientAuth(socket);
configureUseServerCipherSuitesOrder(socket);
}