public class KeyStoreCredentialResolver extends AbstractCriteriaFilteringCredentialResolver
CredentialResolver that extracts Credential's from a key store.
If no key usage type is presented at construction time this resolver will return the key, if available, regardless of the usage type provided to its resolve method.
Resolution will fail if an EntityIdCriterion is not part of the input criteria set.
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<java.lang.String,java.lang.String> |
keyPasswords
Passwords for keys.
|
private java.security.KeyStore |
keyStore
Key store credentials are retrieved from.
|
private UsageType |
keystoreUsage
Usage type of all keys in the store.
|
private org.slf4j.Logger |
log
Class logger.
|
| Constructor and Description |
|---|
KeyStoreCredentialResolver(java.security.KeyStore store,
java.util.Map<java.lang.String,java.lang.String> passwords)
Constructor.
|
KeyStoreCredentialResolver(java.security.KeyStore store,
java.util.Map<java.lang.String,java.lang.String> passwords,
UsageType usage)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected Credential |
buildCredential(java.security.KeyStore.Entry keyStoreEntry,
java.lang.String entityID,
UsageType usage)
Build a credential instance from the key store entry.
|
protected void |
checkCriteriaRequirements(net.shibboleth.utilities.java.support.resolver.CriteriaSet criteriaSet)
Check that required credential criteria are available.
|
protected boolean |
matchUsage(UsageType keyStoreUsage,
UsageType criteriaUsage)
Match usage enum type values from keystore configured usage and from credential criteria.
|
protected X509Credential |
processPrivateKeyEntry(java.security.KeyStore.PrivateKeyEntry privateKeyEntry,
java.lang.String entityID,
UsageType usage)
Build an X509Credential from a keystore private key entry.
|
protected Credential |
processSecretKeyEntry(java.security.KeyStore.SecretKeyEntry secretKeyEntry,
java.lang.String entityID,
UsageType usage)
Build a Credential from a keystore secret key entry.
|
protected X509Credential |
processTrustedCertificateEntry(java.security.KeyStore.TrustedCertificateEntry trustedCertEntry,
java.lang.String entityID,
UsageType usage)
Build an X509Credential from a keystore trusted certificate entry.
|
protected java.lang.Iterable<Credential> |
resolveFromSource(net.shibboleth.utilities.java.support.resolver.CriteriaSet criteriaSet)
Subclasses are required to implement this method to resolve credentials from the
implementation-specific type of underlying credential source.
|
isSatisfyAllPredicates, resolve, setSatisfyAllPredicatesresolveSingleprivate final org.slf4j.Logger log
private final java.security.KeyStore keyStore
private final java.util.Map<java.lang.String,java.lang.String> keyPasswords
private final UsageType keystoreUsage
public KeyStoreCredentialResolver(@Nonnull
java.security.KeyStore store,
@Nonnull
java.util.Map<java.lang.String,java.lang.String> passwords)
store - key store credentials are retrieved frompasswords - for key entries, map key is the entity id, map value is the passwordpublic KeyStoreCredentialResolver(@Nonnull
java.security.KeyStore store,
@Nonnull
java.util.Map<java.lang.String,java.lang.String> passwords,
@Nullable
UsageType usage)
store - key store credentials are retrieved frompasswords - for key entries, map key is the entity id, map value is the passwordusage - usage type of all keys in the store@Nonnull protected java.lang.Iterable<Credential> resolveFromSource(@Nullable net.shibboleth.utilities.java.support.resolver.CriteriaSet criteriaSet) throws net.shibboleth.utilities.java.support.resolver.ResolverException
resolveFromSource in class AbstractCriteriaFilteringCredentialResolvercriteriaSet - the set of criteria used to resolve credentials from the credential sourcenet.shibboleth.utilities.java.support.resolver.ResolverException - thrown if there is an error resolving credentials from the credential sourceprotected void checkCriteriaRequirements(@Nullable
net.shibboleth.utilities.java.support.resolver.CriteriaSet criteriaSet)
criteriaSet - the credential criteria set to evaluateprotected boolean matchUsage(@Nonnull
UsageType keyStoreUsage,
@Nonnull
UsageType criteriaUsage)
keyStoreUsage - the usage type configured for the keystorecriteriaUsage - the value from credential criteria@Nonnull protected Credential buildCredential(@Nonnull java.security.KeyStore.Entry keyStoreEntry, @Nonnull java.lang.String entityID, @Nonnull UsageType usage) throws net.shibboleth.utilities.java.support.resolver.ResolverException
keyStoreEntry - the key store entry to processentityID - the entityID to include in the credentialusage - the usage type to include in the credentialnet.shibboleth.utilities.java.support.resolver.ResolverException - throw if there is a problem building a credential from the key store entryprotected X509Credential processTrustedCertificateEntry(@Nonnull java.security.KeyStore.TrustedCertificateEntry trustedCertEntry, @Nonnull java.lang.String entityID, @Nonnull UsageType usage)
trustedCertEntry - the entry being processedentityID - the entityID to setusage - the usage type to setprotected X509Credential processPrivateKeyEntry(@Nonnull java.security.KeyStore.PrivateKeyEntry privateKeyEntry, @Nonnull java.lang.String entityID, @Nonnull UsageType usage)
privateKeyEntry - the entry being processedentityID - the entityID to setusage - the usage type to setprotected Credential processSecretKeyEntry(@Nonnull java.security.KeyStore.SecretKeyEntry secretKeyEntry, @Nonnull java.lang.String entityID, @Nonnull UsageType usage)
secretKeyEntry - the entry being processedentityID - the entityID to setusage - the usage type to set