From 75f4fb5487b8adc6300c939ea9a0a3302b235d0e Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 26 May 2022 16:48:20 -0500 Subject: [PATCH] fix: remove jans-auth-common dependency #1459 --- jans-scim/service/pom.xml | 4 -- .../service/ExternalIdGeneratorService.java | 50 +++++++++++++++++++ .../io/jans/scim/service/GroupService.java | 2 +- .../io/jans/scim/service/PersonService.java | 2 +- 4 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 jans-scim/service/src/main/java/io/jans/scim/service/ExternalIdGeneratorService.java diff --git a/jans-scim/service/pom.xml b/jans-scim/service/pom.xml index b8335de7963..5190b811fae 100644 --- a/jans-scim/service/pom.xml +++ b/jans-scim/service/pom.xml @@ -93,10 +93,6 @@ io.jans jans-auth-client - - io.jans - jans-auth-common - diff --git a/jans-scim/service/src/main/java/io/jans/scim/service/ExternalIdGeneratorService.java b/jans-scim/service/src/main/java/io/jans/scim/service/ExternalIdGeneratorService.java new file mode 100644 index 00000000000..b8a4cf18a01 --- /dev/null +++ b/jans-scim/service/src/main/java/io/jans/scim/service/ExternalIdGeneratorService.java @@ -0,0 +1,50 @@ +/* + * Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.scim.service; + +import io.jans.model.SimpleCustomProperty; +import io.jans.model.custom.script.CustomScriptType; +import io.jans.model.custom.script.conf.CustomScriptConfiguration; +import io.jans.model.custom.script.type.id.IdGeneratorType; +import io.jans.service.custom.script.ExternalScriptService; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Named; +import java.util.Map; + +/** + * @author gasmyr on 9/17/20. + */ +@ApplicationScoped +@Named("externalIdGeneratorService") +public class ExternalIdGeneratorService extends ExternalScriptService { + + private static final long serialVersionUID = 1727751544454591273L; + + public ExternalIdGeneratorService() { + super(CustomScriptType.ID_GENERATOR); + } + + public String executeExternalGenerateIdMethod(CustomScriptConfiguration customScriptConfiguration, String appId, String idType, String idPrefix) { + try { + log.debug("Executing python 'generateId' method"); + IdGeneratorType externalType = (IdGeneratorType) customScriptConfiguration.getExternalType(); + Map configurationAttributes = customScriptConfiguration.getConfigurationAttributes(); + return externalType.generateId(appId, idType, idPrefix, configurationAttributes); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + saveScriptError(customScriptConfiguration.getCustomScript(), ex); + } + + return null; + } + + public String executeExternalDefaultGenerateIdMethod(String appId, String idType, String idPrefix) { + return executeExternalGenerateIdMethod(this.defaultExternalCustomScript, appId, idType, idPrefix); + } + +} diff --git a/jans-scim/service/src/main/java/io/jans/scim/service/GroupService.java b/jans-scim/service/src/main/java/io/jans/scim/service/GroupService.java index 2c531780888..c9bcb8cd4ac 100644 --- a/jans-scim/service/src/main/java/io/jans/scim/service/GroupService.java +++ b/jans-scim/service/src/main/java/io/jans/scim/service/GroupService.java @@ -6,7 +6,6 @@ package io.jans.scim.service; -import io.jans.as.common.service.common.ExternalIdGeneratorService; import io.jans.as.model.common.IdType; import io.jans.orm.PersistenceEntryManager; import io.jans.orm.exception.EntryPersistenceException; @@ -17,6 +16,7 @@ import io.jans.scim.model.GluuCustomPerson; import io.jans.scim.model.GluuGroup; import io.jans.scim.model.GluuGroupVisibility; +import io.jans.scim.service.ExternalIdGeneratorService; import io.jans.scim.util.OxTrustConstants; import io.jans.util.ArrayHelper; import io.jans.util.StringHelper; 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 593f2685306..988bdb132ec 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,7 +6,6 @@ package io.jans.scim.service; -import io.jans.as.common.service.common.ExternalIdGeneratorService; import io.jans.as.model.common.IdType; import io.jans.model.GluuAttribute; import io.jans.orm.PersistenceEntryManager; @@ -20,6 +19,7 @@ import io.jans.scim.model.GluuCustomAttribute; import io.jans.scim.model.GluuCustomPerson; import io.jans.scim.model.User; +import io.jans.scim.service.ExternalIdGeneratorService; import io.jans.scim.util.OxTrustConstants; import io.jans.util.ArrayHelper; import io.jans.util.OxConstants;