Package net.oauth
Class SimpleOAuthValidator
- java.lang.Object
-
- net.oauth.SimpleOAuthValidator
-
- All Implemented Interfaces:
OAuthValidator
public class SimpleOAuthValidator extends Object implements OAuthValidator
A simple OAuthValidator, which checks the version, whether the timestamp is close to now and the signature is valid. Each check may be overridden.- Author:
- Dirk Balfanz, John Kristian
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_TIMESTAMP_WINDOWThe default window for timestamps is 5 minutes.protected doublemaxVersionprotected doubleminVersionstatic Set<String>SINGLE_PARAMETERSNames of parameters that may not appear twice in a valid message.protected longtimestampWindow
-
Constructor Summary
Constructors Constructor Description SimpleOAuthValidator()Construct a validator that rejects messages more than five minutes out of date, or with a OAuth version other than 1.0, or with an invalid signature.SimpleOAuthValidator(long timestampWindowMsec, double maxVersion)Public constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckSingleParameters(OAuthMessage message)Throw an exception if any SINGLE_PARAMETERS occur repeatedly.protected longcurrentTimeMsec()voidvalidateMessage(OAuthMessage message, OAuthAccessor accessor)protected voidvalidateSignature(OAuthMessage message, OAuthAccessor accessor)protected voidvalidateTimestampAndNonce(OAuthMessage message)This implementation doesn't check the nonce value.protected voidvalidateVersion(OAuthMessage message)
-
-
-
Field Detail
-
DEFAULT_TIMESTAMP_WINDOW
public static final long DEFAULT_TIMESTAMP_WINDOW
The default window for timestamps is 5 minutes.- See Also:
- Constant Field Values
-
SINGLE_PARAMETERS
public static final Set<String> SINGLE_PARAMETERS
Names of parameters that may not appear twice in a valid message. This limitation is specified by OAuth Core section 5.
-
minVersion
protected final double minVersion
- See Also:
- Constant Field Values
-
maxVersion
protected final double maxVersion
-
timestampWindow
protected final long timestampWindow
-
-
Constructor Detail
-
SimpleOAuthValidator
public SimpleOAuthValidator()
Construct a validator that rejects messages more than five minutes out of date, or with a OAuth version other than 1.0, or with an invalid signature.
-
SimpleOAuthValidator
public SimpleOAuthValidator(long timestampWindowMsec, double maxVersion)Public constructor.- Parameters:
timestampWindowSec- specifies, in seconds, the windows (into the past and into the future) in which we'll accept timestamps.maxVersion- the maximum acceptable oauth_version
-
-
Method Detail
-
validateMessage
public void validateMessage(OAuthMessage message, OAuthAccessor accessor) throws OAuthException, IOException, URISyntaxException
- Specified by:
validateMessagein interfaceOAuthValidator- Throws:
URISyntaxExceptionOAuthException- TODOOAuthProblemException- the message is invalid. The implementation should throw exceptions that conform to the OAuth Problem Reporting extension.IOException- TODO
-
checkSingleParameters
protected void checkSingleParameters(OAuthMessage message) throws IOException, OAuthException
Throw an exception if any SINGLE_PARAMETERS occur repeatedly.- Throws:
IOExceptionOAuthException
-
validateVersion
protected void validateVersion(OAuthMessage message) throws OAuthException, IOException
- Throws:
OAuthExceptionIOException
-
validateTimestampAndNonce
protected void validateTimestampAndNonce(OAuthMessage message) throws IOException, OAuthProblemException
This implementation doesn't check the nonce value.- Throws:
IOExceptionOAuthProblemException
-
validateSignature
protected void validateSignature(OAuthMessage message, OAuthAccessor accessor) throws OAuthException, IOException, URISyntaxException
-
currentTimeMsec
protected long currentTimeMsec()
-
-