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;
}
}