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 2013/11/11 17:56:53 UTC

svn commit: r1540775 - in /syncope/branches/1_1_X/core/src: main/java/org/apache/syncope/core/connid/ main/java/org/apache/syncope/core/persistence/beans/ main/java/org/apache/syncope/core/persistence/beans/user/ main/java/org/apache/syncope/core/propa...

Author: ilgrosso
Date: Mon Nov 11 16:56:53 2013
New Revision: 1540775

URL: http://svn.apache.org/r1540775
Log:
[SYNCOPE-435] Adding logic to asses whether mandatory attributes defined in mapping are actually provided during create() or update() on connectors

Modified:
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractDerAttr.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationException.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationTaskExecutor.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/LDAPMembershipPropagationActions.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/PropagationManager.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/DerivedSchemaDataBinder.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/JexlUtil.java
    syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/MappingUtil.java
    syncope/branches/1_1_X/core/src/main/resources/syncopeContext.xml
    syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/connid/ConnObjectUtil.java Mon Nov 11 16:56:53 2013
@@ -86,12 +86,6 @@ public class ConnObjectUtil {
     private static final Logger LOG = LoggerFactory.getLogger(ConnObjectUtil.class);
 
     /**
-     * JEXL engine for evaluating connector's account link.
-     */
-    @Autowired
-    private JexlUtil jexlUtil;
-
-    /**
      * User data binder.
      */
     @Autowired
@@ -350,14 +344,14 @@ public class ConnObjectUtil {
         if (template != null) {
             if (template instanceof UserTO) {
                 if (StringUtils.isNotBlank(((UserTO) template).getUsername())) {
-                    String evaluated = jexlUtil.evaluate(((UserTO) template).getUsername(), attributableTO);
+                    String evaluated = JexlUtil.evaluate(((UserTO) template).getUsername(), attributableTO);
                     if (StringUtils.isNotBlank(evaluated)) {
                         ((UserTO) attributableTO).setUsername(evaluated);
                     }
                 }
 
                 if (StringUtils.isNotBlank(((UserTO) template).getPassword())) {
-                    String evaluated = jexlUtil.evaluate(((UserTO) template).getPassword(), attributableTO);
+                    String evaluated = JexlUtil.evaluate(((UserTO) template).getPassword(), attributableTO);
                     if (StringUtils.isNotBlank(evaluated)) {
                         ((UserTO) attributableTO).setPassword(evaluated);
                     }
@@ -378,7 +372,7 @@ public class ConnObjectUtil {
             }
             if (template instanceof RoleTO) {
                 if (StringUtils.isNotBlank(((RoleTO) template).getName())) {
-                    String evaluated = jexlUtil.evaluate(((RoleTO) template).getName(), attributableTO);
+                    String evaluated = JexlUtil.evaluate(((RoleTO) template).getName(), attributableTO);
                     if (StringUtils.isNotBlank(evaluated)) {
                         ((RoleTO) attributableTO).setName(evaluated);
                     }
@@ -635,7 +629,7 @@ public class ConnObjectUtil {
 
         if (template.getValues() != null && !template.getValues().isEmpty()) {
             for (String value : template.getValues()) {
-                String evaluated = jexlUtil.evaluate(value, attributableTO);
+                String evaluated = JexlUtil.evaluate(value, attributableTO);
                 if (StringUtils.isNotBlank(evaluated)) {
                     result.addValue(evaluated);
                 }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractDerAttr.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractDerAttr.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractDerAttr.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/beans/AbstractDerAttr.java Mon Nov 11 16:56:53 2013
@@ -25,9 +25,7 @@ import javax.persistence.Id;
 import javax.persistence.MappedSuperclass;
 import org.apache.commons.jexl2.JexlContext;
 import org.apache.commons.jexl2.MapContext;
-import org.apache.syncope.core.util.ApplicationContextProvider;
 import org.apache.syncope.core.util.JexlUtil;
-import org.springframework.context.ConfigurableApplicationContext;
 
 @MappedSuperclass
 public abstract class AbstractDerAttr extends AbstractBaseBean {
@@ -48,16 +46,13 @@ public abstract class AbstractDerAttr ex
      * @return the value of this derived attribute
      */
     public String getValue(final Collection<? extends AbstractAttr> attributes) {
-        final ConfigurableApplicationContext context = ApplicationContextProvider.getApplicationContext();
-        final JexlUtil jexlUtil = context.getBean(JexlUtil.class);
-
         // Prepare context using user attributes
         final JexlContext jexlContext = new MapContext();
-        jexlUtil.addAttrsToContext(attributes, jexlContext);
-        jexlUtil.addFieldsToContext(getOwner(), jexlContext);
+        JexlUtil.addAttrsToContext(attributes, jexlContext);
+        JexlUtil.addFieldsToContext(getOwner(), jexlContext);
 
         // Evaluate expression using the context prepared before
-        return jexlUtil.evaluate(getDerivedSchema().getExpression(), jexlContext);
+        return JexlUtil.evaluate(getDerivedSchema().getExpression(), jexlContext);
     }
 
     public abstract <T extends AbstractAttributable> T getOwner();

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java Mon Nov 11 16:56:53 2013
@@ -69,7 +69,7 @@ public class SyncopeUser extends Abstrac
     @Id
     private Long id;
 
-    @NotNull
+    @NotNull(message = "Blank password")
     private String password;
 
     @Transient
@@ -119,7 +119,7 @@ public class SyncopeUser extends Abstrac
      * Username/Login.
      */
     @Column(unique = true)
-    @NotNull
+    @NotNull(message = "Blank username")
     private String username;
 
     /**
@@ -507,8 +507,8 @@ public class SyncopeUser extends Abstrac
                 res = passwordHistory.subList(size >= passwordHistory.size()
                         ? 0
                         : passwordHistory.size() - size, passwordHistory.size()).contains(cipherAlgorithm == null
-                        ? password
-                        : PasswordEncoder.encode(password, cipherAlgorithm));
+                                ? password
+                                : PasswordEncoder.encode(password, cipherAlgorithm));
             } catch (Exception e) {
                 LOG.error("Error evaluating password history", e);
             }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationException.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationException.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationException.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationException.java Mon Nov 11 16:56:53 2013
@@ -37,7 +37,6 @@ public class PropagationException extend
      * @param stackTrace original stacktrace
      */
     public PropagationException(final String resourceName, final String stackTrace) {
-
         super("Exception during provision on resource " + resourceName + "\n" + stackTrace);
 
         this.resourceName = resourceName;

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationTaskExecutor.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationTaskExecutor.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationTaskExecutor.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/PropagationTaskExecutor.java Mon Nov 11 16:56:53 2013
@@ -31,6 +31,18 @@ import org.apache.syncope.core.persisten
 public interface PropagationTaskExecutor {
 
     /**
+     * Name for special propagation attribute used to indicate whether there are attributes, marked as mandatory in the
+     * mapping but not to be propagated.
+     */
+    String MANDATORY_MISSING_ATTR_NAME = "__MANDATORY_MISSING__";
+
+    /**
+     * Name for special propagation attribute used to indicate whether there are attributes, marked as mandatory in the
+     * mapping but about to be propagated as null or empty.
+     */
+    String MANDATORY_NULL_OR_EMPTY_ATTR_NAME = "__MANDATORY_NULL_OR_EMPTY__";
+
+    /**
      * Execute the given PropagationTask and returns the generated TaskExec.
      *
      * @param task to be executed

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/AbstractPropagationTaskExecutor.java Mon Nov 11 16:56:53 2013
@@ -20,10 +20,12 @@ package org.apache.syncope.core.propagat
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.apache.commons.lang.StringUtils;
@@ -33,6 +35,7 @@ import org.apache.syncope.common.types.M
 import org.apache.syncope.common.types.PropagationMode;
 import org.apache.syncope.common.types.PropagationTaskExecStatus;
 import org.apache.syncope.common.types.TraceLevel;
+import org.apache.syncope.common.validation.SyncopeClientException;
 import org.apache.syncope.core.audit.AuditManager;
 import org.apache.syncope.core.connid.ConnObjectUtil;
 import org.apache.syncope.core.notification.NotificationManager;
@@ -66,7 +69,7 @@ import org.springframework.beans.factory
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.transaction.annotation.Transactional;
 
-@Transactional(rollbackFor = {Throwable.class})
+@Transactional(rollbackFor = { Throwable.class })
 public abstract class AbstractPropagationTaskExecutor implements PropagationTaskExecutor {
 
     /**
@@ -137,11 +140,32 @@ public abstract class AbstractPropagatio
     }
 
     protected void createOrUpdate(final PropagationTask task, final ConnectorObject beforeObj,
-            final Connector connector, final Set<String> propagationAttempted) {
+            final Connector connector, final Set<String> propagationAttempted) throws SyncopeClientException {
 
         // set of attributes to be propagated
         final Set<Attribute> attributes = new HashSet<Attribute>(task.getAttributes());
 
+        // check if there is any missing or null / empty mandatory attribute
+        List<Object> mandatoryAttrNames = new ArrayList<Object>();
+        Attribute mandatoryMissing = AttributeUtil.find(MANDATORY_MISSING_ATTR_NAME, task.getAttributes());
+        if (mandatoryMissing != null) {
+            attributes.remove(mandatoryMissing);
+
+            if (beforeObj == null) {
+                mandatoryAttrNames.addAll(mandatoryMissing.getValue());
+            }
+        }
+        Attribute mandatoryNullOrEmpty = AttributeUtil.find(MANDATORY_NULL_OR_EMPTY_ATTR_NAME, task.getAttributes());
+        if (mandatoryNullOrEmpty != null) {
+            attributes.remove(mandatoryNullOrEmpty);
+
+            mandatoryAttrNames.addAll(mandatoryNullOrEmpty.getValue());
+        }
+        if (!mandatoryAttrNames.isEmpty()) {
+            throw new IllegalArgumentException(
+                    "Not attempted because there are mandatory attributes without value(s): " + mandatoryAttrNames);
+        }
+
         if (beforeObj == null) {
             // 1. get accountId
             final String accountId = task.getAccountId();
@@ -245,7 +269,7 @@ public abstract class AbstractPropagatio
     }
 
     protected void delete(final PropagationTask task, final ConnectorObject beforeObj,
-            final Connector connector, final Set<String> propagationAttempted) {
+            final Connector connector, final Set<String> propagationAttempted) throws SyncopeClientException {
 
         if (beforeObj == null) {
             LOG.debug("{} not found on external resource: ignoring delete", task.getAccountId());
@@ -408,7 +432,7 @@ public abstract class AbstractPropagatio
                 task.getPropagationOperation().name().toLowerCase(),
                 result,
                 beforeObj, // searching for before object is too much expensive ... 
-                new Object[] {execution, afterObj},
+                new Object[] { execution, afterObj },
                 task);
 
         auditManager.audit(
@@ -418,7 +442,7 @@ public abstract class AbstractPropagatio
                 task.getPropagationOperation().name().toLowerCase(),
                 result,
                 beforeObj, // searching for before object is too much expensive ... 
-                new Object[] {execution, afterObj},
+                new Object[] { execution, afterObj },
                 task);
 
         return execution;
@@ -490,7 +514,7 @@ public abstract class AbstractPropagatio
                     new ObjectClass(task.getObjectClassName()),
                     new Uid(accountId),
                     connector.getOperationOptions(AttributableUtil.getInstance(task.getSubjectType()).
-                    getMappingItems(task.getResource(), MappingPurpose.PROPAGATION)));
+                            getMappingItems(task.getResource(), MappingPurpose.PROPAGATION)));
         } catch (TimeoutException toe) {
             LOG.debug("Request timeout", toe);
             throw toe;

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/LDAPMembershipPropagationActions.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/LDAPMembershipPropagationActions.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/LDAPMembershipPropagationActions.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/LDAPMembershipPropagationActions.java Mon Nov 11 16:56:53 2013
@@ -55,9 +55,6 @@ public class LDAPMembershipPropagationAc
     @Autowired
     protected UserDAO userDAO;
 
-    @Autowired
-    protected JexlUtil jexlUtil;
-
     /**
      * Allows easy subclassing for the ConnId AD connector bundle.
      *
@@ -83,11 +80,11 @@ public class LDAPMembershipPropagationAc
                         LOG.debug("Evaluating accountLink for {}", role);
 
                         final JexlContext jexlContext = new MapContext();
-                        jexlUtil.addFieldsToContext(role, jexlContext);
-                        jexlUtil.addAttrsToContext(role.getAttributes(), jexlContext);
-                        jexlUtil.addDerAttrsToContext(role.getDerivedAttributes(), role.getAttributes(), jexlContext);
+                        JexlUtil.addFieldsToContext(role, jexlContext);
+                        JexlUtil.addAttrsToContext(role.getAttributes(), jexlContext);
+                        JexlUtil.addDerAttrsToContext(role.getDerivedAttributes(), role.getAttributes(), jexlContext);
                         final String roleAccountLink =
-                                jexlUtil.evaluate(task.getResource().getRmapping().getAccountLink(), jexlContext);
+                                JexlUtil.evaluate(task.getResource().getRmapping().getAccountLink(), jexlContext);
                         LOG.debug("AccountLink for {} is '{}'", role, roleAccountLink);
                         if (StringUtils.isNotBlank(roleAccountLink)) {
                             roleAccountLinks.add(roleAccountLink);

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/PropagationManager.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/PropagationManager.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/PropagationManager.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/propagation/impl/PropagationManager.java Mon Nov 11 16:56:53 2013
@@ -45,11 +45,13 @@ import org.apache.syncope.core.persisten
 import org.apache.syncope.core.persistence.dao.NotFoundException;
 import org.apache.syncope.core.persistence.dao.ResourceDAO;
 import org.apache.syncope.core.propagation.PropagationByResource;
+import org.apache.syncope.core.propagation.PropagationTaskExecutor;
 import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
 import org.apache.syncope.core.rest.data.AbstractAttributableDataBinder;
 import org.apache.syncope.core.rest.data.RoleDataBinder;
 import org.apache.syncope.core.rest.data.UserDataBinder;
 import org.apache.syncope.core.util.AttributableUtil;
+import org.apache.syncope.core.util.JexlUtil;
 import org.apache.syncope.core.util.MappingUtil;
 import org.apache.syncope.core.util.VirAttrCache;
 import org.apache.syncope.core.workflow.WorkflowResult;
@@ -64,7 +66,7 @@ import org.springframework.transaction.a
 /**
  * Manage the data propagation to external resources.
  */
-@Transactional(rollbackFor = {Throwable.class})
+@Transactional(rollbackFor = { Throwable.class })
 public class PropagationManager {
 
     /**
@@ -446,6 +448,7 @@ public class PropagationManager {
      * Prepare attributes for sending to a connector instance.
      *
      * @param <T> user / role
+     * @param attrUtil user / role
      * @param subject given user / role
      * @param password clear-text password
      * @param vAttrsToBeRemoved virtual attributes to be removed
@@ -454,17 +457,16 @@ public class PropagationManager {
      * @param resource target resource
      * @return account link + prepared attributes
      */
-    protected <T extends AbstractAttributable> Map.Entry<String, Set<Attribute>> prepareAttributes(final T subject,
-            final String password, final Set<String> vAttrsToBeRemoved,
-            final Map<String, AttributeMod> vAttrsToBeUpdated, final Boolean enable, final ExternalResource resource) {
+    protected <T extends AbstractAttributable> Map.Entry<String, Set<Attribute>> prepareAttributes(
+            final AttributableUtil attrUtil, final T subject, final String password,
+            final Set<String> vAttrsToBeRemoved, final Map<String, AttributeMod> vAttrsToBeUpdated,
+            final Boolean enable, final ExternalResource resource) {
 
         LOG.debug("Preparing resource attributes for {} on resource {} with attributes {}",
                 subject, resource, subject.getAttributes());
 
         Set<Attribute> attributes = new HashSet<Attribute>();
         String accountId = null;
-
-        final AttributableUtil attrUtil = AttributableUtil.getInstance(subject);
         for (AbstractMappingItem mapping : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
             LOG.debug("Processing schema {}", mapping.getIntAttrName());
 
@@ -473,6 +475,7 @@ public class PropagationManager {
                         && mapping.getIntMappingType() == IntMappingType.UserVirtualSchema)
                         || (attrUtil.getType() == AttributableType.ROLE
                         && mapping.getIntMappingType() == IntMappingType.RoleVirtualSchema)) {
+
                     LOG.debug("Expire entry cache {}-{}", subject.getId(), mapping.getIntAttrName());
                     virAttrCache.expire(attrUtil.getType(), subject.getId(), mapping.getIntAttrName());
                 }
@@ -485,9 +488,7 @@ public class PropagationManager {
                 }
 
                 if (preparedAttribute.getValue() != null) {
-                    final Attribute alreadyAdded = AttributeUtil.find(preparedAttribute.getValue().getName(),
-                            attributes);
-
+                    Attribute alreadyAdded = AttributeUtil.find(preparedAttribute.getValue().getName(), attributes);
                     if (alreadyAdded == null) {
                         attributes.add(preparedAttribute.getValue());
                     } else {
@@ -578,11 +579,36 @@ public class PropagationManager {
                     task.setPropagationMode(resource.getPropagationMode());
                     task.setOldAccountId(propByRes.getOldAccountId(resource.getName()));
 
-                    Map.Entry<String, Set<Attribute>> preparedAttrs = prepareAttributes(subject, password,
+                    Map.Entry<String, Set<Attribute>> preparedAttrs = prepareAttributes(attrUtil, subject, password,
                             vAttrsToBeRemoved, vAttrsToBeUpdated, enable, resource);
                     task.setAccountId(preparedAttrs.getKey());
-                    task.setAttributes(preparedAttrs.getValue());
 
+                    // Check if any of mandatory attributes (in the mapping) is missing or not received any value: 
+                    // if so, add special attributes that will be evaluated by PropagationTaskExecutor
+                    List<String> mandatoryMissing = new ArrayList<String>();
+                    List<String> mandatoryNullOrEmpty = new ArrayList<String>();
+                    for (AbstractMappingItem item : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
+                        if (!item.isAccountid()
+                                && JexlUtil.evaluateMandatoryCondition(item.getMandatoryCondition(), subject)) {
+
+                            Attribute attr = AttributeUtil.find(item.getExtAttrName(), preparedAttrs.getValue());
+                            if (attr == null) {
+                                mandatoryMissing.add(item.getExtAttrName());
+                            } else if (attr.getValue() == null || attr.getValue().isEmpty()) {
+                                mandatoryNullOrEmpty.add(item.getExtAttrName());
+                            }
+                        }
+                    }
+                    if (!mandatoryMissing.isEmpty()) {
+                        preparedAttrs.getValue().add(AttributeBuilder.build(
+                                PropagationTaskExecutor.MANDATORY_MISSING_ATTR_NAME, mandatoryMissing));
+                    }
+                    if (!mandatoryNullOrEmpty.isEmpty()) {
+                        preparedAttrs.getValue().add(AttributeBuilder.build(
+                                PropagationTaskExecutor.MANDATORY_NULL_OR_EMPTY_ATTR_NAME, mandatoryNullOrEmpty));
+                    }
+
+                    task.setAttributes(preparedAttrs.getValue());
                     tasks.add(task);
 
                     LOG.debug("PropagationTask created: {}", task);

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/AbstractAttributableDataBinder.java Mon Nov 11 16:56:53 2013
@@ -117,9 +117,6 @@ public abstract class AbstractAttributab
     @Autowired
     protected PolicyDAO policyDAO;
 
-    @Autowired
-    private JexlUtil jexlUtil;
-
     private <T extends AbstractSchema> T getSchema(final String schemaName, final Class<T> reference) {
         T schema = null;
         if (StringUtils.isNotBlank(schemaName)) {
@@ -205,17 +202,6 @@ public abstract class AbstractAttributab
         }
     }
 
-    private boolean evaluateMandatoryCondition(final String mandatoryCondition,
-            final AbstractAttributable attributable) {
-
-        JexlContext jexlContext = new MapContext();
-        jexlUtil.addAttrsToContext(attributable.getAttributes(), jexlContext);
-        jexlUtil.addDerAttrsToContext(attributable.getDerivedAttributes(), attributable.getAttributes(), jexlContext);
-        jexlUtil.addVirAttrsToContext(attributable.getVirtualAttributes(), jexlContext);
-
-        return Boolean.parseBoolean(jexlUtil.evaluate(mandatoryCondition, jexlContext));
-    }
-
     private boolean evaluateMandatoryCondition(final AttributableUtil attrUtil, final ExternalResource resource,
             final AbstractAttributable attributable, final String intAttrName, final IntMappingType intMappingType) {
 
@@ -225,7 +211,7 @@ public abstract class AbstractAttributab
                 attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION), intAttrName, intMappingType);
         for (Iterator<AbstractMappingItem> itor = mappings.iterator(); itor.hasNext() && !result;) {
             final AbstractMappingItem mapping = itor.next();
-            result |= evaluateMandatoryCondition(mapping.getMandatoryCondition(), attributable);
+            result |= JexlUtil.evaluateMandatoryCondition(mapping.getMandatoryCondition(), attributable);
         }
 
         return result;
@@ -258,7 +244,7 @@ public abstract class AbstractAttributab
         for (AbstractSchema schema : schemaDAO.findAll(attrUtil.schemaClass())) {
             if (attributable.getAttribute(schema.getName()) == null
                     && !schema.isReadonly()
-                    && (evaluateMandatoryCondition(schema.getMandatoryCondition(), attributable)
+                    && (JexlUtil.evaluateMandatoryCondition(schema.getMandatoryCondition(), attributable)
                     || evaluateMandatoryCondition(attrUtil, attributable, schema.getName(),
                     attrUtil.intMappingType()))) {
 

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/DerivedSchemaDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/DerivedSchemaDataBinder.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/DerivedSchemaDataBinder.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/DerivedSchemaDataBinder.java Mon Nov 11 16:56:53 2013
@@ -26,16 +26,12 @@ import org.apache.syncope.common.validat
 import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
 import org.apache.syncope.core.util.JexlUtil;
 import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Component;
 
 @Component
 public class DerivedSchemaDataBinder {
 
-    @Autowired
-    private JexlUtil jexlUtil;
-
     private AbstractDerSchema populate(final AbstractDerSchema derSchema, final DerivedSchemaTO derSchemaTO) {
         SyncopeClientCompositeErrorException scce = new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
 
@@ -45,7 +41,7 @@ public class DerivedSchemaDataBinder {
             requiredValuesMissing.addElement("expression");
 
             scce.addException(requiredValuesMissing);
-        } else if (!jexlUtil.isExpressionValid(derSchemaTO.getExpression())) {
+        } else if (!JexlUtil.isExpressionValid(derSchemaTO.getExpression())) {
             SyncopeClientException invalidMandatoryCondition = new SyncopeClientException(
                     SyncopeClientExceptionType.InvalidValues);
             invalidMandatoryCondition.addElement(derSchemaTO.getExpression());

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/ResourceDataBinder.java Mon Nov 11 16:56:53 2013
@@ -64,15 +64,12 @@ public class ResourceDataBinder {
      */
     private static final Logger LOG = LoggerFactory.getLogger(ResourceDataBinder.class);
 
-    private static final String[] MAPPINGITEM_IGNORE_PROPERTIES = {"id", "mapping"};
+    private static final String[] MAPPINGITEM_IGNORE_PROPERTIES = { "id", "mapping" };
 
     @Autowired
     private ConnInstanceDAO connInstanceDAO;
 
     @Autowired
-    private JexlUtil jexlUtil;
-
-    @Autowired
     private PolicyDAO policyDAO;
 
     public ExternalResource create(final ResourceTO resourceTO) {
@@ -204,7 +201,7 @@ public class ResourceDataBinder {
         }
 
         // no mandatory condition implies mandatory condition false
-        if (!jexlUtil.isExpressionValid(itemTO.getMandatoryCondition() == null
+        if (!JexlUtil.isExpressionValid(itemTO.getMandatoryCondition() == null
                 ? "false" : itemTO.getMandatoryCondition())) {
 
             SyncopeClientException invalidMandatoryCondition = new SyncopeClientException(

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/SchemaDataBinder.java Mon Nov 11 16:56:53 2013
@@ -40,11 +40,8 @@ public class SchemaDataBinder {
     @Autowired
     private SchemaDAO schemaDAO;
 
-    @Autowired
-    private JexlUtil jexlUtil;
-
     private <T extends AbstractDerSchema> void populate(final AbstractSchema schema, final SchemaTO schemaTO) {
-        if (!jexlUtil.isExpressionValid(schemaTO.getMandatoryCondition())) {
+        if (!JexlUtil.isExpressionValid(schemaTO.getMandatoryCondition())) {
             SyncopeClientCompositeErrorException scce =
                     new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
 

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/TaskDataBinder.java Mon Nov 11 16:56:53 2013
@@ -65,9 +65,9 @@ public class TaskDataBinder {
      */
     private static final Logger LOG = LoggerFactory.getLogger(TaskDataBinder.class);
 
-    private static final String[] IGNORE_TASK_PROPERTIES = {"executions", "resource",};
+    private static final String[] IGNORE_TASK_PROPERTIES = { "executions", "resource", };
 
-    private static final String[] IGNORE_TASK_EXECUTION_PROPERTIES = {"id", "task"};
+    private static final String[] IGNORE_TASK_EXECUTION_PROPERTIES = { "id", "task" };
 
     @Autowired
     private ResourceDAO resourceDAO;
@@ -78,17 +78,14 @@ public class TaskDataBinder {
     @Autowired
     private SchedulerFactoryBean scheduler;
 
-    @Autowired
-    private JexlUtil jexlUtil;
-
     private void checkJexl(final AbstractAttributableTO attributableTO, final SyncopeClientException sce) {
         for (AttributeTO attrTO : attributableTO.getAttributes()) {
-            if (!attrTO.getValues().isEmpty() && !jexlUtil.isExpressionValid(attrTO.getValues().get(0))) {
+            if (!attrTO.getValues().isEmpty() && !JexlUtil.isExpressionValid(attrTO.getValues().get(0))) {
                 sce.addElement("Invalid JEXL: " + attrTO.getValues().get(0));
             }
         }
         for (AttributeTO attrTO : attributableTO.getVirtualAttributes()) {
-            if (!attrTO.getValues().isEmpty() && !jexlUtil.isExpressionValid(attrTO.getValues().get(0))) {
+            if (!attrTO.getValues().isEmpty() && !JexlUtil.isExpressionValid(attrTO.getValues().get(0))) {
                 sce.addElement("Invalid JEXL: " + attrTO.getValues().get(0));
             }
         }
@@ -101,10 +98,10 @@ public class TaskDataBinder {
         if (taskTO.getUserTemplate() != null) {
             UserTO template = taskTO.getUserTemplate();
 
-            if (StringUtils.isNotBlank(template.getUsername()) && !jexlUtil.isExpressionValid(template.getUsername())) {
+            if (StringUtils.isNotBlank(template.getUsername()) && !JexlUtil.isExpressionValid(template.getUsername())) {
                 sce.addElement("Invalid JEXL: " + template.getUsername());
             }
-            if (StringUtils.isNotBlank(template.getPassword()) && !jexlUtil.isExpressionValid(template.getPassword())) {
+            if (StringUtils.isNotBlank(template.getPassword()) && !JexlUtil.isExpressionValid(template.getPassword())) {
                 sce.addElement("Invalid JEXL: " + template.getPassword());
             }
 
@@ -117,7 +114,7 @@ public class TaskDataBinder {
         if (taskTO.getRoleTemplate() != null) {
             RoleTO template = taskTO.getRoleTemplate();
 
-            if (StringUtils.isNotBlank(template.getName()) && !jexlUtil.isExpressionValid(template.getName())) {
+            if (StringUtils.isNotBlank(template.getName()) && !JexlUtil.isExpressionValid(template.getName())) {
                 sce.addElement("Invalid JEXL: " + template.getName());
             }
 

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/rest/data/UserDataBinder.java Mon Nov 11 16:56:53 2013
@@ -288,7 +288,6 @@ public class UserDataBinder extends Abst
             if (membership == null) {
                 LOG.debug("Invalid membership id specified to be removed: {}", membershipId);
             } else {
-
                 if (!membershipToBeAddedRoleIds.contains(membership.getSyncopeRole().getId())) {
                     toBeDeprovisioned.addAll(membership.getSyncopeRole().getResourceNames());
                 }
@@ -311,7 +310,6 @@ public class UserDataBinder extends Abst
 
                     // remove derived attributes
                     for (AbstractDerAttr derAttr : membership.getDerivedAttributes()) {
-
                         attributeIds.add(derAttr.getId());
                     }
                     for (Long derAttrId : attributeIds) {

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/AttributableUtil.java Mon Nov 11 16:56:53 2013
@@ -232,6 +232,7 @@ public class AttributableUtil {
                     }
                 }
                 break;
+
             case PROPAGATION:
                 for (T item : items) {
                     if (MappingPurpose.SYNCHRONIZATION != item.getPurpose()) {
@@ -239,7 +240,9 @@ public class AttributableUtil {
                     }
                 }
                 break;
+
             case BOTH:
+            default:
                 result.addAll(items);
         }
 

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/JexlUtil.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/JexlUtil.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/JexlUtil.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/JexlUtil.java Mon Nov 11 16:56:53 2013
@@ -33,11 +33,11 @@ import org.apache.commons.lang.StringUti
 import org.apache.syncope.common.to.AbstractAttributableTO;
 import org.apache.syncope.common.to.AttributeTO;
 import org.apache.syncope.core.persistence.beans.AbstractAttr;
+import org.apache.syncope.core.persistence.beans.AbstractAttributable;
 import org.apache.syncope.core.persistence.beans.AbstractDerAttr;
 import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * @see http://commons.apache.org/jexl/reference/index.html
@@ -50,15 +50,24 @@ public class JexlUtil {
      */
     private static final Logger LOG = LoggerFactory.getLogger(JexlUtil.class);
 
-    private static final String[] IGNORE_FIELDS = {"password", "clearPassword", "serialVersionUID"};
+    private static final String[] IGNORE_FIELDS = { "password", "clearPassword", "serialVersionUID" };
 
-    @Autowired
-    private JexlEngine jexlEngine;
+    private static JexlEngine jexlEngine;
 
-    public boolean isExpressionValid(final String expression) {
+    private static JexlEngine getEngine() {
+        synchronized (LOG) {
+            if (jexlEngine == null) {
+                jexlEngine = ApplicationContextProvider.getApplicationContext().getBean(JexlEngine.class);
+            }
+        }
+
+        return jexlEngine;
+    }
+
+    public static boolean isExpressionValid(final String expression) {
         boolean result;
         try {
-            jexlEngine.createExpression(expression);
+            getEngine().createExpression(expression);
             result = true;
         } catch (JexlException e) {
             LOG.error("Invalid jexl expression: " + expression, e);
@@ -68,12 +77,12 @@ public class JexlUtil {
         return result;
     }
 
-    public String evaluate(final String expression, final JexlContext jexlContext) {
-        String result = "";
+    public static String evaluate(final String expression, final JexlContext jexlContext) {
+        String result = StringUtils.EMPTY;
 
         if (StringUtils.isNotBlank(expression) && jexlContext != null) {
             try {
-                Expression jexlExpression = jexlEngine.createExpression(expression);
+                Expression jexlExpression = getEngine().createExpression(expression);
                 Object evaluated = jexlExpression.evaluate(jexlContext);
                 if (evaluated != null) {
                     result = evaluated.toString();
@@ -88,15 +97,10 @@ public class JexlUtil {
         return result;
     }
 
-    public JexlContext addFieldsToContext(final Object attributable, final JexlContext jexlContext) {
-        JexlContext context = jexlContext == null
-                ? new MapContext()
-                : jexlContext;
-
+    public static void addFieldsToContext(final Object attributable, final JexlContext jexlContext) {
         final Field[] fields = attributable.getClass().getDeclaredFields();
-        for (int i = 0; i < fields.length; i++) {
+        for (Field field : fields) {
             try {
-                Field field = fields[i];
                 field.setAccessible(true);
                 final String fieldName = field.getName();
                 if ((!field.isSynthetic()) && (!fieldName.startsWith("pc"))
@@ -106,8 +110,8 @@ public class JexlUtil {
 
                     final Object fieldValue = field.get(attributable);
 
-                    context.set(fieldName, fieldValue == null
-                            ? ""
+                    jexlContext.set(fieldName, fieldValue == null
+                            ? StringUtils.EMPTY
                             : (field.getType().equals(Date.class)
                             ? DataFormat.format((Date) fieldValue, false)
                             : fieldValue));
@@ -118,74 +122,65 @@ public class JexlUtil {
                 LOG.error("Reading class attributes error", e);
             }
         }
-
-        return context;
     }
 
-    public JexlContext addAttrsToContext(final Collection<? extends AbstractAttr> attributes,
+    public static void addAttrsToContext(final Collection<? extends AbstractAttr> attributes,
             final JexlContext jexlContext) {
 
-        JexlContext context = jexlContext == null
-                ? new MapContext()
-                : jexlContext;
-
         for (AbstractAttr attr : attributes) {
             List<String> attributeValues = attr.getValuesAsStrings();
             String expressionValue = attributeValues.isEmpty()
-                    ? ""
+                    ? StringUtils.EMPTY
                     : attributeValues.get(0);
 
             LOG.debug("Add attribute {} with value {}", attr.getSchema().getName(), expressionValue);
 
-            context.set(attr.getSchema().getName(), expressionValue);
+            jexlContext.set(attr.getSchema().getName(), expressionValue);
         }
-
-        return context;
     }
 
-    public JexlContext addDerAttrsToContext(final Collection<? extends AbstractDerAttr> derAttrs,
+    public static void addDerAttrsToContext(final Collection<? extends AbstractDerAttr> derAttrs,
             final Collection<? extends AbstractAttr> attrs, final JexlContext jexlContext) {
 
-        JexlContext context = jexlContext == null
-                ? new MapContext()
-                : jexlContext;
-
         for (AbstractDerAttr derAttr : derAttrs) {
             String expressionValue = derAttr.getValue(attrs);
             if (expressionValue == null) {
-                expressionValue = "";
+                expressionValue = StringUtils.EMPTY;
             }
 
             LOG.debug("Add derived attribute {} with value {}", derAttr.getDerivedSchema().getName(), expressionValue);
 
-            context.set(derAttr.getDerivedSchema().getName(), expressionValue);
+            jexlContext.set(derAttr.getDerivedSchema().getName(), expressionValue);
         }
-
-        return context;
     }
 
-    public JexlContext addVirAttrsToContext(final Collection<? extends AbstractVirAttr> virAttrs,
+    public static void addVirAttrsToContext(final Collection<? extends AbstractVirAttr> virAttrs,
             final JexlContext jexlContext) {
 
-        JexlContext context = jexlContext == null
-                ? new MapContext()
-                : jexlContext;
-
         for (AbstractVirAttr virAttr : virAttrs) {
             List<String> attributeValues = virAttr.getValues();
             String expressionValue = attributeValues.isEmpty()
-                    ? ""
+                    ? StringUtils.EMPTY
                     : attributeValues.get(0);
 
             LOG.debug("Add virtual attribute {} with value {}", virAttr.getVirtualSchema().getName(), expressionValue);
 
-            context.set(virAttr.getVirtualSchema().getName(), expressionValue);
+            jexlContext.set(virAttr.getVirtualSchema().getName(), expressionValue);
         }
+    }
+
+    public static boolean evaluateMandatoryCondition(final String mandatoryCondition,
+            final AbstractAttributable attributable) {
+
+        JexlContext jexlContext = new MapContext();
+        addAttrsToContext(attributable.getAttributes(), jexlContext);
+        addDerAttrsToContext(attributable.getDerivedAttributes(), attributable.getAttributes(), jexlContext);
+        addVirAttrsToContext(attributable.getVirtualAttributes(), jexlContext);
 
-        return context;
+        return Boolean.parseBoolean(evaluate(mandatoryCondition, jexlContext));
     }
 
-    public String evaluate(final String expression, final AbstractAttributableTO attributableTO) {
+    public static String evaluate(final String expression, final AbstractAttributableTO attributableTO) {
         final JexlContext context = new MapContext();
 
         addFieldsToContext(attributableTO, context);
@@ -193,7 +188,7 @@ public class JexlUtil {
         for (AttributeTO attr : attributableTO.getAttributes()) {
             List<String> values = attr.getValues();
             String expressionValue = values.isEmpty()
-                    ? ""
+                    ? StringUtils.EMPTY
                     : values.get(0);
 
             LOG.debug("Add attribute {} with value {}", attr.getSchema(), expressionValue);
@@ -203,7 +198,7 @@ public class JexlUtil {
         for (AttributeTO derAttr : attributableTO.getDerivedAttributes()) {
             List<String> values = derAttr.getValues();
             String expressionValue = values.isEmpty()
-                    ? ""
+                    ? StringUtils.EMPTY
                     : values.get(0);
 
             LOG.debug("Add derived attribute {} with value {}", derAttr.getSchema(), expressionValue);
@@ -213,7 +208,7 @@ public class JexlUtil {
         for (AttributeTO virAttr : attributableTO.getVirtualAttributes()) {
             List<String> values = virAttr.getValues();
             String expressionValue = values.isEmpty()
-                    ? ""
+                    ? StringUtils.EMPTY
                     : values.get(0);
 
             LOG.debug("Add virtual attribute {} with value {}", virAttr.getSchema(), expressionValue);
@@ -224,4 +219,10 @@ public class JexlUtil {
         // Evaluate expression using the context prepared before
         return evaluate(expression, context);
     }
+
+    /**
+     * Private default constructor, for static-only classes.
+     */
+    private JexlUtil() {
+    }
 }

Modified: syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/MappingUtil.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/MappingUtil.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/MappingUtil.java (original)
+++ syncope/branches/1_1_X/core/src/main/java/org/apache/syncope/core/util/MappingUtil.java Mon Nov 11 16:56:53 2013
@@ -30,7 +30,6 @@ import org.apache.commons.jexl2.JexlCont
 import org.apache.commons.jexl2.MapContext;
 import org.apache.commons.lang.StringUtils;
 import org.apache.syncope.common.mod.AttributeMod;
-import org.apache.syncope.common.types.AttributableType;
 import org.apache.syncope.common.types.IntMappingType;
 import org.apache.syncope.common.types.AttributeSchemaType;
 import org.apache.syncope.core.connid.PasswordGenerator;
@@ -60,6 +59,7 @@ import org.identityconnectors.framework.
 import org.identityconnectors.framework.common.objects.Attribute;
 import org.identityconnectors.framework.common.objects.AttributeBuilder;
 import org.identityconnectors.framework.common.objects.Name;
+import org.identityconnectors.framework.common.objects.OperationalAttributes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.ConfigurableApplicationContext;
@@ -125,7 +125,6 @@ public final class MappingUtil {
      * @param vAttrsToBeRemoved virtual attributes to be removed
      * @param vAttrsToBeUpdated virtual attributes to be added
      * @return account link + prepared attribute
-     * @throws ClassNotFoundException if schema type for given mapping does not exists in current class loader
      */
     @SuppressWarnings("unchecked")
     public static <T extends AbstractAttributable> Map.Entry<String, Attribute> prepareAttribute(
@@ -267,14 +266,11 @@ public final class MappingUtil {
         // Evaluate AccountLink expression
         String evalAccountLink = null;
         if (StringUtils.isNotBlank(attrUtil.getAccountLink(resource))) {
-            final ConfigurableApplicationContext context = ApplicationContextProvider.getApplicationContext();
-            final JexlUtil jexlUtil = context.getBean(JexlUtil.class);
-
             final JexlContext jexlContext = new MapContext();
-            jexlUtil.addFieldsToContext(subject, jexlContext);
-            jexlUtil.addAttrsToContext(subject.getAttributes(), jexlContext);
-            jexlUtil.addDerAttrsToContext(subject.getDerivedAttributes(), subject.getAttributes(), jexlContext);
-            evalAccountLink = jexlUtil.evaluate(attrUtil.getAccountLink(resource), jexlContext);
+            JexlUtil.addFieldsToContext(subject, jexlContext);
+            JexlUtil.addAttrsToContext(subject.getAttributes(), jexlContext);
+            JexlUtil.addDerAttrsToContext(subject.getDerivedAttributes(), subject.getAttributes(), jexlContext);
+            evalAccountLink = JexlUtil.evaluate(attrUtil.getAccountLink(resource), jexlContext);
         }
 
         // If AccountLink evaluates to an empty string, just use the provided AccountId as Name(),

Modified: syncope/branches/1_1_X/core/src/main/resources/syncopeContext.xml
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/main/resources/syncopeContext.xml?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/main/resources/syncopeContext.xml (original)
+++ syncope/branches/1_1_X/core/src/main/resources/syncopeContext.xml Mon Nov 11 16:56:53 2013
@@ -91,8 +91,6 @@ under the License.
     <property name="silent" value="false"/>
   </bean>
   
-  <bean id="jexlUtil" class="org.apache.syncope.core.util.JexlUtil"/>
-  
   <bean id="virAttrCache" class="org.apache.syncope.core.util.VirAttrCache" scope="singleton">
     <constructor-arg value="60"/>
     <constructor-arg value="5000"/>

Modified: syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1540775&r1=1540774&r2=1540775&view=diff
==============================================================================
--- syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ syncope/branches/1_1_X/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Mon Nov 11 16:56:53 2013
@@ -2199,7 +2199,7 @@ public class UserTestITCase extends Abst
 
     @Test
     public void issueSYNCOPE383() {
-        // 1. create user on testdb and testdb2
+        // 1. create user without resources
         UserTO userTO = getUniqueSampleTO("syncope383@apache.org");
         userTO.getResources().clear();
         userTO = createUser(userTO);
@@ -2281,19 +2281,17 @@ public class UserTestITCase extends Abst
         //modify virtual attribute
         userMod.addVirtualAttributeToBeRemoved("virtualdata");
         userMod.addVirtualAttributeToBeUpdated(attributeMod("virtualdata", "test@testoneone.com"));
+        
         // check Syncope change password
-
         PropagationRequestTO pwdPropRequest = new PropagationRequestTO();
-        //change pwd on Syncope
-        pwdPropRequest.addResource("ws-target-resource-2");
-        //change pwd on Syncope
         pwdPropRequest.setOnSyncope(true);
+        pwdPropRequest.addResource("ws-target-resource-2");
         userMod.setPwdPropRequest(pwdPropRequest);
+        
         toBeUpdated = userService.update(userMod.getId(), userMod);
         assertNotNull(toBeUpdated);
         assertEquals("test@testoneone.com", toBeUpdated.getVirtualAttributes().get(0).getValues().get(0));
         // check if propagates correctly with assertEquals on size of tasks list
-
         assertEquals(2, toBeUpdated.getPropagationStatusTOs().size());
     }
 
@@ -2355,15 +2353,44 @@ public class UserTestITCase extends Abst
         assertNotNull(userTO);
     }
 
-    private boolean getBooleanAttribute(ConnObjectTO connObjectTO, String attrName) {
+    @Test
+    public void issueSYNCOPE435() {
+        // 1. try to create user without password - fail
+        UserTO userTO = getUniqueSampleTO("syncope435@syncope.apache.org");
+        userTO.setPassword(null);
+        userTO.getMemberships().clear();
+
+        try {
+            createUser(userTO);
+            fail();
+        } catch (SyncopeClientCompositeErrorException e) {
+            assertNotNull(e.getException(SyncopeClientExceptionType.InvalidSyncopeUser));
+        }
+
+        userTO.setPassword("password123");
+        userTO = createUser(userTO);
+        assertNotNull(userTO);
+
+        // 2. try to update user by subscribing a resource - works but propagation is not even attempted
+        UserMod userMod = new UserMod();
+        userMod.getResourcesToBeAdded().add("ws-target-resource-1");
+
+        userTO = userService.update(userTO.getId(), userMod);
+        assertEquals(Collections.singleton("ws-target-resource-1"), userTO.getResources());
+        assertFalse(userTO.getPropagationStatusTOs().get(0).getStatus().isSuccessful());
+        assertTrue(userTO.getPropagationStatusTOs().get(0).getFailureReason().
+                startsWith("Not attempted because there are mandatory attributes without value(s): [__PASSWORD__]"));
+    }
+
+    private boolean getBooleanAttribute(final ConnObjectTO connObjectTO, final String attrName) {
         return Boolean.parseBoolean(getStringAttribute(connObjectTO, attrName));
     }
 
-    private String getStringAttribute(ConnObjectTO connObjectTO, String attrName) {
+    private String getStringAttribute(final ConnObjectTO connObjectTO, final String attrName) {
         return connObjectTO.getAttributeMap().get(attrName).getValues().get(0);
     }
 
-    private long getMaxTaskId(List<PropagationTaskTO> tasks) {
+    private long getMaxTaskId(final List<PropagationTaskTO> tasks) {
         long newMaxId = Long.MIN_VALUE;
         for (PropagationTaskTO task : tasks) {
             if (task.getId() > newMaxId) {