From 1a39d0882eb1875396d637ad5142eaae88be526e Mon Sep 17 00:00:00 2001 From: Yuriy Movchan Date: Fri, 23 Dec 2022 20:38:59 +0300 Subject: [PATCH] fix: user attributes not updated #2753 --- .../jans/as/server/service/ClientService.java | 1 - .../io/jans/scim/service/PersonService.java | 39 +++++++++++++------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/jans-auth-server/server/src/main/java/io/jans/as/server/service/ClientService.java b/jans-auth-server/server/src/main/java/io/jans/as/server/service/ClientService.java index 99116bf2a84..b21d91395a8 100644 --- a/jans-auth-server/server/src/main/java/io/jans/as/server/service/ClientService.java +++ b/jans-auth-server/server/src/main/java/io/jans/as/server/service/ClientService.java @@ -78,7 +78,6 @@ public void persist(Client client) { ldapEntryManager.persist(client); } - private Client ignoreCustomObjectClassesForNonLDAP(Client client) { String persistenceType = ldapEntryManager.getPersistenceType(); log.debug("persistenceType: {}", persistenceType); diff --git a/jans-scim/service/src/main/java/io/jans/scim/service/PersonService.java b/jans-scim/service/src/main/java/io/jans/scim/service/PersonService.java index 835ab807762..c6fbcf48864 100644 --- a/jans-scim/service/src/main/java/io/jans/scim/service/PersonService.java +++ b/jans-scim/service/src/main/java/io/jans/scim/service/PersonService.java @@ -6,6 +6,18 @@ package io.jans.scim.service; +import java.io.Serializable; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.slf4j.Logger; + import io.jans.as.model.common.IdType; import io.jans.model.GluuAttribute; import io.jans.orm.PersistenceEntryManager; @@ -23,20 +35,8 @@ import io.jans.util.ArrayHelper; import io.jans.util.OxConstants; import io.jans.util.StringHelper; - import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.time.Instant; -import java.util.UUID; - -import org.slf4j.Logger; /** * Provides operations with persons @@ -91,6 +91,8 @@ public void addPerson(GluuCustomPerson person) throws Exception { if (persons == null || persons.size() == 0) { person.setCreationDate(new Date()); attributeService.applyMetaData(person.getCustomAttributes()); + + ignoreCustomObjectClassesForNonLDAP(person); persistenceEntryManager.persist(person); } else { throw new DuplicateEntryException("Duplicate UID value: " + person.getUid()); @@ -105,6 +107,19 @@ public void addPerson(GluuCustomPerson person) throws Exception { } + private GluuCustomPerson ignoreCustomObjectClassesForNonLDAP(GluuCustomPerson person) { + String persistenceType = persistenceEntryManager.getPersistenceType(); + log.debug("persistenceType: {}", persistenceType); + if (!PersistenceEntryManager.PERSITENCE_TYPES.ldap.name().equals(persistenceType)) { + log.debug( + "Setting CustomObjectClasses :{} to null as it's used only for LDAP and current persistenceType is {} ", + person.getCustomObjectClasses(), persistenceType); + person.setCustomObjectClasses(null); + } + + return person; + } + public void updatePerson(GluuCustomPerson person) throws Exception { try { Date updateDate = new Date();