@Test(expected = ThirdPartyErrorException.class) public void testLoadUserUnparseable() { OAuth2IdPToken result = new OAuth2IdPToken(); result.setAccessToken("github_access_token"); doThrow(ProcessingException.class) .when(getResponse).readEntity(GithubUserEntity.class); githubAuth.loadUserIdentity(result); }
@Override protected OAuth2User loadUserIdentity(final OAuth2IdPToken token) { Response r = getClient() .target(USER_ENDPOINT) .request() .header(HttpHeaders.AUTHORIZATION, HttpUtil.authHeaderBearer(token.getAccessToken())) .get(); try { if (r.getStatusInfo().getFamily().equals(Family.SUCCESSFUL)) { GithubUserEntity githubUser = r.readEntity(GithubUserEntity.class); if (githubUser.getId() == null) { throw new ThirdPartyErrorException(); } return githubUser.asGenericUser(); } else { Map<String, String> params = r.readEntity(MAP_TYPE); throw new ThirdPartyErrorException(params); } } catch (ProcessingException e) { throw new ThirdPartyErrorException(); } finally { r.close(); } }
GithubAuthenticator extends AbstractOAuth2Authenticator { @Override protected OAuth2User loadUserIdentity(final OAuth2IdPToken token) { Response r = getClient() .target(USER_ENDPOINT) .request() .header(HttpHeaders.AUTHORIZATION, HttpUtil.authHeaderBearer(token.getAccessToken())) .get(); try { if (r.getStatusInfo().getFamily().equals(Family.SUCCESSFUL)) { GithubUserEntity githubUser = r.readEntity(GithubUserEntity.class); if (githubUser.getId() == null) { throw new ThirdPartyErrorException(); } return githubUser.asGenericUser(); } else { Map<String, String> params = r.readEntity(MAP_TYPE); throw new ThirdPartyErrorException(params); } } catch (ProcessingException e) { throw new ThirdPartyErrorException(); } finally { r.close(); } } }
GithubAuthenticator extends AbstractOAuth2Authenticator { @Override protected OAuth2User loadUserIdentity(final OAuth2IdPToken token) { Response r = getClient() .target(USER_ENDPOINT) .request() .header(HttpHeaders.AUTHORIZATION, HttpUtil.authHeaderBearer(token.getAccessToken())) .get(); try { if (r.getStatusInfo().getFamily().equals(Family.SUCCESSFUL)) { GithubUserEntity githubUser = r.readEntity(GithubUserEntity.class); if (githubUser.getId() == null) { throw new ThirdPartyErrorException(); } return githubUser.asGenericUser(); } else { Map<String, String> params = r.readEntity(MAP_TYPE); throw new ThirdPartyErrorException(params); } } catch (ProcessingException e) { throw new ThirdPartyErrorException(); } finally { r.close(); } }  }
GithubAuthenticator extends AbstractOAuth2Authenticator { @Override protected OAuth2User loadUserIdentity(final OAuth2IdPToken token) { Response r = getClient() .target(USER_ENDPOINT) .request() .header(HttpHeaders.AUTHORIZATION, HttpUtil.authHeaderBearer(token.getAccessToken())) .get(); try { if (r.getStatusInfo().getFamily().equals(Family.SUCCESSFUL)) { GithubUserEntity githubUser = r.readEntity(GithubUserEntity.class); if (githubUser.getId() == null) { throw new ThirdPartyErrorException(); } return githubUser.asGenericUser(); } else { Map<String, String> params = r.readEntity(MAP_TYPE); throw new ThirdPartyErrorException(params); } } catch (ProcessingException e) { throw new ThirdPartyErrorException(); } finally { r.close(); } }   }
GithubAuthenticator extends AbstractOAuth2Authenticator { @Override protected OAuth2User loadUserIdentity(final OAuth2IdPToken token) { Response r = getClient() .target(USER_ENDPOINT) .request() .header(HttpHeaders.AUTHORIZATION, HttpUtil.authHeaderBearer(token.getAccessToken())) .get(); try { if (r.getStatusInfo().getFamily().equals(Family.SUCCESSFUL)) { GithubUserEntity githubUser = r.readEntity(GithubUserEntity.class); if (githubUser.getId() == null) { throw new ThirdPartyErrorException(); } return githubUser.asGenericUser(); } else { Map<String, String> params = r.readEntity(MAP_TYPE); throw new ThirdPartyErrorException(params); } } catch (ProcessingException e) { throw new ThirdPartyErrorException(); } finally { r.close(); } }    }