@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(); // calculate based on the host component only
		} else {
			Set<String> redirectUris = client.getRedirectUris();
			UriComponents uri = UriComponentsBuilder.fromUriString(Iterables.getOnlyElement(redirectUris)).build();
			sectorIdentifier = uri.getHost(); // calculate based on the host of the only redirect URI
		}

		if (sectorIdentifier != null) {
			// if there's a sector identifier, use that for the lookup
			PairwiseIdentifier pairwise = pairwiseIdentifierRepository.getBySectorIdentifier(userInfo.getSub(), sectorIdentifier);

			if (pairwise == null) {
				// we don't have an identifier, need to make and save one

				pairwise = new PairwiseIdentifier();
				pairwise.setIdentifier(UUID.randomUUID().toString());
				pairwise.setUserSub(userInfo.getSub());
				pairwise.setSectorIdentifier(sectorIdentifier);

				pairwiseIdentifierRepository.save(pairwise);
			}

			return pairwise.getIdentifier();
		} else {

			return null;
		}
	}
@Test
	public void testGetIdentifier_newEqual() {

		String pairwise1 = service.getIdentifier(userInfoRegular, pairwiseClient1);
		Mockito.verify(pairwiseIdentifierRepository, Mockito.atLeast(1)).save(Matchers.any(PairwiseIdentifier.class));

		PairwiseIdentifier pairwiseId = new PairwiseIdentifier();
		pairwiseId.setUserSub(regularSub);
		pairwiseId.setIdentifier(pairwise1);
		pairwiseId.setSectorIdentifier(sectorHost12);

		Mockito.when(pairwiseIdentifierRepository.getBySectorIdentifier(regularSub, sectorHost12)).thenReturn(pairwiseId);

		String pairwise2 = service.getIdentifier(userInfoRegular, pairwiseClient2);

		assertNotSame(pairwiseSub, pairwise1);
		assertNotSame(pairwiseSub, pairwise2);

		assertEquals(pairwise1, pairwise2);

		// see if the pairwise id's are actual UUIDs
		UUID uudi1 = UUID.fromString(pairwise1);
		UUID uuid2 = UUID.fromString(pairwise2);

	}