當前位置: 首頁>>代碼示例>>Java>>正文


Java SSLSessionContext.getSession方法代碼示例

本文整理匯總了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);
            }
        }
    }
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:28,代碼來源:SdkTLSSocketFactory.java

示例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]));
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:24,代碼來源:SSLSessionContextTest.java

示例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
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:27,代碼來源:ClientHandshakeImpl.java

示例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
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:27,代碼來源:ClientHandshakeImpl.java

示例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;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:11,代碼來源:SSLContextResource.java

示例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);
    }
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:9,代碼來源:SSLSessionDefinition.java


注:本文中的javax.net.ssl.SSLSessionContext.getSession方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。