< prev index next >

src/java.base/share/classes/sun/security/ssl/SSLServerSocketImpl.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 26,36 **** package sun.security.ssl; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; - import java.util.concurrent.locks.ReentrantLock; import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLServerSocket; /** * This class provides a simple way for servers to support conventional --- 26,35 ----
*** 55,65 **** * @author David Brownell */ final class SSLServerSocketImpl extends SSLServerSocket { private final SSLContextImpl sslContext; private final SSLConfiguration sslConfig; - private final ReentrantLock serverSocketLock = new ReentrantLock(); SSLServerSocketImpl(SSLContextImpl sslContext) throws IOException { super(); this.sslContext = sslContext; --- 54,63 ----
*** 84,111 **** this.sslConfig = new SSLConfiguration(sslContext, false); this.sslConfig.isClientMode = false; } @Override ! public String[] getEnabledCipherSuites() { ! serverSocketLock.lock(); ! try { ! return CipherSuite.namesOf(sslConfig.enabledCipherSuites); ! } finally { ! serverSocketLock.unlock(); ! } } @Override ! public void setEnabledCipherSuites(String[] suites) { ! serverSocketLock.lock(); ! try { ! sslConfig.enabledCipherSuites = ! CipherSuite.validValuesOf(suites); ! } finally { ! serverSocketLock.unlock(); ! } } @Override public String[] getSupportedCipherSuites() { return CipherSuite.namesOf(sslContext.getSupportedCipherSuites()); --- 82,99 ---- this.sslConfig = new SSLConfiguration(sslContext, false); this.sslConfig.isClientMode = false; } @Override ! public synchronized String[] getEnabledCipherSuites() { ! return CipherSuite.namesOf(sslConfig.enabledCipherSuites); } @Override ! public synchronized void setEnabledCipherSuites(String[] suites) { ! sslConfig.enabledCipherSuites = ! CipherSuite.validValuesOf(suites); } @Override public String[] getSupportedCipherSuites() { return CipherSuite.namesOf(sslContext.getSupportedCipherSuites());
*** 116,272 **** return ProtocolVersion.toStringArray( sslContext.getSupportedProtocolVersions()); } @Override ! public String[] getEnabledProtocols() { ! serverSocketLock.lock(); ! try { ! return ProtocolVersion.toStringArray(sslConfig.enabledProtocols); ! } finally { ! serverSocketLock.unlock(); ! } } @Override ! public void setEnabledProtocols(String[] protocols) { ! serverSocketLock.lock(); ! try { ! if (protocols == null) { ! throw new IllegalArgumentException("Protocols cannot be null"); ! } ! ! sslConfig.enabledProtocols = ProtocolVersion.namesOf(protocols); ! } finally { ! serverSocketLock.unlock(); } } @Override ! public void setNeedClientAuth(boolean need) { ! serverSocketLock.lock(); ! try { ! sslConfig.clientAuthType = ! (need ? ClientAuthType.CLIENT_AUTH_REQUIRED : ! ClientAuthType.CLIENT_AUTH_NONE); ! } finally { ! serverSocketLock.unlock(); ! } } @Override ! public boolean getNeedClientAuth() { ! serverSocketLock.lock(); ! try { ! return (sslConfig.clientAuthType == ClientAuthType.CLIENT_AUTH_REQUIRED); - } finally { - serverSocketLock.unlock(); - } } @Override ! public void setWantClientAuth(boolean want) { ! serverSocketLock.lock(); ! try { ! sslConfig.clientAuthType = ! (want ? ClientAuthType.CLIENT_AUTH_REQUESTED : ! ClientAuthType.CLIENT_AUTH_NONE); ! } finally { ! serverSocketLock.unlock(); ! } } @Override ! public boolean getWantClientAuth() { ! serverSocketLock.lock(); ! try { ! return (sslConfig.clientAuthType == ClientAuthType.CLIENT_AUTH_REQUESTED); - } finally { - serverSocketLock.unlock(); - } } @Override ! public void setUseClientMode(boolean useClientMode) { ! serverSocketLock.lock(); ! try { ! /* ! * If we need to change the client mode and the enabled ! * protocols and cipher suites haven't specifically been ! * set by the user, change them to the corresponding ! * default ones. ! */ ! if (sslConfig.isClientMode != useClientMode) { ! if (sslContext.isDefaultProtocolVesions( ! sslConfig.enabledProtocols)) { ! sslConfig.enabledProtocols = sslContext.getDefaultProtocolVersions(!useClientMode); ! } ! if (sslContext.isDefaultCipherSuiteList( ! sslConfig.enabledCipherSuites)) { ! sslConfig.enabledCipherSuites = sslContext.getDefaultCipherSuites(!useClientMode); - } - - sslConfig.isClientMode = useClientMode; } ! } finally { ! serverSocketLock.unlock(); } } @Override ! public boolean getUseClientMode() { ! serverSocketLock.lock(); ! try { ! return sslConfig.isClientMode; ! } finally { ! serverSocketLock.unlock(); ! } } @Override ! public void setEnableSessionCreation(boolean flag) { ! serverSocketLock.lock(); ! try { ! sslConfig.enableSessionCreation = flag; ! } finally { ! serverSocketLock.unlock(); ! } } @Override ! public boolean getEnableSessionCreation() { ! serverSocketLock.lock(); ! try { ! return sslConfig.enableSessionCreation; ! } finally { ! serverSocketLock.unlock(); ! } } @Override ! public SSLParameters getSSLParameters() { ! serverSocketLock.lock(); ! try { ! return sslConfig.getSSLParameters(); ! } finally { ! serverSocketLock.unlock(); ! } } @Override ! public void setSSLParameters(SSLParameters params) { ! serverSocketLock.lock(); ! try { ! sslConfig.setSSLParameters(params); ! } finally { ! serverSocketLock.unlock(); ! } } @Override public Socket accept() throws IOException { SSLSocketImpl s = new SSLSocketImpl(sslContext, sslConfig); --- 104,200 ---- return ProtocolVersion.toStringArray( sslContext.getSupportedProtocolVersions()); } @Override ! public synchronized String[] getEnabledProtocols() { ! return ProtocolVersion.toStringArray(sslConfig.enabledProtocols); } @Override ! public synchronized void setEnabledProtocols(String[] protocols) { ! if (protocols == null) { ! throw new IllegalArgumentException("Protocols cannot be null"); } + + sslConfig.enabledProtocols = ProtocolVersion.namesOf(protocols); } @Override ! public synchronized void setNeedClientAuth(boolean need) { ! sslConfig.clientAuthType = ! (need ? ClientAuthType.CLIENT_AUTH_REQUIRED : ! ClientAuthType.CLIENT_AUTH_NONE); } @Override ! public synchronized boolean getNeedClientAuth() { ! return (sslConfig.clientAuthType == ClientAuthType.CLIENT_AUTH_REQUIRED); } @Override ! public synchronized void setWantClientAuth(boolean want) { ! sslConfig.clientAuthType = ! (want ? ClientAuthType.CLIENT_AUTH_REQUESTED : ! ClientAuthType.CLIENT_AUTH_NONE); } @Override ! public synchronized boolean getWantClientAuth() { ! return (sslConfig.clientAuthType == ClientAuthType.CLIENT_AUTH_REQUESTED); } @Override ! public synchronized void setUseClientMode(boolean useClientMode) { ! /* ! * If we need to change the client mode and the enabled ! * protocols and cipher suites haven't specifically been ! * set by the user, change them to the corresponding ! * default ones. ! */ ! if (sslConfig.isClientMode != useClientMode) { ! if (sslContext.isDefaultProtocolVesions( ! sslConfig.enabledProtocols)) { ! sslConfig.enabledProtocols = sslContext.getDefaultProtocolVersions(!useClientMode); ! } ! if (sslContext.isDefaultCipherSuiteList( ! sslConfig.enabledCipherSuites)) { ! sslConfig.enabledCipherSuites = sslContext.getDefaultCipherSuites(!useClientMode); } ! ! sslConfig.isClientMode = useClientMode; } } @Override ! public synchronized boolean getUseClientMode() { ! return sslConfig.isClientMode; } @Override ! public synchronized void setEnableSessionCreation(boolean flag) { ! sslConfig.enableSessionCreation = flag; } @Override ! public synchronized boolean getEnableSessionCreation() { ! return sslConfig.enableSessionCreation; } @Override ! public synchronized SSLParameters getSSLParameters() { ! return sslConfig.getSSLParameters(); } @Override ! public synchronized void setSSLParameters(SSLParameters params) { ! sslConfig.setSSLParameters(params); } @Override public Socket accept() throws IOException { SSLSocketImpl s = new SSLSocketImpl(sslContext, sslConfig);
< prev index next >