http://git-wip-us.apache.org/repos/asf/syncope/blob/14774113/ext/saml2sp/client-enduser/src/main/java/org/apache/syncope/client/enduser/pages/SAML2SPLogout.java
----------------------------------------------------------------------
diff --git 
a/ext/saml2sp/client-enduser/src/main/java/org/apache/syncope/client/enduser/pages/SAML2SPLogout.java
 
b/ext/saml2sp/client-enduser/src/main/java/org/apache/syncope/client/enduser/pages/SAML2SPLogout.java
new file mode 100644
index 0000000..39ac276
--- /dev/null
+++ 
b/ext/saml2sp/client-enduser/src/main/java/org/apache/syncope/client/enduser/pages/SAML2SPLogout.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.enduser.pages;
+
+import org.apache.syncope.client.enduser.SyncopeEnduserSession;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+public class SAML2SPLogout extends WebPage {
+
+    private static final long serialVersionUID = 8581614051773949262L;
+
+    public SAML2SPLogout(final PageParameters parameters) {
+        super(parameters);
+
+        SyncopeEnduserSession.get().invalidateNow();
+
+        setResponsePage(getApplication().getHomePage());
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/14774113/ext/saml2sp/client-enduser/src/main/java/org/apache/syncope/client/enduser/resources/SAML2IdPsResource.java
----------------------------------------------------------------------
diff --git 
a/ext/saml2sp/client-enduser/src/main/java/org/apache/syncope/client/enduser/resources/SAML2IdPsResource.java
 
b/ext/saml2sp/client-enduser/src/main/java/org/apache/syncope/client/enduser/resources/SAML2IdPsResource.java
new file mode 100644
index 0000000..7926802
--- /dev/null
+++ 
b/ext/saml2sp/client-enduser/src/main/java/org/apache/syncope/client/enduser/resources/SAML2IdPsResource.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.enduser.resources;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.apache.syncope.client.enduser.SyncopeEnduserSession;
+import org.apache.syncope.client.enduser.annotations.Resource;
+import org.apache.syncope.common.lib.to.SAML2IdPTO;
+import org.apache.syncope.common.rest.api.service.SAML2IdPService;
+import org.apache.wicket.request.resource.AbstractResource;
+
+@Resource(key = "saml2IdPs", path = "/api/saml2IdPs")
+public class SAML2IdPsResource extends BaseResource {
+
+    private static final long serialVersionUID = -1538214102767503491L;
+
+    @Override
+    protected ResourceResponse newResourceResponse(final Attributes 
attributes) {
+        ResourceResponse response = new ResourceResponse();
+        response.setContentType(MediaType.APPLICATION_JSON);
+        response.setTextEncoding(StandardCharsets.UTF_8.name());
+        try {
+            final ArrayNode result = MAPPER.createArrayNode();
+
+            for (SAML2IdPTO idp : 
SyncopeEnduserSession.get().getService(SAML2IdPService.class).list()) {
+                ObjectNode idpNode = MAPPER.createObjectNode();
+                idpNode.put("name", idp.getName());
+                idpNode.put("entityID", idp.getEntityID());
+                idpNode.put("logout", idp.isLogoutSupported());
+                result.add(idpNode);
+            }
+
+            response.setWriteCallback(new AbstractResource.WriteCallback() {
+
+                @Override
+                public void writeData(final Attributes attributes) throws 
IOException {
+                    
attributes.getResponse().write(MAPPER.writeValueAsString(result));
+                }
+            });
+            response.setStatusCode(Response.Status.OK.getStatusCode());
+        } catch (Exception e) {
+            LOG.error("Error retrieving available SAML 2.0 Identity 
Providers", e);
+            response.setError(
+                    Response.Status.BAD_REQUEST.getStatusCode(),
+                    "ErrorMessage{{ " + e.getMessage() + "}}");
+        }
+
+        return response;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/14774113/ext/saml2sp/logic/src/main/java/org/apache/syncope/core/logic/SAML2IdPLogic.java
----------------------------------------------------------------------
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 eb1a94f..7c8417e 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
@@ -69,10 +69,20 @@ public class SAML2IdPLogic extends 
AbstractSAML2Logic<SAML2IdPTO> {
     @Autowired
     private SAML2ReaderWriter saml2rw;
 
-    private SAML2IdPTO complete(final SAML2IdPTO input) {
-        SAML2IdPEntity idp = cache.get(input.getEntityID());
-        
input.setLogoutSupported(idp.getSLOLocation(SAMLConstants.SAML2_POST_BINDING_URI)
 != null);
-        return input;
+    private SAML2IdPTO complete(final SAML2IdP idp, final SAML2IdPTO idpTO) {
+        SAML2IdPEntity idpEntity = cache.get(idpTO.getEntityID());
+        if (idpEntity == null) {
+            try {
+                idpEntity = cache.put(idp);
+            } catch (Exception e) {
+                LOG.error("Could not build SAML 2.0 IdP with key ", 
idp.getEntityID(), e);
+            }
+        }
+
+        idpTO.setLogoutSupported(idpEntity == null
+                ? false
+                : 
idpEntity.getSLOLocation(SAMLConstants.SAML2_POST_BINDING_URI) != null);
+        return idpTO;
     }
 
     @PreAuthorize("isAuthenticated()")
@@ -82,7 +92,7 @@ public class SAML2IdPLogic extends 
AbstractSAML2Logic<SAML2IdPTO> {
 
             @Override
             public SAML2IdPTO transform(final SAML2IdP input) {
-                return complete(binder.getIdPTO(input));
+                return complete(input, binder.getIdPTO(input));
             }
         }, new ArrayList<SAML2IdPTO>());
     }
@@ -97,7 +107,7 @@ public class SAML2IdPLogic extends 
AbstractSAML2Logic<SAML2IdPTO> {
             throw new NotFoundException("SAML 2.0 IdP '" + key + "'");
         }
 
-        return complete(binder.getIdPTO(idp));
+        return complete(idp, binder.getIdPTO(idp));
     }
 
     private List<SAML2IdPTO> importIdPs(final InputStream input) throws 
Exception {
@@ -224,7 +234,8 @@ public class SAML2IdPLogic extends 
AbstractSAML2Logic<SAML2IdPTO> {
 
         if (key != null) {
             try {
-                return complete(binder.getIdPTO(idpDAO.find(key)));
+                SAML2IdP idp = idpDAO.find(key);
+                return complete(idp, binder.getIdPTO(idp));
             } catch (Throwable ignore) {
                 LOG.debug("Unresolved reference", ignore);
                 throw new UnresolvedReferenceException(ignore);

http://git-wip-us.apache.org/repos/asf/syncope/blob/14774113/fit/enduser-reference/pom.xml
----------------------------------------------------------------------
diff --git a/fit/enduser-reference/pom.xml b/fit/enduser-reference/pom.xml
index fe389ff..0354f8a 100644
--- a/fit/enduser-reference/pom.xml
+++ b/fit/enduser-reference/pom.xml
@@ -62,6 +62,12 @@ under the License.
     </dependency>
 
     <dependency>
+      <groupId>org.apache.syncope.ext.saml2sp</groupId>
+      <artifactId>syncope-ext-saml2sp-client-enduser</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>

http://git-wip-us.apache.org/repos/asf/syncope/blob/14774113/fit/enduser-reference/src/main/resources/saml2sp-agent.properties
----------------------------------------------------------------------
diff --git a/fit/enduser-reference/src/main/resources/saml2sp-agent.properties 
b/fit/enduser-reference/src/main/resources/saml2sp-agent.properties
new file mode 100644
index 0000000..1d53d49
--- /dev/null
+++ b/fit/enduser-reference/src/main/resources/saml2sp-agent.properties
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+conf.directory=${conf.directory}
+
+anonymousUser=${anonymousUser}
+anonymousKey=${anonymousKey}
+
+scheme=http
+host=localhost
+port=9080
+rootPath=/syncope/rest/
+useGZIPCompression=true

http://git-wip-us.apache.org/repos/asf/syncope/blob/14774113/fit/enduser-reference/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/fit/enduser-reference/src/main/webapp/WEB-INF/web.xml 
b/fit/enduser-reference/src/main/webapp/WEB-INF/web.xml
index 10afe42..fa4720d 100644
--- a/fit/enduser-reference/src/main/webapp/WEB-INF/web.xml
+++ b/fit/enduser-reference/src/main/webapp/WEB-INF/web.xml
@@ -30,9 +30,27 @@ under the License.
     <param-value>deployment</param-value>
   </context-param>
 
+  <context-param>
+    <param-name>saml2sp.login.success.url</param-name>
+    
<param-value>../wicket/bookmarkable/org.apache.syncope.client.enduser.pages.SAML2SPLogin</param-value>
+  </context-param>
+  <context-param>
+    <param-name>saml2sp.login.error.url</param-name>
+    
<param-value>../wicket/bookmarkable/org.apache.syncope.client.enduser.pages.HomePage</param-value>
+  </context-param>
+  
+  <context-param>
+    <param-name>saml2sp.logout.success.url</param-name>
+    
<param-value>../wicket/bookmarkable/org.apache.syncope.client.enduser.pages.SAML2SPLogout</param-value>
+  </context-param>
+  <context-param>
+    <param-name>saml2sp.logout.error.url</param-name>
+    
<param-value>../wicket/bookmarkable/org.apache.syncope.client.enduser.pages.HomePage</param-value>
+  </context-param>
+
   <!-- SESSION TIMEOUT (MINUTES)-->
   <session-config>
     <session-timeout>30</session-timeout>
   </session-config>
 
-</web-app>
\ No newline at end of file
+</web-app>

http://git-wip-us.apache.org/repos/asf/syncope/blob/14774113/fit/enduser-reference/src/test/resources/rebel.xml
----------------------------------------------------------------------
diff --git a/fit/enduser-reference/src/test/resources/rebel.xml 
b/fit/enduser-reference/src/test/resources/rebel.xml
index eca8af7..da15397 100644
--- a/fit/enduser-reference/src/test/resources/rebel.xml
+++ b/fit/enduser-reference/src/test/resources/rebel.xml
@@ -26,6 +26,10 @@ under the License.
     </dir>
     <dir name="${basedir}/../../client/enduser/target/classes">
     </dir>
+    <dir name="${basedir}/../../ext/saml2sp/agent/target/classes">
+    </dir>
+    <dir name="${basedir}/../../ext/saml2sp/client-enduser/target/classes">
+    </dir>
   </classpath>
 
   <web>
@@ -37,6 +41,10 @@ under the License.
       <dir 
name="${basedir}/../../client/enduser/target/classes/META-INF/resources">
       </dir>
     </link>
+    <link target="/">
+      <dir name="${basedir}/../../ext/saml2sp/client-enduser/target/classes">
+      </dir>
+    </link>
   </web>
 
 </application>

Reply via email to