public HttpRequest getAuthorizationRequest(final OAuth2Accessor accessor, final String completeAuthorizationUrl) throws OAuth2RequestException { throw new OAuth2RequestException(CodeGrantTypeHandler.ERROR, "inappropriate call to CodeGrantTypeHandler.getAuthorizationRequest()", null); }
@Test public void testGetError_1() throws Exception { final OAuth2RequestException fixture = new OAuth2RequestException( OAuth2Error.AUTHENTICATION_PROBLEM, "", new Throwable()); final OAuth2Error result = fixture.getError(); Assert.assertNotNull(result); Assert.assertEquals("authentication_problem", result.getErrorCode()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.name()); Assert.assertEquals(2, result.ordinal()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.toString()); }
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; }
} catch (final OAuth2RequestException e) { authorizationRequest = null; ret = new OAuth2HandlerError(e.getError(), e.getErrorText(), e);
@Test public void testGetError_1() throws Exception { final OAuth2RequestException fixture = new OAuth2RequestException( OAuth2Error.AUTHENTICATION_PROBLEM, "", new Throwable()); final OAuth2Error result = fixture.getError(); Assert.assertNotNull(result); Assert.assertEquals("authentication_problem", result.getErrorCode()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.name()); Assert.assertEquals(2, result.ordinal()); Assert.assertEquals("AUTHENTICATION_PROBLEM", result.toString()); }
public void setSecret(final byte[] secret) throws OAuth2RequestException { this.secret = secret; try { this.encryptedSecret = this.encrypter == null ? secret : this.encrypter.encrypt(secret); } catch (final OAuth2EncryptionException e) { throw new OAuth2RequestException(OAuth2Error.SECRET_ENCRYPTION_PROBLEM, "OAuth2TokenPersistence could not encrypt the token secret", e); } }
public void setMacSecret(final byte[] secret) throws OAuth2RequestException { this.macSecret = secret; try { this.encryptedMacSecret = this.encrypter == null ? secret : this.encrypter.encrypt(secret); } catch (final OAuth2EncryptionException e) { throw new OAuth2RequestException(OAuth2Error.SECRET_ENCRYPTION_PROBLEM, "OAuth2TokenPersistence could not encrypt the mac secret", e); } }
private String getAuthorizationBody(final OAuth2Accessor accessor) throws OAuth2RequestException { String ret = ""; final Map<String, String> queryParams = Maps.newHashMap(); queryParams.put(OAuth2Message.GRANT_TYPE, this.getGrantType()); final String clientId = accessor.getClientId(); final byte[] secretBytes = accessor.getClientSecret(); String secret; try { secret = new String(secretBytes, "UTF-8"); } catch (final UnsupportedEncodingException e) { throw new OAuth2RequestException(OAuth2Error.CLIENT_CREDENTIALS_PROBLEM, "error getting authorization body", e); } queryParams.put(OAuth2Message.CLIENT_ID, clientId); queryParams.put(OAuth2Message.CLIENT_SECRET, secret); ret = OAuth2Utils.buildUrl(ret, queryParams, null); final char firstChar = ret.charAt(0); if (firstChar == '?' || firstChar == '&') { ret = ret.substring(1); } return ret; }
public String getCompleteUrl(final OAuth2Accessor accessor) throws OAuth2RequestException { throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "accessor is null", null); throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "accessor is invalid", null); throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "grant type is not client_credentials", null); throw new OAuth2RequestException(OAuth2Error.CLIENT_CREDENTIALS_PROBLEM, "problem getting complete url", e);
public String getCompleteUrl(final OAuth2Accessor accessor) throws OAuth2RequestException { if (accessor == null) { throw new OAuth2RequestException(CodeGrantTypeHandler.ERROR, "accessor is null", null); throw new OAuth2RequestException(CodeGrantTypeHandler.ERROR, "accessor is invalid", null); throw new OAuth2RequestException(CodeGrantTypeHandler.ERROR, "grant type is not code", null); queryParams.put(OAuth2Message.STATE, state.getEncryptedState()); } catch (final BlobCrypterException e) { throw new OAuth2RequestException(OAuth2Error.CODE_GRANT_PROBLEM, "encryption problem", e);
@Test public void testOAuth2RequestException_1() throws Exception { final OAuth2Error error = OAuth2Error.AUTHENTICATION_PROBLEM; final String errorText = ""; final Throwable cause = new Throwable(); final OAuth2RequestException result = new OAuth2RequestException(error, errorText, cause); Assert.assertNotNull(result); }
@Test public void testOAuth2RequestException_1() throws Exception { final OAuth2Error error = OAuth2Error.AUTHENTICATION_PROBLEM; final String errorText = ""; final Throwable cause = new Throwable(); final OAuth2RequestException result = new OAuth2RequestException(error, errorText, cause); Assert.assertNotNull(result); }
throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "completeAuthorizationUrl is null", null); throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "accessor is null", null); throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "accessor is invalid", null); throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "grant type is not client_credentials", null); request, accessor); if (error != null) { throw new OAuth2RequestException(error.getError(), error.getContextMessage(), error.getCause(), error.getUri(), error.getDescription()); request.setPostBody(this.getAuthorizationBody(accessor).getBytes("UTF-8")); } catch (final UnsupportedEncodingException e) { throw new OAuth2RequestException(OAuth2Error.CLIENT_CREDENTIALS_PROBLEM, "ClientCredentialsGrantTypeHandler - exception setting post body", e);
final OAuth2Spec oauthSpec = spec.getModulePrefs().getOAuth2Spec(); if (oauthSpec == null) { throw new OAuth2RequestException(OAuth2Error.LOOKUP_SPEC_PROBLEM, "Failed to retrieve OAuth URLs, spec for gadget " + securityToken.getAppUrl() + " does not contain OAuth element.", null); throw new OAuth2RequestException(OAuth2Error.LOOKUP_SPEC_PROBLEM, "Failed to retrieve OAuth URLs, spec for gadget does not contain OAuth service " + arguments.getServiceName() + ". Known services: "
GadgetOAuth2TokenStore.LOG.log("Error finding GadgetContext " + gadgetUri.toString(), e); throw new OAuth2RequestException(OAuth2Error.GADGET_SPEC_PROBLEM, gadgetUri.toString(), e); } catch (final GadgetException e) { if (isLogging) { GadgetOAuth2TokenStore.LOG.log("Error finding GadgetContext " + gadgetUri.toString(), e); throw new OAuth2RequestException(OAuth2Error.GADGET_SPEC_PROBLEM, gadgetUri.toString(), e);
this.store.removeToken(accessToken); } catch (final GadgetException e) { throw new OAuth2RequestException(OAuth2Error.MISSING_SERVER_RESPONSE, "error removing access_token", null); this.store.removeToken(refreshToken); } catch (final GadgetException e) { throw new OAuth2RequestException(OAuth2Error.MISSING_SERVER_RESPONSE, "error removing refresh_token", null); ret = this.fetcher.fetch(request); } catch (final GadgetException e) { throw new OAuth2RequestException(OAuth2Error.MISSING_SERVER_RESPONSE, "GadgetException fetchFromServer", e); throw new OAuth2RequestException(OAuth2Error.MISSING_SERVER_RESPONSE, "response is null", null); this.store.removeToken(accessToken); } catch (final GadgetException e) { throw new OAuth2RequestException(OAuth2Error.MISSING_SERVER_RESPONSE, "error removing access_token", null);