Search in sources :

Example 1 with NotUniqueUserProfileException

use of org.forgerock.openam.authentication.modules.deviceprint.exceptions.NotUniqueUserProfileException in project OpenAM by OpenRock.

the class UserProfilesDao method saveProfiles.

/**
     * Saves the DAO's internal user profiles cache to LDAP.
     *
     * @throws NotUniqueUserProfileException If two or more user profiles have the same uuid or name.
     */
public void saveProfiles() throws NotUniqueUserProfileException {
    validate();
    Set<String> vals = new HashSet<String>();
    for (UserProfile userProfile : profiles) {
        Writer strWriter = new StringWriter();
        try {
            mapper.writeValue(strWriter, userProfile);
            vals.add(strWriter.toString());
        } catch (Exception e) {
            DEBUG.error("Error while serializing profiles. " + e);
        }
    }
    Map<String, Set> attrMap = new HashMap<String, Set>();
    attrMap.put(LDAP_DEVICE_PRINT_ATTRIBUTE_NAME, vals);
    try {
        amIdentity.setAttributes(attrMap);
        amIdentity.store();
        DEBUG.message("Profiles stored");
    } catch (Exception e) {
        DEBUG.error("Could not store profiles. " + e);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) UserProfile(org.forgerock.openam.authentication.modules.deviceprint.model.UserProfile) StringWriter(java.io.StringWriter) HashMap(java.util.HashMap) StringWriter(java.io.StringWriter) Writer(java.io.Writer) NotUniqueUserProfileException(org.forgerock.openam.authentication.modules.deviceprint.exceptions.NotUniqueUserProfileException) HashSet(java.util.HashSet)

Aggregations

StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 NotUniqueUserProfileException (org.forgerock.openam.authentication.modules.deviceprint.exceptions.NotUniqueUserProfileException)1 UserProfile (org.forgerock.openam.authentication.modules.deviceprint.model.UserProfile)1