do not include the token in the signature if it's empty

This commit is contained in:
Pablo Fernandez committed 2012-06-22 13:28:05 -03:00
1 parent 2f55386995
commit 97fa26fce7
2 files changed
+23 -1

No files matched your search

+18
View File
@@ -57,4 +57,22 @@ public class Token implements Serializable
{
return String.format("Token[%s , %s]", token, secret);
}
/**
* Returns true if the token is empty (token = "", secret = "")
*/
public boolean isEmpty()
{
return "".equals(this.token) && "".equals(this.secret);
}
/**
* Factory method that returns an empty token (token = "", secret = "").
*
* Useful for two legged OAuth.
*/
public static Token empty()
{
return new Token("","");
}
}
@@ -88,8 +88,12 @@ public class OAuth10aServiceImpl implements OAuthService
public void signRequest(Token token, OAuthRequest request)
{
config.log("signing request: " + request.getCompleteUrl());
request.addOAuthParameter(OAuthConstants.TOKEN, token.getToken());
// Do not append the token if empty. This is for two legged OAuth calls.
if (!token.isEmpty())
{
request.addOAuthParameter(OAuthConstants.TOKEN, token.getToken());
}
config.log("setting token to: " + token);
addOAuthParams(request, token);
appendSignature(request);