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/12/12 07:52:35 UTC

[syncope] 02/02: [SYNCOPE-1410] Avoid ClassCastException

This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 4e128aa366b6b08035e8f2476f2f60bd0b531f20
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Wed Dec 12 08:52:24 2018 +0100

    [SYNCOPE-1410] Avoid ClassCastException
---
 .../apache/syncope/core/provisioning/java/utils/TemplateUtils.java  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/utils/TemplateUtils.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/utils/TemplateUtils.java
index 65abf2f..cd23a66 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/utils/TemplateUtils.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/utils/TemplateUtils.java
@@ -185,7 +185,11 @@ public class TemplateUtils {
 
             fillRelationships((GroupableRelatableTO) reqEntity, ((GroupableRelatableTO) template));
             fillMemberships((GroupableRelatableTO) reqEntity, ((GroupableRelatableTO) template));
-            ((UserTO) reqEntity).getRoles().addAll(((UserTO) template).getRoles());
+            if (reqEntity instanceof UserTO) {
+                ((UserTO) reqEntity).getRoles().addAll(((UserTO) template).getRoles());
+            } else if (reqEntity instanceof UserCR) {
+                ((UserCR) reqEntity).getRoles().addAll(((UserTO) template).getRoles());
+            }
         } else if (template instanceof GroupTO) {
             if (StringUtils.isNotBlank(((GroupTO) template).getName())) {
                 String evaluated = JexlUtils.evaluate(((GroupTO) template).getName(), jexlContext);