You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2018/01/08 13:28:13 UTC

[4/4] syncope git commit: Allow for user self-activate / self-disable / self-reactivate (with mandatory token)

Allow for user self-activate / self-disable / self-reactivate (with mandatory token)


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

Branch: refs/heads/master
Commit: f868f0a9ad0eee669985f848dcc467db751b3cf1
Parents: 4f005ef
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Jan 8 14:15:34 2018 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Jan 8 14:15:53 2018 +0100

----------------------------------------------------------------------
 .../common/rest/api/service/UserSelfService.java      | 14 ++++++++++++++
 .../java/org/apache/syncope/core/logic/UserLogic.java | 13 +++++++++++++
 .../core/rest/cxf/service/UserSelfServiceImpl.java    |  7 +++++++
 3 files changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/f868f0a9/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/UserSelfService.java
----------------------------------------------------------------------
diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/UserSelfService.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/UserSelfService.java
index 651c9d0..397217d 100644
--- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/UserSelfService.java
+++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/UserSelfService.java
@@ -31,6 +31,7 @@ import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import org.apache.cxf.jaxrs.ext.PATCH;
+import org.apache.syncope.common.lib.patch.StatusPatch;
 import org.apache.syncope.common.lib.patch.UserPatch;
 import org.apache.syncope.common.lib.to.UserTO;
 
@@ -89,6 +90,19 @@ public interface UserSelfService extends JAXRSService {
     Response update(@NotNull UserTO user);
 
     /**
+     * Self-perform a status update.
+     *
+     * @param statusPatch status update details
+     * @return Response object featuring the updated user enriched with propagation status information
+     * - ProvisioningResult as Entity
+     */
+    @POST
+    @Path("{key}/status")
+    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    Response status(@NotNull StatusPatch statusPatch);
+
+    /**
      * Self-deletes user.
      *
      * @return Response object featuring the deleted user - ProvisioningResult as Entity

http://git-wip-us.apache.org/repos/asf/syncope/blob/f868f0a9/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
----------------------------------------------------------------------
diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
index b4fb038..cfc92f9 100644
--- a/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
+++ b/core/logic/src/main/java/org/apache/syncope/core/logic/UserLogic.java
@@ -246,6 +246,19 @@ public class UserLogic extends AbstractAnyLogic<UserTO, UserPatch> {
                 Collections.<String>emptySet());
     }
 
+    @PreAuthorize("isAuthenticated()")
+    public ProvisioningResult<UserTO> selfStatus(final StatusPatch statusPatch, final boolean nullPriorityAsync) {
+        statusPatch.setKey(userDAO.findKey(AuthContextUtils.getUsername()));
+        Pair<String, List<PropagationStatus>> updated = setStatusOnWfAdapter(statusPatch, nullPriorityAsync);
+
+        return afterUpdate(
+                binder.returnUserTO(binder.getUserTO(updated.getKey())),
+                updated.getRight(),
+                Collections.<LogicActions>emptyList(),
+                false,
+                Collections.<String>emptySet());
+    }
+
     @PreAuthorize("hasRole('" + StandardEntitlement.MUST_CHANGE_PASSWORD + "')")
     public ProvisioningResult<UserTO> changePassword(final String password, final boolean nullPriorityAsync) {
         UserPatch userPatch = new UserPatch();

http://git-wip-us.apache.org/repos/asf/syncope/blob/f868f0a9/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserSelfServiceImpl.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserSelfServiceImpl.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserSelfServiceImpl.java
index f6a800f..92b0144 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserSelfServiceImpl.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/service/UserSelfServiceImpl.java
@@ -22,6 +22,7 @@ import javax.ws.rs.core.Response;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.syncope.common.lib.AnyOperations;
 import org.apache.syncope.common.lib.SyncopeClientException;
+import org.apache.syncope.common.lib.patch.StatusPatch;
 import org.apache.syncope.common.lib.patch.UserPatch;
 import org.apache.syncope.common.lib.to.ProvisioningResult;
 import org.apache.syncope.common.lib.to.UserTO;
@@ -77,6 +78,12 @@ public class UserSelfServiceImpl extends AbstractServiceImpl implements UserSelf
     }
 
     @Override
+    public Response status(final StatusPatch statusPatch) {
+        ProvisioningResult<UserTO> updated = logic.selfStatus(statusPatch, isNullPriorityAsync());
+        return modificationResponse(updated);
+    }
+
+    @Override
     public Response delete() {
         ProvisioningResult<UserTO> deleted = logic.selfDelete(isNullPriorityAsync());
         return modificationResponse(deleted);