@Test public void testLoadUser() { OAuth2IdPToken result = new OAuth2IdPToken(); result.setAccessToken("google_access_token"); GoogleUserEntity user = new GoogleUserEntity(); user.setId("test_id"); user.setName("test name"); doReturn(user).when(getResponse).readEntity(GoogleUserEntity.class); OAuth2User returnedUser = googleAuth.loadUserIdentity(result); assertEquals(returnedUser.getId(), user.getId()); assertEquals("test name", returnedUser.getClaims().get("name")); }
@Override protected OAuth2User loadUserIdentity(final OAuth2IdPToken token) { Response r = getClient() .target("https: .request() .header(HttpHeaders.AUTHORIZATION, HttpUtil.authHeaderBearer(token.getAccessToken())) .get(); try { if (r.getStatusInfo().getFamily().equals(Family.SUCCESSFUL)) { GoogleUserEntity gUser = r.readEntity(GoogleUserEntity.class); if (Strings.isNullOrEmpty(gUser.getId())) { throw new ThirdPartyErrorException(); } return gUser.asGenericUser(); } else { Map<String, String> params = r.readEntity(MAP_TYPE); throw new ThirdPartyErrorException(params); } } catch (ProcessingException e) { throw new ThirdPartyErrorException(); } finally { r.close(); } }
GoogleAuthenticator extends AbstractOAuth2Authenticator { @Override protected OAuth2User loadUserIdentity(final OAuth2IdPToken token) { Response r = getClient() .target("https: .request() .header(HttpHeaders.AUTHORIZATION, HttpUtil.authHeaderBearer(token.getAccessToken())) .get(); try { if (r.getStatusInfo().getFamily().equals(Family.SUCCESSFUL)) { GoogleUserEntity gUser = r.readEntity(GoogleUserEntity.class); if (Strings.isNullOrEmpty(gUser.getId())) { throw new ThirdPartyErrorException(); } return gUser.asGenericUser(); } else { Map<String, String> params = r.readEntity(MAP_TYPE); throw new ThirdPartyErrorException(params); } } catch (ProcessingException e) { throw new ThirdPartyErrorException(); } finally { r.close(); } } }
GoogleAuthenticator extends AbstractOAuth2Authenticator { @Override protected OAuth2User loadUserIdentity(final OAuth2IdPToken token) { Response r = getClient() .target("https: .request() .header(HttpHeaders.AUTHORIZATION, HttpUtil.authHeaderBearer(token.getAccessToken())) .get(); try { if (r.getStatusInfo().getFamily().equals(Family.SUCCESSFUL)) { GoogleUserEntity gUser = r.readEntity(GoogleUserEntity.class); if (Strings.isNullOrEmpty(gUser.getId())) { throw new ThirdPartyErrorException(); } return gUser.asGenericUser(); } else { Map<String, String> params = r.readEntity(MAP_TYPE); throw new ThirdPartyErrorException(params); } } catch (ProcessingException e) { throw new ThirdPartyErrorException(); } finally { r.close(); } }  }
GoogleAuthenticator extends AbstractOAuth2Authenticator { @Override protected OAuth2User loadUserIdentity(final OAuth2IdPToken token) { Response r = getClient() .target("https: .request() .header(HttpHeaders.AUTHORIZATION, HttpUtil.authHeaderBearer(token.getAccessToken())) .get(); try { if (r.getStatusInfo().getFamily().equals(Family.SUCCESSFUL)) { GoogleUserEntity gUser = r.readEntity(GoogleUserEntity.class); if (Strings.isNullOrEmpty(gUser.getId())) { throw new ThirdPartyErrorException(); } return gUser.asGenericUser(); } else { Map<String, String> params = r.readEntity(MAP_TYPE); throw new ThirdPartyErrorException(params); } } catch (ProcessingException e) { throw new ThirdPartyErrorException(); } finally { r.close(); } }   }
GoogleAuthenticator extends AbstractOAuth2Authenticator { @Override protected OAuth2User loadUserIdentity(final OAuth2IdPToken token) { Response r = getClient() .target("https: .request() .header(HttpHeaders.AUTHORIZATION, HttpUtil.authHeaderBearer(token.getAccessToken())) .get(); try { if (r.getStatusInfo().getFamily().equals(Family.SUCCESSFUL)) { GoogleUserEntity gUser = r.readEntity(GoogleUserEntity.class); if (Strings.isNullOrEmpty(gUser.getId())) { throw new ThirdPartyErrorException(); } return gUser.asGenericUser(); } else { Map<String, String> params = r.readEntity(MAP_TYPE); throw new ThirdPartyErrorException(params); } } catch (ProcessingException e) { throw new ThirdPartyErrorException(); } finally { r.close(); } }    }