use of org.forgerock.openam.authentication.modules.deviceprint.model.UserProfile in project OpenAM by OpenRock.
the class DevicePrintService method createNewProfile.
/**
* Creates a new User Profile with the given Device Print information in LDAP.
*
* @param devicePrint The Device Print to store.
* @throws NotUniqueUserProfileException If the Device print information's id is not unique.
*/
public void createNewProfile(DevicePrint devicePrint) throws NotUniqueUserProfileException {
UserProfile profile = new UserProfile(new Date(), new Date(), 1L);
profile.setDevicePrint(devicePrint);
profile.setUuid(new RandomHashGenerator().getRandomHash());
saveProfile(profile);
}
use of org.forgerock.openam.authentication.modules.deviceprint.model.UserProfile in project OpenAM by OpenRock.
the class DevicePrintService method removeOldestProfile.
/**
* Finds the oldest User's profile and removes it from LDAP.
*/
private void removeOldestProfile() {
UserProfile oldestProfile = null;
Date oldestDate = new Date();
for (UserProfile userProfile : userProfilesDao.getProfiles()) {
if (userProfile.getLastSelectedDate().before(oldestDate)) {
oldestDate = userProfile.getLastSelectedDate();
oldestProfile = userProfile;
}
}
if (oldestProfile != null) {
userProfilesDao.getProfiles().remove(oldestProfile);
}
}
use of org.forgerock.openam.authentication.modules.deviceprint.model.UserProfile in project OpenAM by OpenRock.
the class DevicePrintService method getBestMatchingUserProfile.
/**
* Uses the given Device Print information to find the best matching stored Device Print information from stored
* User Profiles. It uses the penalty points set in the authentication module settings to determine whether a stored
* Device print matches the given one.
*
* If no match is found null is returned.
*
* @param devicePrint The Device Print to find a match for.
* @return The matching User Profile or null.
*/
public UserProfile getBestMatchingUserProfile(DevicePrint devicePrint) {
SortedMap<ComparisonResult, UserProfile> comparisonResultMap = new TreeMap<ComparisonResult, UserProfile>();
for (UserProfile userProfile : getNotExpiredProfiles()) {
DevicePrint storedDevicePrint = userProfile.getDevicePrint();
comparisonResultMap.put(devicePrintComparator.compare(devicePrint, storedDevicePrint, devicePrintAuthenticationConfig), userProfile);
}
if (comparisonResultMap.isEmpty()) {
return null;
}
ComparisonResult selectedComparisonResult = comparisonResultMap.firstKey();
UserProfile selectedProfile = null;
if (selectedComparisonResult.getPenaltyPoints() <= devicePrintAuthenticationConfig.getLong(DevicePrintAuthenticationConfig.MAX_TOLERATED_PENALTY_POINTS)) {
selectedProfile = comparisonResultMap.get(selectedComparisonResult);
}
return selectedProfile;
}
Aggregations