Package org.wildfly.security.credential
Interface Credential
-
- All Superinterfaces:
Cloneable
- All Known Subinterfaces:
AlgorithmCredential
,X509CertificateChainCredential
- All Known Implementing Classes:
AbstractX509CertificateChainCredential
,BearerTokenCredential
,GSSKerberosCredential
,KeyPairCredential
,PasswordCredential
,PublicKeyCredential
,SecretKeyCredential
,SSHCredential
,X509CertificateChainPrivateCredential
,X509CertificateChainPublicCredential
public interface Credential extends Cloneable
A credential is a piece of information that can be used to verify or produce evidence.
-
-
Field Summary
Fields Modifier and Type Field Description static Credential[]
NO_CREDENTIALS
An array with no credentials.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default boolean
canVerify(Class<? extends Evidence> evidenceClass, String algorithmName)
Determine whether this credential can, generally speaking, verify the given evidence type.default boolean
canVerify(Evidence evidence)
Determine whether this credential can verify the given evidence.default <C extends Credential,R>
RcastAndApply(Class<C> credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec, Function<C,R> function)
Cast this credential type and apply a function if the type matches.default <C extends Credential,R>
RcastAndApply(Class<C> credentialType, String algorithmName, Function<C,R> function)
Cast this credential type and apply a function if the type matches.default <C extends Credential,R>
RcastAndApply(Class<C> credentialType, Function<C,R> function)
Cast this credential type and apply a function if the type matches.default <C extends Credential>
CcastAs(Class<C> credentialType)
Cast this credential type if the type matches.default <C extends Credential>
CcastAs(Class<C> credentialType, String algorithmName)
Cast this credential type if the type and algorithm matches.default <C extends Credential>
CcastAs(Class<C> credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec)
Cast this credential type if the type, algorithm, and parameters match.Credential
clone()
Creates and returns a copy of thisCredential
.static Credential
fromKeyStoreEntry(KeyStore.Entry keyStoreEntry)
Convert a key store entry into a credential object.default boolean
matches(Class<? extends Credential> credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec)
Determine if this credential matches the given criteria.default boolean
matches(AlgorithmCredential other)
Determine if this credential is the same kind of credential as the given credential.default boolean
matches(Credential other)
Determine if this credential is the same kind of credential as the given credential.default boolean
verify(Supplier<Provider[]> providerSupplier, Evidence evidence)
Verify the given evidence.default boolean
verify(Evidence evidence)
Deprecated.useverify(Supplier, Evidence)
instead
-
-
-
Field Detail
-
NO_CREDENTIALS
static final Credential[] NO_CREDENTIALS
An array with no credentials.
-
-
Method Detail
-
canVerify
default boolean canVerify(Class<? extends Evidence> evidenceClass, String algorithmName)
Determine whether this credential can, generally speaking, verify the given evidence type.- Parameters:
evidenceClass
- the evidence type (must not benull
)algorithmName
- the evidence algorithm name (may benull
if the type of evidence does not support algorithm names)- Returns:
true
if the evidence can be verified by this credential,false
otherwise
-
canVerify
default boolean canVerify(Evidence evidence)
Determine whether this credential can verify the given evidence.- Parameters:
evidence
- the evidence (must not benull
)- Returns:
true
if the evidence can be verified by this credential,false
otherwise
-
verify
@Deprecated default boolean verify(Evidence evidence)
Deprecated.useverify(Supplier, Evidence)
insteadVerify the given evidence.- Parameters:
evidence
- the evidence to verify (must not benull
)- Returns:
true
if the evidence is verified,false
otherwise
-
verify
default boolean verify(Supplier<Provider[]> providerSupplier, Evidence evidence)
Verify the given evidence.- Parameters:
providerSupplier
- the provider supplier to use for verification purposesevidence
- the evidence to verify (must not benull
)- Returns:
true
if the evidence is verified,false
otherwise
-
castAs
default <C extends Credential> C castAs(Class<C> credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec)
Cast this credential type if the type, algorithm, and parameters match.- Type Parameters:
C
- the credential type- Parameters:
credentialType
- the credential type class to checkalgorithmName
- the name of the algorithm ornull
if any algorithm is acceptableparameterSpec
- the parameter specification ornull
if any parameter specification is acceptable- Returns:
- the credential cast as the target type, or
null
if the credential does not match the criteria
-
castAs
default <C extends Credential> C castAs(Class<C> credentialType, String algorithmName)
Cast this credential type if the type and algorithm matches.- Type Parameters:
C
- the credential type- Parameters:
credentialType
- the credential type class to checkalgorithmName
- the name of the algorithm ornull
if any algorithm is acceptable- Returns:
- the credential cast as the target type, or
null
if the credential does not match the criteria
-
castAs
default <C extends Credential> C castAs(Class<C> credentialType)
Cast this credential type if the type matches.- Type Parameters:
C
- the credential type- Parameters:
credentialType
- the credential type class to check- Returns:
- the credential cast as the target type, or
null
if the credential does not match the criteria
-
castAndApply
default <C extends Credential,R> R castAndApply(Class<C> credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec, Function<C,R> function)
Cast this credential type and apply a function if the type matches.- Type Parameters:
C
- the credential typeR
- the return type- Parameters:
credentialType
- the credential type class to checkalgorithmName
- the name of the algorithm ornull
if any algorithm is acceptableparameterSpec
- the parameter specification ornull
if any parameter specification is acceptablefunction
- the function to apply- Returns:
- the result of the function, or
null
if the credential is not of the given type
-
castAndApply
default <C extends Credential,R> R castAndApply(Class<C> credentialType, String algorithmName, Function<C,R> function)
Cast this credential type and apply a function if the type matches.- Type Parameters:
C
- the credential typeR
- the return type- Parameters:
credentialType
- the credential type class to checkalgorithmName
- the name of the algorithm ornull
if any algorithm is acceptablefunction
- the function to apply- Returns:
- the result of the function, or
null
if the credential is not of the given type
-
castAndApply
default <C extends Credential,R> R castAndApply(Class<C> credentialType, Function<C,R> function)
Cast this credential type and apply a function if the type matches.- Type Parameters:
C
- the credential typeR
- the return type- Parameters:
credentialType
- the credential type class to checkfunction
- the function to apply- Returns:
- the result of the function, or
null
if the credential is not of the given type
-
clone
Credential clone()
Creates and returns a copy of thisCredential
.- Returns:
- a copy of this
Credential
.
-
matches
default boolean matches(Credential other)
Determine if this credential is the same kind of credential as the given credential.- Parameters:
other
- the other credential- Returns:
true
if the credentials are of the same kind,false
otherwise
-
matches
default boolean matches(AlgorithmCredential other)
Determine if this credential is the same kind of credential as the given credential.- Parameters:
other
- the other credential- Returns:
true
if the credentials are of the same kind,false
otherwise
-
matches
default boolean matches(Class<? extends Credential> credentialType, String algorithmName, AlgorithmParameterSpec parameterSpec)
Determine if this credential matches the given criteria.- Parameters:
credentialType
- the credential type class to checkalgorithmName
- the name of the algorithm ornull
if any algorithm is acceptableparameterSpec
- the parameter specification ornull
if any parameter specification is acceptable- Returns:
true
if the credential matches the specification,false
otherwise
-
fromKeyStoreEntry
static Credential fromKeyStoreEntry(KeyStore.Entry keyStoreEntry)
Convert a key store entry into a credential object.- Parameters:
keyStoreEntry
- the key store entry to convert (must not benull
)- Returns:
- the corresponding credential, or
null
if the entry type is unrecognized
-
-