Ignore:
Timestamp:
2014-02-13T21:10:18+01:00 (11 years ago)
Author:
stoecker
Message:

see #9710 - update oauth library code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/oauth/signpost/AbstractOAuthProvider.java

    r4231 r6849  
    5858    }
    5959
    60     public String retrieveRequestToken(OAuthConsumer consumer, String callbackUrl)
    61             throws OAuthMessageSignerException, OAuthNotAuthorizedException,
    62             OAuthExpectationFailedException, OAuthCommunicationException {
     60    public synchronized String retrieveRequestToken(OAuthConsumer consumer, String callbackUrl,
     61            String... customOAuthParams) throws OAuthMessageSignerException,
     62            OAuthNotAuthorizedException, OAuthExpectationFailedException,
     63            OAuthCommunicationException {
    6364
    6465        // invalidate current credentials, if any
     
    6768        // 1.0a expects the callback to be sent while getting the request token.
    6869        // 1.0 service providers would simply ignore this parameter.
    69         retrieveToken(consumer, requestTokenEndpointUrl, OAuth.OAUTH_CALLBACK, callbackUrl);
     70        HttpParameters params = new HttpParameters();
     71        params.putAll(customOAuthParams, true);
     72        params.put(OAuth.OAUTH_CALLBACK, callbackUrl, true);
     73
     74        retrieveToken(consumer, requestTokenEndpointUrl, params);
    7075
    7176        String callbackConfirmed = responseParameters.getFirst(OAuth.OAUTH_CALLBACK_CONFIRMED);
     
    8489    }
    8590
    86     public void retrieveAccessToken(OAuthConsumer consumer, String oauthVerifier)
    87             throws OAuthMessageSignerException, OAuthNotAuthorizedException,
    88             OAuthExpectationFailedException, OAuthCommunicationException {
     91    public synchronized void retrieveAccessToken(OAuthConsumer consumer, String oauthVerifier,
     92            String... customOAuthParams) throws OAuthMessageSignerException,
     93            OAuthNotAuthorizedException, OAuthExpectationFailedException,
     94            OAuthCommunicationException {
    8995
    9096        if (consumer.getToken() == null || consumer.getTokenSecret() == null) {
     
    94100        }
    95101
     102        HttpParameters params = new HttpParameters();
     103        params.putAll(customOAuthParams, true);
     104
    96105        if (isOAuth10a && oauthVerifier != null) {
    97             retrieveToken(consumer, accessTokenEndpointUrl, OAuth.OAUTH_VERIFIER, oauthVerifier);
    98         } else {
    99             retrieveToken(consumer, accessTokenEndpointUrl);
    100         }
     106            params.put(OAuth.OAUTH_VERIFIER, oauthVerifier, true);
     107        }
     108        retrieveToken(consumer, accessTokenEndpointUrl, params);
    101109    }
    102110
     
    126134     *        the URL at which the service provider serves the OAuth token that
    127135     *        is to be fetched
    128      * @param additionalParameters
    129      *        you can pass parameters here (typically OAuth parameters such as
    130      *        oauth_callback or oauth_verifier) which will go directly into the
    131      *        signer, i.e. you don't have to put them into the request first,
    132      *        just so the consumer pull them out again. Pass them sequentially
    133      *        in key/value order.
     136     * @param customOAuthParams
     137     *        you can pass custom OAuth parameters here (such as oauth_callback
     138     *        or oauth_verifier) which will go directly into the signer, i.e.
     139     *        you don't have to put them into the request first.
    134140     * @throws OAuthMessageSignerException
    135141     *         if signing the token request fails
     
    143149     */
    144150    protected void retrieveToken(OAuthConsumer consumer, String endpointUrl,
    145             String... additionalParameters) throws OAuthMessageSignerException,
     151            HttpParameters customOAuthParams) throws OAuthMessageSignerException,
    146152            OAuthCommunicationException, OAuthNotAuthorizedException,
    147153            OAuthExpectationFailedException {
     
    159165                request.setHeader(header, defaultHeaders.get(header));
    160166            }
    161             if (additionalParameters != null) {
    162                 HttpParameters httpParams = new HttpParameters();
    163                 httpParams.putAll(additionalParameters, true);
    164                 consumer.setAdditionalParameters(httpParams);
    165             }
    166 
     167            if (customOAuthParams != null && !customOAuthParams.isEmpty()) {
     168                consumer.setAdditionalParameters(customOAuthParams);
     169            }
     170           
    167171            if (this.listener != null) {
    168172                this.listener.prepareRequest(request);
     
    170174
    171175            consumer.sign(request);
    172 
     176           
    173177            if (this.listener != null) {
    174178                this.listener.prepareSubmission(request);
Note: See TracChangeset for help on using the changeset viewer.