当前位置: 首页>>代码示例>>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;未经允许,请勿转载。