public class CertStore extends CapiHandle
HCERTSTORE type,
and is used for all situations where an HCERTSTORE is
required for a native call.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
INTERMEDIATE |
static java.lang.String |
PERSONAL |
static java.lang.String |
TRUSTED_ROOT |
| Modifier and Type | Method and Description |
|---|---|
void |
addCertificateContextToStore(CertContext certContext,
CertStoreAddDisposition addDisposition)
Adds the given certificate to this store.
|
void |
close()
Closes the handle to the certificate store, freeing memory and
resources.
|
CertContext |
enumCertificatesInStore(CertContext previousContext)
Enumerates the certificates contained in this certificate store.
|
CertContext |
findCertificateInStore(CertContext certToFind)
Attempt to find the given certificate in this store, and return a
read-only copy of it if it is.
|
CertContext |
findCertificateInStore(int findFlags,
CertFindType findType,
java.lang.Object findParameter,
CertContext previousCertContext)
Attempt to find a certificate in this store matching the given
parameters, and return a read-only copy of it if it is.
|
static CertStore |
openStore(CertStoreProvType storeProviderType,
int encodingType,
CryptProvider cryptProvider,
int flags,
java.lang.String parameter)
Opens a certificate store and returns a handle to the newly opened store.
|
static CertStore |
openSystemStore(CryptProvider cryptProvider,
java.lang.String storeName)
Opens a system certificate store and returns a handle to the newly
opened store.
|
clearHandle, debugInfo, debugInfo, equals, finalize, getHandle, hashCode, setExtendedDebuggingpublic static final java.lang.String PERSONAL
public static final java.lang.String TRUSTED_ROOT
public static final java.lang.String INTERMEDIATE
public static CertStore openStore(CertStoreProvType storeProviderType, int encodingType, CryptProvider cryptProvider, int flags, java.lang.String parameter) throws CapiException
storeProviderType - the store provider type. Only the store types that take string
parameters when opening can currently be used, those that require
handles to Windows objects such as registry keys cannot. Also, this
class does not support modification of certificate stores, so
store types that are transient, e.g. CERT_STORE_PROV_MEMORY, can be
opened but are of little use.encodingType - the certificate and message encoding type. Only applicable to
the CERT_STORE_PROV_FILENAME provider type, where it will most commonly
be CapiConstants.X509_ASN_ENCODING | CapiConstants.PKCS_7_ASN_ENCODINGcryptProvider - a cryptographic service provider which is used to verify signatures.
Passing null for this parameter causes a default provider
to be used, which should be suitable for almost all uses.flags - flags to pass to CertOpenStore. These flags are in
CapiConstants, beginning with CERT_STORE. See the MSDN
documentation for full details.parameter - the parameter to pass to CertOpenStore. The contents
of the string will depend of the choice of storeProviderType.null if the
store does not exist.CapiException - if there is any problem opening the store.CertOpenStorepublic static CertStore openSystemStore(CryptProvider cryptProvider, java.lang.String storeName) throws CapiException
openStore, but is
suitable for most non-specialized access to certificate stores.
Note that this call may create the given certificate store if it
does not exist. If this behaviour is not desired, call
openStore instead, using the
CERT_STORE_OPEN_EXISTING_FLAG flag.
cryptProvider - A handle to a CSP. This can be null to use the
default CSP. If it is not null, it must be a
CryptProvider obtained by a call to
CryptProvider.cryptAcquireContext()storeName - The name of the store to open. Some commonly used names are
null if the
store does not exist.CapiException - if there is any problem opening the specified certificate store.CertOpenSystemStorepublic void close()
close in class CapiHandlepublic CertContext enumCertificatesInStore(CertContext previousContext) throws CapiException
previousContext - the result of a previous call to this method. The first time
this method is called, null should be used.
previousContext is no longer usable after this call,
so if it is still required, it should be duplicated and the duplicate
used for further function calls. The duplicate must be explicitly
closed when no longer needed.null if all certificates have been enumerated.CapiException - if this certificate store is no longer valid, or if the
given certificate does not belong to the certificate store.CertEnumCertificatesInStorepublic void addCertificateContextToStore(CertContext certContext, CertStoreAddDisposition addDisposition) throws CapiException
certContext - A handle to an open PCCERT_CONTEXT object in CAPI that will be added to
this certificate store.addDisposition - The Specifies the action to take if a matching certificate or a link to
a matching certificate already exists in the store.CapiException - if the certificate cannot be added.CertAddCertificateContextToStorepublic CertContext findCertificateInStore(CertContext certToFind) throws CapiException
certToFind - the certificate to find.null if the certificate is not found, or a
read-only CertContext object if it is. The returned
object must be explicitly closed.CapiException - if there is a problem searching for the certificate.CertFindCertificateInStorepublic CertContext findCertificateInStore(int findFlags, CertFindType findType, java.lang.Object findParameter, CertContext previousCertContext) throws CapiException
findFlags - flags to use when searching for the certificate.findType - the type of search to perform. Currently only CERT_FIND_SHA1_HASH
and CERT_FIND_PROPERTY are supported.findParameter - must be an instance of byte[] for all currently supported
find types.previousCertContext - the result of a previous call to this method if this method is being
called multiple times. Set to null the first time this
method is called. Any non-null value passed in is always released,
regardless of whether this method is successful or throws an Exception.null if the certificate is not found, or a
read-only CertContext object if it is. The returned
object must be explicitly closed.CapiException - if the given property is not supported, or there is a problem with the
parameters that causes the search to fail.CertFindCertificateInStore