Interface Credential

    • 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 be null)
        algorithmName - the evidence algorithm name (may be null 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 be null)
        Returns:
        true if the evidence can be verified by this credential, false otherwise
      • verify

        default boolean verify​(Evidence evidence)
        Verify the given evidence.
        Parameters:
        evidence - the evidence to verify (must not be null)
        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 purposes
        evidence - the evidence to verify (must not be null)
        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 check
        algorithmName - the name of the algorithm or null if any algorithm is acceptable
        parameterSpec - the parameter specification or null 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 check
        algorithmName - the name of the algorithm or null 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 type
        R - the return type
        Parameters:
        credentialType - the credential type class to check
        algorithmName - the name of the algorithm or null if any algorithm is acceptable
        parameterSpec - the parameter specification or null if any parameter specification is acceptable
        function - 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 type
        R - the return type
        Parameters:
        credentialType - the credential type class to check
        algorithmName - the name of the algorithm or null if any algorithm is acceptable
        function - 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 type
        R - the return type
        Parameters:
        credentialType - the credential type class to check
        function - the function to apply
        Returns:
        the result of the function, or null if the credential is not of the given type
      • 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 check
        algorithmName - the name of the algorithm or null if any algorithm is acceptable
        parameterSpec - the parameter specification or null 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 be null)
        Returns:
        the corresponding credential, or null if the entry type is unrecognized