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


Java SSLContext.getServerSessionContext方法代码示例

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


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

示例1: main

import javax.net.ssl.SSLContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
//        try {
            SSLServerSocketFactory ssf =
                (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
            SSLServerSocket ss = (SSLServerSocket)ssf.createServerSocket();
            String[] protocols = ss.getSupportedProtocols();
            for (int i = 0; i < protocols.length; i++) {
//                try {
                    if (protocols[i].equals("SSLv2Hello")) {
                        continue;
                    }
                    SSLContext sslc = SSLContext.getInstance(protocols[i]);
                    SSLSessionContext sslsc = sslc.getServerSessionContext();
                    System.out.println("Protocol: " + protocols[i]);
                    sslsc.setSessionTimeout(Integer.MAX_VALUE);
                    int newtime = sslsc.getSessionTimeout();
                    if (newtime != Integer.MAX_VALUE) {
                        throw new Exception ("Expected timeout: " +
                            Integer.MAX_VALUE + ", got instead: " +
                            newtime);
                    }
//                } catch (Exception e) {
//                }
            }
//        } catch (Exception e) {
//            System.out.println(e);
//        }
        System.out.println("Finished");
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:Timeout.java

示例2: init

import javax.net.ssl.SSLContext; //导入方法依赖的package包/类
/**
 * Reads the keystore and initializes the SSL socket factory.
 */
void init() throws IOException {
	try {

		String clientAuthStr = endpoint.getClientAuth();
		if ("true".equalsIgnoreCase(clientAuthStr) || "yes".equalsIgnoreCase(clientAuthStr)) {
			requireClientAuth = true;
		} else if ("want".equalsIgnoreCase(clientAuthStr)) {
			wantClientAuth = true;
		}

		SSLContext context = createSSLContext();
		context.init(getKeyManagers(), getTrustManagers(), null);

		// Configure SSL session cache
		SSLSessionContext sessionContext = context.getServerSessionContext();
		if (sessionContext != null) {
			configureSessionContext(sessionContext);
		}

		// create proxy
		sslProxy = context.getServerSocketFactory();

		// Determine which cipher suites to enable
		enabledCiphers = getEnableableCiphers(context);
		enabledProtocols = getEnableableProtocols(context);

		allowUnsafeLegacyRenegotiation = "true".equals(endpoint.getAllowUnsafeLegacyRenegotiation());

		// Check the SSL config is OK
		checkConfig();

	} catch (Exception e) {
		if (e instanceof IOException)
			throw (IOException) e;
		throw new IOException(e.getMessage(), e);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:41,代码来源:JSSESocketFactory.java

示例3: init

import javax.net.ssl.SSLContext; //导入方法依赖的package包/类
/**
 * Reads the keystore and initializes the SSL socket factory.
 */
void init() throws IOException {
    try {

        String clientAuthStr = endpoint.getClientAuth();
        if("true".equalsIgnoreCase(clientAuthStr) ||
           "yes".equalsIgnoreCase(clientAuthStr)) {
            requireClientAuth = true;
        } else if("want".equalsIgnoreCase(clientAuthStr)) {
            wantClientAuth = true;
        }

        SSLContext context = createSSLContext();
        context.init(getKeyManagers(), getTrustManagers(), null);

        // Configure SSL session cache
        SSLSessionContext sessionContext =
            context.getServerSessionContext();
        if (sessionContext != null) {
            configureSessionContext(sessionContext);
        }

        // create proxy
        sslProxy = context.getServerSocketFactory();

        // Determine which cipher suites to enable
        enabledCiphers = getEnableableCiphers(context);
        enabledProtocols = getEnableableProtocols(context);

        allowUnsafeLegacyRenegotiation = "true".equals(
                endpoint.getAllowUnsafeLegacyRenegotiation());

        // Check the SSL config is OK
        checkConfig();

    } catch(Exception e) {
        if( e instanceof IOException )
            throw (IOException)e;
        throw new IOException(e.getMessage(), e);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:44,代码来源:JSSESocketFactory.java


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