当前位置: 首页>>代码示例>>Java>>正文


Java SSLEngine.getSession方法代码示例

本文整理汇总了Java中javax.net.ssl.SSLEngine.getSession方法的典型用法代码示例。如果您正苦于以下问题:Java SSLEngine.getSession方法的具体用法?Java SSLEngine.getSession怎么用?Java SSLEngine.getSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.net.ssl.SSLEngine的用法示例。


在下文中一共展示了SSLEngine.getSession方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: operationComplete

import javax.net.ssl.SSLEngine; //导入方法依赖的package包/类
/**
 * Only allow the connection to stay open if certificate passes auth
 */
public void operationComplete(ChannelFuture future)
        throws SSLPeerUnverifiedException {
    if (future.isSuccess()) {
        LOG.debug("Successful handshake with session 0x{}",
                Long.toHexString(cnxn.sessionId));
        SSLEngine eng = sslHandler.getEngine();
        SSLSession session = eng.getSession();
        cnxn.setClientCertificateChain(session.getPeerCertificates());

        String authProviderProp
                = System.getProperty(ZKConfig.SSL_AUTHPROVIDER, "x509");

        X509AuthenticationProvider authProvider =
                (X509AuthenticationProvider)
                        ProviderRegistry.getProvider(authProviderProp);

        if (authProvider == null) {
            LOG.error("Auth provider not found: {}", authProviderProp);
            cnxn.close();
            return;
        }

        if (KeeperException.Code.OK !=
                authProvider.handleAuthentication(cnxn, null)) {
            LOG.error("Authentication failed for session 0x{}",
                    Long.toHexString(cnxn.sessionId));
            cnxn.close();
            return;
        }

        allChannels.add(future.getChannel());
        addCnxn(cnxn);
    } else {
        LOG.error("Unsuccessful handshake with session 0x{}",
                Long.toHexString(cnxn.sessionId));
        cnxn.close();
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:42,代码来源:NettyServerCnxnFactory.java

示例2: main

import javax.net.ssl.SSLEngine; //导入方法依赖的package包/类
public static void main (String[] args) throws Exception {
    SSLContext context = SSLContext.getDefault();

    // set the property before initialization SSLEngine.
    System.setProperty("jsse.SSLEngine.acceptLargeFragments", "true");

    SSLEngine cliEngine = context.createSSLEngine();
    cliEngine.setUseClientMode(true);

    SSLEngine srvEngine = context.createSSLEngine();
    srvEngine.setUseClientMode(false);

    SSLSession cliSession = cliEngine.getSession();
    SSLSession srvSession = srvEngine.getSession();

    // check packet buffer sizes.
    if (cliSession.getPacketBufferSize() < 33049 ||
        srvSession.getPacketBufferSize() < 33049) {
            throw new Exception("Don't accept large SSL/TLS fragments");
    }

    // check application data buffer sizes.
    if (cliSession.getApplicationBufferSize() < 32768 ||
        srvSession.getApplicationBufferSize() < 32768) {
            throw new Exception(
                    "Don't accept large SSL/TLS application data ");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:AcceptLargeFragments.java


注:本文中的javax.net.ssl.SSLEngine.getSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。