org.appng.core.security

## Class DigestValidator

- java.lang.Object
- - org.appng.core.security.DigestValidator

-     public class DigestValidator
      extends Object

  Utility class to validate a digest.
  Author:
    Matthias Herlitzius, Matthias Müller
  See Also:
    `DigestUtil`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DigestValidator(String digest)` Validate the digest, assuming a maximum age of 3 minutes.
    `DigestValidator(String digest, int maxOffsetMinutes)` Validate the digest.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getTimestamp()` Returns the timestamp that was extracted from the digest.
    `String` | `getUsername()` Returns the username that was extracted from the digest.
    `String` | `getUtcOffset()` Returns the UTC offset that was extracted from the digest.
    `boolean` | `validate(String sharedSecret)` Validates the digest using the given shared secret.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DigestValidator

          public DigestValidator(String digest)

      Validate the digest, assuming a maximum age of 3 minutes.
      Parameters:
        `digest` - the digest to validate

    - #### DigestValidator

          public DigestValidator(String digest,
                                 int maxOffsetMinutes)

      Validate the digest.
      Parameters:
        `digest` - the digest to validate
        `maxOffsetMinutes` - the maximum age of the digest in minutes

  - ### Method Detail

    - #### validate

          public boolean validate(String sharedSecret)

      Validates the digest using the given shared secret.
      Parameters:
        `sharedSecret` - the shared secret
      Returns:
        - `true` if the digest is syntactically and semantically correct, i.e. if it not exceeds the maximum age and the hash value matches the expected one
        - `false` otherwise

    - #### getUsername

          public String getUsername()

      Returns the username that was extracted from the digest.
      Returns:
        the username, if the digest was syntactically correct, an empty String otherwise

    - #### getTimestamp

          public String getTimestamp()

      Returns the timestamp that was extracted from the digest.
      Returns:
        the timestamp, if the digest was syntactically correct, an empty String otherwise

    - #### getUtcOffset

          public String getUtcOffset()

      Returns the UTC offset that was extracted from the digest.
      Returns:
        the UTC offset, if the digest was syntactically correct, an empty String otherwise

Copyright © 2011–2023 aiticon GmbH. All rights reserved.