gatein SVN: r4452 - in components/wsrp/trunk: admin-gui/src/test/java/org/gatein/wsrp/other and 1 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-09-30 16:38:55 -0400 (Thu, 30 Sep 2010)
New Revision: 4452
Modified:
components/wsrp/trunk/admin-gui/pom.xml
components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/other/ConsumerBeanTestCase.java
components/wsrp/trunk/consumer/pom.xml
Log:
- GTNWSRP-83:
+ Use a custom ConsumerRegistry so that we can inject a mock endpoint configuration into "real" consumer to be able to test closer to real conditions.
+ Created attached test jar in consumer so that we can reuse the test classes in admin-gui module.
- Improved comment in consumer POM since it wasn't accurate.
Modified: components/wsrp/trunk/admin-gui/pom.xml
===================================================================
--- components/wsrp/trunk/admin-gui/pom.xml 2010-09-30 19:26:55 UTC (rev 4451)
+++ components/wsrp/trunk/admin-gui/pom.xml 2010-09-30 20:38:55 UTC (rev 4452)
@@ -81,5 +81,13 @@
<artifactId>jsf-facelets</artifactId>
<version>1.1.15</version>
</dependency>
+
+ <dependency>
+ <groupId>org.gatein.wsrp</groupId>
+ <artifactId>wsrp-consumer</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/other/ConsumerBeanTestCase.java
===================================================================
--- components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/other/ConsumerBeanTestCase.java 2010-09-30 19:26:55 UTC (rev 4451)
+++ components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/other/ConsumerBeanTestCase.java 2010-09-30 20:38:55 UTC (rev 4452)
@@ -25,9 +25,13 @@
import junit.framework.TestCase;
import org.gatein.common.NotYetImplemented;
+import org.gatein.wsrp.WSRPConsumer;
import org.gatein.wsrp.admin.ui.BeanContext;
import org.gatein.wsrp.admin.ui.ConsumerBean;
+import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
import org.gatein.wsrp.consumer.registry.InMemoryConsumerRegistry;
+import org.gatein.wsrp.test.protocol.v2.BehaviorBackedServiceFactory;
+import org.gatein.wsrp.test.support.MockEndpointConfigurationInfo;
import java.util.Locale;
import java.util.Map;
@@ -42,13 +46,15 @@
public class ConsumerBeanTestCase extends TestCase
{
private static final String CONSUMER_ID = "foo";
- private static final String WSDL = "wsdl";
+
+ /** Since our consumers use the MockEndpointConfigurationInfo, this is the WSDL they are configured with */
+ private static final String WSDL = BehaviorBackedServiceFactory.DEFAULT_WSDL_URL;
private ConsumerBean bean;
protected void setUp() throws Exception
{
bean = new ConsumerBean();
- InMemoryConsumerRegistry registry = new InMemoryConsumerRegistry();
+ ConsumerRegistry registry = new TestInMemoryConsumerRegistry();
registry.createConsumer(CONSUMER_ID, null, WSDL);
bean.setRegistry(registry);
bean.setBeanContext(new TestBeanContext());
@@ -141,4 +147,16 @@
throw new NotYetImplemented();
}
}
+
+ private static class TestInMemoryConsumerRegistry extends InMemoryConsumerRegistry
+ {
+ @Override
+ public WSRPConsumer createConsumer(String id, Integer expirationCacheSeconds, String wsdlURL)
+ {
+ // Use a "real" consumer but with a fake endpoint configuration so we can fake WS access
+ WSRPConsumer consumer = super.createConsumer(id, expirationCacheSeconds, wsdlURL);
+ consumer.getProducerInfo().setEndpointConfigurationInfo(new MockEndpointConfigurationInfo());
+ return consumer;
+ }
+ }
}
Modified: components/wsrp/trunk/consumer/pom.xml
===================================================================
--- components/wsrp/trunk/consumer/pom.xml 2010-09-30 19:26:55 UTC (rev 4451)
+++ components/wsrp/trunk/consumer/pom.xml 2010-09-30 20:38:55 UTC (rev 4452)
@@ -21,7 +21,8 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.gatein.wsrp</groupId>
<artifactId>wsrp-parent</artifactId>
@@ -102,7 +103,7 @@
</dependency>
</dependencies>
- <!-- Disable some tests for now until we can find some time to work on migrating them -->
+ <!-- Ignore all classes in the org.gatein.wsrp.test packages are they are not tests -->
<build>
<plugins>
<plugin>
@@ -114,6 +115,18 @@
</excludes>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
\ No newline at end of file
14 years, 2 months
gatein SVN: r4451 - in components/wsrp/trunk/admin-gui: src/test/java/org/gatein/wsrp/other and 1 other directory.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-09-30 15:26:55 -0400 (Thu, 30 Sep 2010)
New Revision: 4451
Modified:
components/wsrp/trunk/admin-gui/pom.xml
components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/other/ConsumerBeanTestCase.java
Log:
- GTNWSRP-83: Re-activated and improved existing tests. Lots more work needed, of course!
Modified: components/wsrp/trunk/admin-gui/pom.xml
===================================================================
--- components/wsrp/trunk/admin-gui/pom.xml 2010-09-30 19:22:55 UTC (rev 4450)
+++ components/wsrp/trunk/admin-gui/pom.xml 2010-09-30 19:26:55 UTC (rev 4451)
@@ -21,7 +21,8 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.gatein.wsrp</groupId>
<artifactId>wsrp-parent</artifactId>
@@ -81,20 +82,4 @@
<version>1.1.15</version>
</dependency>
</dependencies>
-
- <!-- Disable some tests for now until we can find some time to work on migrating them -->
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <exclude>org/gatein/wsrp/other/*</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
</project>
Modified: components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/other/ConsumerBeanTestCase.java
===================================================================
--- components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/other/ConsumerBeanTestCase.java 2010-09-30 19:22:55 UTC (rev 4450)
+++ components/wsrp/trunk/admin-gui/src/test/java/org/gatein/wsrp/other/ConsumerBeanTestCase.java 2010-09-30 19:26:55 UTC (rev 4451)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
* contributors as indicated by the @authors tag. See the
* copyright.txt in the distribution for a full listing of
* individual contributors.
@@ -24,8 +24,14 @@
package org.gatein.wsrp.other;
import junit.framework.TestCase;
+import org.gatein.common.NotYetImplemented;
+import org.gatein.wsrp.admin.ui.BeanContext;
import org.gatein.wsrp.admin.ui.ConsumerBean;
+import org.gatein.wsrp.consumer.registry.InMemoryConsumerRegistry;
+import java.util.Locale;
+import java.util.Map;
+
/**
* TODO: re-activate tests once test-support module is updated.
*
@@ -35,36 +41,64 @@
*/
public class ConsumerBeanTestCase extends TestCase
{
+ private static final String CONSUMER_ID = "foo";
+ private static final String WSDL = "wsdl";
private ConsumerBean bean;
protected void setUp() throws Exception
{
bean = new ConsumerBean();
-// bean.setRegistry(new MockConsumerRegistry());
+ InMemoryConsumerRegistry registry = new InMemoryConsumerRegistry();
+ registry.createConsumer(CONSUMER_ID, null, WSDL);
+ bean.setRegistry(registry);
+ bean.setBeanContext(new TestBeanContext());
// consumer associated with bean is null at this point so it should be loaded from the registry
-// bean.setId(MockConsumerRegistry.CONSUMER2);
+ bean.setId(CONSUMER_ID);
}
- // todo: remove when tests are re-activated
- public void testNothing()
+ public void testInitialState()
{
- assertTrue(true);
- }
+ assertEquals(CONSUMER_ID, bean.getId());
+ assertEquals(WSDL, bean.getWsdl());
- /*public void testInitialState()
- {
-// assertEquals(MockConsumerRegistry.CONSUMER2, bean.getId());
-// assertEquals(MockConsumerRegistry.MOCK_MARKUP, bean.getMarkup());
-// assertEquals(MockConsumerRegistry.MOCK_SERVICE_DESCRIPTION, bean.getServiceDescription());
assertFalse(bean.isModified());
+ assertTrue(bean.isRefreshNeeded());
+
+ assertFalse(bean.isActive());
+
+ assertFalse(bean.isRegistrationChecked());
+ assertTrue(bean.isRegistrationCheckNeeded());
+ assertFalse(bean.isRegistered());
+ assertFalse(bean.isRegistrationLocallyModified());
+ assertFalse(bean.isRegistrationPropertiesExisting());
+
+ try
+ {
+ assertFalse(bean.isRegistrationRequired());
+ fail("Can't know if registration is required without a refresh");
+ }
+ catch (IllegalStateException e)
+ {
+ // expected
+ }
+ try
+ {
+ assertFalse(bean.isRegistrationValid());
+ fail("Can't know if registration is valid without a refresh");
+ }
+ catch (Exception e)
+ {
+ // expected
+ }
}
- public void testSetId()
+ public void testSetId()
{
String newId = "newId";
bean.setId(newId);
assertEquals(newId, bean.getId());
+
assertTrue(bean.isModified());
}
@@ -106,5 +140,5 @@
{
throw new NotYetImplemented();
}
- }*/
+ }
}
14 years, 2 months
gatein SVN: r4450 - components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-09-30 15:22:55 -0400 (Thu, 30 Sep 2010)
New Revision: 4450
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java
Log:
- Log to debug instead of info.
Modified: components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java
===================================================================
--- components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java 2010-09-30 19:21:41 UTC (rev 4449)
+++ components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/registry/AbstractConsumerRegistry.java 2010-09-30 19:22:55 UTC (rev 4450)
@@ -111,7 +111,7 @@
save(info, "Couldn't create Consumer '" + id + "'");
- log.info(CONSUMER_WITH_ID + id + "' created");
+ log.debug(CONSUMER_WITH_ID + id + "' created");
return createConsumerFrom(info);
}
@@ -149,7 +149,7 @@
throw new ConsumerException(CONSUMER_WITH_ID + id + "' doesn't exist!");
}
- log.info(CONSUMER_WITH_ID + id + "' destroyed");
+ log.debug(CONSUMER_WITH_ID + id + "' destroyed");
}
public void persistConsumer(WSRPConsumer consumer)
14 years, 2 months
gatein SVN: r4449 - in components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp: protocol/v2 and 3 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-09-30 15:21:41 -0400 (Thu, 30 Sep 2010)
New Revision: 4449
Added:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/RequestedMarkupBehavior.java
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/WSRP1ConsumerBaseTest.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v2/WSRP2ConsumerBaseTest.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/BehaviorBackedServiceFactory.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/BehaviorBackedServiceFactory.java
Log:
- GTNWSRP-82: Added RequestedMarkupBehavior class to record currently requested markup behavior so that we can remove dependency of BehaviorBackedServiceFactory on tests.
Modified: components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java
===================================================================
--- components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java 2010-09-30 18:47:31 UTC (rev 4448)
+++ components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/MarkupTestCase.java 2010-09-30 19:21:41 UTC (rev 4449)
@@ -54,6 +54,7 @@
import org.gatein.wsrp.test.protocol.v1.behaviors.ResourceMarkupBehavior;
import org.gatein.wsrp.test.protocol.v1.behaviors.SessionMarkupBehavior;
import org.gatein.wsrp.test.support.MockHttpServletRequest;
+import org.gatein.wsrp.test.support.RequestedMarkupBehavior;
import org.gatein.wsrp.test.support.TestPortletInvocationContext;
import org.oasis.wsrp.v1.V1CookieProtocol;
import org.oasis.wsrp.v1.V1Extension;
@@ -298,7 +299,7 @@
render.setWindowContext(new AbstractWindowContext("windowcontext"));
render.setPortalContext(new AbstractPortalContext());
- requestedMarkupBehavior = portletHandle;
+ RequestedMarkupBehavior.setRequestedMarkupBehavior(portletHandle);
return render;
}
@@ -312,7 +313,7 @@
action.setUserContext(new MockUserContext());
action.setTarget(PortletContext.createPortletContext(portletHandle));
- requestedMarkupBehavior = portletHandle;
+ RequestedMarkupBehavior.setRequestedMarkupBehavior(portletHandle);
return action;
}
Modified: components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/WSRP1ConsumerBaseTest.java
===================================================================
--- components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/WSRP1ConsumerBaseTest.java 2010-09-30 18:47:31 UTC (rev 4448)
+++ components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v1/WSRP1ConsumerBaseTest.java 2010-09-30 19:21:41 UTC (rev 4449)
@@ -47,6 +47,7 @@
import org.gatein.wsrp.test.protocol.v1.behaviors.ResourceMarkupBehavior;
import org.gatein.wsrp.test.protocol.v1.behaviors.SessionMarkupBehavior;
import org.gatein.wsrp.test.support.MockConsumerRegistry;
+import org.gatein.wsrp.test.support.RequestedMarkupBehavior;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,9 +71,7 @@
protected WSRPConsumerImpl consumer = new WSRPConsumerImpl();
private boolean strict = true;
- protected static String requestedMarkupBehavior;
-
public void setUp() throws Exception
{
// reset producer state
@@ -202,21 +201,10 @@
return producer.getBehaviorRegistry().getServiceDescriptionBehavior().getPortletNumber();
}
- /**
- * So that BehaviorBackedServiceFactory can retrieve the proper behavior when retrieving the markup service for
- * invocation.
- *
- * @return
- */
- public static String getRequestedMarkupBehavior()
- {
- return requestedMarkupBehavior;
- }
-
@Override
protected void tearDown() throws Exception
{
// reset the requested markup behavior
- requestedMarkupBehavior = null;
+ RequestedMarkupBehavior.setRequestedMarkupBehavior(null);
}
}
Modified: components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java
===================================================================
--- components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java 2010-09-30 18:47:31 UTC (rev 4448)
+++ components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v2/MarkupTestCase.java 2010-09-30 19:21:41 UTC (rev 4449)
@@ -54,6 +54,7 @@
import org.gatein.wsrp.test.protocol.v2.behaviors.ResourceMarkupBehavior;
import org.gatein.wsrp.test.protocol.v2.behaviors.SessionMarkupBehavior;
import org.gatein.wsrp.test.support.MockHttpServletRequest;
+import org.gatein.wsrp.test.support.RequestedMarkupBehavior;
import org.gatein.wsrp.test.support.TestPortletInvocationContext;
import org.oasis.wsrp.v2.CookieProtocol;
import org.oasis.wsrp.v2.EventDescription;
@@ -302,7 +303,7 @@
render.setWindowContext(new AbstractWindowContext("windowcontext"));
render.setPortalContext(new AbstractPortalContext());
- requestedMarkupBehavior = portletHandle;
+ RequestedMarkupBehavior.setRequestedMarkupBehavior(portletHandle);
return render;
}
@@ -316,7 +317,7 @@
action.setUserContext(new MockUserContext());
action.setTarget(PortletContext.createPortletContext(portletHandle));
- requestedMarkupBehavior = portletHandle;
+ RequestedMarkupBehavior.setRequestedMarkupBehavior(portletHandle);
return action;
}
Modified: components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v2/WSRP2ConsumerBaseTest.java
===================================================================
--- components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v2/WSRP2ConsumerBaseTest.java 2010-09-30 18:47:31 UTC (rev 4448)
+++ components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/protocol/v2/WSRP2ConsumerBaseTest.java 2010-09-30 19:21:41 UTC (rev 4449)
@@ -47,6 +47,7 @@
import org.gatein.wsrp.test.protocol.v2.behaviors.ResourceMarkupBehavior;
import org.gatein.wsrp.test.protocol.v2.behaviors.SessionMarkupBehavior;
import org.gatein.wsrp.test.support.MockConsumerRegistry;
+import org.gatein.wsrp.test.support.RequestedMarkupBehavior;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,9 +71,7 @@
protected WSRPConsumerImpl consumer = new WSRPConsumerImpl();
private boolean strict = true;
- protected static String requestedMarkupBehavior;
-
public void setUp() throws Exception
{
// reset producer state
@@ -202,21 +201,10 @@
return producer.getBehaviorRegistry().getServiceDescriptionBehavior().getPortletNumber();
}
- /**
- * So that BehaviorBackedServiceFactory can retrieve the proper behavior when retrieving the markup service for
- * invocation.
- *
- * @return
- */
- public static String getRequestedMarkupBehavior()
- {
- return requestedMarkupBehavior;
- }
-
@Override
protected void tearDown() throws Exception
{
// reset the requested markup behavior
- requestedMarkupBehavior = null;
+ RequestedMarkupBehavior.setRequestedMarkupBehavior(null);
}
}
Modified: components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/BehaviorBackedServiceFactory.java
===================================================================
--- components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/BehaviorBackedServiceFactory.java 2010-09-30 18:47:31 UTC (rev 4448)
+++ components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v1/BehaviorBackedServiceFactory.java 2010-09-30 19:21:41 UTC (rev 4449)
@@ -26,7 +26,6 @@
import org.gatein.common.NotYetImplemented;
import org.gatein.pc.api.Mode;
import org.gatein.pc.api.WindowState;
-import org.gatein.wsrp.protocol.v1.WSRP1ConsumerBaseTest;
import org.gatein.wsrp.services.MarkupService;
import org.gatein.wsrp.services.PortletManagementService;
import org.gatein.wsrp.services.RegistrationService;
@@ -36,6 +35,7 @@
import org.gatein.wsrp.services.v1.V1PortletManagementService;
import org.gatein.wsrp.services.v1.V1RegistrationService;
import org.gatein.wsrp.services.v1.V1ServiceDescriptionService;
+import org.gatein.wsrp.test.support.RequestedMarkupBehavior;
import org.oasis.wsrp.v1.V1AccessDenied;
import org.oasis.wsrp.v1.V1GetMarkup;
import org.oasis.wsrp.v1.V1InconsistentParameters;
@@ -94,7 +94,7 @@
}
if (WSRPV1MarkupPortType.class.isAssignableFrom(serviceClass))
{
- String requestedMarkupBehavior = WSRP1ConsumerBaseTest.getRequestedMarkupBehavior();
+ String requestedMarkupBehavior = RequestedMarkupBehavior.getRequestedMarkupBehavior();
if (requestedMarkupBehavior == null)
{
requestedMarkupBehavior = MARKUP;
Modified: components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/BehaviorBackedServiceFactory.java
===================================================================
--- components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/BehaviorBackedServiceFactory.java 2010-09-30 18:47:31 UTC (rev 4448)
+++ components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/protocol/v2/BehaviorBackedServiceFactory.java 2010-09-30 19:21:41 UTC (rev 4449)
@@ -26,7 +26,6 @@
import org.gatein.common.NotYetImplemented;
import org.gatein.pc.api.Mode;
import org.gatein.pc.api.WindowState;
-import org.gatein.wsrp.protocol.v2.WSRP2ConsumerBaseTest;
import org.gatein.wsrp.services.MarkupService;
import org.gatein.wsrp.services.PortletManagementService;
import org.gatein.wsrp.services.RegistrationService;
@@ -36,6 +35,7 @@
import org.gatein.wsrp.services.v2.V2PortletManagementService;
import org.gatein.wsrp.services.v2.V2RegistrationService;
import org.gatein.wsrp.services.v2.V2ServiceDescriptionService;
+import org.gatein.wsrp.test.support.RequestedMarkupBehavior;
import org.oasis.wsrp.v2.AccessDenied;
import org.oasis.wsrp.v2.GetMarkup;
import org.oasis.wsrp.v2.InconsistentParameters;
@@ -94,7 +94,7 @@
}
if (WSRPV2MarkupPortType.class.isAssignableFrom(serviceClass))
{
- String requestedMarkupBehavior = WSRP2ConsumerBaseTest.getRequestedMarkupBehavior();
+ String requestedMarkupBehavior = RequestedMarkupBehavior.getRequestedMarkupBehavior();
if (requestedMarkupBehavior == null)
{
requestedMarkupBehavior = MARKUP;
Added: components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/RequestedMarkupBehavior.java
===================================================================
--- components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/RequestedMarkupBehavior.java (rev 0)
+++ components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/RequestedMarkupBehavior.java 2010-09-30 19:21:41 UTC (rev 4449)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated 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.gatein.wsrp.test.support;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class RequestedMarkupBehavior
+{
+ private static ThreadLocal<String> requestedMarkupBehavior = new ThreadLocal<String>();
+
+ public static String getRequestedMarkupBehavior()
+ {
+ return requestedMarkupBehavior.get();
+ }
+
+ public static void setRequestedMarkupBehavior(String requestedMarkupBehavior)
+ {
+ RequestedMarkupBehavior.requestedMarkupBehavior.set(requestedMarkupBehavior);
+ }
+}
14 years, 2 months
gatein SVN: r4448 - in portal/trunk: component/pc/src/main/java/org/exoplatform/portal/pc and 1 other directory.
by do-not-reply@jboss.org
Author: mstruk
Date: 2010-09-30 14:47:31 -0400 (Thu, 30 Sep 2010)
New Revision: 4448
Modified:
portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java
portal/trunk/pom.xml
Log:
Revert: GTNPORTAL-1257: Seam session outlives the GateIn session
- wait for pc 2.2.0-Beta04 to be released
Modified: portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java
===================================================================
--- portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java 2010-09-30 18:47:13 UTC (rev 4447)
+++ portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java 2010-09-30 18:47:31 UTC (rev 4448)
@@ -36,7 +36,6 @@
import org.gatein.pc.portlet.aspects.ProducerCacheInterceptor;
import org.gatein.pc.portlet.aspects.RequestAttributeConversationInterceptor;
import org.gatein.pc.portlet.aspects.SecureTransportInterceptor;
-import org.gatein.pc.portlet.aspects.SessionInvalidatorInterceptor;
import org.gatein.pc.portlet.aspects.ValveInterceptor;
import org.gatein.pc.portlet.container.ContainerPortletDispatcher;
import org.gatein.pc.portlet.container.ContainerPortletInvoker;
@@ -97,10 +96,8 @@
bridgepInterceptor.setNext(ccppInterceptor);
ProducerCacheInterceptor producerCacheInterceptor = new ProducerCacheInterceptor();
producerCacheInterceptor.setNext(bridgepInterceptor);
- SessionInvalidatorInterceptor sessionInvalidatorInterceptor = new SessionInvalidatorInterceptor();
- sessionInvalidatorInterceptor.setNext(producerCacheInterceptor);
ContextDispatcherInterceptor contextDispatcherInterceptor = new ContextDispatcherInterceptor();
- contextDispatcherInterceptor.setNext(sessionInvalidatorInterceptor);
+ contextDispatcherInterceptor.setNext(producerCacheInterceptor);
SecureTransportInterceptor secureTransportInterceptor = new SecureTransportInterceptor();
secureTransportInterceptor.setNext(contextDispatcherInterceptor);
ValveInterceptor valveInterceptor = new ValveInterceptor();
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-09-30 18:47:13 UTC (rev 4447)
+++ portal/trunk/pom.xml 2010-09-30 18:47:31 UTC (rev 4448)
@@ -46,7 +46,7 @@
<nl.captcha.simplecaptcha.version>1.1.1-GA-Patch01</nl.captcha.simplecaptcha.version>
<org.gatein.common.version>2.0.3-GA</org.gatein.common.version>
<org.gatein.wci.version>2.0.2-GA</org.gatein.wci.version>
- <org.gatein.pc.version>2.2.0-Beta04-SNAPSHOT</org.gatein.pc.version>
+ <org.gatein.pc.version>2.2.0-Beta03</org.gatein.pc.version>
<org.picketlink.idm>1.1.5.GA</org.picketlink.idm>
<org.gatein.wsrp.version>2.0.0-Alpha03</org.gatein.wsrp.version>
<org.gatein.mop.version>1.0.3-GA</org.gatein.mop.version>
14 years, 2 months
gatein SVN: r4447 - in components/wsrp/trunk/common/src: test/java/org/gatein/wsrp/other and 1 other directory.
by do-not-reply@jboss.org
Author: mwringe
Date: 2010-09-30 14:47:13 -0400 (Thu, 30 Sep 2010)
New Revision: 4447
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPResourceURL.java
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/other/WSRPPortletURLTestCase.java
Log:
GTNWSRP-81: fix issues with throwing exceptions about missing parameters which are not actually required. Updated tests to test for this.
Modified: components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPResourceURL.java
===================================================================
--- components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPResourceURL.java 2010-09-30 15:24:53 UTC (rev 4446)
+++ components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/WSRPResourceURL.java 2010-09-30 18:47:13 UTC (rev 4447)
@@ -111,11 +111,6 @@
requiresRewrite = Boolean.valueOf(requireRewrite);
params.remove(WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE);
}
- else
- {
- throw new IllegalArgumentException("The parsed parameters don't contain a value for the required "
- + WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE + " parameter in " + originalURL);
- }
String url = getRawParameterValueFor(params, WSRPRewritingConstants.RESOURCE_URL);
if (url != null)
@@ -138,6 +133,13 @@
{
resourceId = resourceIDParam;
}
+
+ // we either need a resource Id or (requiredRewrite and url)
+ if (resourceIDParam == null && (requireRewrite == null || url == null))
+ {
+ throw new IllegalArgumentException("The parsed parameters don't are not valid for a resource url. It must contain either a "
+ + WSRP2RewritingConstants.RESOURCE_ID + " or " + WSRPRewritingConstants.RESOURCE_URL + " and " + WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE + " parameter in " + originalURL);
+ }
String preferOperationParam = getRawParameterValueFor(params, WSRP2RewritingConstants.RESOURCE_PREFER_OPERATION);
if (preferOperationParam != null)
Modified: components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/other/WSRPPortletURLTestCase.java
===================================================================
--- components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/other/WSRPPortletURLTestCase.java 2010-09-30 15:24:53 UTC (rev 4446)
+++ components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/other/WSRPPortletURLTestCase.java 2010-09-30 18:47:13 UTC (rev 4447)
@@ -112,6 +112,45 @@
assertEquals("false",resourceMap.get(WSRP2RewritingConstants.RESOURCE_PREFER_OPERATION));
}
+ public void testResourcesNoRequiresRewrite()
+ {
+ String expected = "wsrp_rewrite?wsrp-urlType=resource&wsrp-resourceID=resource_123" +
+ "&wsrp-url=http%3A%2F%2Ftest.com%2Fimages%2Ftest.gif&/wsrp_rewrite";
+ WSRPPortletURL url = WSRPPortletURL.create(expected);
+
+ assertTrue(url instanceof WSRPResourceURL);
+ WSRPResourceURL resource = (WSRPResourceURL)url;
+ assertFalse(resource.requiresRewrite());
+ assertEquals("http://test.com/images/test.gif", resource.getResourceURL().toExternalForm());
+
+ //resource.getResourceId will not return the actual resource id, but an encoded resource map used to determine how to access the resource
+ Map<String, String> resourceMap = WSRPResourceURL.decodeResource(resource.getResourceId());
+ String resourceID = resourceMap.get(WSRP2RewritingConstants.RESOURCE_ID);
+ assertEquals("resource_123", resourceID);
+
+ String resourceURL = resourceMap.get(WSRPRewritingConstants.RESOURCE_URL);
+ assertEquals("http://test.com/images/test.gif", resourceURL);
+ assertEquals("false",resourceMap.get(WSRP2RewritingConstants.RESOURCE_PREFER_OPERATION));
+ }
+
+ public void testResourcesNoResourceURL()
+ {
+ String expected = "wsrp_rewrite?wsrp-urlType=resource&wsrp-resourceID=resource_123" +
+ "&wsrp-requiresRewrite=false/wsrp_rewrite";
+ WSRPPortletURL url = WSRPPortletURL.create(expected);
+
+ assertTrue(url instanceof WSRPResourceURL);
+ WSRPResourceURL resource = (WSRPResourceURL)url;
+ assertFalse(resource.requiresRewrite());
+
+ //resource.getResourceId will not return the actual resource id, but an encoded resource map used to determine how to access the resource
+ Map<String, String> resourceMap = WSRPResourceURL.decodeResource(resource.getResourceId());
+ String resourceID = resourceMap.get(WSRP2RewritingConstants.RESOURCE_ID);
+ assertEquals("resource_123", resourceID);
+
+ assertEquals("false",resourceMap.get(WSRP2RewritingConstants.RESOURCE_PREFER_OPERATION));
+ }
+
public void testPreferOperation()
{
String expected = "wsrp_rewrite?wsrp-urlType=resource&wsrp-resourceID=resource_123" +
14 years, 2 months
gatein SVN: r4446 - in portal/trunk: component/pc/src/main/java/org/exoplatform/portal/pc and 1 other directory.
by do-not-reply@jboss.org
Author: mstruk
Date: 2010-09-30 11:24:53 -0400 (Thu, 30 Sep 2010)
New Revision: 4446
Modified:
portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java
portal/trunk/pom.xml
Log:
GTNPORTAL-1257: Seam session outlives the GateIn session
Modified: portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java
===================================================================
--- portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java 2010-09-30 15:23:54 UTC (rev 4445)
+++ portal/trunk/component/pc/src/main/java/org/exoplatform/portal/pc/ExoKernelIntegration.java 2010-09-30 15:24:53 UTC (rev 4446)
@@ -36,6 +36,7 @@
import org.gatein.pc.portlet.aspects.ProducerCacheInterceptor;
import org.gatein.pc.portlet.aspects.RequestAttributeConversationInterceptor;
import org.gatein.pc.portlet.aspects.SecureTransportInterceptor;
+import org.gatein.pc.portlet.aspects.SessionInvalidatorInterceptor;
import org.gatein.pc.portlet.aspects.ValveInterceptor;
import org.gatein.pc.portlet.container.ContainerPortletDispatcher;
import org.gatein.pc.portlet.container.ContainerPortletInvoker;
@@ -96,8 +97,10 @@
bridgepInterceptor.setNext(ccppInterceptor);
ProducerCacheInterceptor producerCacheInterceptor = new ProducerCacheInterceptor();
producerCacheInterceptor.setNext(bridgepInterceptor);
+ SessionInvalidatorInterceptor sessionInvalidatorInterceptor = new SessionInvalidatorInterceptor();
+ sessionInvalidatorInterceptor.setNext(producerCacheInterceptor);
ContextDispatcherInterceptor contextDispatcherInterceptor = new ContextDispatcherInterceptor();
- contextDispatcherInterceptor.setNext(producerCacheInterceptor);
+ contextDispatcherInterceptor.setNext(sessionInvalidatorInterceptor);
SecureTransportInterceptor secureTransportInterceptor = new SecureTransportInterceptor();
secureTransportInterceptor.setNext(contextDispatcherInterceptor);
ValveInterceptor valveInterceptor = new ValveInterceptor();
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-09-30 15:23:54 UTC (rev 4445)
+++ portal/trunk/pom.xml 2010-09-30 15:24:53 UTC (rev 4446)
@@ -46,7 +46,7 @@
<nl.captcha.simplecaptcha.version>1.1.1-GA-Patch01</nl.captcha.simplecaptcha.version>
<org.gatein.common.version>2.0.3-GA</org.gatein.common.version>
<org.gatein.wci.version>2.0.2-GA</org.gatein.wci.version>
- <org.gatein.pc.version>2.2.0-Beta03</org.gatein.pc.version>
+ <org.gatein.pc.version>2.2.0-Beta04-SNAPSHOT</org.gatein.pc.version>
<org.picketlink.idm>1.1.5.GA</org.picketlink.idm>
<org.gatein.wsrp.version>2.0.0-Alpha03</org.gatein.wsrp.version>
<org.gatein.mop.version>1.0.3-GA</org.gatein.mop.version>
14 years, 2 months
gatein SVN: r4445 - components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/aspects.
by do-not-reply@jboss.org
Author: mstruk
Date: 2010-09-30 11:23:54 -0400 (Thu, 30 Sep 2010)
New Revision: 4445
Added:
components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/aspects/SessionInvalidatorInterceptor.java
Log:
GTNPORTAL-1257: Seam session outlives the GateIn session
Added: components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/aspects/SessionInvalidatorInterceptor.java
===================================================================
--- components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/aspects/SessionInvalidatorInterceptor.java (rev 0)
+++ components/pc/trunk/portlet/src/main/java/org/gatein/pc/portlet/aspects/SessionInvalidatorInterceptor.java 2010-09-30 15:23:54 UTC (rev 4445)
@@ -0,0 +1,151 @@
+/*
+ * 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.gatein.pc.portlet.aspects;
+
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.api.invocation.PortletInvocation;
+import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
+import org.gatein.pc.portlet.PortletInvokerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.Collections;
+
+/**
+ * This is a port of http://svn.exoplatform.org/projects/portlet-container/branches/2.1.x/comp...
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class SessionInvalidatorInterceptor extends PortletInvokerInterceptor
+{
+
+ private static final String IDENTITY_TOKEN = "javax.portlet.identity.token";
+
+ private final static Logger log = LoggerFactory.getLogger(SessionInvalidatorInterceptor.class);
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws IllegalArgumentException, PortletInvokerException
+ {
+ //req = RequestContext.<PortalRequestContext>getCurrentInstance().getRequest();
+ HttpServletRequest req = invocation.getDispatchedRequest();
+
+ check(req);
+ try
+ {
+ return super.invoke(invocation);
+ }
+ finally
+ {
+ update(req);
+ }
+ }
+
+ public void update(HttpServletRequest request)
+ {
+ String portalIdentity = request.getRemoteUser();
+ boolean trace = log.isTraceEnabled();
+ String contextPath = request.getContextPath();
+ HttpSession session = request.getSession(false);
+ if (session != null)
+ {
+ String id = session.getId();
+ String sessionIdentity = (String) session.getAttribute(IDENTITY_TOKEN);
+ if (portalIdentity != null)
+ {
+ if (!portalIdentity.equals(sessionIdentity))
+ {
+ if (trace)
+ {
+ log.trace("Updating portlet session " + id + " (" + contextPath + ") from " + sessionIdentity + " to " + portalIdentity);
+ }
+
+ //
+ session.setAttribute(IDENTITY_TOKEN, portalIdentity);
+ }
+ }
+ else
+ {
+ if (sessionIdentity != null)
+ {
+ if (trace)
+ {
+ log.trace("Updating portlet session " + id + " (" + contextPath + ") by removing the " + sessionIdentity + " value");
+ }
+
+ //
+ session.removeAttribute(IDENTITY_TOKEN);
+ }
+ }
+ }
+ }
+
+ public void check(HttpServletRequest request)
+ {
+ boolean trace = log.isTraceEnabled();
+ String portalIdentity = request.getRemoteUser();
+ String contextPath = request.getContextPath();
+ HttpSession session = request.getSession(false);
+ if (session != null)
+ {
+ String id = session.getId();
+ String sessionIdentity = (String) session.getAttribute(IDENTITY_TOKEN);
+
+ //
+ if (portalIdentity == null)
+ {
+ if (sessionIdentity != null)
+ {
+ // It means that user is anonymous and the portlet session is still associated to a previous identity
+ if (trace)
+ {
+ log.trace("Detected user logout for session " + id + " (" + contextPath + ")");
+ }
+
+ purge(session);
+ }
+ }
+ else
+ {
+ if (sessionIdentity != null && !sessionIdentity.equals(portalIdentity))
+ {
+ // It means that we don't have the same identity in portal and portlet session
+ if (trace)
+ {
+ log.trace("Detected different user for session " + id + " (" + contextPath + ")");
+ }
+
+ purge(session);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void purge(HttpSession session)
+ {
+ for (String name : (Iterable<String>) Collections.list(session.getAttributeNames()))
+ {
+ session.removeAttribute(name);
+ }
+ }
+}
14 years, 2 months
gatein SVN: r4444 - in portal/branches/wci: portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component and 3 other directories.
by do-not-reply@jboss.org
Author: alain_defrance
Date: 2010-09-30 10:05:42 -0400 (Thu, 30 Sep 2010)
New Revision: 4444
Added:
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/LogoutControl.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/PortalLogoutLifecycle.java
Modified:
portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
portal/branches/wci/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java
portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
Log:
WCI authentication in progress
Modified: portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
===================================================================
--- portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-09-30 14:01:44 UTC (rev 4443)
+++ portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-09-30 14:05:42 UTC (rev 4444)
@@ -122,7 +122,10 @@
req.getSession().removeAttribute(InitiateLoginServlet.CREDENTIALS);
sendAuth(resp, credentials.getUsername(), genericAuthentication.getTicket());
}
- resp.sendRedirect(resp.encodeRedirectURL(""));
+ else
+ {
+ resp.sendRedirect(resp.encodeRedirectURL(""));
+ }
}
}
Added: portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/LogoutControl.java
===================================================================
--- portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/LogoutControl.java (rev 0)
+++ portal/branches/wci/component/web/security/src/main/java/org/exoplatform/web/login/LogoutControl.java 2010-09-30 14:05:42 UTC (rev 4444)
@@ -0,0 +1,44 @@
+/*
+* Copyright (C) 2003-2009 eXo Platform SAS.
+*
+* 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.exoplatform.web.login;
+
+/**
+ * @author <a href="mailto:alain.defrance@exoplatform.com">Alain Defrance</a>
+ * @version $Revision$
+ */
+public class LogoutControl
+{
+ private static final ThreadLocal<Boolean> wantLogout = new ThreadLocal<Boolean>();
+
+ public static void cancelLogout()
+ {
+ wantLogout.set(false);
+ }
+
+ public static void wantLogout()
+ {
+ wantLogout.set(true);
+ }
+
+ public static boolean isLogoutRequired()
+ {
+ return wantLogout.get();
+ }
+}
Modified: portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java
===================================================================
--- portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2010-09-30 14:01:44 UTC (rev 4443)
+++ portal/branches/wci/portlet/exoadmin/src/main/java/org/exoplatform/navigation/webui/component/UISiteManagement.java 2010-09-30 14:05:42 UTC (rev 4444)
@@ -44,6 +44,7 @@
import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
import org.exoplatform.util.ReflectionUtil;
import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.web.login.LogoutControl;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.ComponentConfigs;
@@ -252,7 +253,7 @@
if (config == null || Util.getUIPortal().getName().equals(portalName))
{
HttpServletRequest request = prContext.getRequest();
- request.getSession().invalidate();
+ LogoutControl.wantLogout();
prContext.setResponseComplete(true);
prContext.getResponse().sendRedirect(request.getContextPath());
return;
Modified: portal/branches/wci/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
===================================================================
--- portal/branches/wci/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2010-09-30 14:01:44 UTC (rev 4443)
+++ portal/branches/wci/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2010-09-30 14:05:42 UTC (rev 4444)
@@ -33,6 +33,7 @@
<application-lifecycle-listeners>
<listener>org.exoplatform.portal.application.UserSiteLifeCycle</listener>
+ <listener>org.exoplatform.portal.application.PortalLogoutLifecycle</listener>
<listener>org.exoplatform.portal.application.PortalStatisticLifecycle</listener>
<listener>org.exoplatform.portal.application.PortalApplicationLifecycle</listener>
<listener>org.exoplatform.webui.application.MonitorApplicationLifecycle</listener>
Added: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/PortalLogoutLifecycle.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/PortalLogoutLifecycle.java (rev 0)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/application/PortalLogoutLifecycle.java 2010-09-30 14:05:42 UTC (rev 4444)
@@ -0,0 +1,67 @@
+/*
+* Copyright (C) 2003-2009 eXo Platform SAS.
+*
+* 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.exoplatform.portal.application;
+
+import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.web.application.Application;
+import org.exoplatform.web.application.ApplicationLifecycle;
+import org.exoplatform.web.application.RequestFailure;
+import org.exoplatform.web.login.LogoutControl;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.gatein.wci.impl.DefaultServletContainerFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:alain.defrance@exoplatform.com">Alain Defrance</a>
+ * @version $Revision$
+ */
+public class PortalLogoutLifecycle implements ApplicationLifecycle<WebuiRequestContext>
+{
+
+ public void onInit(Application app) throws Exception
+ {
+ }
+
+ public void onStartRequest(Application app, WebuiRequestContext context) throws Exception
+ {
+ LogoutControl.cancelLogout();
+ }
+
+ public void onFailRequest(Application app, WebuiRequestContext context, RequestFailure failureType) throws Exception
+ {
+ }
+
+ public void onEndRequest(Application app, WebuiRequestContext context) throws Exception
+ {
+ if (LogoutControl.isLogoutRequired())
+ {
+ PortalRequestContext prContext = Util.getPortalRequestContext();
+ HttpServletRequest request = prContext.getRequest();
+ HttpServletResponse response = prContext.getResponse();
+ DefaultServletContainerFactory.getInstance().getServletContainer().logout(request, response);
+ }
+ }
+
+ public void onDestroy(Application app) throws Exception
+ {
+ }
+}
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-09-30 14:01:44 UTC (rev 4443)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-09-30 14:05:42 UTC (rev 4444)
@@ -45,6 +45,7 @@
import org.exoplatform.services.organization.User;
import org.exoplatform.services.resources.ResourceBundleManager;
import org.exoplatform.web.login.InitiateLoginServlet;
+import org.exoplatform.web.login.LogoutControl;
import org.exoplatform.web.security.security.AbstractTokenService;
import org.exoplatform.web.security.security.CookieTokenService;
import org.exoplatform.webui.application.WebuiRequestContext;
@@ -413,8 +414,8 @@
AbstractTokenService tokenService = AbstractTokenService.getInstance(CookieTokenService.class);
tokenService.deleteToken(token);
}
-
- req.getSession().invalidate();
+
+ LogoutControl.wantLogout();
Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
cookie.setPath(req.getContextPath());
cookie.setMaxAge(0);
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java 2010-09-30 14:01:44 UTC (rev 4443)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalActionListener.java 2010-09-30 14:05:42 UTC (rev 4444)
@@ -22,6 +22,7 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.webui.application.UIPortlet;
import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.web.login.LogoutControl;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
import org.exoplatform.webui.event.Event;
@@ -45,7 +46,7 @@
public void execute(Event<UIComponent> event) throws Exception
{
PortalRequestContext prContext = Util.getPortalRequestContext();
- prContext.getRequest().getSession().invalidate();
+ LogoutControl.wantLogout();
HttpServletRequest request = prContext.getRequest();
String portalName = URLEncoder.encode(Util.getUIPortal().getName(), "UTF-8");
String redirect = request.getContextPath() + "/public/" + portalName + "/";
Modified: portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
===================================================================
--- portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-09-30 14:01:44 UTC (rev 4443)
+++ portal/branches/wci/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-09-30 14:05:42 UTC (rev 4444)
@@ -46,6 +46,7 @@
import org.exoplatform.services.resources.LocaleConfigService;
import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.web.application.JavascriptManager;
+import org.exoplatform.web.login.LogoutControl;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.ComponentConfigs;
@@ -497,7 +498,7 @@
if (editPortal.getOwner().equals(prContext.getPortalOwner()))
{
HttpServletRequest request = prContext.getRequest();
- request.getSession().invalidate();
+ LogoutControl.wantLogout();
prContext.setResponseComplete(true);
prContext.getResponse().sendRedirect(request.getContextPath());
return;
14 years, 2 months
gatein SVN: r4443 - in components/wci/branches/adf: test/core/src/main/java/org/gatein/wci/container and 7 other directories.
by do-not-reply@jboss.org
Author: alain_defrance
Date: 2010-09-30 10:01:44 -0400 (Thu, 30 Sep 2010)
New Revision: 4443
Modified:
components/wci/branches/adf/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java
components/wci/branches/adf/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java
components/wci/branches/adf/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java
components/wci/branches/adf/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/ServletContainer.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java
components/wci/branches/adf/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java
Log:
logout feature added
Modified: components/wci/branches/adf/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java
===================================================================
--- components/wci/branches/adf/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java 2010-09-30 12:12:57 UTC (rev 4442)
+++ components/wci/branches/adf/jetty/src/main/java/org/gatein/wci/jetty/Jetty6ServletContainerContext.java 2010-09-30 14:01:44 UTC (rev 4443)
@@ -66,7 +66,11 @@
return GenericAuthentication.getInstance().login(userName, password.toCharArray());
}
+ public void logout(HttpServletRequest request, HttpServletResponse response) {
+ GenericAuthentication.getInstance().logout(request, response);
+ }
+
public void start()
{
DefaultServletContainerFactory.registerContext(this);
Modified: components/wci/branches/adf/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java
===================================================================
--- components/wci/branches/adf/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java 2010-09-30 12:12:57 UTC (rev 4442)
+++ components/wci/branches/adf/test/core/src/main/java/org/gatein/wci/container/ServletContainerContextImpl.java 2010-09-30 14:01:44 UTC (rev 4443)
@@ -66,4 +66,9 @@
{
return GenericAuthentication.getInstance().login(userName, password.toCharArray());
}
+
+ public void logout(HttpServletRequest request, HttpServletResponse response)
+ {
+ GenericAuthentication.getInstance().logout(request, response);
+ }
}
Modified: components/wci/branches/adf/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java
===================================================================
--- components/wci/branches/adf/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java 2010-09-30 12:12:57 UTC (rev 4442)
+++ components/wci/branches/adf/tomcat6/src/main/java/org/gatein/wci/tomcat/TC6ServletContainerContext.java 2010-09-30 14:01:44 UTC (rev 4443)
@@ -104,6 +104,11 @@
return GenericAuthentication.getInstance().login(userName, password.toCharArray());
}
+ public void logout(HttpServletRequest request, HttpServletResponse response)
+ {
+ GenericAuthentication.getInstance().logout(request, response);
+ }
+
public synchronized void containerEvent(ContainerEvent event)
{
if (event.getData() instanceof Host)
Modified: components/wci/branches/adf/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java
===================================================================
--- components/wci/branches/adf/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java 2010-09-30 12:12:57 UTC (rev 4442)
+++ components/wci/branches/adf/tomcat7/src/main/java/org/gatein/wci/tomcat/TC7ServletContainerContext.java 2010-09-30 14:01:44 UTC (rev 4443)
@@ -100,15 +100,31 @@
this.registration = null;
}
- public AuthenticationResult login(HttpServletRequest request, HttpServletResponse response, String userName, String password) {
- try {
- request.login(userName, password);
- } catch (ServletException e) {
- e.printStackTrace();
- }
- return new ProgrammaticAuthenticationResult();
- }
+ public AuthenticationResult login(HttpServletRequest request, HttpServletResponse response, String userName, String password)
+ {
+ try
+ {
+ request.login(userName, password);
+ }
+ catch (ServletException e)
+ {
+ e.printStackTrace(); // TODO : manage correctly this exception.
+ }
+ return new ProgrammaticAuthenticationResult();
+ }
+ public void logout(HttpServletRequest request, HttpServletResponse response)
+ {
+ try
+ {
+ request.logout();
+ }
+ catch (ServletException e)
+ {
+ e.printStackTrace(); // TODO : manage correctly this exception.
+ }
+ }
+
public synchronized void containerEvent(ContainerEvent event)
{
if (event.getData() instanceof Host)
Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/ServletContainer.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/ServletContainer.java 2010-09-30 12:12:57 UTC (rev 4442)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/ServletContainer.java 2010-09-30 14:01:44 UTC (rev 4443)
@@ -102,4 +102,12 @@
* @param password the password of the username
*/
AuthenticationResult login(HttpServletRequest request, HttpServletResponse response, String userName, String password);
+
+ /**
+ * Authentication support.
+ *
+ * @param request the request valid in the current servlet context
+ * @param response the response valid in the current servlet context
+ */
+ void logout(HttpServletRequest request, HttpServletResponse response);
}
Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java 2010-09-30 12:12:57 UTC (rev 4442)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/Authentication.java 2010-09-30 14:01:44 UTC (rev 4443)
@@ -19,6 +19,9 @@
package org.gatein.wci.authentication;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
/**
* @author <a href="mailto:alain.defrance@exoplatform.com">Alain Defrance</a>
* @version $Revision$
@@ -26,6 +29,6 @@
public interface Authentication
{
public AuthenticationResult login(String login, char[] password);
- public void logout();
+ public void logout(HttpServletRequest request, HttpServletResponse response);
public void addAuthenticationListener(AuthenticationListener listener);
}
Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java 2010-09-30 12:12:57 UTC (rev 4442)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/authentication/GenericAuthentication.java 2010-09-30 14:01:44 UTC (rev 4443)
@@ -19,6 +19,9 @@
package org.gatein.wci.authentication;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
/**
* @author <a href="mailto:alain.defrance@exoplatform.com">Alain Defrance</a>
* @version $Revision$
@@ -32,15 +35,16 @@
public AuthenticationResult login(String login, char[] password)
{
- String ticket = TICKET_SERVICE.createTicket(new WCICredentials(login, new String(password)));
+ String ticket = TICKET_SERVICE.createTicket(new WCICredentials(login, new String(password)));
- fireEvent(EventType.LOGIN, new AuthenticationEvent(login, password));
- return new GenericAuthenticationResult(ticket);
+ fireEvent(EventType.LOGIN, new AuthenticationEvent(login, password));
+ return new GenericAuthenticationResult(ticket);
}
- public void logout()
+ public void logout(HttpServletRequest request, HttpServletResponse response)
{
- fireEvent(EventType.LOGOUT, new AuthenticationEvent("", new char[1]));
+ request.getSession().invalidate();
+ fireEvent(EventType.LOGOUT, new AuthenticationEvent("", new char[1]));
}
public static GenericAuthentication getInstance() {
Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java 2010-09-30 12:12:57 UTC (rev 4442)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/DefaultServletContainer.java 2010-09-30 14:01:44 UTC (rev 4443)
@@ -95,6 +95,10 @@
return registration.context.login(request, response, userName, password);
}
+ public void logout(HttpServletRequest request, HttpServletResponse response) {
+ registration.context.logout(request, response);
+ }
+
public WebExecutor getExecutor(HttpServletRequest request, HttpServletResponse response)
{
throw new NotYetImplemented();
Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java 2010-09-30 12:12:57 UTC (rev 4442)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/impl/generic/GenericServletContainerContext.java 2010-09-30 14:01:44 UTC (rev 4443)
@@ -135,6 +135,11 @@
return GenericAuthentication.getInstance().login(userName, password.toCharArray());
}
+ public void logout(HttpServletRequest request, HttpServletResponse response)
+ {
+ GenericAuthentication.getInstance().logout(request, response);
+ }
+
//
public void contextInitialized(ServletContextEvent servletContextEvent)
Modified: components/wci/branches/adf/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java
===================================================================
--- components/wci/branches/adf/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java 2010-09-30 12:12:57 UTC (rev 4442)
+++ components/wci/branches/adf/wci/src/main/java/org/gatein/wci/spi/ServletContainerContext.java 2010-09-30 14:01:44 UTC (rev 4443)
@@ -85,6 +85,14 @@
AuthenticationResult login(HttpServletRequest request, HttpServletResponse response, String userName, String password);
/**
+ * Authentication support.
+ *
+ * @param request the request valid in the current servlet context
+ * @param response the response valid in the current servlet context
+ */
+ void logout(HttpServletRequest request, HttpServletResponse response);
+
+ /**
* The callback interface that a servlet container context can obtain from its registration against
* the <code>org.jboss.portal.web.ServletContainer</code> singleton.
*/
14 years, 2 months