Return-Path: X-Original-To: apmail-syncope-commits-archive@www.apache.org Delivered-To: apmail-syncope-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 082F7C680 for ; Mon, 5 Jan 2015 13:34:06 +0000 (UTC) Received: (qmail 81682 invoked by uid 500); 5 Jan 2015 13:34:07 -0000 Delivered-To: apmail-syncope-commits-archive@syncope.apache.org Received: (qmail 81629 invoked by uid 500); 5 Jan 2015 13:34:07 -0000 Mailing-List: contact commits-help@syncope.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@syncope.apache.org Delivered-To: mailing list commits@syncope.apache.org Received: (qmail 81489 invoked by uid 99); 5 Jan 2015 13:34:06 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jan 2015 13:34:06 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 9A719A3F772; Mon, 5 Jan 2015 13:34:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ilgrosso@apache.org To: commits@syncope.apache.org Date: Mon, 05 Jan 2015 13:34:10 -0000 Message-Id: <59ab847a0ee2448a92c08646ae8f4e0e@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [05/53] [abbrv] syncope git commit: Password managed now included in the provisionig manager Password managed now included in the provisionig manager Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/0da02810 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/0da02810 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/0da02810 Branch: refs/heads/2_0_X Commit: 0da02810041a4bbd5c0892a02924cf726a9e016e Parents: 5b3b124 Author: giacomolm Authored: Thu Dec 18 10:42:56 2014 +0100 Committer: giacomolm Committed: Thu Dec 18 10:42:56 2014 +0100 ---------------------------------------------------------------------- .../DefaultUserProvisioningManager.java | 20 ++++++ .../core/provisioning/ProvisioningManager.java | 42 +++++++++++ .../provisioning/UserProvisioningManager.java | 4 ++ .../camel/CamelUserProvisioningManager.java | 48 +++++++++---- .../DefaultUserConfirmPwdResetPropagation.java | 60 ++++++++++++++++ .../provisioning/ProvisioningManager.java | 42 ----------- .../core/rest/controller/UserController.java | 73 +------------------- core/src/main/resources/camelRoute.xml | 40 ++++++++++- core/src/main/resources/coreContext.xml | 1 + 9 files changed, 201 insertions(+), 129 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/0da02810/core/src/main/java/org/apache/syncope/core/provisioning/DefaultUserProvisioningManager.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/syncope/core/provisioning/DefaultUserProvisioningManager.java b/core/src/main/java/org/apache/syncope/core/provisioning/DefaultUserProvisioningManager.java index 86f6ebe..54f677c 100644 --- a/core/src/main/java/org/apache/syncope/core/provisioning/DefaultUserProvisioningManager.java +++ b/core/src/main/java/org/apache/syncope/core/provisioning/DefaultUserProvisioningManager.java @@ -344,4 +344,24 @@ public class DefaultUserProvisioningManager implements UserProvisioningManager{ } } + @Override + public void requestPasswordReset(Long id) { + uwfAdapter.requestPasswordReset(id); + } + + @Override + public void confirmPasswordReset(SyncopeUser user, String token, String password) { + + uwfAdapter.confirmPasswordReset(user.getId(), token, password); + + List tasks = propagationManager.getUserUpdateTaskIds(user, null, null); + PropagationReporter propReporter = + ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class); + try { + taskExecutor.execute(tasks, propReporter); + } catch (PropagationException e) { + LOG.error("Error propagation primary resource", e); + propReporter.onPrimaryResourceFailure(tasks); + } + } } http://git-wip-us.apache.org/repos/asf/syncope/blob/0da02810/core/src/main/java/org/apache/syncope/core/provisioning/ProvisioningManager.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/syncope/core/provisioning/ProvisioningManager.java b/core/src/main/java/org/apache/syncope/core/provisioning/ProvisioningManager.java new file mode 100644 index 0000000..adc1cb0 --- /dev/null +++ b/core/src/main/java/org/apache/syncope/core/provisioning/ProvisioningManager.java @@ -0,0 +1,42 @@ +/* + * 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; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import org.apache.syncope.common.mod.AbstractAttributableMod; +import org.apache.syncope.common.to.AbstractAttributableTO; +import org.apache.syncope.common.to.PropagationStatus; + +public interface ProvisioningManager{ + + public Map.Entry> create(T subject); + + public Map.Entry> update(M subjectMod); + + public List delete(Long subjectId); + + public Long unlink(M subjectMod); + + public Long link(M subjectMod); + + public List deprovision(Long user, Collection resources); + +} http://git-wip-us.apache.org/repos/asf/syncope/blob/0da02810/core/src/main/java/org/apache/syncope/core/provisioning/UserProvisioningManager.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/syncope/core/provisioning/UserProvisioningManager.java b/core/src/main/java/org/apache/syncope/core/provisioning/UserProvisioningManager.java index da29a42..32a4d18 100644 --- a/core/src/main/java/org/apache/syncope/core/provisioning/UserProvisioningManager.java +++ b/core/src/main/java/org/apache/syncope/core/provisioning/UserProvisioningManager.java @@ -47,4 +47,8 @@ public interface UserProvisioningManager extends ProvisioningManager props = new HashMap(); + props.put("user", user); + props.put("userId", user.getId()); + props.put("token", token); + props.put("password", password); + + sendMessage("direct:confirmPwdReset", user, props); + Exchange o = pollingConsumer.receive(); + + if (o.getProperty(Exchange.EXCEPTION_CAUGHT) != null) { + throw (RuntimeException) o.getProperty(Exchange.EXCEPTION_CAUGHT); + } + } + } http://git-wip-us.apache.org/repos/asf/syncope/blob/0da02810/core/src/main/java/org/apache/syncope/core/provisioning/camel/processors/DefaultUserConfirmPwdResetPropagation.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/syncope/core/provisioning/camel/processors/DefaultUserConfirmPwdResetPropagation.java b/core/src/main/java/org/apache/syncope/core/provisioning/camel/processors/DefaultUserConfirmPwdResetPropagation.java new file mode 100644 index 0000000..2447689 --- /dev/null +++ b/core/src/main/java/org/apache/syncope/core/provisioning/camel/processors/DefaultUserConfirmPwdResetPropagation.java @@ -0,0 +1,60 @@ +/* + * 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.camel.processors; + +import java.util.List; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.syncope.common.to.UserTO; +import org.apache.syncope.core.persistence.beans.PropagationTask; +import org.apache.syncope.core.persistence.beans.user.SyncopeUser; +import org.apache.syncope.core.propagation.PropagationException; +import org.apache.syncope.core.propagation.PropagationReporter; +import org.apache.syncope.core.propagation.PropagationTaskExecutor; +import org.apache.syncope.core.propagation.impl.PropagationManager; +import org.apache.syncope.core.util.ApplicationContextProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; + + +public class DefaultUserConfirmPwdResetPropagation implements Processor{ + + private static final Logger LOG = LoggerFactory.getLogger(DefaultUserConfirmPwdResetPropagation.class); + + @Autowired + protected PropagationManager propagationManager; + @Autowired + protected PropagationTaskExecutor taskExecutor; + + @Override + public void process(Exchange exchange){ + SyncopeUser user = exchange.getProperty("user", SyncopeUser.class); + + List tasks = propagationManager.getUserUpdateTaskIds(user, null, null); + PropagationReporter propReporter = + ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class); + try { + taskExecutor.execute(tasks, propReporter); + } catch (PropagationException e) { + LOG.error("Error propagation primary resource", e); + propReporter.onPrimaryResourceFailure(tasks); + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/0da02810/core/src/main/java/org/apache/syncope/core/provisioning/provisioning/ProvisioningManager.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/syncope/core/provisioning/provisioning/ProvisioningManager.java b/core/src/main/java/org/apache/syncope/core/provisioning/provisioning/ProvisioningManager.java deleted file mode 100644 index adc1cb0..0000000 --- a/core/src/main/java/org/apache/syncope/core/provisioning/provisioning/ProvisioningManager.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import org.apache.syncope.common.mod.AbstractAttributableMod; -import org.apache.syncope.common.to.AbstractAttributableTO; -import org.apache.syncope.common.to.PropagationStatus; - -public interface ProvisioningManager{ - - public Map.Entry> create(T subject); - - public Map.Entry> update(M subjectMod); - - public List delete(Long subjectId); - - public Long unlink(M subjectMod); - - public Long link(M subjectMod); - - public List deprovision(Long user, Collection resources); - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/0da02810/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java b/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java index d8fa5f8..606d46b 100644 --- a/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java +++ b/core/src/main/java/org/apache/syncope/core/rest/controller/UserController.java @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -43,11 +42,8 @@ import org.apache.syncope.common.to.UserTO; import org.apache.syncope.common.types.ClientExceptionType; import org.apache.syncope.common.SyncopeClientException; import org.apache.syncope.common.mod.AttributeMod; -import org.apache.syncope.common.mod.MembershipMod; import org.apache.syncope.common.types.SubjectType; import org.apache.syncope.common.to.PropagationStatus; -import org.apache.syncope.core.persistence.beans.CamelRoute; -import org.apache.syncope.core.persistence.beans.PropagationTask; import org.apache.syncope.core.provisioning.UserProvisioningManager; import org.apache.syncope.core.persistence.beans.role.SyncopeRole; import org.apache.syncope.core.persistence.beans.user.SyncopeUser; @@ -57,18 +53,11 @@ import org.apache.syncope.core.persistence.dao.NotFoundException; import org.apache.syncope.core.persistence.dao.RoleDAO; import org.apache.syncope.core.persistence.dao.UserDAO; import org.apache.syncope.core.persistence.dao.search.OrderByClause; -import org.apache.syncope.core.propagation.PropagationByResource; -import org.apache.syncope.core.propagation.PropagationException; -import org.apache.syncope.core.propagation.PropagationReporter; import org.apache.syncope.core.propagation.PropagationTaskExecutor; import org.apache.syncope.core.propagation.impl.PropagationManager; -import org.apache.syncope.core.provisioning.camel.CamelUserProvisioningManager; import org.apache.syncope.core.rest.data.AttributableTransformer; import org.apache.syncope.core.rest.data.UserDataBinder; -import org.apache.syncope.core.util.ApplicationContextProvider; import org.apache.syncope.core.util.EntitlementUtil; -import org.apache.syncope.core.workflow.WorkflowResult; -import org.apache.syncope.core.workflow.user.UserWorkflowAdapter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Component; @@ -108,9 +97,6 @@ public class UserController extends AbstractSubjectController { @Autowired protected AttributableTransformer attrTransformer; - @Autowired - protected UserWorkflowAdapter uwfAdapter; - @Resource(name = "defaultUserProvisioningManager") protected UserProvisioningManager provisioningManager; @@ -269,50 +255,6 @@ public class UserController extends AbstractSubjectController { } } - //Actual operations: workflow, propagation, notification - /*WorkflowResult> updated = uwfAdapter.update(actual); - - List tasks = propagationManager.getUserUpdateTaskIds(updated); - if (tasks.isEmpty()) { - // SYNCOPE-459: take care of user virtual attributes ... - final PropagationByResource propByResVirAttr = binder.fillVirtual( - updated.getResult().getKey().getId(), - actual.getVirAttrsToRemove(), - actual.getVirAttrsToUpdate()); - // SYNCOPE-501: update only virtual attributes (if any of them changed), password propagation is - // not required, take care also of membership virtual attributes - boolean addOrUpdateMemberships = false; - for (MembershipMod membershipMod : actual.getMembershipsToAdd()) { - if (!binder.fillMembershipVirtual( - updated.getResult().getKey().getId(), - membershipMod.getRole(), - null, - membershipMod.getVirAttrsToRemove(), - membershipMod.getVirAttrsToUpdate(), - false).isEmpty()) { - - addOrUpdateMemberships = true; - } - } - tasks.addAll(!propByResVirAttr.isEmpty() || addOrUpdateMemberships || removeMemberships - ? propagationManager.getUserUpdateTaskIds(updated, false, null) - : Collections.emptyList()); - } - - PropagationReporter propagationReporter = ApplicationContextProvider.getApplicationContext(). - getBean(PropagationReporter.class); - - if (!tasks.isEmpty()) { - try { - taskExecutor.execute(tasks, propagationReporter); - } catch (PropagationException e) { - LOG.error("Error propagation primary resource", e); - propagationReporter.onPrimaryResourceFailure(tasks); - } - } - - final UserTO updatedTO = binder.getUserTO(updated.getResult().getKey().getId()); - updatedTO.getPropagationStatusTOs().addAll(propagationReporter.getStatuses());*/ Map.Entry> updated = provisioningManager.update(actual,removeMemberships); final UserTO updatedTO = binder.getUserTO(updated.getKey()); @@ -372,7 +314,7 @@ public class UserController extends AbstractSubjectController { throw SyncopeClientException.build(ClientExceptionType.InvalidSecurityAnswer); } - uwfAdapter.requestPasswordReset(user.getId()); + provisioningManager.requestPasswordReset(user.getId()); } @PreAuthorize("isAnonymous() or hasRole(T(org.apache.syncope.common.SyncopeConstants).ANONYMOUS_ENTITLEMENT)") @@ -382,18 +324,7 @@ public class UserController extends AbstractSubjectController { if (user == null) { throw new NotFoundException("User with token " + token); } - - uwfAdapter.confirmPasswordReset(user.getId(), token, password); - - List tasks = propagationManager.getUserUpdateTaskIds(user, null, null); - PropagationReporter propReporter = - ApplicationContextProvider.getApplicationContext().getBean(PropagationReporter.class); - try { - taskExecutor.execute(tasks, propReporter); - } catch (PropagationException e) { - LOG.error("Error propagation primary resource", e); - propReporter.onPrimaryResourceFailure(tasks); - } + provisioningManager.confirmPasswordReset(user, token, password); } @PreAuthorize("isAuthenticated() " http://git-wip-us.apache.org/repos/asf/syncope/blob/0da02810/core/src/main/resources/camelRoute.xml ---------------------------------------------------------------------- diff --git a/core/src/main/resources/camelRoute.xml b/core/src/main/resources/camelRoute.xml index c7ac19a..e1ad071 100644 --- a/core/src/main/resources/camelRoute.xml +++ b/core/src/main/resources/camelRoute.xml @@ -413,6 +413,43 @@ under the License. + + + + + + + + + java.lang.RuntimeException + + false + + + + + + + + + + + + + + java.lang.RuntimeException + + false + + + + + + @@ -422,9 +459,10 @@ under the License. + - + http://git-wip-us.apache.org/repos/asf/syncope/blob/0da02810/core/src/main/resources/coreContext.xml ---------------------------------------------------------------------- diff --git a/core/src/main/resources/coreContext.xml b/core/src/main/resources/coreContext.xml index da55cfc..3950689 100644 --- a/core/src/main/resources/coreContext.xml +++ b/core/src/main/resources/coreContext.xml @@ -162,6 +162,7 @@ under the License. +