1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18package javax.net.ssl; 19 20import java.util.Enumeration; 21 22/** 23 * A collection of {@code SSLSession}s. 24 */ 25public interface SSLSessionContext { 26 /** 27 * Returns an iterable of all session identifiers in this session context. 28 * 29 * @return an iterable of all session identifiers in this session context. 30 */ 31 @SuppressWarnings("unchecked") 32 public Enumeration getIds(); 33 34 /** 35 * Returns the session for the specified session identifier. 36 * 37 * @param sessionId 38 * the session identifier of the session to look up. 39 * @return the session for the specified session identifier, or {@code null} 40 * if the specified session identifier does not refer to a session 41 * in this context. 42 */ 43 public SSLSession getSession(byte[] sessionId); 44 45 /** 46 * Returns the size of the session cache for this session context. 47 * 48 * @return the size of the session cache for this session context, or 49 * {@code zero} if unlimited. 50 */ 51 public int getSessionCacheSize(); 52 53 /** 54 * Returns the timeout for sessions in this session context. Sessions 55 * exceeding the timeout are invalidated. 56 * 57 * @return the timeout in seconds, or {@code zero} if unlimited. 58 */ 59 public int getSessionTimeout(); 60 61 /** 62 * Sets the size of the session cache for this session context. 63 * 64 * @param size 65 * the size of the session cache, or {@code zero} for unlimited 66 * cache size. 67 * @throws IllegalArgumentException 68 * if {@code size} is negative. 69 */ 70 public void setSessionCacheSize(int size) throws IllegalArgumentException; 71 72 /** 73 * Sets the timeout for sessions in this context. Sessions exceeding the 74 * timeout are invalidated. 75 * 76 * @param seconds 77 * the timeout in seconds, or {@code zero} if unlimited. 78 * @throws IllegalArgumentException 79 * if {@code seconds} is negative. 80 */ 81 public void setSessionTimeout(int seconds) throws IllegalArgumentException; 82} 83