本文整理汇总了Java中javax.net.ssl.SSLSession.getCipherSuite方法的典型用法代码示例。如果您正苦于以下问题:Java SSLSession.getCipherSuite方法的具体用法?Java SSLSession.getCipherSuite怎么用?Java SSLSession.getCipherSuite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.net.ssl.SSLSession
的用法示例。
在下文中一共展示了SSLSession.getCipherSuite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import javax.net.ssl.SSLSession; //导入方法依赖的package包/类
public static Handshake get(SSLSession session) {
String cipherSuiteString = session.getCipherSuite();
if (cipherSuiteString == null) throw new IllegalStateException("cipherSuite == null");
CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
String tlsVersionString = session.getProtocol();
if (tlsVersionString == null) throw new IllegalStateException("tlsVersion == null");
TlsVersion tlsVersion = TlsVersion.forJavaName(tlsVersionString);
Certificate[] peerCertificates;
try {
peerCertificates = session.getPeerCertificates();
} catch (SSLPeerUnverifiedException ignored) {
peerCertificates = null;
}
List<Certificate> peerCertificatesList = peerCertificates != null
? Util.immutableList(peerCertificates)
: Collections.<Certificate>emptyList();
Certificate[] localCertificates = session.getLocalCertificates();
List<Certificate> localCertificatesList = localCertificates != null
? Util.immutableList(localCertificates)
: Collections.<Certificate>emptyList();
return new Handshake(tlsVersion, cipherSuite, peerCertificatesList, localCertificatesList);
}
示例2: get
import javax.net.ssl.SSLSession; //导入方法依赖的package包/类
public static Handshake get(SSLSession session) {
String cipherSuite = session.getCipherSuite();
if (cipherSuite == null) {
throw new IllegalStateException("cipherSuite == null");
}
Certificate[] peerCertificates;
List<Certificate> peerCertificatesList;
List<Certificate> localCertificatesList;
try {
peerCertificates = session.getPeerCertificates();
} catch (SSLPeerUnverifiedException e) {
peerCertificates = null;
}
if (peerCertificates != null) {
peerCertificatesList = Util.immutableList(peerCertificates);
} else {
peerCertificatesList = Collections.emptyList();
}
Certificate[] localCertificates = session.getLocalCertificates();
if (localCertificates != null) {
localCertificatesList = Util.immutableList(localCertificates);
} else {
localCertificatesList = Collections.emptyList();
}
return new Handshake(cipherSuite, peerCertificatesList, localCertificatesList);
}