public class CapiIdentities extends java.util.AbstractCollection<CapiIdentity> implements CapiIdentityFilter
CapiIdentity objects, and can be used
to find digital identities in CAPI. It extends AbstractCollection,
but follows the semantics of an unmodifiable collection. This means that any
add method will throw an UnsupportedOperationException,
and the Iterator returned by a call to iterator()
does not support the remove() operation.
An instance of this class should be obtained by calling the static
findIdentities() method. This method searches through the "MY"
certificate store of the current Windows user, looking for certificates with
private keys available. A CapiIdentity is formed by grouping together certificates
which belong to the same identity in the Certification Authority. The matching of
certificates to an identity is done by private key container name, which have
specific naming rules.
This class has convenience methods to find an identity matching a key container
name. Other search methods should use the standard method of iterating over a
Collection with an Iterator and testing each
CapiIdenity.
A CapiCertFilter may be used to filter out Certificates in CAPI that are
not acceptable for forming an identity. A custom CapiCertFilter may be
defined and passed to the findIdentities(CapiCertFilter), or if more than
one filter is required, a CapiSearchFilter containing multiple CapiCertFilter
objects may be defined.
It is important to note that it will not necessarily be possible to access all of the identities in the collection. For example, some may have been created with a different security descriptor from the one currently in use that will prevent access to the private key.
findIdentities(),
AbstractCollection| Modifier and Type | Method and Description |
|---|---|
static CapiIdentities |
findIdentities()
Searches the "MY" certificate store of the currently logged in Windows
user for certificates that can be used to log in to a
User
object. |
static CapiIdentities |
findIdentities(CapiCertFilter filter)
Searches the "MY" certificate store of the currently logged in Windows
user for certificates that can be used to log in to a
User
object. |
static CapiIdentities |
findIdentities(CapiCertFilter filter,
CapiIdentityFilter idfilter)
Searches the "MY" certificate store of the currently logged in Windows
user for certificates that can be used to log in to a
User
object. |
static CapiIdentity |
findIdentity(CapiCertFilter filter)
This method returns the first CapiIdentity found after searching for identities
with the specific filter.
|
CapiIdentity |
findMatchingIdentity(CapiCertificateAndKeyInfo ccaki,
CapiIdentityFilter filter)
Finds the identity to which the given CapiCertificateAndKeyInfo matches by
calling the
CapiIdentityFilter.matchIdentity(CapiIdentity, CapiCertificateAndKeyInfo)
method. |
CapiIdentity |
findMatchingIdentity(CapiContainerName containerName)
Finds the identity to which the given key container name belongs.
|
static CertStore |
getIdentityCertStore(java.lang.String storeName)
This method is used to get the CertStore that is used when
retrieving identities.
|
java.util.Iterator<CapiIdentity> |
iterator()
Returns an
Iterator that can be used to iterate through all
identities stored in this set. |
boolean |
matchIdentity(CapiIdentity identity,
CapiCertificateAndKeyInfo ccaki)
Check if the passed in CapiCerticateAndKeyInfo belongs to the specified CapiIdentity.
|
int |
size()
Returns the number of identities in this collection.
|
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringpublic java.util.Iterator<CapiIdentity> iterator()
Iterator that can be used to iterate through all
identities stored in this set. The object returned by calling the
next() method of the iterator should be cast to a
CapiIdentity.iterator in interface java.lang.Iterable<CapiIdentity>iterator in interface java.util.Collection<CapiIdentity>iterator in class java.util.AbstractCollection<CapiIdentity>Iterator that can be used to iterate through all
identities stored in this set.public int size()
size in interface java.util.Collection<CapiIdentity>size in class java.util.AbstractCollection<CapiIdentity>public CapiIdentity findMatchingIdentity(CapiContainerName containerName)
containerName - The name of the key container for which to find a matching identitynull if no matching
identity is found.public CapiIdentity findMatchingIdentity(CapiCertificateAndKeyInfo ccaki, CapiIdentityFilter filter)
CapiIdentityFilter.matchIdentity(CapiIdentity, CapiCertificateAndKeyInfo)
method.ccaki - The CapiCertificateAndKeyInfo which will be used to find certificates and key that belong
to this identity.filter - The CapiIdentityFilter used to find the certificates and keys that belong to this
identity.null if no matching
identity is found.public boolean matchIdentity(CapiIdentity identity, CapiCertificateAndKeyInfo ccaki)
In an Entrust Identity, there can be multiple certificates and keys. For example, encryption, verification and
non-repudiation. When these certificates are stored in CAPI using Entrust, the CapiContainerName
is used to find other certificates that may be associated with that identity. However, if the Entrust
certificates were added into CAPI using a third-party mechanism, such as a P11 driver, or an export from
P12, then the Entrust container format will not be used. Therefore, this identity will be considered an
unknown identity and the toolkit will use the SubjectDN and IssuerDN of the certificates in CAPI to find
the certificates that belong to the same identity.
Note: Because the Entrust CAPI container format was not used when writing the certificates into CAPI, this identity will not be able to be managed by the toolkit. Attempting to manage such an identity may result in undefined behaviour, and is not supported by the toolkit.
matchIdentity in interface CapiIdentityFilteridentity - The CapiIdentityccaki - The CapiCertificateAndKeyInfopublic static CapiIdentities findIdentities() throws CapiException
User
object. To be acceptable, a certificate must:
CapiIdentity objects that may be used
to construct a CapiCredentialReader to log in to a
UserCapiException - if any non-recoverable error occurs searching for certificates, such
as not being able to open the "MY" certificate store.public static CapiIdentity findIdentity(CapiCertFilter filter) throws CapiException
CertIdentityCertFilter.filter - The CapiCertFilter used to filter out acceptable certificates used
to find identitiesCapiException - if an error occursCapiCertFilterpublic static CapiIdentities findIdentities(CapiCertFilter filter) throws CapiException
User
object.
The CapiCertFilter is used to filter out certificates that should not
be considered for use when searching for identities
filter - The CapiCertFilter used to filter out certificates which
should be considered acceptable.CapiIdentity objects that may be used
to construct a CapiCredentialReader to log in to a
UserCapiException - if any non-recoverable error occurs searching for certificates, such
as not being able to open the "MY" certificate store.CapiIdentityCertFilter,
UnverifiedCertFilter,
CapiSearchFilterpublic static CapiIdentities findIdentities(CapiCertFilter filter, CapiIdentityFilter idfilter) throws CapiException
User
object.
The CapiCertFilter is used to filter out certificates that should not
be considered for use when searching for identities
The CapiIdentityFilter is used to identify certificates which should
belong to the same identity. Null may be specified to indicate the default
matchIdentity(CapiIdentity, CapiCertificateAndKeyInfo) filter will
be used.
filter - The CapiCertFilter used to filter out certificates which should not be
considered acceptable.idfilter - The CapiIdentityFilter used to match the certificates and keys that belong
to the same identity.CapiIdentity objects that may be used
to construct a CapiCredentialReader to log in to a
UserCapiException - if any non-recoverable error occurs searching for certificates, such
as not being able to open the "MY" certificate store.CapiIdentityCertFilter,
UnverifiedCertFilter,
CapiSearchFilterpublic static CertStore getIdentityCertStore(java.lang.String storeName) throws CapiException
provType - The CertStoreProvTypecryptProvider - the CryptProviderCapiException