List of usage examples for javax.net.ssl SSLSessionContext getSession
public SSLSession getSession(byte[] sessionId);
SSLSession
bound to the specified session id. From source file:ee.ria.xroad.proxy.clientproxy.FastestConnectionSelectingSSLSocketFactory.java
private CachedSSLSessionHostInformation getCachedSSLSessionHostURI(URI[] addresses) { SSLSessionContext sessionCtx = sslContext.getClientSessionContext(); Enumeration<byte[]> ids = sessionCtx.getIds(); while (ids.hasMoreElements()) { byte[] id = ids.nextElement(); SSLSession session = sessionCtx.getSession(id); if (session != null) { for (URI address : addresses) { if (isSessionHost(session, address)) { log.trace("Found cached session for {}", address); return new CachedSSLSessionHostInformation(address, session); }/*from w w w.j a v a 2 s . c om*/ } } } return new CachedSSLSessionHostInformation(); }
From source file:com.thoughtworks.go.security.AuthSSLProtocolSocketFactory.java
private boolean isEmptyKeyStore() { SSLSessionContext sessionContext = sslContextWithKeyStore.getClientSessionContext(); @SuppressWarnings("unchecked") Enumeration<byte[]> sessionIds = sessionContext.getIds(); if (sessionIds.hasMoreElements()) { byte[] sessionId = sessionIds.nextElement(); Certificate[] localCertificates = sessionContext.getSession(sessionId).getLocalCertificates(); return localCertificates == null || localCertificates.length > 0; } else {//from ww w. j a v a 2s . c o m return true; } }
From source file:com.ksc.http.conn.ssl.SdkTLSSocketFactory.java
/** * Invalidates all SSL/TLS sessions in {@code sessionContext} associated with {@code remoteAddress}. * * @param sessionContext collection of SSL/TLS sessions to be (potentially) invalidated * @param remoteAddress associated with sessions to invalidate *//* w w w. j av a 2 s .c om*/ private void clearSessionCache(final SSLSessionContext sessionContext, final InetSocketAddress remoteAddress) { final String hostName = remoteAddress.getHostName(); final int port = remoteAddress.getPort(); final Enumeration<byte[]> ids = sessionContext.getIds(); if (ids == null) { return; } while (ids.hasMoreElements()) { final byte[] id = ids.nextElement(); final SSLSession session = sessionContext.getSession(id); if (session != null && session.getPeerHost() != null && session.getPeerHost().equalsIgnoreCase(hostName) && session.getPeerPort() == port) { session.invalidate(); if (LOG.isDebugEnabled()) { LOG.debug("Invalidated session " + session); } } } }
From source file:com.amazonaws.http.conn.ssl.SdkTLSSocketFactory.java
/** * Invalidates all SSL/TLS sessions in {@code sessionContext} associated with {@code remoteAddress}. * @param sessionContext collection of SSL/TLS sessions to be (potentially) invalidated * @param remoteAddress associated with sessions to invalidate *//* w ww . ja v a2 s . c om*/ private void clearSessionCache(final SSLSessionContext sessionContext, final InetSocketAddress remoteAddress) { final String hostName = remoteAddress.getHostName(); final int port = remoteAddress.getPort(); final Enumeration<byte[]> ids = sessionContext.getIds(); if (ids == null) { return; } while (ids.hasMoreElements()) { final byte[] id = ids.nextElement(); final SSLSession session = sessionContext.getSession(id); if (session != null && session.getPeerHost() != null && session.getPeerHost().equalsIgnoreCase(hostName) && session.getPeerPort() == port) { session.invalidate(); if (log.isDebugEnabled()) { log.debug("Invalidated session " + session); } } } }