[seam-commits] Seam SVN: r13772 - in modules/security/trunk/examples: openid-op/src/main/java/org/jboss/seam/security/examples/openid and 6 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Sep 21 08:37:26 EDT 2010


Author: marcelkolsteren
Date: 2010-09-21 08:37:23 -0400 (Tue, 21 Sep 2010)
New Revision: 13772

Removed:
   modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/RequestObserver.java
   modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/RequestObserver.java
Modified:
   modules/security/trunk/examples/openid-op/pom.xml
   modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/Attributes.java
   modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/DialogueAwareViewHandler.java
   modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/Login.java
   modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/OpenIdProviderSpiImpl.java
   modules/security/trunk/examples/openid-rp/pom.xml
   modules/security/trunk/examples/openid-rp/src/main/java/org/jboss/seam/security/examples/id_consumer/Identity.java
   modules/security/trunk/examples/openid-rp/src/main/java/org/jboss/seam/security/examples/id_consumer/OpenIdRelyingPartySpiImpl.java
   modules/security/trunk/examples/saml-idp/pom.xml
   modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Configuration.java
   modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Identity.java
   modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Login.java
   modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/SamlIdentityProviderSpiImpl.java
   modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/SessionManagement.java
   modules/security/trunk/examples/saml-sp/pom.xml
   modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/Configuration.java
   modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/Identity.java
   modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/SamlServiceProviderSpiImpl.java
Log:
Updated SAML and OpenID sample applications, because of changes in the external authentication API and SPI.

Modified: modules/security/trunk/examples/openid-op/pom.xml
===================================================================
--- modules/security/trunk/examples/openid-op/pom.xml	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/openid-op/pom.xml	2010-09-21 12:37:23 UTC (rev 13772)
@@ -15,8 +15,6 @@
    </parent>
 
    <properties>
-      <seam.faces.version>3.0.0-SNAPSHOT</seam.faces.version>
-      <seam.international.version>3.0.0-SNAPSHOT</seam.international.version>
       <weld.extensions.version>1.0.0.Alpha2</weld.extensions.version>
    </properties>
 

Modified: modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/Attributes.java
===================================================================
--- modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/Attributes.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/Attributes.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -29,7 +29,9 @@
 import java.util.Map;
 
 import javax.enterprise.inject.Model;
+import javax.faces.context.ExternalContext;
 import javax.inject.Inject;
+import javax.servlet.http.HttpServletResponse;
 
 import org.jboss.seam.security.external.api.OpenIdProviderApi;
 import org.jboss.seam.security.external.api.OpenIdRequestedAttribute;
@@ -46,6 +48,9 @@
    @Inject
    private OpenIdProviderApi providerApi;
 
+   @Inject
+   private ExternalContext externalContext;
+
    public void setRequestedAttributes(List<OpenIdRequestedAttribute> requestedAttributes)
    {
       attributeVOs = new LinkedList<AttributeVO>();
@@ -73,6 +78,6 @@
             attributeValues.put(attributeVO.getRequestedAttribute().getAlias(), Arrays.asList(attributeVO.getAttributeValue()));
          }
       }
-      providerApi.setAttributes(attributeValues);
+      providerApi.setAttributes(attributeValues, (HttpServletResponse) externalContext.getResponse());
    }
 }

Modified: modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/DialogueAwareViewHandler.java
===================================================================
--- modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/DialogueAwareViewHandler.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/DialogueAwareViewHandler.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -25,10 +25,11 @@
 import javax.faces.application.ViewHandlerWrapper;
 import javax.faces.context.FacesContext;
 import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletResponse;
 
-import org.jboss.seam.security.external.DialogueFilter;
+import org.jboss.seam.security.external.ResponseHolderImpl;
+import org.jboss.seam.security.external.api.ResponseHolder;
 import org.jboss.seam.security.external.dialogues.DialogueBeanProvider;
-import org.jboss.seam.security.external.dialogues.api.Dialogue;
 
 /**
  * @author Marcel Kolsteren
@@ -36,10 +37,6 @@
  */
 public class DialogueAwareViewHandler extends ViewHandlerWrapper
 {
-   private static final String QUERY_STRING_DELIMITER = "?";
-   private static final String PARAMETER_PAIR_DELIMITER = "&";
-   private static final String PARAMETER_ASSIGNMENT_OPERATOR = "=";
-
    private ViewHandler delegate;
 
    public DialogueAwareViewHandler(ViewHandler delegate)
@@ -54,8 +51,9 @@
       ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
       if (DialogueBeanProvider.dialogueManager(servletContext).isAttached())
       {
-         Dialogue dialogue = DialogueBeanProvider.dialogue(servletContext);
-         return appendDialogueIdIfNecessary(actionUrl, facesContext, dialogue.getDialogueId());
+         String dialogueId = DialogueBeanProvider.dialogue(servletContext).getDialogueId();
+         ResponseHolder responseHolder = new ResponseHolderImpl((HttpServletResponse) facesContext.getExternalContext().getResponse(), dialogueId);
+         return responseHolder.addDialogueIdToUrl(actionUrl);
       }
       else
       {
@@ -63,18 +61,6 @@
       }
    }
 
-   public String appendDialogueIdIfNecessary(String url, FacesContext facesContext, String cid)
-   {
-      String paramName = DialogueFilter.DIALOGUE_ID_PARAM;
-      int queryStringIndex = url.indexOf(QUERY_STRING_DELIMITER);
-      if (queryStringIndex < 0 || url.indexOf(paramName + PARAMETER_ASSIGNMENT_OPERATOR, queryStringIndex) < 0)
-      {
-         url = new StringBuilder(url).append(queryStringIndex < 0 ? QUERY_STRING_DELIMITER : PARAMETER_PAIR_DELIMITER).append(paramName).append(PARAMETER_ASSIGNMENT_OPERATOR).append(cid).toString();
-      }
-      return url;
-
-   }
-
    /**
     * @see {@link ViewHandlerWrapper#getWrapped()}
     */

Modified: modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/Login.java
===================================================================
--- modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/Login.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/Login.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -22,7 +22,9 @@
 package org.jboss.seam.security.examples.openid;
 
 import javax.enterprise.inject.Model;
+import javax.faces.context.ExternalContext;
 import javax.inject.Inject;
+import javax.servlet.http.HttpServletResponse;
 
 import org.jboss.seam.security.external.api.OpenIdProviderApi;
 import org.jboss.seam.security.external.dialogues.DialogueManager;
@@ -45,6 +47,9 @@
    @Inject
    private Identity identity;
 
+   @Inject
+   private ExternalContext externalContext;
+
    public String getUserName()
    {
       return userName;
@@ -86,7 +91,7 @@
       identity.localLogin(userName);
       if (dialogueManager.isAttached())
       {
-         opApi.authenticationSucceeded(userName);
+         opApi.authenticationSucceeded(userName, (HttpServletResponse) externalContext.getResponse());
          return null;
       }
       else
@@ -99,7 +104,7 @@
    {
       if (dialogueManager.isAttached())
       {
-         opApi.authenticationFailed();
+         opApi.authenticationFailed((HttpServletResponse) externalContext.getResponse());
       }
       else
       {

Modified: modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/OpenIdProviderSpiImpl.java
===================================================================
--- modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/OpenIdProviderSpiImpl.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/openid-op/src/main/java/org/jboss/seam/security/examples/openid/OpenIdProviderSpiImpl.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -31,15 +31,11 @@
 import org.jboss.seam.security.external.api.OpenIdProviderApi;
 import org.jboss.seam.security.external.api.OpenIdRequestedAttribute;
 import org.jboss.seam.security.external.api.ResponseHolder;
-import org.jboss.seam.security.external.dialogues.api.Dialogue;
 import org.jboss.seam.security.external.spi.OpenIdProviderSpi;
 
 public class OpenIdProviderSpiImpl implements OpenIdProviderSpi
 {
    @Inject
-   private ResponseHolder responseHolder;
-
-   @Inject
    private ServletContext servletContext;
 
    @Inject
@@ -49,16 +45,13 @@
    private OpenIdProviderApi opApi;
 
    @Inject
-   private Dialogue dialogue;
-
-   @Inject
    private Attributes attributes;
 
-   public void authenticate(String realm, String userName, boolean immediate)
+   public void authenticate(String realm, String userName, boolean immediate, ResponseHolder responseHolder)
    {
       if (identity.isLoggedIn() && userName != null && !userName.equals(identity.getUserName()))
       {
-         opApi.authenticationFailed();
+         opApi.authenticationFailed(responseHolder.getResponse());
       }
       else
       {
@@ -66,13 +59,13 @@
          {
             StringBuilder url = new StringBuilder();
             url.append(servletContext.getContextPath());
-            url.append("/Login.jsf?dialogueId=").append((dialogue.getDialogueId()));
-            url.append("&realm=").append(URLEncoder.encode(realm, "UTF-8"));
+            url.append("/Login.jsf");
+            url.append("?realm=").append(URLEncoder.encode(realm, "UTF-8"));
             if (userName != null)
             {
                url.append("&userName=").append(URLEncoder.encode(userName, "UTF-8"));
             }
-            responseHolder.getResponse().sendRedirect(url.toString());
+            responseHolder.redirectWithDialoguePropagation(url.toString());
          }
          catch (IOException e)
          {
@@ -81,17 +74,10 @@
       }
    }
 
-   public void fetchParameters(List<OpenIdRequestedAttribute> requestedAttributes)
+   public void fetchParameters(List<OpenIdRequestedAttribute> requestedAttributes, ResponseHolder responseHolder)
    {
       attributes.setRequestedAttributes(requestedAttributes);
-      try
-      {
-         responseHolder.getResponse().sendRedirect(servletContext.getContextPath() + "/Attributes.jsf?dialogueId=" + dialogue.getDialogueId());
-      }
-      catch (IOException e)
-      {
-         throw new RuntimeException(e);
-      }
+      responseHolder.redirectWithDialoguePropagation(servletContext.getContextPath() + "/Attributes.jsf");
    }
 
    public boolean userExists(String userName)

Modified: modules/security/trunk/examples/openid-rp/pom.xml
===================================================================
--- modules/security/trunk/examples/openid-rp/pom.xml	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/openid-rp/pom.xml	2010-09-21 12:37:23 UTC (rev 13772)
@@ -17,6 +17,7 @@
    <properties>
       <seam.faces.version>3.0.0-SNAPSHOT</seam.faces.version>
       <seam.international.version>3.0.0-SNAPSHOT</seam.international.version>
+      <weld.extensions.version>1.0.0.Alpha2</weld.extensions.version>
    </properties>
 
    <build>
@@ -38,12 +39,34 @@
       </dependency>
 
       <dependency>
+         <groupId>org.jboss.weld</groupId>
+         <artifactId>weld-extensions</artifactId>
+         <version>${weld.extensions.version}</version>
+      </dependency>
+
+      <dependency>
          <groupId>org.jboss.seam.servlet</groupId>
          <artifactId>seam-servlet</artifactId>
          <version>3.0.0-SNAPSHOT</version>
       </dependency>
 
       <dependency>
+         <groupId>org.jboss.seam.faces</groupId>
+         <artifactId>seam-faces-api</artifactId>
+      </dependency>
+
+      <dependency>
+         <groupId>org.jboss.seam.faces</groupId>
+         <artifactId>seam-faces</artifactId>
+      </dependency>
+
+      <dependency>
+         <groupId>org.jboss.weld</groupId>
+         <artifactId>weld-extensions</artifactId>
+         <version>${weld.extensions.version}</version>
+      </dependency>
+
+      <dependency>
          <groupId>javax.enterprise</groupId>
          <artifactId>cdi-api</artifactId>
          <scope>provided</scope>

Modified: modules/security/trunk/examples/openid-rp/src/main/java/org/jboss/seam/security/examples/id_consumer/Identity.java
===================================================================
--- modules/security/trunk/examples/openid-rp/src/main/java/org/jboss/seam/security/examples/id_consumer/Identity.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/openid-rp/src/main/java/org/jboss/seam/security/examples/id_consumer/Identity.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -27,9 +27,11 @@
 
 import javax.enterprise.context.SessionScoped;
 import javax.faces.application.FacesMessage;
+import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.inject.Inject;
 import javax.inject.Named;
+import javax.servlet.http.HttpServletResponse;
 
 import org.jboss.seam.security.external.api.OpenIdPrincipal;
 import org.jboss.seam.security.external.api.OpenIdRelyingPartyApi;
@@ -46,6 +48,9 @@
    @Inject
    private OpenIdRelyingPartyApi openIdApi;
 
+   @Inject
+   private ExternalContext externalContext;
+
    public OpenIdPrincipal getOpenIdPrincipal()
    {
       return openIdPrincipal;
@@ -57,7 +62,7 @@
       {
          List<OpenIdRequestedAttribute> attributes = new LinkedList<OpenIdRequestedAttribute>();
          attributes.add(new OpenIdRequestedAttribute("email", "http://schema.openid.net/contact/email", false, null));
-         openIdApi.login(openId, attributes);
+         openIdApi.login(openId, attributes, (HttpServletResponse) externalContext.getResponse());
       }
       else
       {

Modified: modules/security/trunk/examples/openid-rp/src/main/java/org/jboss/seam/security/examples/id_consumer/OpenIdRelyingPartySpiImpl.java
===================================================================
--- modules/security/trunk/examples/openid-rp/src/main/java/org/jboss/seam/security/examples/id_consumer/OpenIdRelyingPartySpiImpl.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/openid-rp/src/main/java/org/jboss/seam/security/examples/id_consumer/OpenIdRelyingPartySpiImpl.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -33,15 +33,12 @@
 public class OpenIdRelyingPartySpiImpl implements OpenIdRelyingPartySpi
 {
    @Inject
-   private ResponseHolder responseHolder;
-
-   @Inject
    private ServletContext servletContext;
 
    @Inject
    private Identity identity;
 
-   public void loginSucceeded(OpenIdPrincipal principal)
+   public void loginSucceeded(OpenIdPrincipal principal, ResponseHolder responseHolder)
    {
       try
       {
@@ -54,7 +51,7 @@
       }
    }
 
-   public void loginFailed(String message)
+   public void loginFailed(String message, ResponseHolder responseHolder)
    {
       try
       {

Modified: modules/security/trunk/examples/saml-idp/pom.xml
===================================================================
--- modules/security/trunk/examples/saml-idp/pom.xml	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-idp/pom.xml	2010-09-21 12:37:23 UTC (rev 13772)
@@ -14,6 +14,11 @@
       <relativePath>../../pom.xml</relativePath>
    </parent>
 
+   <properties>
+      <seam.faces.version>3.0.0-SNAPSHOT</seam.faces.version>
+      <weld.extensions.version>1.0.0.Alpha2</weld.extensions.version>
+   </properties>
+
    <build>
       <finalName>saml-idp</finalName>
    </build>
@@ -33,12 +38,28 @@
       </dependency>
 
       <dependency>
+         <groupId>org.jboss.weld</groupId>
+         <artifactId>weld-extensions</artifactId>
+         <version>${weld.extensions.version}</version>
+      </dependency>
+
+      <dependency>
          <groupId>org.jboss.seam.servlet</groupId>
          <artifactId>seam-servlet</artifactId>
          <version>3.0.0-SNAPSHOT</version>
       </dependency>
 
       <dependency>
+         <groupId>org.jboss.seam.faces</groupId>
+         <artifactId>seam-faces-api</artifactId>
+      </dependency>
+
+      <dependency>
+         <groupId>org.jboss.seam.faces</groupId>
+         <artifactId>seam-faces</artifactId>
+      </dependency>
+
+      <dependency>
          <groupId>javax.enterprise</groupId>
          <artifactId>cdi-api</artifactId>
          <scope>provided</scope>

Modified: modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Configuration.java
===================================================================
--- modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Configuration.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Configuration.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -35,7 +35,7 @@
 import javax.faces.context.FacesContext;
 import javax.inject.Inject;
 
-import org.jboss.seam.security.external.api.SamlEntityConfigurationApi;
+import org.jboss.seam.security.external.api.SamlIdentityProviderConfigurationApi;
 import org.jboss.seam.security.external.saml.SamlExternalEntity;
 
 @Model
@@ -44,7 +44,7 @@
    private String spMetaDataUrl;
 
    @Inject
-   private SamlEntityConfigurationApi samlEntityConfig;
+   private SamlIdentityProviderConfigurationApi idpConfigApi;
 
    public String getSpMetaDataUrl()
    {
@@ -65,7 +65,7 @@
          urlConnection.setConnectTimeout(3000);
          urlConnection.setReadTimeout(3000);
          Reader reader = new InputStreamReader(urlConnection.getInputStream());
-         SamlExternalEntity samlEntity = samlEntityConfig.addExternalSamlEntity(reader);
+         SamlExternalEntity samlEntity = idpConfigApi.addExternalSamlEntity(reader);
 
          FacesMessage facesMessage = new FacesMessage("SAML entity " + samlEntity.getEntityId() + " has been added.");
          FacesContext.getCurrentInstance().addMessage(null, facesMessage);
@@ -84,13 +84,13 @@
 
    public String getMetaDataUrl()
    {
-      return samlEntityConfig.getMetaDataURL();
+      return idpConfigApi.getMetaDataURL();
    }
 
    public List<String> getSpEntityIds()
    {
       List<String> entityIds = new LinkedList<String>();
-      for (SamlExternalEntity entity : samlEntityConfig.getExternalSamlEntities())
+      for (SamlExternalEntity entity : idpConfigApi.getExternalSamlEntities())
       {
          entityIds.add(entity.getEntityId());
       }

Modified: modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Identity.java
===================================================================
--- modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Identity.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Identity.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -23,9 +23,11 @@
 
 import java.io.Serializable;
 
+import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.inject.Inject;
 import javax.inject.Named;
+import javax.servlet.http.HttpServletResponse;
 
 import org.jboss.seam.security.external.api.SamlIdentityProviderApi;
 import org.jboss.seam.security.external.api.SamlNameId;
@@ -39,6 +41,9 @@
    @Inject
    private SamlIdentityProviderApi samlIdp;
 
+   @Inject
+   private ExternalContext externalContext;
+
    public void localLogin(String userName)
    {
       samlIdp.localLogin(new SamlNameId(userName, null, null), null);
@@ -46,7 +51,7 @@
 
    public void remoteLogin(String spEntityId)
    {
-      samlIdp.remoteLogin(spEntityId, null);
+      samlIdp.remoteLogin(spEntityId, null, (HttpServletResponse) externalContext.getResponse());
    }
 
    public void localLogout()
@@ -56,7 +61,7 @@
 
    public void globalLogout()
    {
-      samlIdp.globalLogout();
+      samlIdp.globalLogout((HttpServletResponse) externalContext.getResponse());
    }
 
    public boolean isLoggedIn()

Modified: modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Login.java
===================================================================
--- modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Login.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/Login.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -22,7 +22,9 @@
 package org.jboss.seam.security.examples.id_provider;
 
 import javax.enterprise.inject.Model;
+import javax.faces.context.ExternalContext;
 import javax.inject.Inject;
+import javax.servlet.http.HttpServletResponse;
 
 import org.jboss.seam.security.external.api.SamlIdentityProviderApi;
 import org.jboss.seam.security.external.dialogues.DialogueManager;
@@ -43,6 +45,9 @@
    @Inject
    private Identity identity;
 
+   @Inject
+   private ExternalContext externalContext;
+
    public String getUserName()
    {
       return userName;
@@ -69,7 +74,7 @@
       if (dialogueId != null)
       {
          dialogueManager.attachDialogue(dialogueId);
-         samlIdentityProviderApi.authenticationSucceeded();
+         samlIdentityProviderApi.authenticationSucceeded((HttpServletResponse) externalContext.getResponse());
          dialogueManager.detachDialogue();
          return "SAML_LOGIN";
       }
@@ -84,7 +89,7 @@
       if (dialogueId != null)
       {
          dialogueManager.attachDialogue(dialogueId);
-         samlIdentityProviderApi.authenticationFailed();
+         samlIdentityProviderApi.authenticationFailed((HttpServletResponse) externalContext.getResponse());
          dialogueManager.detachDialogue();
       }
       else

Deleted: modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/RequestObserver.java
===================================================================
--- modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/RequestObserver.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/RequestObserver.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.security.examples.id_provider;
-
-import javax.enterprise.event.Observes;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jboss.seam.security.external.api.ResponseHolder;
-import org.jboss.seam.security.external.dialogues.api.AfterDialogueActivation;
-
-public class RequestObserver
-{
-   @Inject
-   private ResponseHolder responseHolder;
-
-   public void dialogueCreated(@Observes AfterDialogueActivation event)
-   {
-      if (FacesContext.getCurrentInstance() != null)
-      {
-         ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
-         responseHolder.setResponse((HttpServletResponse) externalContext.getResponse());
-      }
-   }
-}
\ No newline at end of file

Modified: modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/SamlIdentityProviderSpiImpl.java
===================================================================
--- modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/SamlIdentityProviderSpiImpl.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/SamlIdentityProviderSpiImpl.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -28,7 +28,6 @@
 
 import org.jboss.seam.security.external.api.ResponseHolder;
 import org.jboss.seam.security.external.api.SamlIdentityProviderApi;
-import org.jboss.seam.security.external.dialogues.api.Dialogue;
 import org.jboss.seam.security.external.saml.idp.SamlIdpSession;
 import org.jboss.seam.security.external.spi.SamlIdentityProviderSpi;
 import org.slf4j.Logger;
@@ -39,40 +38,27 @@
    private Logger log;
 
    @Inject
-   private ResponseHolder responseHolder;
-
-   @Inject
    private ServletContext servletContext;
 
    @Inject
-   private Dialogue dialogue;
-
-   @Inject
    private Identity identity;
 
    @Inject
    private SamlIdentityProviderApi idpApi;
 
-   public void authenticate()
+   public void authenticate(ResponseHolder responseHolder)
    {
       if (identity.isLoggedIn())
       {
-         idpApi.authenticationSucceeded();
+         idpApi.authenticationSucceeded(responseHolder.getResponse());
       }
       else
       {
-         try
-         {
-            responseHolder.getResponse().sendRedirect(servletContext.getContextPath() + "/Login.jsf?dialogueId=" + dialogue.getDialogueId());
-         }
-         catch (IOException e)
-         {
-            throw new RuntimeException(e);
-         }
+         responseHolder.redirectWithDialoguePropagation(servletContext.getContextPath() + "/Login.jsf");
       }
    }
 
-   public void singleLogoutFailed()
+   public void singleLogoutFailed(ResponseHolder responseHolder)
    {
       try
       {
@@ -84,7 +70,7 @@
       }
    }
 
-   public void singleLogoutSucceeded()
+   public void singleLogoutSucceeded(ResponseHolder responseHolder)
    {
       try
       {

Modified: modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/SessionManagement.java
===================================================================
--- modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/SessionManagement.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-idp/src/main/java/org/jboss/seam/security/examples/id_provider/SessionManagement.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -25,7 +25,9 @@
 import java.util.List;
 
 import javax.enterprise.inject.Model;
+import javax.faces.context.ExternalContext;
 import javax.inject.Inject;
+import javax.servlet.http.HttpServletResponse;
 
 import org.jboss.seam.security.external.api.SamlIdentityProviderApi;
 import org.jboss.seam.security.external.api.SamlIdentityProviderConfigurationApi;
@@ -40,6 +42,9 @@
    @Inject
    private SamlIdentityProviderConfigurationApi idpConfApi;
 
+   @Inject
+   private ExternalContext externalContext;
+
    public List<String> getNonParticipatingServiceProviders()
    {
       List<String> serviceProviders = new LinkedList<String>();
@@ -77,6 +82,6 @@
       {
          throw new RuntimeException("No local SAML session.");
       }
-      idpApi.remoteLogin(spEntityId, null);
+      idpApi.remoteLogin(spEntityId, null, (HttpServletResponse) externalContext.getResponse());
    }
 }

Modified: modules/security/trunk/examples/saml-sp/pom.xml
===================================================================
--- modules/security/trunk/examples/saml-sp/pom.xml	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-sp/pom.xml	2010-09-21 12:37:23 UTC (rev 13772)
@@ -17,6 +17,7 @@
    <properties>
       <seam.faces.version>3.0.0-SNAPSHOT</seam.faces.version>
       <seam.international.version>3.0.0-SNAPSHOT</seam.international.version>
+      <weld.extensions.version>1.0.0.Alpha2</weld.extensions.version>
    </properties>
 
    <build>
@@ -38,12 +39,28 @@
       </dependency>
 
       <dependency>
+         <groupId>org.jboss.weld</groupId>
+         <artifactId>weld-extensions</artifactId>
+         <version>${weld.extensions.version}</version>
+      </dependency>
+
+      <dependency>
          <groupId>org.jboss.seam.servlet</groupId>
          <artifactId>seam-servlet</artifactId>
          <version>3.0.0-SNAPSHOT</version>
       </dependency>
 
       <dependency>
+         <groupId>org.jboss.seam.faces</groupId>
+         <artifactId>seam-faces-api</artifactId>
+      </dependency>
+
+      <dependency>
+         <groupId>org.jboss.seam.faces</groupId>
+         <artifactId>seam-faces</artifactId>
+      </dependency>
+
+      <dependency>
          <groupId>javax.enterprise</groupId>
          <artifactId>cdi-api</artifactId>
          <scope>provided</scope>

Modified: modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/Configuration.java
===================================================================
--- modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/Configuration.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/Configuration.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -35,7 +35,7 @@
 import javax.faces.context.FacesContext;
 import javax.inject.Inject;
 
-import org.jboss.seam.security.external.api.SamlEntityConfigurationApi;
+import org.jboss.seam.security.external.api.SamlServiceProviderConfigurationApi;
 import org.jboss.seam.security.external.saml.SamlExternalEntity;
 
 @Model
@@ -44,7 +44,7 @@
    private String idpMetaDataUrl;
 
    @Inject
-   private SamlEntityConfigurationApi samlEntityConfig;
+   private SamlServiceProviderConfigurationApi spConfigApi;
 
    public String getIdpMetaDataUrl()
    {
@@ -65,7 +65,7 @@
          urlConnection.setConnectTimeout(3000);
          urlConnection.setReadTimeout(3000);
          Reader reader = new InputStreamReader(urlConnection.getInputStream());
-         SamlExternalEntity samlEntity = samlEntityConfig.addExternalSamlEntity(reader);
+         SamlExternalEntity samlEntity = spConfigApi.addExternalSamlEntity(reader);
 
          FacesMessage facesMessage = new FacesMessage("SAML entity " + samlEntity.getEntityId() + " has been added.");
          FacesContext.getCurrentInstance().addMessage(null, facesMessage);
@@ -84,13 +84,13 @@
 
    public String getMetaDataUrl()
    {
-      return samlEntityConfig.getMetaDataURL();
+      return spConfigApi.getMetaDataURL();
    }
 
    public List<String> getIdpEntityIds()
    {
       List<String> entityIds = new LinkedList<String>();
-      for (SamlExternalEntity entity : samlEntityConfig.getExternalSamlEntities())
+      for (SamlExternalEntity entity : spConfigApi.getExternalSamlEntities())
       {
          entityIds.add(entity.getEntityId());
       }

Modified: modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/Identity.java
===================================================================
--- modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/Identity.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/Identity.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -23,8 +23,10 @@
 
 import javax.enterprise.inject.Model;
 import javax.faces.application.FacesMessage;
+import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 import javax.inject.Inject;
+import javax.servlet.http.HttpServletResponse;
 
 import org.jboss.seam.security.external.api.SamlServiceProviderApi;
 import org.jboss.seam.security.external.dialogues.api.Dialogued;
@@ -36,12 +38,15 @@
    @Inject
    private SamlServiceProviderApi samlSpApi;
 
+   @Inject
+   private ExternalContext externalContext;
+
    @Dialogued
    public void login(String idpEntityId)
    {
       if (!isLoggedIn())
       {
-         samlSpApi.login(idpEntityId);
+         samlSpApi.login(idpEntityId, (HttpServletResponse) externalContext.getResponse());
       }
       else
       {
@@ -72,7 +77,7 @@
       {
          if (samlSpApi.getSession() != null)
          {
-            samlSpApi.globalLogout();
+            samlSpApi.globalLogout((HttpServletResponse) externalContext.getResponse());
          }
       }
       else

Deleted: modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/RequestObserver.java
===================================================================
--- modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/RequestObserver.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/RequestObserver.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.security.examples.id_consumer;
-
-import javax.enterprise.event.Observes;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletResponse;
-
-import org.jboss.seam.security.external.api.ResponseHolder;
-import org.jboss.seam.security.external.dialogues.api.AfterDialogueActivation;
-
-public class RequestObserver
-{
-   @Inject
-   private ResponseHolder responseHolder;
-
-   public void dialogueCreated(@Observes AfterDialogueActivation event)
-   {
-      if (FacesContext.getCurrentInstance() != null)
-      {
-         ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
-         responseHolder.setResponse((HttpServletResponse) externalContext.getResponse());
-      }
-   }
-
-}

Modified: modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/SamlServiceProviderSpiImpl.java
===================================================================
--- modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/SamlServiceProviderSpiImpl.java	2010-09-21 12:35:01 UTC (rev 13771)
+++ modules/security/trunk/examples/saml-sp/src/main/java/org/jboss/seam/security/examples/id_consumer/SamlServiceProviderSpiImpl.java	2010-09-21 12:37:23 UTC (rev 13772)
@@ -38,15 +38,12 @@
    SamlServiceProviderApi samlServiceProviderApi;
 
    @Inject
-   ResponseHolder responseHolder;
-
-   @Inject
    private Logger log;
 
    @Inject
    private ServletContext servletContext;
 
-   public void loginSucceeded(SamlSpSession session)
+   public void loginSucceeded(SamlSpSession session, ResponseHolder responseHolder)
    {
       try
       {
@@ -58,7 +55,7 @@
       }
    }
 
-   public void loginFailed()
+   public void loginFailed(ResponseHolder responseHolder)
    {
       try
       {
@@ -70,7 +67,7 @@
       }
    }
 
-   public void globalLogoutFailed(String statusCode)
+   public void globalLogoutFailed(String statusCode, ResponseHolder responseHolder)
    {
       try
       {
@@ -82,7 +79,7 @@
       }
    }
 
-   public void globalLogoutSucceeded()
+   public void globalLogoutSucceeded(ResponseHolder responseHolder)
    {
       try
       {
@@ -94,7 +91,7 @@
       }
    }
 
-   public void loggedIn(SamlSpSession session, String url)
+   public void loggedIn(SamlSpSession session, String url, ResponseHolder responseHolder)
    {
       try
       {



More information about the seam-commits mailing list