public class SimpleOAuthValidator extends Object implements OAuthValidator
This implementation is less than industrial strength:
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_MAX_TIMESTAMP_AGE
The default maximum age of timestamps is 5 minutes.
|
static long |
DEFAULT_TIMESTAMP_WINDOW |
protected long |
maxTimestampAgeMsec |
protected double |
maxVersion |
protected double |
minVersion |
static Set<String> |
SINGLE_PARAMETERS
Names of parameters that may not appear twice in a valid message.
|
Constructor and Description |
---|
SimpleOAuthValidator()
Construct a validator that rejects messages more than five minutes old or
with a OAuth version other than 1.0.
|
SimpleOAuthValidator(long maxTimestampAgeMsec,
double maxVersion)
Public constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkSingleParameters(OAuthMessage message)
Throw an exception if any SINGLE_PARAMETERS occur repeatedly.
|
protected long |
currentTimeMsec()
Get the number of milliseconds since midnight, January 1, 1970 UTC.
|
Date |
releaseGarbage()
Allow objects that are no longer useful to become garbage.
|
void |
validateMessage(OAuthMessage message,
OAuthAccessor accessor) |
protected Date |
validateNonce(OAuthMessage message,
long timestamp,
long currentTimeMsec)
Throw an exception if the nonce has been validated previously.
|
protected void |
validateSignature(OAuthMessage message,
OAuthAccessor accessor) |
protected void |
validateTimestamp(OAuthMessage message,
long timestamp,
long currentTimeMsec)
Throw an exception if the timestamp [sec] is out of range.
|
protected void |
validateTimestampAndNonce(OAuthMessage message)
Throw an exception if the timestamp is out of range or the nonce has been
validated previously.
|
protected void |
validateVersion(OAuthMessage message) |
public static final long DEFAULT_MAX_TIMESTAMP_AGE
public static final long DEFAULT_TIMESTAMP_WINDOW
public static final Set<String> SINGLE_PARAMETERS
protected final double minVersion
protected final double maxVersion
protected final long maxTimestampAgeMsec
public SimpleOAuthValidator()
public SimpleOAuthValidator(long maxTimestampAgeMsec, double maxVersion)
maxTimestampAgeMsec
- the range of valid timestamps, in milliseconds into the past
or future. So the total range of valid timestamps is twice
this value, rounded to the nearest second.maxVersion
- the maximum valid oauth_versionpublic Date releaseGarbage()
public void validateMessage(OAuthMessage message, OAuthAccessor accessor) throws OAuthException, IOException, URISyntaxException
validateMessage
in interface OAuthValidator
URISyntaxException
OAuthException
- the message doesn't conform to OAuth. The exception contains
information that conforms to the OAuth Problem
Reporting extension.IOException
- the message couldn't be read.protected void checkSingleParameters(OAuthMessage message) throws IOException, OAuthException
IOException
OAuthException
protected void validateVersion(OAuthMessage message) throws OAuthException, IOException
OAuthException
IOException
protected void validateTimestampAndNonce(OAuthMessage message) throws IOException, OAuthProblemException
IOException
OAuthProblemException
protected void validateTimestamp(OAuthMessage message, long timestamp, long currentTimeMsec) throws IOException, OAuthProblemException
IOException
OAuthProblemException
protected Date validateNonce(OAuthMessage message, long timestamp, long currentTimeMsec) throws IOException, OAuthProblemException
IOException
OAuthProblemException
protected void validateSignature(OAuthMessage message, OAuthAccessor accessor) throws OAuthException, IOException, URISyntaxException
protected long currentTimeMsec()
Copyright © 2023. All rights reserved.