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 2019/12/05 13:07:08 UTC

[syncope] 01/02: White noise

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 7dcd93842b7ab82b9092d74681885b890cc7ffd2
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Thu Dec 5 08:36:32 2019 +0100

    White noise
---
 .../java/org/apache/syncope/core/logic/SAML2IdPLogic.java |  3 ++-
 .../java/org/apache/syncope/core/logic/SAML2SPLogic.java  | 15 ++++++++-------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2IdPLogic.java b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2IdPLogic.java
index 1aafa1a..31c3a12 100644
--- a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2IdPLogic.java
+++ b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2IdPLogic.java
@@ -44,6 +44,7 @@ import org.apache.syncope.core.persistence.api.entity.SAML2IdP;
 import org.apache.syncope.core.provisioning.api.data.SAML2IdPDataBinder;
 import org.apache.wss4j.common.saml.OpenSAMLUtil;
 import org.opensaml.saml.common.xml.SAMLConstants;
+import org.opensaml.saml.saml2.core.NameID;
 import org.opensaml.saml.saml2.metadata.EntitiesDescriptor;
 import org.opensaml.saml.saml2.metadata.EntityDescriptor;
 import org.opensaml.saml.saml2.metadata.IDPSSODescriptor;
@@ -149,7 +150,7 @@ public class SAML2IdPLogic extends AbstractSAML2Logic<SAML2IdPTO> {
 
             ItemTO connObjectKeyItem = new ItemTO();
             connObjectKeyItem.setIntAttrName("username");
-            connObjectKeyItem.setExtAttrName("NameID");
+            connObjectKeyItem.setExtAttrName(NameID.DEFAULT_ELEMENT_LOCAL_NAME);
             idpTO.setConnObjectKeyItem(connObjectKeyItem);
 
             SAML2IdPEntity idp = cache.put(idpEntityDescriptor, idpTO);
diff --git a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2SPLogic.java b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2SPLogic.java
index b63318d..de8eb2f 100644
--- a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2SPLogic.java
+++ b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2SPLogic.java
@@ -27,6 +27,7 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 import javax.annotation.Resource;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
@@ -438,12 +439,12 @@ public class SAML2SPLogic extends AbstractSAML2Logic<EntityTO> {
         Assertion assertion = validatorResponse.getOpensamlAssertion();
         NameID nameID = assertion.getSubject().getNameID();
         if (nameID == null) {
-            throw new IllegalArgumentException("NameID not found");
+            throw new IllegalArgumentException(NameID.DEFAULT_ELEMENT_LOCAL_NAME + " not found");
         }
 
         String keyValue = null;
         if (StringUtils.isNotBlank(nameID.getValue())
-                && idp.getConnObjectKeyItem().getExtAttrName().equals("NameID")) {
+                && idp.getConnObjectKeyItem().getExtAttrName().equals(NameID.DEFAULT_ELEMENT_LOCAL_NAME)) {
 
             keyValue = nameID.getValue();
         }
@@ -472,11 +473,11 @@ public class SAML2SPLogic extends AbstractSAML2Logic<EntityTO> {
                         }
                     }
 
-                    Attr attrTO = new Attr();
-                    attrTO.setSchema(attrName);
-                    attr.getAttributeValues().stream().
-                            filter(value -> value.getDOM() != null).
-                            forEachOrdered(value -> attrTO.getValues().add(value.getDOM().getTextContent()));
+                    Attr attrTO = new Attr.Builder(attrName).
+                            values(attr.getAttributeValues().stream().
+                                    filter(value -> value.getDOM() != null).
+                                    map(value -> value.getDOM().getTextContent()).
+                                    collect(Collectors.toList())).build();
                     responseTO.getAttrs().add(attrTO);
                 }
             }