本文整理匯總了Java中javax.net.ssl.SSLSessionContext.getSessionTimeout方法的典型用法代碼示例。如果您正苦於以下問題:Java SSLSessionContext.getSessionTimeout方法的具體用法?Java SSLSessionContext.getSessionTimeout怎麽用?Java SSLSessionContext.getSessionTimeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.net.ssl.SSLSessionContext
的用法示例。
在下文中一共展示了SSLSessionContext.getSessionTimeout方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import javax.net.ssl.SSLSessionContext; //導入方法依賴的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");
}
示例2: isValid
import javax.net.ssl.SSLSessionContext; //導入方法依賴的package包/類
/**
* Returns a boolean flag signaling whether a SSL session is valid
* and available for resuming or joining or not.
*
* @return true if this session may be resumed.
*/
public boolean isValid() {
SSLSessionContext context = sessionContext;
if (isValid
&& context != null
&& context.getSessionTimeout() != 0
&& getCreationTime() + (context.getSessionTimeout() * 1000)
< System.currentTimeMillis()) {
isValid = false;
}
return isValid;
}