sun.security.util.Cache Java Examples

The following examples show how to use sun.security.util.Cache. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LDAPCertStoreImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a <code>CertStore</code> with the specified parameters.
 */
LDAPCertStoreImpl(String serverName, int port)
    throws InvalidAlgorithmParameterException {
    createInitialDirContext(serverName, port);
    // Create CertificateFactory for use later on
    try {
        cf = CertificateFactory.getInstance("X.509");
    } catch (CertificateException e) {
        throw new InvalidAlgorithmParameterException(
            "unable to create CertificateFactory for X.509");
    }
    if (LIFETIME == 0) {
        valueCache = Cache.newNullCache();
    } else if (LIFETIME < 0) {
        valueCache = Cache.newSoftMemoryCache(DEFAULT_CACHE_SIZE);
    } else {
        valueCache = Cache.newSoftMemoryCache(DEFAULT_CACHE_SIZE, LIFETIME);
    }
}
 
Example #2
Source File: X509Factory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add the X509CertImpl or X509CRLImpl to the cache.
 */
private static synchronized <V> void addToCache(Cache<Object, V> cache,
        byte[] encoding, V value) {
    if (encoding.length > ENC_MAX_LENGTH) {
        return;
    }
    Object key = new Cache.EqualByteArray(encoding);
    cache.put(key, value);
}
 
Example #3
Source File: X509Factory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add the X509CertImpl or X509CRLImpl to the cache.
 */
private static synchronized <V> void addToCache(Cache<Object, V> cache,
        byte[] encoding, V value) {
    if (encoding.length > ENC_MAX_LENGTH) {
        return;
    }
    Object key = new Cache.EqualByteArray(encoding);
    cache.put(key, value);
}
 
Example #4
Source File: X509CertificatePair.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a X509CertificatePair from its encoding. Uses cache lookup
 * if possible.
 */
public static synchronized X509CertificatePair generateCertificatePair
        (byte[] encoded) throws CertificateException {
    Object key = new Cache.EqualByteArray(encoded);
    X509CertificatePair pair = cache.get(key);
    if (pair != null) {
        return pair;
    }
    pair = new X509CertificatePair(encoded);
    key = new Cache.EqualByteArray(pair.encoded);
    cache.put(key, pair);
    return pair;
}
 
Example #5
Source File: X509CertificatePair.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a X509CertificatePair from its encoding. Uses cache lookup
 * if possible.
 */
public static synchronized X509CertificatePair generateCertificatePair
        (byte[] encoded) throws CertificateException {
    Object key = new Cache.EqualByteArray(encoded);
    X509CertificatePair pair = cache.get(key);
    if (pair != null) {
        return pair;
    }
    pair = new X509CertificatePair(encoded);
    key = new Cache.EqualByteArray(pair.encoded);
    cache.put(key, pair);
    return pair;
}
 
Example #6
Source File: X509CertificatePair.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a X509CertificatePair from its encoding. Uses cache lookup
 * if possible.
 */
public static synchronized X509CertificatePair generateCertificatePair
        (byte[] encoded) throws CertificateException {
    Object key = new Cache.EqualByteArray(encoded);
    X509CertificatePair pair = cache.get(key);
    if (pair != null) {
        return pair;
    }
    pair = new X509CertificatePair(encoded);
    key = new Cache.EqualByteArray(pair.encoded);
    cache.put(key, pair);
    return pair;
}
 
Example #7
Source File: X509Factory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add the X509CertImpl or X509CRLImpl to the cache.
 */
private static synchronized <V> void addToCache(Cache<Object, V> cache,
        byte[] encoding, V value) {
    if (encoding.length > ENC_MAX_LENGTH) {
        return;
    }
    Object key = new Cache.EqualByteArray(encoding);
    cache.put(key, value);
}
 
Example #8
Source File: LDAPCertStore.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a <code>CertStore</code> with the specified parameters.
 * For this class, the parameters object must be an instance of
 * <code>LDAPCertStoreParameters</code>.
 *
 * @param params the algorithm parameters
 * @exception InvalidAlgorithmParameterException if params is not an
 *   instance of <code>LDAPCertStoreParameters</code>
 */
public LDAPCertStore(CertStoreParameters params)
        throws InvalidAlgorithmParameterException {
    super(params);
    if (!(params instanceof LDAPCertStoreParameters))
      throw new InvalidAlgorithmParameterException(
        "parameters must be LDAPCertStoreParameters");

    LDAPCertStoreParameters lparams = (LDAPCertStoreParameters) params;

    // Create InitialDirContext needed to communicate with the server
    createInitialDirContext(lparams.getServerName(), lparams.getPort());

    // Create CertificateFactory for use later on
    try {
        cf = CertificateFactory.getInstance("X.509");
    } catch (CertificateException e) {
        throw new InvalidAlgorithmParameterException(
            "unable to create CertificateFactory for X.509");
    }
    if (LIFETIME == 0) {
        valueCache = Cache.newNullCache();
    } else if (LIFETIME < 0) {
        valueCache = Cache.newSoftMemoryCache(DEFAULT_CACHE_SIZE);
    } else {
        valueCache = Cache.newSoftMemoryCache(DEFAULT_CACHE_SIZE, LIFETIME);
    }
}
 
Example #9
Source File: SSLSessionContextImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
SSLSessionContextImpl(boolean server) {
    timeout = DEFAULT_SESSION_TIMEOUT;
    cacheLimit = getDefaults(server);    // default cache size

    // use soft reference
    sessionCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
    sessionHostPortCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
}
 
Example #10
Source File: SSLSessionContextImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
SSLSessionContextImpl() {
    cacheLimit = getDefaultCacheLimit();    // default cache size
    timeout = 86400;                        // default, 24 hours

    // use soft reference
    sessionCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
    sessionHostPortCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
}
 
Example #11
Source File: X509CertificatePair.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Create a X509CertificatePair from its encoding. Uses cache lookup
 * if possible.
 */
public static synchronized X509CertificatePair generateCertificatePair
        (byte[] encoded) throws CertificateException {
    Object key = new Cache.EqualByteArray(encoded);
    X509CertificatePair pair = cache.get(key);
    if (pair != null) {
        return pair;
    }
    pair = new X509CertificatePair(encoded);
    key = new Cache.EqualByteArray(pair.encoded);
    cache.put(key, pair);
    return pair;
}
 
Example #12
Source File: X509Factory.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Add the X509CertImpl or X509CRLImpl to the cache.
 */
private static synchronized <V> void addToCache(Cache<Object, V> cache,
        byte[] encoding, V value) {
    if (encoding.length > ENC_MAX_LENGTH) {
        return;
    }
    Object key = new Cache.EqualByteArray(encoding);
    cache.put(key, value);
}
 
Example #13
Source File: X509Factory.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add the X509CertImpl or X509CRLImpl to the cache.
 */
private static synchronized <V> void addToCache(Cache<Object, V> cache,
        byte[] encoding, V value) {
    if (encoding.length > ENC_MAX_LENGTH) {
        return;
    }
    Object key = new Cache.EqualByteArray(encoding);
    cache.put(key, value);
}
 
Example #14
Source File: SSLSessionContextImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
SSLSessionContextImpl() {
    cacheLimit = getDefaultCacheLimit();    // default cache size
    timeout = 86400;                        // default, 24 hours

    // use soft reference
    sessionCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
    sessionHostPortCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
}
 
Example #15
Source File: X509CertificatePair.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a X509CertificatePair from its encoding. Uses cache lookup
 * if possible.
 */
public static synchronized X509CertificatePair generateCertificatePair
        (byte[] encoded) throws CertificateException {
    Object key = new Cache.EqualByteArray(encoded);
    X509CertificatePair pair = cache.get(key);
    if (pair != null) {
        return pair;
    }
    pair = new X509CertificatePair(encoded);
    key = new Cache.EqualByteArray(pair.encoded);
    cache.put(key, pair);
    return pair;
}
 
Example #16
Source File: X509CertificatePair.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a X509CertificatePair from its encoding. Uses cache lookup
 * if possible.
 */
public static synchronized X509CertificatePair generateCertificatePair
        (byte[] encoded) throws CertificateException {
    Object key = new Cache.EqualByteArray(encoded);
    X509CertificatePair pair = cache.get(key);
    if (pair != null) {
        return pair;
    }
    pair = new X509CertificatePair(encoded);
    key = new Cache.EqualByteArray(pair.encoded);
    cache.put(key, pair);
    return pair;
}
 
Example #17
Source File: X509CertificatePair.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a X509CertificatePair from its encoding. Uses cache lookup
 * if possible.
 */
public static synchronized X509CertificatePair generateCertificatePair
        (byte[] encoded) throws CertificateException {
    Object key = new Cache.EqualByteArray(encoded);
    X509CertificatePair pair = cache.get(key);
    if (pair != null) {
        return pair;
    }
    pair = new X509CertificatePair(encoded);
    key = new Cache.EqualByteArray(pair.encoded);
    cache.put(key, pair);
    return pair;
}
 
Example #18
Source File: X509Factory.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Add the X509CertImpl or X509CRLImpl to the cache.
 */
private static synchronized void addToCache(Cache cache, byte[] encoding,
        Object value) {
    if (encoding.length > ENC_MAX_LENGTH) {
        return;
    }
    Object key = new Cache.EqualByteArray(encoding);
    cache.put(key, value);
}
 
Example #19
Source File: LDAPCertStore.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a <code>CertStore</code> with the specified parameters.
 * For this class, the parameters object must be an instance of
 * <code>LDAPCertStoreParameters</code>.
 *
 * @param params the algorithm parameters
 * @exception InvalidAlgorithmParameterException if params is not an
 *   instance of <code>LDAPCertStoreParameters</code>
 */
public LDAPCertStore(CertStoreParameters params)
        throws InvalidAlgorithmParameterException {
    super(params);
    if (!(params instanceof LDAPCertStoreParameters))
      throw new InvalidAlgorithmParameterException(
        "parameters must be LDAPCertStoreParameters");

    LDAPCertStoreParameters lparams = (LDAPCertStoreParameters) params;

    // Create InitialDirContext needed to communicate with the server
    createInitialDirContext(lparams.getServerName(), lparams.getPort());

    // Create CertificateFactory for use later on
    try {
        cf = CertificateFactory.getInstance("X.509");
    } catch (CertificateException e) {
        throw new InvalidAlgorithmParameterException(
            "unable to create CertificateFactory for X.509");
    }
    if (LIFETIME == 0) {
        valueCache = Cache.newNullCache();
    } else if (LIFETIME < 0) {
        valueCache = Cache.newSoftMemoryCache(DEFAULT_CACHE_SIZE);
    } else {
        valueCache = Cache.newSoftMemoryCache(DEFAULT_CACHE_SIZE, LIFETIME);
    }
}
 
Example #20
Source File: X509CertificatePair.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a X509CertificatePair from its encoding. Uses cache lookup
 * if possible.
 */
public static synchronized X509CertificatePair generateCertificatePair
        (byte[] encoded) throws CertificateException {
    Object key = new Cache.EqualByteArray(encoded);
    X509CertificatePair pair = cache.get(key);
    if (pair != null) {
        return pair;
    }
    pair = new X509CertificatePair(encoded);
    key = new Cache.EqualByteArray(pair.encoded);
    cache.put(key, pair);
    return pair;
}
 
Example #21
Source File: X509Factory.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Get the X509CertImpl or X509CRLImpl from the cache.
 */
private static synchronized Object getFromCache(Cache cache,
        byte[] encoding) {
    Object key = new Cache.EqualByteArray(encoding);
    Object value = cache.get(key);
    return value;
}
 
Example #22
Source File: X509Factory.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add the X509CertImpl or X509CRLImpl to the cache.
 */
private static synchronized <V> void addToCache(Cache<Object, V> cache,
        byte[] encoding, V value) {
    if (encoding.length > ENC_MAX_LENGTH) {
        return;
    }
    Object key = new Cache.EqualByteArray(encoding);
    cache.put(key, value);
}
 
Example #23
Source File: SSLSessionContextImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
SSLSessionContextImpl() {
    cacheLimit = getDefaultCacheLimit();    // default cache size
    timeout = 86400;                        // default, 24 hours

    // use soft reference
    sessionCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
    sessionHostPortCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
}
 
Example #24
Source File: SSLSessionContextImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
SSLSessionContextImpl() {
    cacheLimit = getDefaultCacheLimit();    // default cache size
    timeout = 86400;                        // default, 24 hours

    // use soft reference
    sessionCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
    sessionHostPortCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
}
 
Example #25
Source File: LDAPCertStore.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a <code>CertStore</code> with the specified parameters.
 * For this class, the parameters object must be an instance of
 * <code>LDAPCertStoreParameters</code>.
 *
 * @param params the algorithm parameters
 * @exception InvalidAlgorithmParameterException if params is not an
 *   instance of <code>LDAPCertStoreParameters</code>
 */
public LDAPCertStore(CertStoreParameters params)
        throws InvalidAlgorithmParameterException {
    super(params);
    if (!(params instanceof LDAPCertStoreParameters))
      throw new InvalidAlgorithmParameterException(
        "parameters must be LDAPCertStoreParameters");

    LDAPCertStoreParameters lparams = (LDAPCertStoreParameters) params;

    // Create InitialDirContext needed to communicate with the server
    createInitialDirContext(lparams.getServerName(), lparams.getPort());

    // Create CertificateFactory for use later on
    try {
        cf = CertificateFactory.getInstance("X.509");
    } catch (CertificateException e) {
        throw new InvalidAlgorithmParameterException(
            "unable to create CertificateFactory for X.509");
    }
    if (LIFETIME == 0) {
        valueCache = Cache.newNullCache();
    } else if (LIFETIME < 0) {
        valueCache = Cache.newSoftMemoryCache(DEFAULT_CACHE_SIZE);
    } else {
        valueCache = Cache.newSoftMemoryCache(DEFAULT_CACHE_SIZE, LIFETIME);
    }
}
 
Example #26
Source File: X509CertificatePair.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a X509CertificatePair from its encoding. Uses cache lookup
 * if possible.
 */
public static synchronized X509CertificatePair generateCertificatePair
        (byte[] encoded) throws CertificateException {
    Object key = new Cache.EqualByteArray(encoded);
    X509CertificatePair pair = cache.get(key);
    if (pair != null) {
        return pair;
    }
    pair = new X509CertificatePair(encoded);
    key = new Cache.EqualByteArray(pair.encoded);
    cache.put(key, pair);
    return pair;
}
 
Example #27
Source File: X509Factory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add the X509CertImpl or X509CRLImpl to the cache.
 */
private static synchronized <V> void addToCache(Cache<Object, V> cache,
        byte[] encoding, V value) {
    if (encoding.length > ENC_MAX_LENGTH) {
        return;
    }
    Object key = new Cache.EqualByteArray(encoding);
    cache.put(key, value);
}
 
Example #28
Source File: SSLSessionContextImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
SSLSessionContextImpl() {
    cacheLimit = getDefaultCacheLimit();    // default cache size
    timeout = 86400;                        // default, 24 hours

    // use soft reference
    sessionCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
    sessionHostPortCache = Cache.newSoftMemoryCache(cacheLimit, timeout);
}
 
Example #29
Source File: X509CertificatePair.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a X509CertificatePair from its encoding. Uses cache lookup
 * if possible.
 */
public static synchronized X509CertificatePair generateCertificatePair
        (byte[] encoded) throws CertificateException {
    Object key = new Cache.EqualByteArray(encoded);
    X509CertificatePair pair = cache.get(key);
    if (pair != null) {
        return pair;
    }
    pair = new X509CertificatePair(encoded);
    key = new Cache.EqualByteArray(pair.encoded);
    cache.put(key, pair);
    return pair;
}
 
Example #30
Source File: X509CertificatePair.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a X509CertificatePair from its encoding. Uses cache lookup
 * if possible.
 */
public static synchronized X509CertificatePair generateCertificatePair
        (byte[] encoded) throws CertificateException {
    Object key = new Cache.EqualByteArray(encoded);
    X509CertificatePair pair = cache.get(key);
    if (pair != null) {
        return pair;
    }
    pair = new X509CertificatePair(encoded);
    key = new Cache.EqualByteArray(pair.encoded);
    cache.put(key, pair);
    return pair;
}