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/01/29 15:39:49 UTC

[1/2] syncope git commit: [SYNCOPE-1265] Populating the IdP cache upon startup

Repository: syncope
Updated Branches:
  refs/heads/2_0_X 6c96d5129 -> 71b39dd4b
  refs/heads/master c1975406a -> 78af14813


[SYNCOPE-1265] Populating the IdP cache upon startup


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

Branch: refs/heads/2_0_X
Commit: 71b39dd4b3cb552e8f5f0d8fc5eaf979252868af
Parents: 6c96d51
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Jan 29 16:38:02 2018 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Jan 29 16:38:02 2018 +0100

----------------------------------------------------------------------
 .../syncope/core/logic/init/SAML2SPLoader.java  | 31 ++++++++++++++++++++
 1 file changed, 31 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/71b39dd4/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/init/SAML2SPLoader.java
----------------------------------------------------------------------
diff --git a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/init/SAML2SPLoader.java b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/init/SAML2SPLoader.java
index 308b95e..8d9fba0 100644
--- a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/init/SAML2SPLoader.java
+++ b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/init/SAML2SPLoader.java
@@ -30,9 +30,14 @@ import org.apache.syncope.common.lib.PropertyUtils;
 import org.apache.syncope.core.persistence.api.SyncopeLoader;
 import org.apache.syncope.core.provisioning.api.EntitlementsHolder;
 import org.apache.syncope.common.lib.types.SAML2SPEntitlement;
+import org.apache.syncope.core.logic.saml2.SAML2IdPCache;
 import org.apache.syncope.core.logic.saml2.SAML2ReaderWriter;
+import org.apache.syncope.core.persistence.api.DomainsHolder;
+import org.apache.syncope.core.persistence.api.dao.SAML2IdPDAO;
+import org.apache.syncope.core.persistence.api.entity.SAML2IdP;
 import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.apache.syncope.core.spring.ResourceWithFallbackLoader;
+import org.apache.syncope.core.spring.security.AuthContextUtils;
 import org.apache.wss4j.common.saml.OpenSAMLUtil;
 import org.opensaml.core.criterion.EntityIdCriterion;
 import org.opensaml.security.credential.Credential;
@@ -63,6 +68,15 @@ public class SAML2SPLoader implements SyncopeLoader {
     @Autowired
     private SAML2ReaderWriter saml2rw;
 
+    @Autowired
+    private DomainsHolder domainsHolder;
+
+    @Autowired
+    private SAML2IdPCache cache;
+
+    @Autowired
+    private SAML2IdPDAO idpDAO;
+
     private boolean inited;
 
     private KeyStore keystore;
@@ -127,6 +141,23 @@ public class SAML2SPLoader implements SyncopeLoader {
             LOG.error("Could not initialize the SAML 2.0 Service Provider certificate", e);
             inited = false;
         }
+
+        for (String domain : domainsHolder.getDomains().keySet()) {
+            AuthContextUtils.execWithAuthContext(domain, new AuthContextUtils.Executable<Void>() {
+
+                @Override
+                public Void exec() {
+                    for (SAML2IdP idp : idpDAO.findAll()) {
+                        try {
+                            cache.put(idp);
+                        } catch (Exception e) {
+                            LOG.error("Could not cache the SAML 2.0 IdP with key ", idp.getEntityID(), e);
+                        }
+                    }
+                    return null;
+                }
+            });
+        }
     }
 
     public boolean isInited() {


[2/2] syncope git commit: [SYNCOPE-1265] Populating the IdP cache upon startup

Posted by il...@apache.org.
[SYNCOPE-1265] Populating the IdP cache upon startup


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

Branch: refs/heads/master
Commit: 78af1481312217b78cb41bd1dc292c6e25324c23
Parents: c197540
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Mon Jan 29 16:38:02 2018 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Mon Jan 29 16:39:41 2018 +0100

----------------------------------------------------------------------
 .../syncope/core/logic/init/SAML2SPLoader.java  | 26 ++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/78af1481/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/init/SAML2SPLoader.java
----------------------------------------------------------------------
diff --git a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/init/SAML2SPLoader.java b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/init/SAML2SPLoader.java
index 308b95e..5c47843 100644
--- a/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/init/SAML2SPLoader.java
+++ b/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/init/SAML2SPLoader.java
@@ -30,9 +30,13 @@ import org.apache.syncope.common.lib.PropertyUtils;
 import org.apache.syncope.core.persistence.api.SyncopeLoader;
 import org.apache.syncope.core.provisioning.api.EntitlementsHolder;
 import org.apache.syncope.common.lib.types.SAML2SPEntitlement;
+import org.apache.syncope.core.logic.saml2.SAML2IdPCache;
 import org.apache.syncope.core.logic.saml2.SAML2ReaderWriter;
+import org.apache.syncope.core.persistence.api.DomainsHolder;
+import org.apache.syncope.core.persistence.api.dao.SAML2IdPDAO;
 import org.apache.syncope.core.spring.ApplicationContextProvider;
 import org.apache.syncope.core.spring.ResourceWithFallbackLoader;
+import org.apache.syncope.core.spring.security.AuthContextUtils;
 import org.apache.wss4j.common.saml.OpenSAMLUtil;
 import org.opensaml.core.criterion.EntityIdCriterion;
 import org.opensaml.security.credential.Credential;
@@ -63,6 +67,15 @@ public class SAML2SPLoader implements SyncopeLoader {
     @Autowired
     private SAML2ReaderWriter saml2rw;
 
+    @Autowired
+    private DomainsHolder domainsHolder;
+
+    @Autowired
+    private SAML2IdPCache cache;
+
+    @Autowired
+    private SAML2IdPDAO idpDAO;
+
     private boolean inited;
 
     private KeyStore keystore;
@@ -127,6 +140,19 @@ public class SAML2SPLoader implements SyncopeLoader {
             LOG.error("Could not initialize the SAML 2.0 Service Provider certificate", e);
             inited = false;
         }
+
+        domainsHolder.getDomains().keySet().forEach(domain -> {
+            AuthContextUtils.execWithAuthContext(domain, () -> {
+                idpDAO.findAll().forEach(idp -> {
+                    try {
+                        cache.put(idp);
+                    } catch (Exception e) {
+                        LOG.error("Could not cache the SAML 2.0 IdP with key ", idp.getEntityID(), e);
+                    }
+                });
+                return null;
+            });
+        });
     }
 
     public boolean isInited() {