Search in sources :

Example 1 with CustomEntry

use of org.xdi.ldap.model.CustomEntry in project oxAuth by GluuFederation.

the class ClientService method updatAccessTime.

public void updatAccessTime(Client client, boolean isUpdateLogonTime) {
    if (!appConfiguration.getUpdateClientAccessTime()) {
        return;
    }
    String clientDn = client.getDn();
    CustomEntry customEntry = new CustomEntry();
    customEntry.setDn(clientDn);
    customEntry.setCustomObjectClasses(CLIENT_OBJECT_CLASSES);
    Date now = new GregorianCalendar(TimeZone.getTimeZone("UTC")).getTime();
    CustomAttribute customAttributeLastAccessTime = new CustomAttribute("oxLastAccessTime", now);
    customEntry.getCustomAttributes().add(customAttributeLastAccessTime);
    if (isUpdateLogonTime) {
        CustomAttribute customAttributeLastLogonTime = new CustomAttribute("oxLastLogonTime", now);
        customEntry.getCustomAttributes().add(customAttributeLastLogonTime);
    }
    try {
        ldapEntryManager.merge(customEntry);
    } catch (EntryPersistenceException epe) {
        log.error("Failed to update oxLastAccessTime and oxLastLoginTime of client '{}'", clientDn);
    }
    removeFromCache(client);
}
Also used : CustomEntry(org.xdi.ldap.model.CustomEntry) CustomAttribute(org.xdi.ldap.model.CustomAttribute) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException)

Example 2 with CustomEntry

use of org.xdi.ldap.model.CustomEntry in project oxAuth by GluuFederation.

the class AuthenticationService method updateLastLogonUserTime.

private void updateLastLogonUserTime(User user) {
    if (!appConfiguration.getUpdateUserLastLogonTime()) {
        return;
    }
    CustomEntry customEntry = new CustomEntry();
    customEntry.setDn(user.getDn());
    customEntry.setCustomObjectClasses(UserService.USER_OBJECT_CLASSES);
    CustomAttribute customAttribute = new CustomAttribute("oxLastLogonTime", new Date());
    customEntry.getCustomAttributes().add(customAttribute);
    try {
        ldapEntryManager.merge(customEntry);
    } catch (EntryPersistenceException epe) {
        log.error("Failed to update oxLastLoginTime of user '{}'", user.getUserId());
    }
}
Also used : CustomEntry(org.xdi.ldap.model.CustomEntry) CustomAttribute(org.xdi.ldap.model.CustomAttribute) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException)

Aggregations

EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)2 CustomAttribute (org.xdi.ldap.model.CustomAttribute)2 CustomEntry (org.xdi.ldap.model.CustomEntry)2