}
}
public OAuthToken makeAccessToken(String consumerKey, String requestTokenKey,
String verifier) throws OAuthException {
OAuthRequestToken requestToken = verifyAndRemoveRequestToken(consumerKey, requestTokenKey, verifier);
try {
String token = makeRandomString();
String secret = makeRandomString();
String[] scopes = requestToken.getScopes();
String[] permissions = requestToken.getPermissions();
update("INSERT INTO access_tokens(token,consumer_key,secret,scopes,permissions) "
+ "VALUES('" + token + "', '" + consumerKey + "', '"
+ secret + "'"
+ ", " + (scopes != null ? "'" + scopes[0] + "'" : null)
+ ", " + (permissions != null ? "'" + permissions[0] + "'" : null)
+ ")");
return new OAuthToken(token, secret,
requestToken.getScopes(), requestToken.getPermissions(), -1, requestToken.getConsumer());
} catch (SQLException ex) {
throw new OAuthException(HttpURLConnection.HTTP_UNAUTHORIZED,
"Request token for the consumer with key " + consumerKey + " can not be created");
}
}