Class OAuthUtils


  • public class OAuthUtils
    extends Object
    Helper methods for OAuth.
    • Constructor Detail

      • OAuthUtils

        public OAuthUtils​(String consumerKey,
                          String consumerSecret)
        Constructs a new instance.
        Parameters:
        consumerKey - the consumer key of the application
        consumerSecret - the consumer secret of the application
    • Method Detail

      • buildUrl

        public URL buildUrl​(String baseUrl,
                            Map<String,​String> params,
                            String token,
                            String tokenSecret)
        Builds a URL from the specified base URL and parameters. It adds all oauth_* parameters including the signature.
        Parameters:
        baseUrl - the base URL
        params - the parameters (can be empty or null)
        token - the oauth token
        tokenSecret - the oauth token secret
        Returns:
        the URL
      • getSignedOAuthParams

        public Map<String,​String> getSignedOAuthParams​(String baseUrl,
                                                             String token,
                                                             String tokenSecret)
        Gets oauth_* parameters with oauth_signature.
        Parameters:
        baseUrl - the base URL (before parameters)
        token - the OAuth token
        tokenSecret - the OAuth token secret
        Returns:
        the oauth_* parameters with oauth_signature
      • getOAuthParams

        public Map<String,​String> getOAuthParams​(String token)
        Gets oauth_* parameters without oauth_signature. You can sign it afterwards with addOAuthSignature(). You may add other oauth parameters in between. If you don't want to add other oauth parameters, you can use getSignedOAuthParams().
        Parameters:
        token - the token or null
        Returns:
        the oauth_* parameters
      • addOAuthSignature

        public void addOAuthSignature​(Map<String,​String> params,
                                      String baseUrl,
                                      String tokenSecret)
        Adds parameter oauth_signature to the specified oauth_* parameters.
        Parameters:
        params - the oauth parameters
        baseUrl - the base URL (before parameters)
        tokenSecret - the token secret