本文整理汇总了Java中javax.net.ssl.SSLServerSocket.getEnabledCipherSuites方法的典型用法代码示例。如果您正苦于以下问题:Java SSLServerSocket.getEnabledCipherSuites方法的具体用法?Java SSLServerSocket.getEnabledCipherSuites怎么用?Java SSLServerSocket.getEnabledCipherSuites使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.net.ssl.SSLServerSocket
的用法示例。
在下文中一共展示了SSLServerSocket.getEnabledCipherSuites方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printInfo
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
public static void printInfo(SSLServerSocket socket) {
System.out.println();
System.out.println("--- SSL ServerSocket Info ---");
System.out.print("SupportedProtocols : ");
printStringArray(socket.getSupportedProtocols());
System.out.print("SupportedCipherSuites : ");
printStringArray(socket.getSupportedCipherSuites());
System.out.print("EnabledProtocols : ");
printStringArray(socket.getEnabledProtocols());
System.out.print("EnabledCipherSuites : ");
String[] supportedCipherSuites = socket.getEnabledCipherSuites();
Arrays.sort(supportedCipherSuites);
printStringArray(supportedCipherSuites);
System.out.println("NeedClientAuth : "
+ socket.getNeedClientAuth());
System.out.println("WantClientAuth : "
+ socket.getWantClientAuth());
System.out.println("-----------------------");
}
示例2: testSetEnabledCipherSuitesStoresCopy
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
@Test
public void testSetEnabledCipherSuitesStoresCopy() throws Exception {
SSLServerSocket socket =
(SSLServerSocket) SSLServerSocketFactory.getDefault().createServerSocket();
String[] array = new String[] {socket.getEnabledCipherSuites()[0]};
String originalFirstElement = array[0];
socket.setEnabledCipherSuites(array);
array[0] = "Modified after having been set";
assertEquals(originalFirstElement, socket.getEnabledCipherSuites()[0]);
}
示例3: 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");
}
}
}
示例4: narrowServerSocketCipherSuites
import javax.net.ssl.SSLServerSocket; //导入方法依赖的package包/类
private static void narrowServerSocketCipherSuites( ServerSocket serverSocket ) {
if( !( serverSocket instanceof SSLServerSocket ) )
return;
logger.finest("Entering ProxiedClientListener:narrowCipherSuites ... ");
SSLServerSocket sslServerSocket = (SSLServerSocket) serverSocket;
String[] suites = sslServerSocket.getEnabledCipherSuites();
logger.finest("Defaulty Support cipher suites are:");
for (int i = 0; i < suites.length; i++) {
logger.finest( suites[i] );
}
String[] filteredSuites = filterSuites(suites, excludeCipher );
logger.finest("nerrowed from " + suites.length + " to " + filteredSuites.length );
for( int i=0; i<filteredSuites.length; i++ )
logger.finest( filteredSuites[i] );
//after this line, the socket's enabledCipherSuites should be only 3
sslServerSocket.setEnabledCipherSuites( filteredSuites );
//if( logger.getLevel().equals( Level.finest ) )
{
String[] newSuites = sslServerSocket.getEnabledCipherSuites();
logger.finest( "Supported cipher suites are: " );
for(int i=0; i<newSuites.length; i++ ) {
logger.finest( newSuites[i] );
}
}
}
示例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");
}
}
}