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 2017/08/31 15:24:14 UTC

[3/4] syncope git commit: Cleaning up log messages

Cleaning up log messages


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/8ce27484
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/8ce27484
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/8ce27484

Branch: refs/heads/master
Commit: 8ce27484a557ea7ee07ffa27134aaeb4215fc172
Parents: 58983df
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Thu Aug 31 17:13:57 2017 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Thu Aug 31 17:19:55 2017 +0200

----------------------------------------------------------------------
 .../apache/syncope/core/logic/SAML2SPLogic.java | 22 ++++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/8ce27484/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2SPLogic.java
----------------------------------------------------------------------
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 755d938..1d64ace 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
@@ -434,6 +434,10 @@ public class SAML2SPLogic extends AbstractSAML2Logic<AbstractBaseBean> {
 
         Assertion assertion = validatorResponse.getOpensamlAssertion();
         NameID nameID = assertion.getSubject().getNameID();
+        if (nameID == null) {
+            throw new IllegalArgumentException("NameID not found");
+        }
+
         String keyValue = null;
         if (StringUtils.isNotBlank(nameID.getValue())
                 && idp.getConnObjectKeyItem().getExtAttrName().equals("NameID")) {
@@ -474,31 +478,27 @@ public class SAML2SPLogic extends AbstractSAML2Logic<AbstractBaseBean> {
                 }
             }
         }
-        if (nameID == null) {
-            throw new IllegalArgumentException("NameID not found");
-        }
-        final String nameIDValue = nameID.getValue();
 
         final List<String> matchingUsers = keyValue == null
                 ? Collections.<String>emptyList()
                 : userManager.findMatchingUser(keyValue, idp.getConnObjectKeyItem());
-        LOG.debug("Found {} matching users for NameID {}", matchingUsers.size(), nameID.getValue());
+        LOG.debug("Found {} matching users for {}", matchingUsers.size(), keyValue);
 
         String username;
         if (matchingUsers.isEmpty()) {
             if (idp.isCreateUnmatching()) {
-                LOG.debug("No user matching NameID {}, about to create", nameID.getValue());
+                LOG.debug("No user matching {}, about to create", keyValue);
 
-                username = AuthContextUtils.execWithAuthContext(AuthContextUtils.getDomain(), ()
-                        -> userManager.create(idp, responseTO, nameIDValue));
+                username = AuthContextUtils.execWithAuthContext(AuthContextUtils.getDomain(),
+                        () -> userManager.create(idp, responseTO, nameID.getValue()));
             } else {
-                throw new NotFoundException("User matching the provided NameID value " + nameID.getValue());
+                throw new NotFoundException("User matching the provided value " + keyValue);
             }
         } else if (matchingUsers.size() > 1) {
-            throw new IllegalArgumentException("Several users match the provided NameID value " + nameID.getValue());
+            throw new IllegalArgumentException("Several users match the provided value " + keyValue);
         } else {
             if (idp.isUpdateMatching()) {
-                LOG.debug("About to update {} for NameID {}", matchingUsers.get(0), nameID.getValue());
+                LOG.debug("About to update {} for {}", matchingUsers.get(0), keyValue);
 
                 username = AuthContextUtils.execWithAuthContext(AuthContextUtils.getDomain(), ()
                         -> userManager.update(matchingUsers.get(0), idp, responseTO));