public OAuth2Request get() { return new BasicOAuth2Request(this.config, this.fetcher, this.authorizationEndpointResponseHandlers, this.clientAuthenticationHandlers, this.grantRequestHandlers, this.resourceRequestHandlers, this.tokenEndpointResponseHandlers, this.sendTraceToClient, this.requestParameterGenerator); } }
private OAuth2Accessor getAccessor() { if (this.internalAccessor == null || !this.internalAccessor.isValid()) { this.internalAccessor = this.getAccessorInternal(); } return this.internalAccessor; }
new Object[] { accessor }); BasicOAuth2Request.LOG.log("BasicOAuth2Request.haveAccessToken(accessor) = {0}", BasicOAuth2Request.haveAccessToken(accessor) != null); BasicOAuth2Request.LOG.log("BasicOAuth2Request.haveRefreshToken(accessor) = {0}", BasicOAuth2Request.haveRefreshToken(accessor) != null); return this.fetchData(accessor, true); return this.getErrorResponseBuilder(accessor.getErrorException(), accessor.getError(), accessor.getErrorContextMessage(), accessor.getErrorUri(), accessor.getErrorContextMessage()); } else { if (BasicOAuth2Request.haveAccessToken(accessor) != null) { ret = this.fetchData(accessor, this.attemptCounter > BasicOAuth2Request.MAX_ATTEMPTS); } else { if (BasicOAuth2Request.haveRefreshToken(accessor) != null) { if (BasicOAuth2Request.checkCanRefresh()) { boolean attempt = false; final String internedAccessor = getAccessorKey(accessor).intern(); if (isLogging) { BasicOAuth2Request.LOG.log("about to synchronize on {0}", internedAccessor); final OAuth2Accessor acc = this.getAccessorInternal(); if (isLogging) { BasicOAuth2Request.LOG.log("acc = {0}", acc); BasicOAuth2Request.LOG.log("BasicOAuth2Request.haveAccessToken(acc) = {0}", BasicOAuth2Request.haveAccessToken(acc) == null); BasicOAuth2Request.LOG.log("BasicOAuth2Request.haveRefreshToken(acc) = {0}",
response = this.sendErrorResponse(null, OAuth2Error.MISSING_FETCH_PARAMS, "no request or security token"); } else { return this.sendErrorResponse(null, OAuth2Error.FETCH_INIT_PROBLEM, "no responseParams or arguments"); accessor = this.getAccessor(); response = this.sendErrorResponse(null, OAuth2Error.FETCH_INIT_PROBLEM, "accessor is null"); } else { responseBuilder = this.attemptFetch(accessor); response = this.processResponse(accessor, responseBuilder); ""); response = this.processResponse(accessor, this.getErrorResponseBuilder(t, OAuth2Error.FETCH_PROBLEM, "exception occurred during fetch")); } finally {
private HttpResponseBuilder fetchData(final OAuth2Accessor accessor, final boolean lastAttempt) { final boolean isLogging = BasicOAuth2Request.LOG.isLoggable(); if (isLogging) { BasicOAuth2Request.LOG.entering(BasicOAuth2Request.LOG_CLASS, "fetchData", accessor); } HttpResponseBuilder ret = null; try { final HttpResponse response = this.fetchFromServer(accessor, this.realRequest, lastAttempt); if (response != null) { ret = new HttpResponseBuilder(response); if (response.getHttpStatusCode() != HttpResponse.SC_OK && this.sendTraceToClient) { this.responseParams.addRequestTrace(this.realRequest, response); } } } catch (final OAuth2RequestException e) { ret = this.getErrorResponseBuilder(e, e.getError(), e.getErrorText(), e.getErrorUri(), e.getErrorDescription()); } if (isLogging) { BasicOAuth2Request.LOG.exiting(BasicOAuth2Request.LOG_CLASS, "fetchData", ret); } return ret; }
refershTokenUrl = BasicOAuth2Request.buildRefreshTokenUrl(accessor); final byte[] body = BasicOAuth2Request.getRefreshBody(accessor).getBytes("UTF-8"); request.setPostBody(body); } catch (final Exception e) {
ret = completeAuthUrl; } else { final OAuth2HandlerError error = this.authorize(accessor, grantRequestHandlerUsed, completeAuthUrl); if (error != null) {