本文整理匯總了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);
}
}