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 client-side SSL sessions
     24  * across processes. For example, this cache enables applications to
     25  * persist and reuse sessions across restarts.
     26  *
     27  * <p>The {@code SSLSessionContext} implementation converts
     28  * {@code SSLSession}s into raw bytes and vice versa. The exact makeup of the
     29  * session data is dependent upon the caller's implementation and is opaque to
     30  * the {@code SSLClientSessionCache} implementation.
     31  *
     32  * @hide
     33  */
     34 @Internal
     35 public interface SSLClientSessionCache {
     36     /**
     37      * Gets data from a pre-existing session for a given server host and port.
     38      *
     39      * @param host from {@link javax.net.ssl.SSLSession#getPeerHost()}
     40      * @param port from {@link javax.net.ssl.SSLSession#getPeerPort()}
     41      * @return the session data or null if none is cached
     42      * @throws NullPointerException if host is null
     43      */
     44     byte[] getSessionData(String host, int port);
     45 
     46     /**
     47      * Stores session data for the given session.
     48      *
     49      * @param session to cache data for
     50      * @param sessionData to cache
     51      * @throws NullPointerException if session, result of
     52      *  {@code session.getPeerHost()} or data is null
     53      */
     54     void putSessionData(SSLSession session, byte[] sessionData);
     55 }