本文整理汇总了Java中javax.net.ssl.SSLSessionContext.getSession方法的典型用法代码示例。如果您正苦于以下问题:Java SSLSessionContext.getSession方法的具体用法?Java SSLSessionContext.getSession怎么用?Java SSLSessionContext.getSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.net.ssl.SSLSessionContext
的用法示例。
在下文中一共展示了SSLSessionContext.getSession方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearSessionCache
import javax.net.ssl.SSLSessionContext; //导入方法依赖的package包/类
/**
* 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
*/
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);
}
}
}
}
示例2: test_getSession
import javax.net.ssl.SSLSessionContext; //导入方法依赖的package包/类
/**
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @tests javax.net.ssl.SSLSessionContex#getSession(byte[] sessionId)
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getSession",
args = {byte[].class}
)
public final void test_getSession() throws NoSuchAlgorithmException, KeyManagementException {
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, null, null);
SSLSessionContext sc = context
.getClientSessionContext();
try {
sc.getSession(null);
} catch (NullPointerException e) {
// expected
}
assertNull(sc.getSession(new byte[5]));
}
示例3: findSessionToResume
import javax.net.ssl.SSLSessionContext; //导入方法依赖的package包/类
private SSLSessionImpl findSessionToResume() {
String host;
int port;
if (engineOwner != null) {
host = engineOwner.getPeerHost();
port = engineOwner.getPeerPort();
} else {
host = socketOwner.getInetAddress().getHostName();
port = socketOwner.getPort();
}
if (host == null || port == -1) {
return null; // starts new session
}
byte[] id;
SSLSession ses;
SSLSessionContext context = parameters.getClientSessionContext();
for (Enumeration<?> en = context.getIds(); en.hasMoreElements();) {
id = (byte[])en.nextElement();
ses = context.getSession(id);
if (host.equals(ses.getPeerHost()) && port == ses.getPeerPort()) {
return (SSLSessionImpl)((SSLSessionImpl)ses).clone(); // resume
}
}
return null; // starts new session
}
示例4: findSessionToResume
import javax.net.ssl.SSLSessionContext; //导入方法依赖的package包/类
private SSLSessionImpl findSessionToResume() {
String host;
int port;
if (engineOwner != null) {
host = engineOwner.getPeerHost();
port = engineOwner.getPeerPort();
} else {
host = socketOwner.getInetAddress().getHostName();
port = socketOwner.getPort();
}
if (host == null || port == -1) {
return null; // starts new session
}
byte[] id;
SSLSession ses;
SSLSessionContext context = parameters.getClientSessionContext();
for (Enumeration en = context.getIds(); en.hasMoreElements();) {
id = (byte[])en.nextElement();
ses = context.getSession(id);
if (host.equals(ses.getPeerHost()) && port == ses.getPeerPort()) {
return (SSLSessionImpl)((SSLSessionImpl)ses).clone(); // resume
}
}
return null; // starts new session
}
示例5: hasChild
import javax.net.ssl.SSLSessionContext; //导入方法依赖的package包/类
@Override
public boolean hasChild(PathElement element) {
SSLContext sslContext;
if (ElytronDescriptionConstants.SSL_SESSION.equals(element.getKey()) && (sslContext = getSSLContext(sslContextServiceController)) != null) {
byte[] sessionId = ByteIterator.ofBytes(element.getValue().getBytes(StandardCharsets.UTF_8)).hexDecode().drain();
SSLSessionContext sslSessionContext = server ? sslContext.getServerSessionContext() : sslContext.getClientSessionContext();
return sslSessionContext.getSession(sessionId) != null;
}
return false;
}
示例6: performRuntime
import javax.net.ssl.SSLSessionContext; //导入方法依赖的package包/类
@Override
protected void performRuntime(ModelNode result, ModelNode operation, SSLContext sslContext) throws OperationFailedException {
SSLSessionContext sslSessionContext = server ? sslContext.getServerSessionContext() : sslContext.getClientSessionContext();
SSLSession sslSession = sslSessionContext.getSession(sessionId(operation));
if (sslSession != null) {
performRuntime(result, operation, sslSession);
}
}