You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by fm...@apache.org on 2013/01/17 18:08:07 UTC
svn commit: r1434780 - in /syncope/branches/1_0_X/core/src:
main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
test/java/org/apache/syncope/core/rest/UserTestITCase.java
Author: fmartelli
Date: Thu Jan 17 17:08:07 2013
New Revision: 1434780
URL: http://svn.apache.org/viewvc?rev=1434780&view=rev
Log:
SYNCOPE-266 - Fix for the branch 1_0_X
Modified:
syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
Modified: syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java?rev=1434780&r1=1434779&r2=1434780&view=diff
==============================================================================
--- syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java (original)
+++ syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java Thu Jan 17 17:08:07 2013
@@ -51,6 +51,7 @@ import org.apache.syncope.core.rest.cont
import org.apache.syncope.core.util.AttributableUtil;
import org.apache.syncope.core.util.ConnObjectUtil;
import org.apache.syncope.core.util.EntitlementUtil;
+import org.apache.syncope.core.util.SchemaMappingUtil;
import org.apache.syncope.types.AttributableType;
import org.apache.syncope.types.CipherAlgorithm;
import org.apache.syncope.types.IntMappingType;
@@ -360,15 +361,24 @@ public class UserDataBinder extends Abst
}
// now, let's see if there are new resource subscriptions without providing password
- Set<String> updatedResources = user.getResourceNames();
- updatedResources.removeAll(currentResources);
- if (!updatedResources.isEmpty() && StringUtils.isBlank(userMod.getPassword())) {
-
- SyncopeClientException sce = new SyncopeClientException(SyncopeClientExceptionType.RequiredValuesMissing);
- sce.addElement("password cannot be empty " + "when subscribing to new resources");
- scce.addException(sce);
+ if (StringUtils.isBlank(userMod.getPassword())) {
+ Set<String> updatedResources = user.getResourceNames();
+ updatedResources.removeAll(currentResources);
+
+ for (String res : updatedResources) {
+ final ExternalResource extRes = resourceDAO.find(res);
+
+ if (extRes != null && !SchemaMappingUtil.getMappings(
+ extRes.getMappings(), "password", IntMappingType.Password).isEmpty()) {
+
+ SyncopeClientException sce =
+ new SyncopeClientException(SyncopeClientExceptionType.RequiredValuesMissing);
+ sce.addElement("password cannot be empty " + "when subscribing to new resources");
+ scce.addException(sce);
- throw scce;
+ throw scce;
+ }
+ }
}
propByRes.addAll(PropagationOperation.DELETE, toBeDeprovisioned);
Modified: syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1434780&r1=1434779&r2=1434780&view=diff
==============================================================================
--- syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ syncope/branches/1_0_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Thu Jan 17 17:08:07 2013
@@ -2189,4 +2189,22 @@ public class UserTestITCase extends Abst
assertEquals(1, userTO.getVirtualAttributes().size());
assertEquals("virtualvalue", userTO.getVirtualAttributes().get(0).getValues().get(0));
}
+
+ @Test
+ public void issueSYNCOPE266() {
+ UserTO userTO = getSampleTO("syncope266@apache.org");
+ userTO.getResources().clear();
+
+ userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
+ assertNotNull(userTO);
+
+ UserMod userMod = new UserMod();
+ userMod.setId(userTO.getId());
+
+ // this resource has not a mapping for Password
+ userMod.addResourceToBeAdded("ws-target-resource-update");
+
+ userTO = restTemplate.postForObject(BASE_URL + "user/update", userMod, UserTO.class);
+ assertNotNull(userTO);
+ }
}