syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skylar...@apache.org
Subject syncope git commit: Added support for SCIM v1.1
Date Mon, 14 May 2018 08:12:31 GMT
Repository: syncope
Updated Branches:
  refs/heads/master f4316c847 -> d18108a0d


Added support for SCIM v1.1


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/d18108a0
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/d18108a0
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/d18108a0

Branch: refs/heads/master
Commit: d18108a0df21326e9236805fa1185f4e264041f8
Parents: f4316c8
Author: skylark17 <matteo.alessandroni@tirasa.net>
Authored: Mon May 14 09:46:32 2018 +0200
Committer: skylark17 <matteo.alessandroni@tirasa.net>
Committed: Mon May 14 10:04:27 2018 +0200

----------------------------------------------------------------------
 .../propagation/SCIMv11PropagationActions.java  | 124 +++++++++++++++++++
 .../core/reference/ITImplementationLookup.java  |   2 +
 pom.xml                                         |   6 +
 3 files changed, 132 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/d18108a0/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/SCIMv11PropagationActions.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/SCIMv11PropagationActions.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/SCIMv11PropagationActions.java
new file mode 100644
index 0000000..b6de2de
--- /dev/null
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/SCIMv11PropagationActions.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.java.propagation;
+
+import org.apache.syncope.common.lib.types.AnyTypeKind;
+import org.apache.syncope.common.lib.types.ResourceOperation;
+import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidPlainAttrValueException;
+import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
+import org.apache.syncope.core.persistence.api.dao.UserDAO;
+import org.apache.syncope.core.persistence.api.entity.AnyUtils;
+import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
+import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+import org.apache.syncope.core.persistence.api.entity.PlainSchema;
+import org.apache.syncope.core.persistence.api.entity.task.PropagationTask;
+import org.apache.syncope.core.persistence.api.entity.task.TaskExec;
+import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
+import org.apache.syncope.core.persistence.api.entity.user.User;
+import org.apache.syncope.core.provisioning.api.propagation.PropagationActions;
+import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * This class is required during setup of an External Resource based on the ConnId
+ * <a href="https://github.com/Tirasa/ConnIdSCIMv11Bundle">SCIM connector</a>.
+ *
+ * It manages:
+ * <ol>
+ * <li>the User id provided by SCIM, which will need to be used for all subsequent
operations</li>
+ * </ol>
+ */
+public class SCIMv11PropagationActions implements PropagationActions {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SCIMv11PropagationActions.class);
+
+    @Autowired
+    private PlainSchemaDAO plainSchemaDAO;
+
+    @Autowired
+    private UserDAO userDAO;
+
+    @Autowired
+    private EntityFactory entityFactory;
+
+    @Autowired
+    private AnyUtilsFactory anyUtilsFactory;
+
+    protected String getSCIMIdSchema() {
+        return "SCIMUserId";
+    }
+
+    @Override
+    public void before(PropagationTask task, ConnectorObject beforeObj) {
+        PropagationActions.super.before(task, beforeObj);
+    }
+
+    @Transactional
+    @Override
+    public void after(final PropagationTask task, final TaskExec execution, final ConnectorObject
afterObj) {
+        if (task.getOperation() == ResourceOperation.DELETE || task.getOperation() == ResourceOperation.NONE)
{
+            return;
+        }
+
+        if (AnyTypeKind.USER.equals(task.getAnyTypeKind())) {
+
+            User user = userDAO.find(task.getEntityKey());
+            if (user == null) {
+                LOG.error("Could not find user {}, skipping", task.getEntityKey());
+            } else {
+                boolean modified = false;
+                AnyUtils anyUtils = anyUtilsFactory.getInstance(user);
+
+                // SCIM v1.1 User ID
+                PlainSchema userId = plainSchemaDAO.find(getSCIMIdSchema());
+                if (userId == null) {
+                    LOG.error("Could not find schema {}, skipping", getSCIMIdSchema());
+                } else {
+                    // set back the __UID__ received by SCIM service
+                    UPlainAttr attr = user.getPlainAttr(getSCIMIdSchema()).orElse(null);
+                    if (attr == null) {
+                        attr = entityFactory.newEntity(UPlainAttr.class);
+                        attr.setSchema(userId);
+                        attr.setOwner(user);
+                        user.add(attr);
+
+                        try {
+                            attr.add(afterObj.getUid().getUidValue(), anyUtils);
+                            modified = true;
+                        } catch (InvalidPlainAttrValueException e) {
+                            LOG.error("Invalid value for attribute {}: {}",
+                                    userId.getKey(), afterObj.getUid().getUidValue(), e);
+                        }
+                    } else {
+                        LOG.debug("User {} has already {} assigned: {}",
+                                user, userId.getKey(), attr.getValuesAsStrings());
+                    }
+                }
+
+                if (modified) {
+                    userDAO.save(user);
+                }
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/d18108a0/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
index 352692e..d3a0f6e 100644
--- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
+++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/ITImplementationLookup.java
@@ -70,6 +70,7 @@ import org.apache.syncope.core.provisioning.java.propagation.DBPasswordPropagati
 import org.apache.syncope.core.provisioning.java.propagation.GoogleAppsPropagationActions;
 import org.apache.syncope.core.provisioning.java.propagation.LDAPMembershipPropagationActions;
 import org.apache.syncope.core.provisioning.java.propagation.LDAPPasswordPropagationActions;
+import org.apache.syncope.core.provisioning.java.propagation.SCIMv11PropagationActions;
 import org.apache.syncope.core.provisioning.java.pushpull.DBPasswordPullActions;
 import org.apache.syncope.core.provisioning.java.pushpull.LDAPMembershipPullActions;
 import org.apache.syncope.core.provisioning.java.pushpull.LDAPPasswordPullActions;
@@ -183,6 +184,7 @@ public class ITImplementationLookup implements ImplementationLookup {
             classNames.add(LDAPPasswordPropagationActions.class.getName());
             classNames.add(DBPasswordPropagationActions.class.getName());
             classNames.add(AzurePropagationActions.class.getName());
+            classNames.add(SCIMv11PropagationActions.class.getName());
             classNames.add(GoogleAppsPropagationActions.class.getName());
             put(ImplementationType.PROPAGATION_ACTIONS, classNames);
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/d18108a0/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8783f43..6e2d823 100644
--- a/pom.xml
+++ b/pom.xml
@@ -365,6 +365,7 @@ under the License.
     <connid.ad.version>1.3.4</connid.ad.version>
     <connid.googleapps.version>1.4.1</connid.googleapps.version>
     <connid.azure.version>1.0.1</connid.azure.version>
+    <connid.scimv11.version>1.0.0-SNAPSHOT</connid.scimv11.version>
 
     <cxf.version>3.2.5-SNAPSHOT</cxf.version>
 
@@ -1787,6 +1788,11 @@ under the License.
                 <artifactId>net.tirasa.connid.bundles.azure</artifactId>
                 <version>${connid.azure.version}</version>
               </artifactItem>
+              <artifactItem>
+                <groupId>net.tirasa.connid.bundles</groupId>
+                <artifactId>net.tirasa.connid.bundles.scimv11</artifactId>
+                <version>${connid.scimv11.version}</version>
+              </artifactItem>
             </artifactItems>
           </configuration>
         </plugin>


Mime
View raw message