src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java
Print this page
*** 42,54 ****
import java.security.cert.CertStoreSpi;
import java.security.cert.CRLException;
import java.security.cert.CRLSelector;
import java.security.cert.URICertStoreParameters;
import java.security.cert.X509Certificate;
- import java.security.cert.X509CertSelector;
import java.security.cert.X509CRL;
- import java.security.cert.X509CRLSelector;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
--- 42,52 ----
*** 158,173 ****
super(params);
if (!(params instanceof URICertStoreParameters)) {
throw new InvalidAlgorithmParameterException
("params must be instanceof URICertStoreParameters");
}
! this.uri = ((URICertStoreParameters) params).uri;
// if ldap URI, use an LDAPCertStore to fetch certs and CRLs
if (uri.getScheme().toLowerCase(Locale.ENGLISH).equals("ldap")) {
ldap = true;
! URICertStoreParameters lparams = new URICertStoreParameters(uri);
! ldapCertStore = CertStore.getInstance("LDAP", lparams);
}
try {
factory = CertificateFactory.getInstance("X.509");
} catch (CertificateException e) {
throw new RuntimeException();
--- 156,170 ----
super(params);
if (!(params instanceof URICertStoreParameters)) {
throw new InvalidAlgorithmParameterException
("params must be instanceof URICertStoreParameters");
}
! this.uri = ((URICertStoreParameters) params).getURI();
// if ldap URI, use an LDAPCertStore to fetch certs and CRLs
if (uri.getScheme().toLowerCase(Locale.ENGLISH).equals("ldap")) {
ldap = true;
! ldapCertStore = CertStore.getInstance("LDAP", params);
}
try {
factory = CertificateFactory.getInstance("X.509");
} catch (CertificateException e) {
throw new RuntimeException();
*** 181,191 ****
private static final Cache<URICertStoreParameters, CertStore>
certStoreCache = Cache.newSoftMemoryCache(CACHE_SIZE);
static synchronized CertStore getInstance(URICertStoreParameters params)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
if (debug != null) {
! debug.println("CertStore URI:" + params.uri);
}
CertStore ucs = certStoreCache.get(params);
if (ucs == null) {
ucs = new UCS(new URICertStore(params), null, "URI", params);
certStoreCache.put(params, ucs);
--- 178,188 ----
private static final Cache<URICertStoreParameters, CertStore>
certStoreCache = Cache.newSoftMemoryCache(CACHE_SIZE);
static synchronized CertStore getInstance(URICertStoreParameters params)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
if (debug != null) {
! debug.println("CertStore URI:" + params.getURI());
}
CertStore ucs = certStoreCache.get(params);
if (ucs == null) {
ucs = new UCS(new URICertStore(params), null, "URI", params);
certStoreCache.put(params, ucs);
*** 210,221 ****
if (!(gn instanceof URIName)) {
return null;
}
URI uri = ((URIName) gn).getURI();
try {
! return URICertStore.getInstance
! (new URICertStore.URICertStoreParameters(uri));
} catch (Exception ex) {
if (debug != null) {
debug.println("exception creating CertStore: " + ex);
ex.printStackTrace();
}
--- 207,217 ----
if (!(gn instanceof URIName)) {
return null;
}
URI uri = ((URIName) gn).getURI();
try {
! return URICertStore.getInstance(new URICertStoreParameters(uri));
} catch (Exception ex) {
if (debug != null) {
debug.println("exception creating CertStore: " + ex);
ex.printStackTrace();
}
*** 419,462 ****
return Collections.emptyList();
}
}
/**
- * CertStoreParameters for the URICertStore.
- */
- static class URICertStoreParameters implements CertStoreParameters {
- private final URI uri;
- private volatile int hashCode = 0;
- URICertStoreParameters(URI uri) {
- this.uri = uri;
- }
- @Override public boolean equals(Object obj) {
- if (!(obj instanceof URICertStoreParameters)) {
- return false;
- }
- URICertStoreParameters params = (URICertStoreParameters) obj;
- return uri.equals(params.uri);
- }
- @Override public int hashCode() {
- if (hashCode == 0) {
- int result = 17;
- result = 37*result + uri.hashCode();
- hashCode = result;
- }
- return hashCode;
- }
- @Override public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- /* Cannot happen */
- throw new InternalError(e.toString(), e);
- }
- }
- }
-
- /**
* This class allows the URICertStore to be accessed as a CertStore.
*/
private static class UCS extends CertStore {
protected UCS(CertStoreSpi spi, Provider p, String type,
CertStoreParameters params) {
--- 415,424 ----