Class DigestValidator


  • public class DigestValidator
    extends Object
    Utility class to validate a digest.
    Author:
    Matthias Herlitzius, Matthias Müller
    See Also:
    DigestUtil
    • 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