Package io.vertx.ext.auth.authentication

## Interface Credentials

- All Known Implementing Classes:
    `HtdigestCredentials`, `Oauth2Credentials`, `OtpCredentials`, `TokenCredentials`, `UsernamePasswordCredentials`, `WebAuthn4JCredentials`

      public interface Credentials

  Abstract representation of a Credentials object. All implementations of this interface will define the required types and parameters for the specific implementation.
  Author:
    Paulo Lopes

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `default Credentials` | `applyHttpChallenge​(String challenge)` | Applies the HTTP Authorization challenge to this Credential instance.
    `default Credentials` | `applyHttpChallenge​(String challenge, HttpMethod method, String uri)` | Applies the HTTP Authorization challenge to this Credential instance.
    `default Credentials` | `applyHttpChallenge​(String challenge, HttpMethod method, String uri, Integer nc, String cnonce)` | Applies the HTTP Authorization challenge to this Credential instance.
    `default <V> void` | `checkValid​(V arg)` | Implementors should override this method to perform validation.
    `default String` | `toHttpAuthorization()` | Encodes this credential as an HTTP Authorization https://tools.ietf.org/html/rfc7235.
    `JsonObject` | `toJson()` | Simple interop to downcast back to JSON for backwards compatibility.

- - ### Method Detail

    - #### checkValid

          default <V> void checkValid​(V arg)
                               throws CredentialValidationException

      Implementors should override this method to perform validation. An argument is allowed to allow custom validation, for example, when given a configuration property, a specific property may be allowed to be null.
      Type Parameters:
        `V` - the generic type of the argument
      Parameters:
        `arg` - optional argument or null.
      Throws:
        `CredentialValidationException` - when the validation fails

    - #### toJson

          JsonObject toJson()

      Simple interop to downcast back to JSON for backwards compatibility.
      Returns:
        JSON representation of this credential.

    - #### applyHttpChallenge

          default Credentials applyHttpChallenge​(String challenge,
                                                 HttpMethod method,
                                                 String uri,
                                                 Integer nc,
                                                 String cnonce)
                                          throws CredentialValidationException

      Applies the HTTP Authorization challenge to this Credential instance. The internal state can change to reflect the extra properties the challenge conveys.

      See https://tools.ietf.org/html/rfc7235 for more information.

      Parameters:
        `challenge` - the challenge is the `WWW-Authenticate` header response from a 401 request. Null challenges are allowed, and in this case, no verification will be performed, however it is up to the implementation to permit this.
        `method` - The http method this response is responding.
        `uri` - The http uri this response is responding.
        `nc` - The client internal counter (optional).
        `cnonce` - The client internal nonce (optional).
      Returns:
        fluent self.
      Throws:
        `CredentialValidationException` - if the challenge cannot be applicable.

    - #### applyHttpChallenge

          default Credentials applyHttpChallenge​(String challenge,
                                                 HttpMethod method,
                                                 String uri)
                                          throws CredentialValidationException

      Applies the HTTP Authorization challenge to this Credential instance. The internal state can change to reflect the extra properties the challenge conveys.

      See https://tools.ietf.org/html/rfc7235 for more information.

      Parameters:
        `challenge` - the challenge is the `WWW-Authenticate` header response from a 401 request. Null challenges are allowed, and in this case, no verification will be performed, however it is up to the implementation to permit this.
        `method` - The http method this response is responding.
        `uri` - The http uri this response is responding.
      Returns:
        fluent self.
      Throws:
        `CredentialValidationException` - if the challenge cannot be applicable.

    - #### applyHttpChallenge

          default Credentials applyHttpChallenge​(String challenge)
                                          throws CredentialValidationException

      Applies the HTTP Authorization challenge to this Credential instance. The internal state can change to reflect the extra properties the challenge conveys.

      See https://tools.ietf.org/html/rfc7235 for more information.

      Parameters:
        `challenge` - the challenge is the `WWW-Authenticate` header response from a 401 request. Null challenges are allowed, and in this case, no verification will be performed, however it is up to the implementation to permit this.
      Returns:
        fluent self.
      Throws:
        `CredentialValidationException` - if the challenge cannot be applicable.

    - #### toHttpAuthorization

          default String toHttpAuthorization()

      Encodes this credential as an HTTP Authorization https://tools.ietf.org/html/rfc7235.

      Calls to this method, expect that `applyHttpChallenge(String, HttpMethod, String, Integer, String)` has been prior executed. For some Authentication schemes, this isn't a requirement but doing so ensures that the object is on the right state.

      Returns:
        HTTP header including scheme.
      Throws:
        `UnsupportedOperationException` - when the the credential object cannot be converted to a HTTP Authorization.