@Test public void testAddToResponse_4() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug(""); fixture.setAuthorizationUrl(""); final HttpResponseBuilder responseBuilder = new HttpResponseBuilder(); final String errorCode = ""; final String errorDescription = ""; final String errorUri = null; final String errorExplanation = ""; fixture.addToResponse(responseBuilder, errorCode, errorDescription, errorUri, errorExplanation); }
@Test public void testGetAuthorizationUrl_1() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug(""); fixture.setAuthorizationUrl(""); final String result = fixture.getAuthorizationUrl(); Assert.assertEquals("", result); }
/** * Add a request/response pair to our trace of actions associated with this * request. */ public void addRequestTrace(final HttpRequest request, final HttpResponse response) { final List<Pair<HttpRequest, HttpResponse>> requestTrace = Lists.newArrayList(); requestTrace.add(Pair.of(request, response)); this.requestTraceString = OAuth2ResponseParams.getRequestTrace(requestTrace); }
@Test public void testSetAuthorizationUrl_1() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug(""); fixture.setAuthorizationUrl(""); final String authorizationUrl = ""; fixture.setAuthorizationUrl(authorizationUrl); } }
@Test public void testAddRequestTrace_1() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug(""); fixture.setAuthorizationUrl(""); final HttpResponseBuilder responseBuilder = new HttpResponseBuilder().setStrictNoCache(); final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI(""))); final HttpResponse response = responseBuilder.create(); fixture.addRequestTrace(request, response); }
@Test public void testOAuth2ResponseParams_1() throws Exception { final OAuth2ResponseParams result = new OAuth2ResponseParams(); Assert.assertNotNull(result); Assert.assertEquals(null, result.getAuthorizationUrl()); }
private HttpResponseBuilder getErrorResponseBuilder(final Throwable t, final OAuth2Error error, final String contextMessage, final String errorUri, final String errorDescription) { final boolean isLogging = BasicOAuth2Request.LOG.isLoggable(); if (isLogging) { BasicOAuth2Request.LOG.entering(BasicOAuth2Request.LOG_CLASS, "getErrorResponseBuilder", new Object[] { t, error, contextMessage, errorUri, errorDescription }); } final HttpResponseBuilder ret = new HttpResponseBuilder().setHttpStatusCode( HttpResponse.SC_FORBIDDEN).setStrictNoCache(); if (t != null && this.sendTraceToClient) { final StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); final String message = sw.toString(); this.responseParams.addDebug(message); } if (this.sendTraceToClient) { this.responseParams.addToResponse(ret, error.getErrorCode(), error.getErrorDescription(contextMessage) + " , " + errorDescription, errorUri, error.getErrorExplanation()); } else { this.responseParams.addToResponse(ret, error.getErrorCode(), "", "", error.getErrorExplanation()); } if (isLogging) { BasicOAuth2Request.LOG.exiting(BasicOAuth2Request.LOG_CLASS, "getErrorResponseBuilder", ret); } return ret; }
private HttpResponse processResponse(final OAuth2Accessor accessor, final HttpResponseBuilder responseBuilder) { final boolean isLogging = BasicOAuth2Request.LOG.isLoggable(); if (isLogging) { BasicOAuth2Request.LOG.entering(BasicOAuth2Request.LOG_CLASS, "processResponse", new Object[] { accessor, responseBuilder == null }); } if (accessor.isErrorResponse() || responseBuilder == null) { return this.sendErrorResponse(accessor.getErrorException(), accessor.getError(), accessor.getErrorContextMessage(), accessor.getErrorUri(), ""); } if (this.responseParams.getAuthorizationUrl() != null) { responseBuilder.setMetadata(OAuth2ResponseParams.APPROVAL_URL, this.responseParams.getAuthorizationUrl()); accessor.setRedirecting(true); } else { accessor.setRedirecting(false); } final HttpResponse ret = responseBuilder.create(); if (isLogging) { BasicOAuth2Request.LOG.exiting(BasicOAuth2Request.LOG_CLASS, "processResponse", "response logged in fetch()"); } return ret; }
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; }
if (completeAuthUrl != null) { this.responseParams.setAuthorizationUrl(completeAuthUrl); accessor.setRedirecting(true); } else {
this.realRequest = request; this.securityToken = request.getSecurityToken(); this.responseParams = new OAuth2ResponseParams(); this.arguments = this.realRequest.getOAuth2Arguments();
@Test public void testAddDebug_1() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug(""); fixture.setAuthorizationUrl(""); final String message = ""; fixture.addDebug(message); }
@Test public void testAddRequestTrace_1() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug(""); fixture.setAuthorizationUrl(""); final HttpResponseBuilder responseBuilder = new HttpResponseBuilder().setStrictNoCache(); final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI(""))); final HttpResponse response = responseBuilder.create(); fixture.addRequestTrace(request, response); }
@Test public void testOAuth2ResponseParams_1() throws Exception { final OAuth2ResponseParams result = new OAuth2ResponseParams(); Assert.assertNotNull(result); Assert.assertEquals(null, result.getAuthorizationUrl()); }
@Test public void testAddToResponse_8() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug((String) null); fixture.setAuthorizationUrl(""); final HttpResponseBuilder responseBuilder = new HttpResponseBuilder(); final String errorCode = ""; final String errorDescription = ""; final String errorUri = ""; final String errorExplanation = ""; fixture.addToResponse(responseBuilder, errorCode, errorDescription, errorUri, errorExplanation); }
@Test public void testAddDebug_1() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug(""); fixture.setAuthorizationUrl(""); final String message = ""; fixture.addDebug(message); }
@Test public void testGetAuthorizationUrl_1() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug(""); fixture.setAuthorizationUrl(""); final String result = fixture.getAuthorizationUrl(); Assert.assertEquals("", result); }
@Test public void testAddToResponse_11() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug((String) null); fixture.setAuthorizationUrl(""); final HttpResponseBuilder responseBuilder = new HttpResponseBuilder(); final String errorCode = null; final String errorDescription = null; final String errorUri = null; final String errorExplanation = null; fixture.addToResponse(responseBuilder, errorCode, errorDescription, errorUri, errorExplanation); }
@Test public void testSetAuthorizationUrl_1() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug(""); fixture.setAuthorizationUrl(""); final String authorizationUrl = ""; fixture.setAuthorizationUrl(authorizationUrl); } }
@Test public void testAddToResponse_16() throws Exception { final OAuth2ResponseParams fixture = new OAuth2ResponseParams(); fixture.addDebug((String) null); fixture.setAuthorizationUrl(""); final HttpResponseBuilder responseBuilder = new HttpResponseBuilder(); final String errorCode = null; final String errorDescription = ""; final String errorUri = ""; final String errorExplanation = ""; fixture.addToResponse(responseBuilder, errorCode, errorDescription, errorUri, errorExplanation); }