本文整理汇总了Java中javax.net.ssl.SSLServerSocket.getSupportedCipherSuites方法的典型用法代码示例。如果您正苦于以下问题:Java SSLServerSocket.getSupportedCipherSuites方法的具体用法?Java SSLServerSocket.getSupportedCipherSuites怎么用?Java SSLServerSocket.getSupportedCipherSuites使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.net.ssl.SSLServerSocket
的用法示例。
在下文中一共展示了SSLServerSocket.getSupportedCipherSuites方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSetEnabledCipherSuitesAffectsGetter
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
@Test
public void testSetEnabledCipherSuitesAffectsGetter() throws Exception {
SSLServerSocket socket =
(SSLServerSocket) SSLServerSocketFactory.getDefault().createServerSocket();
String[] cipherSuites = new String[] {socket.getSupportedCipherSuites()[0]};
socket.setEnabledCipherSuites(cipherSuites);
assertEquals(Arrays.asList(cipherSuites), Arrays.asList(socket.getEnabledCipherSuites()));
}
示例2: test_getSupportedCipherSuites
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* @throws Exception
* @tests javax.net.ssl.SSLServerSocket#getSupportedCipherSuites()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getSupportedCipherSuites",
args = {}
)
public void test_getSupportedCipherSuites() throws Exception {
SSLServerSocket sss = getSSLServerSocket();
String[] res = sss.getSupportedCipherSuites();
assertNotNull("NULL result", res);
assertTrue("no supported cipher suites available.", res.length > 0);
}
示例3: test_getSupportedProtocols
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* @throws IOException
* @tests javax.net.ssl.SSLServerSocket#getSupportedProtocols()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getSupportedProtocols",
args = {}
)
public void test_getSupportedProtocols() throws Exception {
SSLServerSocket sss = getSSLServerSocket();
String[] res = sss.getSupportedCipherSuites();
assertNotNull("NULL result", res);
assertTrue("no supported protocols available.", res.length > 0);
}
示例4: testGetSupportedCipherSuites
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* getSupportedCipherSuites() method testing.
*/
public void testGetSupportedCipherSuites() throws Exception {
SSLServerSocket ssocket = createSSLServerSocket();
String[] supported = ssocket.getSupportedCipherSuites();
assertNotNull(supported);
supported[0] = "NOT_SUPPORTED_CIPHER_SUITE";
supported = ssocket.getEnabledCipherSuites();
for (int i=0; i<supported.length; i++) {
if ("NOT_SUPPORTED_CIPHER_SUITE".equals(supported[i])) {
fail("Modification of the returned result "
+ "causes the modification of the internal state");
}
}
}
示例5: create
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Creates the SSL ServerSocket.
*/
public ServerSocketBar create(InetAddress host, int port)
throws IOException, GeneralSecurityException
{
SSLServerSocketFactory ssFactory = null;
if (_keyStore != null) {
SSLContext sslContext = SSLContext.getInstance(_sslContext);
KeyManagerFactory kmf
= KeyManagerFactory.getInstance(keyManagerFactory());
kmf.init(_keyStore, keyStorePassword().toCharArray());
sslContext.init(kmf.getKeyManagers(), null, null);
/*
if (_cipherSuites != null)
sslContext.createSSLEngine().setEnabledCipherSuites(_cipherSuites);
if (_protocols != null)
sslContext.createSSLEngine().setEnabledProtocols(_protocols);
*/
SSLEngine engine = sslContext.createSSLEngine();
engine.setEnabledProtocols(enabledProtocols(engine.getSupportedProtocols()));
ssFactory = sslContext.getServerSocketFactory();
}
else {
ssFactory = createAnonymousServerFactory(host, port);
}
ServerSocket serverSocket;
int listen = 100;
if (host == null)
serverSocket = ssFactory.createServerSocket(port, listen);
else
serverSocket = ssFactory.createServerSocket(port, listen, host);
SSLServerSocket sslServerSocket = (SSLServerSocket) serverSocket;
if (_cipherSuites != null) {
sslServerSocket.setEnabledCipherSuites(_cipherSuites);
}
if (_cipherSuitesForbidden != null) {
String []cipherSuites = sslServerSocket.getEnabledCipherSuites();
if (cipherSuites == null)
cipherSuites = sslServerSocket.getSupportedCipherSuites();
ArrayList<String> cipherList = new ArrayList<String>();
for (String cipher : cipherSuites) {
if (! isCipherForbidden(cipher, _cipherSuitesForbidden)) {
cipherList.add(cipher);
}
}
cipherSuites = new String[cipherList.size()];
cipherList.toArray(cipherSuites);
sslServerSocket.setEnabledCipherSuites(cipherSuites);
}
sslServerSocket.setEnabledProtocols(enabledProtocols(sslServerSocket.getSupportedProtocols()));
if ("required".equals(_verifyClient))
sslServerSocket.setNeedClientAuth(true);
else if ("optional".equals(_verifyClient))
sslServerSocket.setWantClientAuth(true);
return new ServerSocketWrapper(serverSocket);
}
示例6: testGetEnabledCipherSuites
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* getEnabledCipherSuites() method testing.
*/
public void testGetEnabledCipherSuites() throws Exception {
SSLServerSocket ssocket = createSSLServerSocket();
String[] enabled = ssocket.getEnabledCipherSuites();
assertNotNull(enabled);
String[] supported = ssocket.getSupportedCipherSuites();
for (int i=0; i<enabled.length; i++) {
//System.out.println("Checking of "+enabled[i]);
found: {
for (int j=0; j<supported.length; j++) {
if (enabled[i].equals(supported[j])) {
break found;
}
}
fail("Enabled suite does not belong to the set "
+ "of supported cipher suites: " + enabled[i]);
}
}
ssocket.setEnabledCipherSuites(supported);
for (int i=0; i<supported.length; i++) {
enabled = new String[supported.length - i];
System.arraycopy(supported, 0,
enabled, 0, supported.length-i);
ssocket.setEnabledCipherSuites(enabled);
String[] result = ssocket.getEnabledCipherSuites();
if (result.length != enabled.length) {
fail("Returned result does not correspond to expected.");
}
for (int k=0; k<result.length; k++) {
found: {
for (int n=0; n<enabled.length; n++) {
if (result[k].equals(enabled[n])) {
break found;
}
}
if (result.length != enabled.length) {
fail("Returned result does not correspond "
+ "to expected.");
}
}
}
}
}
示例7: testSetEnabledCipherSuites
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* setEnabledCipherSuites(String[] suites) method testing.
*/
public void testSetEnabledCipherSuites() throws Exception {
SSLServerSocket ssocket = createSSLServerSocket();
String[] enabled = ssocket.getEnabledCipherSuites();
assertNotNull(enabled);
String[] supported = ssocket.getSupportedCipherSuites();
for (int i=0; i<enabled.length; i++) {
//System.out.println("Checking of "+enabled[i]);
found: {
for (int j=0; j<supported.length; j++) {
if (enabled[i].equals(supported[j])) {
break found;
}
}
fail("Enabled suite does not belong to the set "
+ "of supported cipher suites: " + enabled[i]);
}
}
ssocket.setEnabledCipherSuites(supported);
ssocket.setEnabledCipherSuites(enabled);
ssocket.setEnabledCipherSuites(supported);
String[] more_than_supported = new String[supported.length+1];
for (int i=0; i<supported.length+1; i++) {
more_than_supported[i]
= "NOT_SUPPORTED_CIPHER_SUITE";
System.arraycopy(supported, 0,
more_than_supported, 0, i);
System.arraycopy(supported, i,
more_than_supported, i+1, supported.length-i);
try {
ssocket.setEnabledCipherSuites(more_than_supported);
fail("Expected IllegalArgumentException was not thrown");
} catch (IllegalArgumentException e) { }
}
enabled = ssocket.getEnabledCipherSuites();
enabled[0] = "NOT_SUPPORTED_CIPHER_SUITE";
enabled = ssocket.getEnabledCipherSuites();
for (int i=0; i<enabled.length; i++) {
if ("NOT_SUPPORTED_CIPHER_SUITE".equals(enabled[i])) {
fail("Modification of the returned result "
+ "causes the modification of the internal state");
}
}
}
示例8: initServerSocket
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
/**
* Set the requested properties for this server socket.
*
* @param ssocket The server socket to be configured
*/
private void initServerSocket(ServerSocket ssocket) {
SSLServerSocket socket = (SSLServerSocket) ssocket;
// Enable all available cipher suites when the socket is connected
String cipherSuites[] = socket.getSupportedCipherSuites();
socket.setEnabledCipherSuites(cipherSuites);
// Set client authentication if necessary
socket.setNeedClientAuth(clientAuth);
}