Class AbstractCredentialCallback

    • Method Detail

      • getCredential

        public Credential getCredential()
        Get the acquired credential.
        Returns:
        the acquired credential, or null if it wasn't set yet.
      • getCredential

        public <C extends Credential> C getCredential​(Class<C> credentialType)
        Get the acquired credential, if it is set and of the given type, and if so, return the credential cast to the type.
        Type Parameters:
        C - the credential type
        Parameters:
        credentialType - the credential type class (must not be null)
        Returns:
        the credential, or null if the criteria wasn't met
      • getCredential

        public <C extends Credential> C getCredential​(Class<C> credentialType,
                                                      String algorithmName)
        Get the acquired credential, if it is set and of the given type and algorithm, and if so, return the credential cast to the type.
        Type Parameters:
        C - the credential type
        Parameters:
        credentialType - the credential type class (must not be null)
        algorithmName - the algorithm name
        Returns:
        the credential, or null if the criteria are not met
      • getCredential

        public <C extends Credential> C getCredential​(Class<C> credentialType,
                                                      String algorithmName,
                                                      AlgorithmParameterSpec parameterSpec)
        Get the acquired credential, if it is set and of the given type, algorithm, and parameters, and if so, return the credential cast to the type.
        Type Parameters:
        C - the credential type
        Parameters:
        credentialType - the credential type class (must not be null)
        algorithmName - the algorithm name
        parameterSpec - the parameter specification to match, or null if any parameters are allowed or parameters are not used by the credential type
        Returns:
        the credential, or null if the criteria are not met
      • applyToCredential

        public <C extends Credential,​R> R applyToCredential​(Class<C> credentialType,
                                                                  Function<C,​R> function)
        Apply the given function to the acquired credential, if it is set and of the given type. By calling this method, it is possible to apply transformations to the stored credential without failing if the credential was not set.
        Type Parameters:
        C - the credential type
        R - the return type
        Parameters:
        credentialType - the credential type class (must not be null)
        function - the function to apply (must not be null)
        Returns:
        the result of the function, or null if the criteria are not met
      • applyToCredential

        public <C extends Credential,​R> R applyToCredential​(Class<C> credentialType,
                                                                  String algorithmName,
                                                                  Function<C,​R> function)
        Apply the given function to the acquired credential, if it is set and of the given type and algorithm. By calling this method, it is possible to apply transformations to the stored credential without failing if the credential was not set.
        Type Parameters:
        C - the credential type
        R - the return type
        Parameters:
        credentialType - the credential type class (must not be null)
        algorithmName - the algorithm name
        function - the function to apply (must not be null)
        Returns:
        the result of the function, or null if the criteria are not met
      • applyToCredential

        public <C extends Credential,​R> R applyToCredential​(Class<C> credentialType,
                                                                  String algorithmName,
                                                                  AlgorithmParameterSpec parameterSpec,
                                                                  Function<C,​R> function)
        Apply the given function to the acquired credential, if it is set and of the given type and algorithm. By calling this method, it is possible to apply transformations to the stored credential without failing if the credential was not set.
        Type Parameters:
        C - the credential type
        R - the return type
        Parameters:
        credentialType - the credential type class (must not be null)
        algorithmName - the algorithm name
        parameterSpec - the parameter specification to match, or null if any parameters are allowed or parameters are not used by the credential type
        function - the function to apply (must not be null)
        Returns:
        the result of the function, or null if the criteria are not met
      • setCredential

        public void setCredential​(Credential credential)
        Set the credential. The credential must be of the supported type and algorithm.
        Parameters:
        credential - the credential, or null to indicate that no credential is available
        Throws:
        IllegalArgumentException - if the given credential is not supported
      • isCredentialTypeSupported

        public boolean isCredentialTypeSupported​(Class<? extends Credential> credentialType)
        Determine whether the given credential type is supported. Will be false if the credential type requires an algorithm name; in this case, use isCredentialTypeSupported(Class, String) instead.
        Parameters:
        credentialType - the credential type (must not be null)
        Returns:
        true if the credential type is supported, false otherwise
      • isCredentialTypeSupported

        public boolean isCredentialTypeSupported​(Class<? extends Credential> credentialType,
                                                 String algorithmName)
        Determine whether the given credential type is supported for the given algorithm name.
        Parameters:
        credentialType - the credential type (must not be null)
        algorithmName - the algorithm name, or null to indicate that no algorithm name will be available
        Returns:
        true if the credential type is supported, false otherwise
      • isCredentialTypeSupported

        public boolean isCredentialTypeSupported​(Class<? extends Credential> credentialType,
                                                 String algorithmName,
                                                 AlgorithmParameterSpec parameterSpec)
        Determine whether the given credential type is supported for the given algorithm name.
        Parameters:
        credentialType - the credential type (must not be null)
        algorithmName - the algorithm name, or null to indicate that no algorithm name will be available
        parameterSpec - the parameters, or null if no parameters are present in the credential
        Returns:
        true if the credential type is supported, false otherwise
      • isCredentialSupported

        public boolean isCredentialSupported​(Credential credential)
        Determine whether the given credential can be set on this callback.
        Parameters:
        credential - the credential (must not be null)
        Returns:
        true if the credential matches the type and optional algorithm of this callback, false otherwise
      • getCredentialType

        public Class<? extends Credential> getCredentialType()
        Get the supported credential type.
        Returns:
        the supported credential type (not null)
      • getAlgorithm

        public String getAlgorithm()
        Get the algorithm name, if any.
        Returns:
        the algorithm name, or null if any algorithm is suitable or the credential type does not use algorithm names
      • getParameterSpec

        public AlgorithmParameterSpec getParameterSpec()
        Get the parameter specification, if any.
        Returns:
        the parameter specification, or null if any parameters are suitable or the credential type does not use parameters
      • needsInformation

        public boolean needsInformation()
        Description copied from interface: ExtendedCallback
        Determine if this callback is requesting information.
        Specified by:
        needsInformation in interface ExtendedCallback
        Returns:
        true if the callback is requesting information, false if it is only providing information