Changeset 6849 in josm for trunk/src/oauth/signpost/AbstractOAuthProvider.java
- Timestamp:
- 2014-02-13T21:10:18+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/oauth/signpost/AbstractOAuthProvider.java
r4231 r6849 58 58 } 59 59 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 { 63 64 64 65 // invalidate current credentials, if any … … 67 68 // 1.0a expects the callback to be sent while getting the request token. 68 69 // 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); 70 75 71 76 String callbackConfirmed = responseParameters.getFirst(OAuth.OAUTH_CALLBACK_CONFIRMED); … … 84 89 } 85 90 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 { 89 95 90 96 if (consumer.getToken() == null || consumer.getTokenSecret() == null) { … … 94 100 } 95 101 102 HttpParameters params = new HttpParameters(); 103 params.putAll(customOAuthParams, true); 104 96 105 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); 101 109 } 102 110 … … 126 134 * the URL at which the service provider serves the OAuth token that 127 135 * 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. 134 140 * @throws OAuthMessageSignerException 135 141 * if signing the token request fails … … 143 149 */ 144 150 protected void retrieveToken(OAuthConsumer consumer, String endpointUrl, 145 String... additionalParameters) throws OAuthMessageSignerException,151 HttpParameters customOAuthParams) throws OAuthMessageSignerException, 146 152 OAuthCommunicationException, OAuthNotAuthorizedException, 147 153 OAuthExpectationFailedException { … … 159 165 request.setHeader(header, defaultHeaders.get(header)); 160 166 } 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 167 171 if (this.listener != null) { 168 172 this.listener.prepareRequest(request); … … 170 174 171 175 consumer.sign(request); 172 176 173 177 if (this.listener != null) { 174 178 this.listener.prepareSubmission(request);
Note:
See TracChangeset
for help on using the changeset viewer.