• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 public interface SSLClientSessionCache {
33 
34   /**
35    * Gets data from a pre-existing session for a given server host and port.
36    *
37    * @param host from {@link javax.net.ssl.SSLSession#getPeerHost()}
38    * @param port from {@link javax.net.ssl.SSLSession#getPeerPort()}
39    * @return the session data or null if none is cached
40    * @throws NullPointerException if host is null
41    */
getSessionData(String host, int port)42   public byte[] getSessionData(String host, int port);
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, result of
50    *  {@code session.getPeerHost()} or data is null
51    */
putSessionData(SSLSession session, byte[] sessionData)52   public void putSessionData(SSLSession session, byte[] sessionData);
53 }