FileDocCategorySizeDatePackage
SSLClientSessionCacheFactory.javaAPI DocAndroid 1.5 API2282Wed May 06 22:41:56 BST 2009com.google.android.net

SSLClientSessionCacheFactory

public final class SSLClientSessionCacheFactory extends Object
Factory that returns the appropriate implementation of a {@link SSLClientSessionCache} based on gservices.
hide

Fields Summary
private static final String
TAG
public static final String
DB
public static final String
FILE
Constructors Summary
private SSLClientSessionCacheFactory()


    // utility class
      
Methods Summary
public static org.apache.harmony.xnet.provider.jsse.SSLClientSessionCachegetCache(android.content.Context context)
Returns a new {@link SSLClientSessionCache} based on the persistent cache that's specified, if any, in gservices. If no cache is specified, returns null.

param
context The application context used for the per-process persistent cache.
return
A new {@link SSLClientSessionCache}, or null if no persistent cache is configured.

        String type = Settings.Gservices.getString(context.getContentResolver(),
                Settings.Gservices.SSL_SESSION_CACHE);

        if (type != null) {
            if (DB.equals(type)) {
                return DbSSLSessionCache.getInstanceForPackage(context);
            } else if (FILE.equals(type)) {
                File dir = context.getFilesDir();
                File cacheDir = new File(dir, "sslcache");
                if (!cacheDir.exists()) {
                    cacheDir.mkdir();
                }
                try {
                    return FileClientSessionCache.usingDirectory(cacheDir);
                } catch (IOException ioe) {
                    Log.w(TAG, "Unable to create FileClientSessionCache in " + cacheDir.getName(), ioe);
                    return null;
                }
            } else {
                Log.w(TAG, "Ignoring unrecognized type: '" + type + "'");       
            }
        }
        return null;