Package 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 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 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.
-
-
-
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 validatemaxOffsetMinutes
- 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 onefalse
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
-
-