* thrown if malformed URI was sent in the message.
*/
private OAuthEntry getValidatedEntry(final OAuthMessage requestMessage) throws IOException,
OAuthException, URISyntaxException
{
OAuthEntry entry = dataStore.getEntry(requestMessage.getToken());
if (entry == null)
{
throw new OAuthProblemException(OAuth.Problems.TOKEN_REJECTED);
}
if (entry.getType() != OAuthEntry.Type.REQUEST)
{
throw new OAuthProblemException(OAuth.Problems.TOKEN_USED);
}
if (entry.isExpired())
{
throw new OAuthProblemException(OAuth.Problems.TOKEN_EXPIRED);
}
// find consumer key, compare with supplied value, if present.
if (requestMessage.getConsumerKey() == null)
{
OAuthProblemException e = new OAuthProblemException(OAuth.Problems.PARAMETER_ABSENT);
e.setParameter(OAuth.Problems.OAUTH_PARAMETERS_ABSENT, OAuth.OAUTH_CONSUMER_KEY);
throw e;
}
String consumerKey = entry.getConsumerKey();
if (!consumerKey.equals(requestMessage.getConsumerKey()))
{
throw new OAuthProblemException(OAuth.Problems.CONSUMER_KEY_REFUSED);
}
OAuthConsumer consumer = dataStore.getConsumer(consumerKey);
if (consumer == null)
{
throw new OAuthProblemException(OAuth.Problems.CONSUMER_KEY_UNKNOWN);
}
OAuthAccessor accessor = new OAuthAccessor(consumer);
accessor.requestToken = entry.getToken();
accessor.tokenSecret = entry.getTokenSecret();
VALIDATOR.validateMessage(requestMessage, accessor);
return entry;
}