@Test public void testGetIdentifier_existingEqual() { Mockito.when(pairwiseIdentifierRepository.getBySectorIdentifier(regularSub, sectorHost12)).thenReturn(savedPairwiseIdentifier); String pairwise1 = service.getIdentifier(userInfoRegular, pairwiseClient1); String pairwise2 = service.getIdentifier(userInfoRegular, pairwiseClient2); assertEquals(pairwiseSub, pairwise1); assertEquals(pairwiseSub, pairwise2); }
@Override public String getIdentifier(UserInfo userInfo, ClientDetailsEntity client) { String sectorIdentifier = null; if (!Strings.isNullOrEmpty(client.getSectorIdentifierUri())) { UriComponents uri = UriComponentsBuilder.fromUriString(client.getSectorIdentifierUri()).build(); sectorIdentifier = uri.getHost(); } else { Set<String> redirectUris = client.getRedirectUris(); UriComponents uri = UriComponentsBuilder.fromUriString(Iterables.getOnlyElement(redirectUris)).build(); sectorIdentifier = uri.getHost(); } if (sectorIdentifier != null) { PairwiseIdentifier pairwise = pairwiseIdentifierRepository.getBySectorIdentifier(userInfo.getSub(), sectorIdentifier); if (pairwise == null) { pairwise = new PairwiseIdentifier(); pairwise.setIdentifier(UUID.randomUUID().toString()); pairwise.setUserSub(userInfo.getSub()); pairwise.setSectorIdentifier(sectorIdentifier); pairwiseIdentifierRepository.save(pairwise); } return pairwise.getIdentifier(); } else { return null; } }
UUIDPairwiseIdentiferService implements PairwiseIdentiferService { @Override public String getIdentifier(UserInfo userInfo, ClientDetailsEntity client) { String sectorIdentifier = null; if (!Strings.isNullOrEmpty(client.getSectorIdentifierUri())) { UriComponents uri = UriComponentsBuilder.fromUriString(client.getSectorIdentifierUri()).build(); sectorIdentifier = uri.getHost(); } else { Set<String> redirectUris = client.getRedirectUris(); UriComponents uri = UriComponentsBuilder.fromUriString(Iterables.getOnlyElement(redirectUris)).build(); sectorIdentifier = uri.getHost(); } if (sectorIdentifier != null) { PairwiseIdentifier pairwise = pairwiseIdentifierRepository.getBySectorIdentifier(userInfo.getSub(), sectorIdentifier); if (pairwise == null) { pairwise = new PairwiseIdentifier(); pairwise.setIdentifier(UUID.randomUUID().toString()); pairwise.setUserSub(userInfo.getSub()); pairwise.setSectorIdentifier(sectorIdentifier); pairwiseIdentifierRepository.save(pairwise); } return pairwise.getIdentifier(); } else { return null; } } }
UUIDPairwiseIdentiferService implements PairwiseIdentiferService { @Override public String getIdentifier(UserInfo userInfo, ClientDetailsEntity client) { String sectorIdentifier = null; if (!Strings.isNullOrEmpty(client.getSectorIdentifierUri())) { UriComponents uri = UriComponentsBuilder.fromUriString(client.getSectorIdentifierUri()).build(); sectorIdentifier = uri.getHost(); } else { Set<String> redirectUris = client.getRedirectUris(); UriComponents uri = UriComponentsBuilder.fromUriString(Iterables.getOnlyElement(redirectUris)).build(); sectorIdentifier = uri.getHost(); } if (sectorIdentifier != null) { PairwiseIdentifier pairwise = pairwiseIdentifierRepository.getBySectorIdentifier(userInfo.getSub(), sectorIdentifier); if (pairwise == null) { pairwise = new PairwiseIdentifier(); pairwise.setIdentifier(UUID.randomUUID().toString()); pairwise.setUserSub(userInfo.getSub()); pairwise.setSectorIdentifier(sectorIdentifier); pairwiseIdentifierRepository.save(pairwise); } return pairwise.getIdentifier(); } else { return null; } }  }
UUIDPairwiseIdentiferService implements PairwiseIdentiferService { @Override public String getIdentifier(UserInfo userInfo, ClientDetailsEntity client) { String sectorIdentifier = null; if (!Strings.isNullOrEmpty(client.getSectorIdentifierUri())) { UriComponents uri = UriComponentsBuilder.fromUriString(client.getSectorIdentifierUri()).build(); sectorIdentifier = uri.getHost(); } else { Set<String> redirectUris = client.getRedirectUris(); UriComponents uri = UriComponentsBuilder.fromUriString(Iterables.getOnlyElement(redirectUris)).build(); sectorIdentifier = uri.getHost(); } if (sectorIdentifier != null) { PairwiseIdentifier pairwise = pairwiseIdentifierRepository.getBySectorIdentifier(userInfo.getSub(), sectorIdentifier); if (pairwise == null) { pairwise = new PairwiseIdentifier(); pairwise.setIdentifier(UUID.randomUUID().toString()); pairwise.setUserSub(userInfo.getSub()); pairwise.setSectorIdentifier(sectorIdentifier); pairwiseIdentifierRepository.save(pairwise); } return pairwise.getIdentifier(); } else { return null; } }  @Override String getIdentifier(UserInfo userInfo, ClientDetailsEntity client); }
UUIDPairwiseIdentiferService implements PairwiseIdentiferService { @Override public String getIdentifier(UserInfo userInfo, ClientDetailsEntity client) { String sectorIdentifier = null; if (!Strings.isNullOrEmpty(client.getSectorIdentifierUri())) { UriComponents uri = UriComponentsBuilder.fromUriString(client.getSectorIdentifierUri()).build(); sectorIdentifier = uri.getHost(); } else { Set<String> redirectUris = client.getRedirectUris(); UriComponents uri = UriComponentsBuilder.fromUriString(Iterables.getOnlyElement(redirectUris)).build(); sectorIdentifier = uri.getHost(); } if (sectorIdentifier != null) { PairwiseIdentifier pairwise = pairwiseIdentifierRepository.getBySectorIdentifier(userInfo.getSub(), sectorIdentifier); if (pairwise == null) { pairwise = new PairwiseIdentifier(); pairwise.setIdentifier(UUID.randomUUID().toString()); pairwise.setUserSub(userInfo.getSub()); pairwise.setSectorIdentifier(sectorIdentifier); pairwiseIdentifierRepository.save(pairwise); } return pairwise.getIdentifier(); } else { return null; } }  @Override String getIdentifier(UserInfo userInfo, ClientDetailsEntity client);  }