APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.security.provider.certpath

pack-priv Class URICertStore

extends CertStoreSpi
Class Inheritance
Imports
java.io.FilterInputStream, .InputStream, .IOException, java.net.HttpURLConnection, .URI, .URISyntaxException, .URLConnection, java.security.InvalidAlgorithmParameterException, .NoSuchAlgorithmException, .Provider, java.security.cert.CertificateException, .CertificateFactory, .CertSelector, .CertStore, .CertStoreException, .CertStoreParameters, .CertStoreSpi, .CRLException, .CRLSelector, .URICertStoreParameters, .X509Certificate, .X509CRL, java.util.ArrayList, .Collection, .Collections, .LinkedHashSet, .List, .Locale, .Optional, .Set, sun.security.x509.AccessDescription, .GeneralNameInterface, .URIName, sun.security.util.Cache, .Debug, .SecurityProperties, javax.security.auth.x500.X500Principal

A CertStore that retrieves Certificates or CRLs from a URI, for example, as specified in an X.509 AuthorityInformationAccess or CRLDistributionPoint extension.

For CRLs, this implementation retrieves a single DER encoded CRL per URI. For Certificates, this implementation retrieves a single DER encoded CRL or a collection of Certificates encoded as a PKCS#7 "certs-only" CMS message.

This CertStore also implements Certificate/CRL caching. Currently, the cache is shared between all applications in the VM and uses a hardcoded policy. The cache has a maximum size of 185 entries, which are held by SoftReferences. A request will be satisfied from the cache if we last checked for an update within CHECK_INTERVAL (last 30 seconds). Otherwise, we open an URLConnection to download the Certificate(s)/CRL using an If-Modified-Since request (HTTP) if possible. Note that both positive and negative responses are cached, i.e. if we are unable to open the connection or the Certificate(s)/CRL cannot be parsed, we remember this result and additional calls during the CHECK_INTERVAL period do not try to open another connection.

The URICertStore is not currently a standard CertStore type. We should consider adding a standard "URI" CertStore type.

Authors
Andreas Sterbenz, Sean Mullan
Since
1.7

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
URICertStore.AllowedScheme

Enumeration for the allowed schemes we support when following a URI from an authorityInfoAccess extension on a certificate.

pack-priv static class
pack-priv static class
private static class
URICertStore.SizeLimitedInputStream

Stream wrapper used when an InputStream passed into a CertificateFactory needs to be size limited.

private static class
URICertStore.UCS

This class allows the URICertStore to be accessed as a CertStore.

pack-priv abstract static class
URICertStore.URIRuleMatcher

URIRuleMatcher - abstract base class for the rule sets used for various URI schemes.

Field Summary

Modifier and TypeField and Description
private static final boolean
private static Set<URI>
private static final int
CACERT_CONNECT_TIMEOUT

Integer value indicating the connect timeout, in milliseconds, to be used for the CA certificate download.

private static final int
CACERT_READ_TIMEOUT

Integer value indicating the read timeout, in milliseconds, to be used for the CA certificate download.

private static final int
private Collection<X509Certificate>
private static final Cache<URICertStoreParameters, CertStore>
certStoreCache

Returns a URI CertStore.

private static final int
private X509CRL
private static final int
CRL_CONNECT_TIMEOUT

Integer value indicating the connect timeout, in milliseconds, to be used for the CRL download.

private static final int
CRL_READ_TIMEOUT

Integer value indicating the read timeout, in milliseconds, to be used for the CRL download.

private static final Debug
private static final int
private static final int
private static final int
private static final int
private final CertificateFactory
private long
private long
private boolean
private CertStore
private static final long
MAX_CRL_DOWNLOAD_SIZE

Maximum size for a CRL downloaded through a URICertStore in bytes.

private final URI

Constructor Summary

AccessConstructor and Description
pack-priv
URICertStore(CertStoreParameters
specifying the URI
params
)

Creates a URICertStore.

Method Summary

Modifier and TypeMethod and Description
private static void
addCaIssUriFilters(String[]
array containing String URI filters
aiaUriStrs
)

Populate the filter collection from the list of AIA CA issuer URIs found in the com.sun.security.allowedAIALocations security or system property.

public synchronized Collection<X509Certificate>

Returns:

a Collection of X509Certificates that match the specified selector
engineGetCertificates
(CertSelector
a CertSelector used to select which X509Certificates should be returned. Specify null to return all X509Certificates.
selector
)

Implements abstract java.security.cert.CertStoreSpi.engineGetCertificates.

Returns a Collection of X509Certificates that match the specified selector.

public synchronized Collection<X509CRL>

Returns:

A Collection of X509CRLs that match the specified selector
engineGetCRLs
(CRLSelector
A CRLSelector used to select which X509CRLs should be returned. Specify null to return all X509CRLs.
selector
)

Implements abstract java.security.cert.CertStoreSpi.engineGetCRLs.

Returns a Collection of X509CRLs that match the specified selector.

pack-priv static synchronized CertStore
pack-priv static CertStore
getInstance(AccessDescription ad)

Creates a CertStore from information included in the AccessDescription object of a certificate's Authority Information Access Extension.

private static Collection<X509Certificate>
getMatchingCerts(Collection<X509Certificate> certs, CertSelector selector)

Iterates over the specified Collection of X509Certificates and returns only those that match the criteria specified in the CertSelector.

private static Collection<X509CRL>
getMatchingCRLs(X509CRL crl, CRLSelector selector)

Checks if the specified X509CRL matches the criteria specified in the CRLSelector.

private static int
initializeTimeout(String prop, int def)

Initialize the timeout length by getting the specified CRL timeout system property.

Field Detail

CA_ISS_ALLOW_ANYback to summary
private static final boolean CA_ISS_ALLOW_ANY
CA_ISS_URI_FILTERSback to summary
private static Set<URI> CA_ISS_URI_FILTERS
CACERT_CONNECT_TIMEOUTback to summary
private static final int CACERT_CONNECT_TIMEOUT

Integer value indicating the connect timeout, in milliseconds, to be used for the CA certificate download. A timeout of zero is interpreted as an infinite timeout.

CACERT_READ_TIMEOUTback to summary
private static final int CACERT_READ_TIMEOUT

Integer value indicating the read timeout, in milliseconds, to be used for the CA certificate download. A timeout of zero is interpreted as an infinite timeout.

CACHE_SIZEback to summary
private static final int CACHE_SIZE
certsback to summary
private Collection<X509Certificate> certs
certStoreCacheback to summary
private static final Cache<URICertStoreParameters, CertStore> certStoreCache

Returns a URI CertStore. This method consults a cache of CertStores (shared per JVM) using the URI as a key.

CHECK_INTERVALback to summary
private static final int CHECK_INTERVAL
crlback to summary
private X509CRL crl
CRL_CONNECT_TIMEOUTback to summary
private static final int CRL_CONNECT_TIMEOUT

Integer value indicating the connect timeout, in milliseconds, to be used for the CRL download. A timeout of zero is interpreted as an infinite timeout.

CRL_READ_TIMEOUTback to summary
private static final int CRL_READ_TIMEOUT

Integer value indicating the read timeout, in milliseconds, to be used for the CRL download. A timeout of zero is interpreted as an infinite timeout.

debugback to summary
private static final Debug debug
DEFAULT_CACERT_CONNECT_TIMEOUTback to summary
private static final int DEFAULT_CACERT_CONNECT_TIMEOUT
DEFAULT_CACERT_READ_TIMEOUTback to summary
private static final int DEFAULT_CACERT_READ_TIMEOUT
DEFAULT_CRL_CONNECT_TIMEOUTback to summary
private static final int DEFAULT_CRL_CONNECT_TIMEOUT
DEFAULT_CRL_READ_TIMEOUTback to summary
private static final int DEFAULT_CRL_READ_TIMEOUT
factoryback to summary
private final CertificateFactory factory
lastCheckedback to summary
private long lastChecked
lastModifiedback to summary
private long lastModified
ldapback to summary
private boolean ldap
ldapCertStoreback to summary
private CertStore ldapCertStore
MAX_CRL_DOWNLOAD_SIZEback to summary
private static final long MAX_CRL_DOWNLOAD_SIZE

Maximum size for a CRL downloaded through a URICertStore in bytes. This can be controlled by the com.sun.security.crl.maxSize Security or System property. The System property, if set, overrides the Security property. The default size is 20MiB.

uriback to summary
private final URI uri

Constructor Detail

URICertStoreback to summary
pack-priv URICertStore(CertStoreParameters params) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException

Creates a URICertStore.

Parameters
params:CertStoreParameters

specifying the URI

Method Detail

addCaIssUriFiltersback to summary
private static void addCaIssUriFilters(String[] aiaUriStrs)

Populate the filter collection from the list of AIA CA issuer URIs found in the com.sun.security.allowedAIALocations security or system property.

Parameters
aiaUriStrs:String[]

array containing String URI filters

engineGetCertificatesback to summary
public synchronized Collection<X509Certificate> engineGetCertificates(CertSelector selector) throws CertStoreException

Implements abstract java.security.cert.CertStoreSpi.engineGetCertificates.

Returns a Collection of X509Certificates that match the specified selector. If no X509Certificates match the selector, an empty Collection will be returned.

Parameters
selector:CertSelector

a CertSelector used to select which X509Certificates should be returned. Specify null to return all X509Certificates.

Returns:Collection<X509Certificate>

a Collection of X509Certificates that match the specified selector

Annotations
@Override
@SuppressWarnings:unchecked
Exceptions
CertStoreException:
if an exception occurs
engineGetCRLsback to summary
public synchronized Collection<X509CRL> engineGetCRLs(CRLSelector selector) throws CertStoreException

Implements abstract java.security.cert.CertStoreSpi.engineGetCRLs.

Returns a Collection of X509CRLs that match the specified selector. If no X509CRLs match the selector, an empty Collection will be returned.

Parameters
selector:CRLSelector

A CRLSelector used to select which X509CRLs should be returned. Specify null to return all X509CRLs.

Returns:Collection<X509CRL>

A Collection of X509CRLs that match the specified selector

Annotations
@Override
@SuppressWarnings:unchecked
Exceptions
CertStoreException:
if an exception occurs
getInstanceback to summary
pack-priv static synchronized CertStore getInstance(URICertStoreParameters params) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException
getInstanceback to summary
pack-priv static CertStore getInstance(AccessDescription ad)

Creates a CertStore from information included in the AccessDescription object of a certificate's Authority Information Access Extension.

getMatchingCertsback to summary
private static Collection<X509Certificate> getMatchingCerts(Collection<X509Certificate> certs, CertSelector selector)

Iterates over the specified Collection of X509Certificates and returns only those that match the criteria specified in the CertSelector.

getMatchingCRLsback to summary
private static Collection<X509CRL> getMatchingCRLs(X509CRL crl, CRLSelector selector)

Checks if the specified X509CRL matches the criteria specified in the CRLSelector.

initializeTimeoutback to summary
private static int initializeTimeout(String prop, int def)

Initialize the timeout length by getting the specified CRL timeout system property. If the property has not been set, or if its value is negative, set the timeout length to the specified default.

sun.security.provider.certpath back to summary

private final Enum URICertStore.AllowedScheme

extends Enum<URICertStore.AllowedScheme>
Class Inheritance

Enumeration for the allowed schemes we support when following a URI from an authorityInfoAccess extension on a certificate.

Field Summary

Modifier and TypeField and Description
public static final URICertStore.AllowedScheme
public static final URICertStore.AllowedScheme
public static final URICertStore.AllowedScheme
public static final URICertStore.AllowedScheme
public static final URICertStore.AllowedScheme
pack-priv final URICertStore.URIRuleMatcher

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static URICertStore.AllowedScheme

Returns:

the AllowedScheme that corresponds to the name provided, or null if there is no match.
nameOf
(String
the scheme name to be matched
name
)

Return an AllowedScheme based on a case-insensitive match

public static URICertStore.AllowedScheme
public static URICertStore.AllowedScheme[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FTPback to summary
public static final URICertStore.AllowedScheme FTP
HTTPback to summary
public static final URICertStore.AllowedScheme HTTP
HTTPSback to summary
public static final URICertStore.AllowedScheme HTTPS
LDAPback to summary
public static final URICertStore.AllowedScheme LDAP
LDAPSback to summary
public static final URICertStore.AllowedScheme LDAPS
ruleMatcherback to summary
pack-priv final URICertStore.URIRuleMatcher ruleMatcher

Constructor Detail

AllowedSchemeback to summary
private AllowedScheme(URICertStore.URIRuleMatcher matcher)

Method Detail

nameOfback to summary
pack-priv static URICertStore.AllowedScheme nameOf(String name)

Return an AllowedScheme based on a case-insensitive match

Parameters
name:String

the scheme name to be matched

Returns:URICertStore.AllowedScheme

the AllowedScheme that corresponds to the name provided, or null if there is no match.

valueOfback to summary
public static URICertStore.AllowedScheme valueOf(String name)
valuesback to summary
public static URICertStore.AllowedScheme[] values()
sun.security.provider.certpath back to summary

pack-priv Class URICertStore.HttpFtpRuleMatcher

extends URIRuleMatcher
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final URICertStore.HttpFtpRuleMatcher
pack-priv static final URICertStore.HttpFtpRuleMatcher
pack-priv static final URICertStore.HttpFtpRuleMatcher
Inherited from sun.security.provider.certpath.URICertStore.URIRuleMatcher:
wellKnownPort

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static boolean

Returns:

true if candidate is a child path of base, false otherwise.
isRootOf
(URI
the URI that contains the root path
base
,
URI
the URI that contains the path being evaluated
candidate
)

Performs a hierarchical containment check, ensuring that the base URI's path is a root component of the candidate path.

pack-priv boolean
matchRule(URI filterRule, URI caIssuer)

Implements abstract sun.security.provider.certpath.URICertStore.URIRuleMatcher.matchRule.

Attempt to match an AIA URI against a specific filter rule.

Inherited from sun.security.provider.certpath.URICertStore.URIRuleMatcher:
schemeHostPortCheck

Field Detail

FTPback to summary
pack-priv static final URICertStore.HttpFtpRuleMatcher FTP
HTTPback to summary
pack-priv static final URICertStore.HttpFtpRuleMatcher HTTP
HTTPSback to summary
pack-priv static final URICertStore.HttpFtpRuleMatcher HTTPS

Constructor Detail

HttpFtpRuleMatcherback to summary
private HttpFtpRuleMatcher(int port)

Method Detail

isRootOfback to summary
private static boolean isRootOf(URI base, URI candidate)

Performs a hierarchical containment check, ensuring that the base URI's path is a root component of the candidate path. The path comparison is case-sensitive. If the base path ends in a slash (/) then all candidate paths that begin with the base path are allowed. If it does not end in a slash, then it is assumed that the leaf node in the base path is a file component and both paths must match exactly.

Parameters
base:URI

the URI that contains the root path

candidate:URI

the URI that contains the path being evaluated

Returns:boolean

true if candidate is a child path of base, false otherwise.

matchRuleback to summary
pack-priv boolean matchRule(URI filterRule, URI caIssuer)

Implements abstract sun.security.provider.certpath.URICertStore.URIRuleMatcher.matchRule.

Doc from sun.security.provider.certpath.URICertStore.URIRuleMatcher.matchRule.

Attempt to match an AIA URI against a specific filter rule. The specific rules to apply are implementation dependent.

Annotations
@Override
sun.security.provider.certpath back to summary

pack-priv Class URICertStore.LdapRuleMatcher

extends URIRuleMatcher
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final URICertStore.LdapRuleMatcher
pack-priv static final URICertStore.LdapRuleMatcher
Inherited from sun.security.provider.certpath.URICertStore.URIRuleMatcher:
wellKnownPort

Constructor Summary

AccessConstructor and Description
private
LdapRuleMatcher(int port)

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
matchRule(URI filterRule, URI caIssuer)

Implements abstract sun.security.provider.certpath.URICertStore.URIRuleMatcher.matchRule.

Attempt to match an AIA URI against a specific filter rule.

Inherited from sun.security.provider.certpath.URICertStore.URIRuleMatcher:
schemeHostPortCheck

Field Detail

LDAPback to summary
pack-priv static final URICertStore.LdapRuleMatcher LDAP
LDAPSback to summary
pack-priv static final URICertStore.LdapRuleMatcher LDAPS

Constructor Detail

LdapRuleMatcherback to summary
private LdapRuleMatcher(int port)

Method Detail

matchRuleback to summary
pack-priv boolean matchRule(URI filterRule, URI caIssuer)

Implements abstract sun.security.provider.certpath.URICertStore.URIRuleMatcher.matchRule.

Doc from sun.security.provider.certpath.URICertStore.URIRuleMatcher.matchRule.

Attempt to match an AIA URI against a specific filter rule. The specific rules to apply are implementation dependent.

Annotations
@Override
sun.security.provider.certpath back to summary

private Class URICertStore.SizeLimitedInputStream

extends FilterInputStream
Class Inheritance

Stream wrapper used when an InputStream passed into a CertificateFactory needs to be size limited. It will throw IllegalArgumentException when the downloaded resource via the underlying stream exceeds the maximum limit.

Field Summary

Modifier and TypeField and Description
private long
private final long
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.

public int
read(byte[] b, int off, int len)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.

Inherited from java.io.FilterInputStream:
availableclosemarkmarkSupportedreadresetskip

Field Detail

bytesReadback to summary
private long bytesRead
maxBytesback to summary
private final long maxBytes

Constructor Detail

SizeLimitedInputStreamback to summary
private SizeLimitedInputStream(InputStream in, long maxBytes)

Method Detail

readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
sun.security.provider.certpath back to summary

private Class URICertStore.UCS

extends CertStore
Class Inheritance

This class allows the URICertStore to be accessed as a CertStore.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Inherited from java.security.cert.CertStore:
getCertificatesgetCertStoreParametersgetCRLsgetDefaultTypegetInstancegetInstancegetInstancegetProvidergetType

Constructor Detail

UCSback to summary
protected UCS(CertStoreSpi spi, Provider p, String type, CertStoreParameters params)
sun.security.provider.certpath back to summary

pack-priv abstract Class URICertStore.URIRuleMatcher

extends Object
Class Inheritance
Known Direct Subclasses
sun.security.provider.certpath.URICertStore.HttpFtpRuleMatcher, sun.security.provider.certpath.URICertStore.LdapRuleMatcher

URIRuleMatcher - abstract base class for the rule sets used for various URI schemes.

Field Summary

Modifier and TypeField and Description
protected final int

Constructor Summary

AccessConstructor and Description
protected
URIRuleMatcher(int port)

Method Summary

Modifier and TypeMethod and Description
pack-priv abstract boolean

Returns:

true if all matching rules pass, false if any fail.
matchRule
(URI
the filter rule to match against
filterRule
,
URI
the AIA URI being compared
caIssuer
)

Attempt to match an AIA URI against a specific filter rule.

pack-priv boolean

Returns:

true if the scheme, host and port numbers match, false if any of the components do not match. If a port number is omitted in either the filter rule or AIA URI, the well-known port for that scheme is used in the comparison.
schemeHostPortCheck
(URI
the filter rule to match against
filterRule
,
URI
the AIA URI being compared
caIssuer
)

Attempt to match the scheme, host and port between a filter rule URI and a URI coming from an AIA extension.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

wellKnownPortback to summary
protected final int wellKnownPort

Constructor Detail

URIRuleMatcherback to summary
protected URIRuleMatcher(int port)

Method Detail

matchRuleback to summary
pack-priv abstract boolean matchRule(URI filterRule, URI caIssuer)

Attempt to match an AIA URI against a specific filter rule. The specific rules to apply are implementation dependent.

Parameters
filterRule:URI

the filter rule to match against

caIssuer:URI

the AIA URI being compared

Returns:boolean

true if all matching rules pass, false if any fail.

schemeHostPortCheckback to summary
pack-priv boolean schemeHostPortCheck(URI filterRule, URI caIssuer)

Attempt to match the scheme, host and port between a filter rule URI and a URI coming from an AIA extension.

Parameters
filterRule:URI

the filter rule to match against

caIssuer:URI

the AIA URI being compared

Returns:boolean

true if the scheme, host and port numbers match, false if any of the components do not match. If a port number is omitted in either the filter rule or AIA URI, the well-known port for that scheme is used in the comparison.