1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.conscrypt; 18 19 import javax.net.ssl.SSLSession; 20 21 /** 22 * A persistent {@link javax.net.ssl.SSLSession} cache used by 23 * {@link javax.net.ssl.SSLSessionContext} to share server-side SSL sessions 24 * across processes. For example, this cache enables one server to resume 25 * a session started by a different server based on a session ID provided 26 * by the client. 27 * 28 * <p>The {@code SSLSessionContext} implementation converts 29 * {@code SSLSession}s into raw bytes and vice versa. The exact makeup of the 30 * session data is dependent upon the caller's implementation and is opaque to 31 * the {@code SSLServerSessionCache} implementation. 32 */ 33 public interface SSLServerSessionCache { 34 35 /** 36 * Gets the session data for given session ID. 37 * 38 * @param id from {@link javax.net.ssl.SSLSession#getId()} 39 * @return the session data or null if none is cached 40 * @throws NullPointerException if id is null 41 */ getSessionData(byte[] id)42 public byte[] getSessionData(byte[] id); 43 44 /** 45 * Stores session data for the given session. 46 * 47 * @param session to cache data for 48 * @param sessionData to cache 49 * @throws NullPointerException if session or data is null 50 */ putSessionData(SSLSession session, byte[] sessionData)51 public void putSessionData(SSLSession session, byte[] sessionData); 52 }