Home | History | Annotate | Download | only in conscrypt
      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 interface SSLServerSessionCache {
     34     /**
     35      * Gets the session data for given session ID.
     36      *
     37      * @param id from {@link javax.net.ssl.SSLSession#getId()}
     38      * @return the session data or null if none is cached
     39      * @throws NullPointerException if id is null
     40      */
     41     byte[] getSessionData(byte[] id);
     42 
     43     /**
     44      * Stores session data for the given session.
     45      *
     46      * @param session to cache data for
     47      * @param sessionData to cache
     48      * @throws NullPointerException if session or data is null
     49      */
     50     void putSessionData(SSLSession session, byte[] sessionData);
     51 }