Ejemplo n.º 1
0
        /**
         * Fetch data and build a response to return to the client.  We try to always return something
         * reasonable to the calling app no matter what kind of madness happens along the way.  If an
         * unchecked exception occurs, well, then the client is out of luck.
         */
        private sResponse fetchNoThrow()
        {
            HttpResponseBuilder response = null;

            try
            {
                accessorInfo = fetcherConfig.getTokenStore().getOAuthAccessor(
                    realRequest.getSecurityToken(), realRequest.getOAuthArguments(), clientState,
                    responseParams);
                response = fetchWithRetry();
            }
            catch (OAuthResponseParams.OAuthRequestException e)
            {
                // No data for us.
                responseParams.logDetailedWarning("OAuth fetch fatal error", e);
                responseParams.setSendTraceToClient(true);
                if (response == null)
                {
                    response = new HttpResponseBuilder()
                               .setHttpStatusCode(sResponse.SC_FORBIDDEN);
                    responseParams.addToResponse(response);
                    return(response.create());
                }
            }

            // OK, got some data back, annotate it as necessary.
            if (response.getHttpStatusCode() >= 400)
            {
                responseParams.logDetailedWarning("OAuth fetch fatal error");
                responseParams.setSendTraceToClient(true);
            }
            else if (responseParams.getAznUrl() != null && responseParams.sawErrorResponse())
            {
                responseParams.logDetailedWarning("OAuth fetch error, reprompting for user approval");
                responseParams.setSendTraceToClient(true);
            }

            responseParams.addToResponse(response);

            return(response.create());
        }