本文整理汇总了Java中javax.net.ssl.HandshakeCompletedEvent类的典型用法代码示例。如果您正苦于以下问题:Java HandshakeCompletedEvent类的具体用法?Java HandshakeCompletedEvent怎么用?Java HandshakeCompletedEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HandshakeCompletedEvent类属于javax.net.ssl包,在下文中一共展示了HandshakeCompletedEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handshakeCompleted
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
public void handshakeCompleted(HandshakeCompletedEvent evt) {
SSLSession session;
String sessionId;
SSLSocket socket;
if (Error.TRACESYSTEMOUT) {
socket = evt.getSocket();
session = evt.getSession();
Error.printSystemOut("SSL handshake completed:");
Error.printSystemOut(
"------------------------------------------------");
Error.printSystemOut("socket: : " + socket);
Error.printSystemOut("cipher suite : " + session.getCipherSuite());
sessionId = StringConverter.byteArrayToHexString(session.getId());
Error.printSystemOut("session id : " + sessionId);
Error.printSystemOut(
"------------------------------------------------");
}
}
示例2: handshakeCompleted
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
public void handshakeCompleted(HandshakeCompletedEvent evt) {
SSLSession session;
String sessionId;
SSLSocket socket;
if (Trace.TRACE) {
socket = evt.getSocket();
session = evt.getSession();
Trace.printSystemOut("SSL handshake completed:");
Trace.printSystemOut(
"------------------------------------------------");
Trace.printSystemOut("socket: : " + socket);
Trace.printSystemOut("cipher suite : "
+ session.getCipherSuite());
sessionId = StringConverter.byteToHex(session.getId());
Trace.printSystemOut("session id : " + sessionId);
Trace.printSystemOut(
"------------------------------------------------");
}
}
示例3: notifyHandshakeCompletedListeners
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
final void notifyHandshakeCompletedListeners() {
if (listeners != null && !listeners.isEmpty()) {
// notify the listeners
HandshakeCompletedEvent event = new HandshakeCompletedEvent(this, getActiveSession());
for (HandshakeCompletedListener listener : listeners) {
try {
listener.handshakeCompleted(event);
} catch (RuntimeException e) {
// The RI runs the handlers in a separate thread,
// which we do not. But we try to preserve their
// behavior of logging a problem and not killing
// the handshaking thread just because a listener
// has a problem.
Thread thread = Thread.currentThread();
thread.getUncaughtExceptionHandler().uncaughtException(thread, e);
}
}
}
}
示例4: handshakeCompleted
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
@Override
public void handshakeCompleted(HandshakeCompletedEvent event) {
SSLSession session = event.getSession();
sslConnectionInfos.setPeerHost(session.getPeerHost());
sslConnectionInfos.setPeerPort(session.getPeerPort());
sslConnectionInfos.setProtocol(session.getProtocol());
sslConnectionInfos.setCipherSuite(session.getCipherSuite());
Certificate[] locChain = session.getLocalCertificates();
if (locChain != null) {
X509Certificate[] clientCertificates = Arrays.copyOf(locChain, locChain.length, X509Certificate[].class);
sslConnectionInfos.setClientCertificates(clientCertificates);
}
try {
Certificate[] chain = session.getPeerCertificates();
if (chain != null) {
X509Certificate[] serverCertificates = Arrays.copyOf(chain, chain.length, X509Certificate[].class);
sslConnectionInfos.setServerCertificates(serverCertificates);
}
} catch (SSLPeerUnverifiedException e) {
// do nothing
}
}
示例5: connect
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
@Override
public void connect(SocketAddress endpoint, int timeout) throws IOException {
Date start = new Date();
socket.connect(endpoint, timeout);
Date end = new Date();
RequestInfo.get().connect(start, end);
handshakeStart = new Date();
startHandshake();
this.addHandshakeCompletedListener(new HandshakeCompletedListener() {
@Override
public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent) {
if (handshakeStart != null) {
RequestInfo.get().ssl(handshakeStart, new Date());
}
}
});
}
示例6: notifyHandshakeCompletedListeners
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
private void notifyHandshakeCompletedListeners() {
if (listeners != null && !listeners.isEmpty()) {
// notify the listeners
HandshakeCompletedEvent event =
new HandshakeCompletedEvent(this, sslSession);
for (HandshakeCompletedListener listener : listeners) {
try {
listener.handshakeCompleted(event);
} catch (RuntimeException e) {
// The RI runs the handlers in a separate thread,
// which we do not. But we try to preserve their
// behavior of logging a problem and not killing
// the handshaking thread just because a listener
// has a problem.
Thread thread = Thread.currentThread();
thread.getUncaughtExceptionHandler().uncaughtException(thread, e);
}
}
}
}
示例7: test_getCipherSuite
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
/**
* @throws IOException
* @tests javax.net.ssl.HandshakeCompletedEvent#getCipherSuite()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getCipherSuite",
args = {}
)
public final void test_getCipherSuite() throws IOException {
mySSLSession session = new mySSLSession("localhost", 1080, null);
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
try {
assertEquals("SuiteName", event.getCipherSuite());
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
示例8: test_getLocalCertificates
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
/**
* @throws IOException
* @tests javax.net.ssl.HandshakeCompletedEvent#getLocalCertificates()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getLocalCertificates",
args = {}
)
public final void test_getLocalCertificates() throws IOException {
mySSLSession session = new mySSLSession("localhost", 1080, null);
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
try {
assertNull(event.getLocalCertificates());
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
示例9: test_getLocalPrincipal
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
/**
* @throws IOException
* @tests javax.net.ssl.HandshakeCompletedEvent#getLocalPrincipal()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getLocalPrincipal",
args = {}
)
public final void test_getLocalPrincipal() throws IOException {
mySSLSession session = new mySSLSession("localhost", 1080, null);
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
try {
assertNull(event.getLocalPrincipal());
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
示例10: test_getPeerPrincipal
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
/**
* @throws IOException
* @tests javax.net.ssl.HandshakeCompletedEvent#getPeerPrincipal()
*/
@TestTargetNew(
level = TestLevel.SUFFICIENT,
notes = "",
method = "getPeerPrincipal",
args = {}
)
public final void test_getPeerPrincipal() throws IOException {
mySSLSession session = new mySSLSession("localhost", 1080, null);
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
try {
assertNull(event.getPeerPrincipal());
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
示例11: test_getSession
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
/**
* @throws IOException
* @tests javax.net.ssl.HandshakeCompletedEvent#getSession()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getSession",
args = {}
)
public final void test_getSession() throws IOException {
mySSLSession session = new mySSLSession("localhost", 1080, null);
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
try {
SSLSession ss = event.getSession();
assertNotNull(ss);
assertEquals(session, ss);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
示例12: test_getSocket
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
/**
* @throws IOException
* @tests javax.net.ssl.HandshakeCompletedEvent#getSocket()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getSocket",
args = {}
)
public final void test_getSocket() throws IOException {
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, null);
try {
SSLSocket ss = event.getSocket();
assertNotNull(ss);
assertEquals(socket, ss);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
示例13: handshakeCompleted
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
public void handshakeCompleted(HandshakeCompletedEvent evt) {
SSLSession session;
String sessionId;
SSLSocket socket;
if (Error.TRACESYSTEMOUT) {
socket = evt.getSocket();
session = evt.getSession();
Error.printSystemOut("SSL handshake completed:");
Error.printSystemOut(
"------------------------------------------------");
Error.printSystemOut("socket: : " + socket);
Error.printSystemOut("cipher suite : "
+ session.getCipherSuite());
sessionId = StringConverter.byteArrayToHexString(session.getId());
Error.printSystemOut("session id : " + sessionId);
Error.printSystemOut(
"------------------------------------------------");
}
}
示例14: testGetLocalCertificates
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
public final void testGetLocalCertificates() {
if (noFreePort || noSocket) {
return;
}
SSLSession ses = new MySSLSession();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(soc, ses);
Certificate[] certs = event.getLocalCertificates();
Certificate[] ses_certs = ses.getLocalCertificates();
if (certs == null && ses_certs == null) {
return;
}
if (certs == null || ses_certs == null) {
fail("incorrect LocalCertificates");
}
for (int i = 0; i < certs.length; i++) {
if (certs[i] != ses_certs[i]) {
fail("incorrect LocalCertificates");
}
}
}
示例15: testGetCipherSuite
import javax.net.ssl.HandshakeCompletedEvent; //导入依赖的package包/类
public final void testGetCipherSuite() {
if (noFreePort || noSocket) {
return;
}
SSLSession ses = new MySSLSession();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(soc, ses);
String name = event.getCipherSuite();
String name_ses = ses.getCipherSuite();
if (name == null && name_ses != null) {
fail("incorrect null CipherCuite");
}
if (!name.equals(name_ses)) {
fail("incorrect CipherCuite");
}
}