|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
package sun.security.ssl; |
|
|
|
import java.io.IOException; |
|
import java.net.InetAddress; |
|
import java.net.Socket; |
|
import javax.net.ssl.SSLParameters; |
|
import javax.net.ssl.SSLServerSocket; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
final class SSLServerSocketImpl extends SSLServerSocket { |
|
private final SSLContextImpl sslContext; |
|
private final SSLConfiguration sslConfig; |
|
|
|
SSLServerSocketImpl(SSLContextImpl sslContext) throws IOException { |
|
|
|
super(); |
|
this.sslContext = sslContext; |
|
this.sslConfig = new SSLConfiguration(sslContext, false); |
|
} |
|
|
|
SSLServerSocketImpl(SSLContextImpl sslContext, |
|
int port, int backlog) throws IOException { |
|
|
|
super(port, backlog); |
|
this.sslContext = sslContext; |
|
this.sslConfig = new SSLConfiguration(sslContext, false); |
|
} |
|
|
|
SSLServerSocketImpl(SSLContextImpl sslContext, |
|
int port, int backlog, InetAddress address) throws IOException { |
|
|
|
super(port, backlog, address); |
|
this.sslContext = sslContext; |
|
this.sslConfig = new SSLConfiguration(sslContext, 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()); |
|
} |
|
|
|
@Override |
|
public String[] getSupportedProtocols() { |
|
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 (sslConfig.isClientMode != useClientMode) { |
|
if (sslContext.isDefaultProtocolVesions( |
|
sslConfig.enabledProtocols)) { |
|
sslConfig.enabledProtocols = |
|
sslContext.getDefaultProtocolVersions(!useClientMode); |
|
} |
|
|
|
if (sslContext.isDefaultCipherSuiteList( |
|
sslConfig.enabledCipherSuites)) { |
|
sslConfig.enabledCipherSuites = |
|
sslContext.getDefaultCipherSuites(!useClientMode); |
|
} |
|
|
|
sslConfig.toggleClientMode(); |
|
} |
|
} |
|
|
|
@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); |
|
|
|
implAccept(s); |
|
s.doneConnect(); |
|
return s; |
|
} |
|
|
|
@Override |
|
public String toString() { |
|
return "[SSL: "+ super.toString() + "]"; |
|
} |
|
} |