@Test public void getUserIdentities() { String userId = "123"; FederatedIdentityRepresentation fi = new FederatedIdentityRepresentation(); fi.setUserId(userId); fi.setUserName("davyvanroy"); fi.setIdentityProvider("GITHUB"); when(realmResource.users().get(userId).getFederatedIdentity() .stream()).thenReturn(Stream.of(fi)); Stream<UserIdentity> result = keycloakRepository.getUserIdentities(userId); Java6Assertions.assertThat(result.collect(Collectors.toList())).containsExactly( UserIdentity.builder() .provider(Provider.GITHUB) .userId(userId) .username("davyvanroy") .build()); }
public Stream<UserIdentity> getUserIdentities(String userId) { return resource.users().get(userId).getFederatedIdentity() .stream() .map(fi -> UserIdentity.builder().provider(Provider.fromString(fi.getIdentityProvider())).username(fi.getUserName()).userId(fi.getUserId()).build()); }
KeycloakRepositoryImpl implements KeycloakRepository { public Stream<UserIdentity> getUserIdentities(String userId) { return resource.users().get(userId).getFederatedIdentity() .stream() .map(fi -> UserIdentity.builder().provider(Provider.fromString(fi.getIdentityProvider())).username(fi.getUserName()).userId(fi.getUserId()).build()); } }
KeycloakRepositoryImpl implements KeycloakRepository { public Stream<UserIdentity> getUserIdentities(String userId) { return resource.users().get(userId).getFederatedIdentity() .stream() .map(fi -> UserIdentity.builder().provider(Provider.fromString(fi.getIdentityProvider())).username(fi.getUserName()).userId(fi.getUserId()).build()); } KeycloakRepositoryImpl(RealmResource resource, @Value("${keycloak.auth-server-url}") String keycloakUrl); }
KeycloakRepositoryImpl implements KeycloakRepository { public Stream<UserIdentity> getUserIdentities(String userId) { return resource.users().get(userId).getFederatedIdentity() .stream() .map(fi -> UserIdentity.builder().provider(Provider.fromString(fi.getIdentityProvider())).username(fi.getUserName()).userId(fi.getUserId()).build()); } KeycloakRepositoryImpl(RealmResource resource, @Value("${keycloak.auth-server-url}") String keycloakUrl); Stream<UserIdentity> getUserIdentities(String userId); UserRepresentation getUser(String userId); void updateEtherAddress(String userId, String newAddress); @Override void updateEtherAddressVerified(final String userId, final Boolean isVerified); void updateTelegramName(String userId, String telegramName); void updateHeadline(String userId, String headline); void updateVerifiedDeveloper(String userId, Boolean isVerified); @Override boolean isEtherAddressVerified(final UserRepresentation userRepresentation); boolean isVerifiedDeveloper(UserRepresentation userRepresentation); boolean isVerifiedDeveloper(final String userId); String getAttribute(UserRepresentation userRepresentation, String property); String getTelegramName(UserRepresentation userRepresentation); String getPicture(UserRepresentation userRepresentation); String getHeadline(UserRepresentation userRepresentation); String getAccessToken(@NonNull KeycloakAuthenticationToken token, @NonNull Provider provider); boolean userExists(String userId); }
KeycloakRepositoryImpl implements KeycloakRepository { public Stream<UserIdentity> getUserIdentities(String userId) { return resource.users().get(userId).getFederatedIdentity() .stream() .map(fi -> UserIdentity.builder().provider(Provider.fromString(fi.getIdentityProvider())).username(fi.getUserName()).userId(fi.getUserId()).build()); } KeycloakRepositoryImpl(RealmResource resource, @Value("${keycloak.auth-server-url}") String keycloakUrl); Stream<UserIdentity> getUserIdentities(String userId); UserRepresentation getUser(String userId); void updateEtherAddress(String userId, String newAddress); @Override void updateEtherAddressVerified(final String userId, final Boolean isVerified); void updateTelegramName(String userId, String telegramName); void updateHeadline(String userId, String headline); void updateVerifiedDeveloper(String userId, Boolean isVerified); @Override boolean isEtherAddressVerified(final UserRepresentation userRepresentation); boolean isVerifiedDeveloper(UserRepresentation userRepresentation); boolean isVerifiedDeveloper(final String userId); String getAttribute(UserRepresentation userRepresentation, String property); String getTelegramName(UserRepresentation userRepresentation); String getPicture(UserRepresentation userRepresentation); String getHeadline(UserRepresentation userRepresentation); String getAccessToken(@NonNull KeycloakAuthenticationToken token, @NonNull Provider provider); boolean userExists(String userId);  }