OltuOAuth2ClientFacade implements OAuth2ClientFacade { @Override public void requestAccessToken(OAuth2Profile profile) throws OAuth2Exception { try { OAuth2Parameters parameters = buildParametersFrom(profile); OAuthParameterValidator.validate(parameters); getOAuth2TokenExtractor().extractAccessToken(parameters); } catch (OAuthSystemException e) { logAndThrowOAuth2Exception(e); } catch (MalformedURLException e) { logAndThrowOAuth2Exception(e); } catch (URISyntaxException e) { logAndThrowOAuth2Exception(e); } catch (OAuthProblemException e) { e.printStackTrace(); } }  @Override void requestAccessToken(OAuth2Profile profile); @Override void refreshAccessToken(OAuth2Profile profile); @Override void applyAccessToken(OAuth2Profile profile, HttpRequestBase request, String requestContent);  }
@Test public void getsTheAccessTokenForAuthorizationCodeGrantFlow() throws OAuth2Exception { oltuClientFacade.requestAccessToken(profile); assertThat(profile.getAccessToken(), is(OAuth2TestUtils.ACCESS_TOKEN)); }
@Test public void getsTheAccessTokenForImplicitGrantFlow() throws OAuth2Exception { profile.setOAuth2Flow(OAuth2Profile.OAuth2Flow.IMPLICIT_GRANT); oltuClientFacade.requestAccessToken(profile); assertThat(profile.getAccessToken(), is(OAuth2TestUtils.ACCESS_TOKEN)); }
@Test(expected = InvalidOAuthParametersException.class) public void rejectsUrnAsAuthorizationURI() throws Exception { profile.setAuthorizationURI(OAuth2TestUtils.OAUTH_2_OOB_URN); oltuClientFacade.requestAccessToken(profile); }
@Test(expected = InvalidOAuthParametersException.class) public void rejectsNonHttpAuthorizationUrl() throws Exception { profile.setAuthorizationURI("ftp: oltuClientFacade.requestAccessToken(profile); }
@Test(expected = InvalidOAuthParametersException.class) public void rejectsNonUriRedirectUri() throws Exception { profile.setRedirectURI("(/&#)!#%/(¤#!"); oltuClientFacade.requestAccessToken(profile); }
@Test(expected = InvalidOAuthParametersException.class) public void rejectsUrnAsAccessTokenURI() throws Exception { profile.setAccessTokenURI(OAuth2TestUtils.OAUTH_2_OOB_URN); oltuClientFacade.requestAccessToken(profile); }
@Test(expected = InvalidOAuthParametersException.class) public void rejectsNonHttpAccessTokenURI() throws Exception { profile.setAccessTokenURI("ftp: oltuClientFacade.requestAccessToken(profile); }
@Test(expected = InvalidOAuthParametersException.class) public void rejectsEmptyClientId() throws Exception { profile.setClientID(""); oltuClientFacade.requestAccessToken(profile); }
@Test(expected = InvalidOAuthParametersException.class) public void rejectsEmptyClientSecret() throws Exception { profile.setClientSecret(""); oltuClientFacade.requestAccessToken(profile); }