gatein SVN: r8428 - in portal/trunk: component/web/security/src/main/java/org/exoplatform/web/security and 2 other directories.
by do-not-reply@jboss.org
Author: mposolda
Date: 2012-02-15 16:18:41 -0500 (Wed, 15 Feb 2012)
New Revision: 8428
Added:
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/AuthenticationRegistry.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/AuthenticationRegistryImpl.java
Modified:
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/DoLoginServlet.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/common-configuration.xml
portal/trunk/wsrp-integration/extension-ear-as5/src/main/application/lib/jboss5integration.jar/conf/configuration.xml
Log:
GTNPORTAL-2275 Get rid of credentials in HTTP session.
Modified: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/DoLoginServlet.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/DoLoginServlet.java 2012-02-15 15:57:07 UTC (rev 8427)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/DoLoginServlet.java 2012-02-15 21:18:41 UTC (rev 8428)
@@ -19,11 +19,14 @@
package org.exoplatform.web.login;
+import org.exoplatform.container.web.AbstractHttpServlet;
+import org.exoplatform.services.security.ConversationState;
+import org.exoplatform.web.security.AuthenticationRegistry;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
+import org.gatein.wci.security.Credentials;
import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@@ -33,7 +36,7 @@
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
*/
-public class DoLoginServlet extends HttpServlet
+public class DoLoginServlet extends AbstractHttpServlet
{
/** . */
@@ -65,7 +68,39 @@
initialURI = req.getContextPath();
}
+ // Now user is successfuly authenticated, so that we can remove credentials from temporary AuthenticationRegistry
+ // and add them to ConversationState
+ Credentials credentials = removeCredentialsFromRegistry(req);
+ setCredentialsToConversationState(credentials);
+
//
resp.sendRedirect(resp.encodeRedirectURL(initialURI));
}
+
+ /**
+ * Remove credentials from temporary AuthenticationRegistry because authentication of user is now finished.
+ *
+ * @param req
+ * @return credentials,which were removed from AuthenticationRegistry
+ */
+ protected Credentials removeCredentialsFromRegistry(HttpServletRequest req)
+ {
+ AuthenticationRegistry authenticationRegistry = (AuthenticationRegistry)getContainer().getComponentInstanceOfType(AuthenticationRegistry.class);
+ return authenticationRegistry.removeCredentials(req);
+ }
+
+ /**
+ * Add credentials to {@link ConversationState}.
+ *
+ * @param credentials
+ */
+ protected void setCredentialsToConversationState(Credentials credentials)
+ {
+ ConversationState currentConversationState = ConversationState.getCurrent();
+ if (currentConversationState != null && credentials != null)
+ {
+ log.debug("Adding credentials to conversationState for user " + credentials.getUsername());
+ currentConversationState.setAttribute(Credentials.CREDENTIALS, credentials);
+ }
+ }
}
Modified: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java 2012-02-15 15:57:07 UTC (rev 8427)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java 2012-02-15 21:18:41 UTC (rev 8428)
@@ -19,6 +19,9 @@
package org.exoplatform.web.login;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.web.security.AuthenticationRegistry;
+import org.exoplatform.web.security.PortalLoginModule;
import org.gatein.wci.security.Credentials;
import org.gatein.wci.security.WCIController;
@@ -94,7 +97,17 @@
@Override
public Credentials getCredentials(final HttpServletRequest req, final HttpServletResponse resp)
{
- return (Credentials)req.getSession().getAttribute(Credentials.CREDENTIALS);
+ AuthenticationRegistry credRegistry = (AuthenticationRegistry)PortalContainer.getCurrentInstance(servletContext).
+ getComponentInstanceOfType(AuthenticationRegistry.class);
+ Credentials credentials = credRegistry.getCredentials(req);
+
+ // Try to find AuthenticatedCredentials in HTTP session
+ if (credentials == null)
+ {
+ credentials = (Credentials)req.getSession().getAttribute(PortalLoginModule.AUTHENTICATED_CREDENTIALS);
+ }
+
+ return credentials;
}
@Override
Modified: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java 2012-02-15 15:57:07 UTC (rev 8427)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/RememberMeFilter.java 2012-02-15 21:18:41 UTC (rev 8428)
@@ -21,6 +21,7 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.web.AbstractFilter;
+import org.exoplatform.web.security.AuthenticationRegistry;
import org.exoplatform.web.security.security.CookieTokenService;
import org.exoplatform.web.controller.router.PercentEncoding;
import org.gatein.common.logging.Logger;
@@ -68,7 +69,9 @@
token, false);
if (o instanceof Credentials)
{
- req.getSession().setAttribute(Credentials.CREDENTIALS, o);
+ AuthenticationRegistry authenticationRegistry = (AuthenticationRegistry)getContainer().getComponentInstanceOfType(AuthenticationRegistry.class);
+ authenticationRegistry.setCredentials(req, (Credentials)o);
+
resp.sendRedirect(resp.encodeRedirectURL(
loginUrl(
req.getContextPath(),
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/AuthenticationRegistry.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/AuthenticationRegistry.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/AuthenticationRegistry.java 2012-02-15 21:18:41 UTC (rev 8428)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, 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.exoplatform.web.security;
+
+import org.gatein.wci.security.Credentials;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Temporary registry for hold credentials (and potentially other attributes) during login process.
+ *
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+public interface AuthenticationRegistry
+{
+
+ public Credentials getCredentials(HttpServletRequest request);
+
+
+ public void setCredentials(HttpServletRequest request, Credentials credentials);
+
+
+ public Credentials removeCredentials(HttpServletRequest request);
+
+}
Added: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/AuthenticationRegistryImpl.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/AuthenticationRegistryImpl.java (rev 0)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/AuthenticationRegistryImpl.java 2012-02-15 21:18:41 UTC (rev 8428)
@@ -0,0 +1,107 @@
+/*
+ *
+ * JBoss, a division of Red Hat
+ * Copyright 2012, 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.exoplatform.web.security;
+
+import org.gatein.wci.security.Credentials;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Temporary registry for hold credentials (and potentially other attributes) during login process to avoid store them in session.
+ * Registry is used only during authentication process and attributes of target client are cleared after successful authentication,
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+public class AuthenticationRegistryImpl implements AuthenticationRegistry
+{
+
+ // Key is ID of HTTP Session. Value is map with various attributes of single client (session),
+ // which will be used during authentication process.
+ private final ConcurrentMap<String, Map<String, Object>> registry = new ConcurrentHashMap<String, Map<String, Object>>();
+
+
+ public Credentials getCredentials(HttpServletRequest request)
+ {
+ String sessionId = getSessionId(request);
+ Map<String, Object> attributesOfClient = registry.get(sessionId);
+
+ if (attributesOfClient == null)
+ {
+ return null;
+ }
+
+ return (Credentials)attributesOfClient.get(Credentials.CREDENTIALS);
+ }
+
+
+ public void setCredentials(HttpServletRequest request, Credentials credentials)
+ {
+ String sessionId = getSessionId(request);
+
+ Map<String, Object> attributesOfClient = getAttributesOfClient(sessionId);
+ attributesOfClient.put(Credentials.CREDENTIALS, credentials);
+ }
+
+
+ public Credentials removeCredentials(HttpServletRequest request)
+ {
+ String sessionId = getSessionId(request);
+
+ Map<String, Object> attributesOfClient = getAttributesOfClient(sessionId);
+
+ Credentials credentials = (Credentials)attributesOfClient.remove(Credentials.CREDENTIALS);
+
+ // Clear map if no more attributes are here.
+ if (attributesOfClient.size() == 0)
+ {
+ registry.remove(sessionId);
+ }
+
+ return credentials;
+ }
+
+
+ private Map<String, Object> getAttributesOfClient(String sessionId)
+ {
+ Map<String, Object> attributes = registry.get(sessionId);
+
+ if (attributes == null)
+ {
+ attributes = new ConcurrentHashMap<String, Object>();
+ registry.putIfAbsent(sessionId, attributes);
+ }
+
+ return registry.get(sessionId);
+ }
+
+
+ private String getSessionId(HttpServletRequest req)
+ {
+ return req.getSession().getId();
+ }
+}
Modified: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java 2012-02-15 15:57:07 UTC (rev 8427)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginController.java 2012-02-15 21:18:41 UTC (rev 8428)
@@ -19,6 +19,7 @@
package org.exoplatform.web.security;
+import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.web.login.InitiateLoginServlet;
import org.exoplatform.web.security.security.AbstractTokenService;
import org.exoplatform.web.security.security.CookieTokenService;
@@ -64,7 +65,7 @@
{
//Create token
AbstractTokenService tokenService = AbstractTokenService.getInstance(CookieTokenService.class);
- Credentials credentials = (Credentials)req.getSession().getAttribute(Credentials.CREDENTIALS);
+ Credentials credentials = getCredentials(req);
String cookieToken = tokenService.createToken(credentials);
log.debug("Found a remember me request parameter, created a persistent token " + cookieToken + " for it and set it up " +
@@ -95,4 +96,34 @@
String redirectURI = req.getContextPath() + "/dologin?initialURI=" + URLEncoder.encode(uri, "UTF-8");
resp.sendRedirect(resp.encodeRedirectURL(redirectURI));
}
+
+ /**
+ * Read credentials from ConversationState instead of HTTP session.
+ *
+ * @param req
+ * @return credentials
+ */
+ @Override
+ protected Credentials getCredentials(HttpServletRequest req)
+ {
+ return getAuthenticationRegistry(req).getCredentials(req);
+ }
+
+ /**
+ * Set credentials to ConversationState instead of HTTP session
+ *
+ * @param req
+ * @param credentials
+ */
+ @Override
+ protected void setCredentials(HttpServletRequest req, Credentials credentials)
+ {
+ getAuthenticationRegistry(req).setCredentials(req, credentials);
+ }
+
+ private AuthenticationRegistry getAuthenticationRegistry(HttpServletRequest req)
+ {
+ return (AuthenticationRegistry) ExoContainerContext.getCurrentContainer().
+ getComponentInstanceOfType(AuthenticationRegistry.class);
+ }
}
Modified: portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java
===================================================================
--- portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java 2012-02-15 15:57:07 UTC (rev 8427)
+++ portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/PortalLoginModule.java 2012-02-15 21:18:41 UTC (rev 8428)
@@ -169,7 +169,6 @@
else
{
request.getSession().setAttribute(AUTHENTICATED_CREDENTIALS, wc);
- handleCredentialsRemoving(request);
}
}
catch(Exception e)
@@ -187,6 +186,13 @@
*/
public boolean abort() throws LoginException
{
+ HttpServletRequest request = getCurrentHttpServletRequest();
+
+ if (request != null)
+ {
+ handleCredentialsRemoving(request);
+ }
+
return true;
}
@@ -210,14 +216,24 @@
}
/**
- * Remove credentials of authenticated user from HTTP session.
+ * Remove credentials of authenticated user from AuthenticationRegistry.
*
* @param request httpRequest
*/
protected void handleCredentialsRemoving(HttpServletRequest request)
{
- // TODO: We can't remove credentials from HTTP session right now because WSRP-Security relies on it. See method WSSecurityCredentialHelper.handleRequest
- // request.getSession().removeAttribute(Credentials.CREDENTIALS);
+ try
+ {
+ AuthenticationRegistry authenticationRegistry = (AuthenticationRegistry)getContainer().getComponentInstanceOfType(AuthenticationRegistry.class);
+ if (request != null)
+ {
+ authenticationRegistry.removeCredentials(request);
+ }
+ }
+ catch (Exception e)
+ {
+ log.debug("Unable to remove credentials from credentialsRegistry.", e);
+ }
}
private HttpServletRequest getCurrentHttpServletRequest()
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/common-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/common-configuration.xml 2012-02-15 15:57:07 UTC (rev 8427)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/common/common-configuration.xml 2012-02-15 21:18:41 UTC (rev 8428)
@@ -185,6 +185,11 @@
</init-params>
</component>
+ <component>
+ <key>org.exoplatform.web.security.AuthenticationRegistry</key>
+ <type>org.exoplatform.web.security.AuthenticationRegistryImpl</type>
+ </component>
+
<external-component-plugins>
<target-component>org.exoplatform.services.cache.ExoCacheFactory</target-component>
<component-plugin>
Modified: portal/trunk/wsrp-integration/extension-ear-as5/src/main/application/lib/jboss5integration.jar/conf/configuration.xml
===================================================================
--- portal/trunk/wsrp-integration/extension-ear-as5/src/main/application/lib/jboss5integration.jar/conf/configuration.xml 2012-02-15 15:57:07 UTC (rev 8427)
+++ portal/trunk/wsrp-integration/extension-ear-as5/src/main/application/lib/jboss5integration.jar/conf/configuration.xml 2012-02-15 21:18:41 UTC (rev 8428)
@@ -31,10 +31,10 @@
<key>org.gatein.wsrp.wss.credentials.CredentialsAccessor</key>
<!-- Reading credentials from HTTP session -->
- <type>org.gatein.wsrp.wss.credentials.HTTPSessionCredentialsAccessor</type>
+ <!--<type>org.gatein.wsrp.wss.credentials.HTTPSessionCredentialsAccessor</type>-->
<!-- Reading credentials from ConversationState -->
- <!--<type>org.gatein.integration.wsrp.wss.ConversationStateCredentialsAccessor</type>-->
+ <type>org.gatein.integration.wsrp.wss.ConversationStateCredentialsAccessor</type>
</component>
<component>
12 years, 10 months
gatein SVN: r8426 - in portal/trunk/packaging/jboss-as7: extension and 2 other directories.
by do-not-reply@jboss.org
Author: mstruk
Date: 2012-02-14 08:40:41 -0500 (Tue, 14 Feb 2012)
New Revision: 8426
Modified:
portal/trunk/packaging/jboss-as7/extension/pom.xml
portal/trunk/packaging/jboss-as7/modules/pom.xml
portal/trunk/packaging/jboss-as7/pkg/pom.xml
portal/trunk/packaging/jboss-as7/pom.xml
Log:
GTNPORTAL-2154 Support for JBoss AS7
- fixed parent version mismatch that occurred during the last release
Modified: portal/trunk/packaging/jboss-as7/extension/pom.xml
===================================================================
--- portal/trunk/packaging/jboss-as7/extension/pom.xml 2012-02-14 13:18:59 UTC (rev 8425)
+++ portal/trunk/packaging/jboss-as7/extension/pom.xml 2012-02-14 13:40:41 UTC (rev 8426)
@@ -28,7 +28,7 @@
<parent>
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.packaging.jboss7</artifactId>
- <version>3.2.0-CR01-SNAPSHOT</version>
+ <version>3.2.0-CR02-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: portal/trunk/packaging/jboss-as7/modules/pom.xml
===================================================================
--- portal/trunk/packaging/jboss-as7/modules/pom.xml 2012-02-14 13:18:59 UTC (rev 8425)
+++ portal/trunk/packaging/jboss-as7/modules/pom.xml 2012-02-14 13:40:41 UTC (rev 8426)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.packaging.jboss7</artifactId>
- <version>3.2.0-CR01-SNAPSHOT</version>
+ <version>3.2.0-CR02-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: portal/trunk/packaging/jboss-as7/pkg/pom.xml
===================================================================
--- portal/trunk/packaging/jboss-as7/pkg/pom.xml 2012-02-14 13:18:59 UTC (rev 8425)
+++ portal/trunk/packaging/jboss-as7/pkg/pom.xml 2012-02-14 13:40:41 UTC (rev 8426)
@@ -8,7 +8,7 @@
<parent>
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.packaging.jboss7</artifactId>
- <version>3.2.0-CR01-SNAPSHOT</version>
+ <version>3.2.0-CR02-SNAPSHOT</version>
</parent>
<artifactId>exo.portal.packaging.jboss7.pkg</artifactId>
Modified: portal/trunk/packaging/jboss-as7/pom.xml
===================================================================
--- portal/trunk/packaging/jboss-as7/pom.xml 2012-02-14 13:18:59 UTC (rev 8425)
+++ portal/trunk/packaging/jboss-as7/pom.xml 2012-02-14 13:40:41 UTC (rev 8426)
@@ -3,7 +3,7 @@
<parent>
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.packaging</artifactId>
- <version>3.2.0-CR01-SNAPSHOT</version>
+ <version>3.2.0-CR02-SNAPSHOT</version>
</parent>
<artifactId>exo.portal.packaging.jboss7</artifactId>
12 years, 10 months
gatein SVN: r8425 - in epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main: webapp/WEB-INF and 1 other directories.
by do-not-reply@jboss.org
Author: mposolda
Date: 2012-02-14 08:18:59 -0500 (Tue, 14 Feb 2012)
New Revision: 8425
Modified:
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIAccountEditInputSet.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIListUsers.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIOrganizationPortlet.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/OrganizationPortlet_en.properties
epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml
Log:
JBEPP-1401 Fixing bug with "no results found" popup, which can sometimes be shown even if results exist.
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIAccountEditInputSet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIAccountEditInputSet.java 2012-02-13 21:48:05 UTC (rev 8424)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIAccountEditInputSet.java 2012-02-14 13:18:59 UTC (rev 8425)
@@ -110,26 +110,23 @@
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
UIApplication uiApp = context.getUIApplication();
String username = getUIStringInput(USERNAME).getValue();
- User user = service.getUserHandler().findUserByName(username);
- String oldEmail = user.getEmail();
+ User user = service.getUserHandler().findUserByName(username);
if (user == null)
{
uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.user-is-deleted", null, ApplicationMessage.WARNING));
UIUserInfo userInfo = getParent();
if (userInfo != null)
{
- UIUserManagement userManagement = userInfo.getParent();
- UIListUsers listUser = userManagement.getChild(UIListUsers.class);
UIAccountEditInputSet accountInput = userInfo.getChild(UIAccountEditInputSet.class);
UIUserProfileInputSet userProfile = userInfo.getChild(UIUserProfileInputSet.class);
userInfo.setRenderSibling(UIListUsers.class);
- listUser.search(new Query());
accountInput.reset();
userProfile.reset();
context.setProcessRender(true);
}
return false;
}
+ String oldEmail = user.getEmail();
invokeSetBindingField(user);
if (isChangePassword())
{
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIListUsers.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIListUsers.java 2012-02-13 21:48:05 UTC (rev 8424)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIListUsers.java 2012-02-14 13:18:59 UTC (rev 8425)
@@ -91,7 +91,6 @@
grid_.configure(USER_NAME, USER_BEAN_FIELD, USER_ACTION);
grid_.getUIPageIterator().setId("UIListUsersIterator");
grid_.getUIPageIterator().setParent(this);
- search(new Query());
}
/**
@@ -117,18 +116,12 @@
public String getUserSelected()
{
return userSelected_;
- }
+ }
public void search(Query query) throws Exception
{
lastQuery_ = query;
- grid_.getUIPageIterator().setPageList(new FindUsersPageList(query, 10));
- UIPageIterator pageIterator = grid_.getUIPageIterator();
- if (pageIterator.getAvailable() == 0)
- {
- UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
- uiApp.addMessage(new ApplicationMessage("UISearchForm.msg.empty", null));
- }
+ grid_.getUIPageIterator().setPageList(new FindUsersPageList(query, 10));
}
public void quickSearch(UIFormInputSet quickSearchInput) throws Exception
@@ -137,29 +130,33 @@
UIFormStringInput input = (UIFormStringInput)quickSearchInput.getChild(0);
UIFormSelectBox select = (UIFormSelectBox)quickSearchInput.getChild(1);
String name = input.getValue();
- if (name == null || name.equals(""))
+ if (name != null && !(name = name.trim()).equals(""))
{
- search(new Query());
- return;
- }
- if (name.indexOf("*") < 0)
+ if (name.indexOf("*") < 0)
+ {
+ if (name.charAt(0) != '*')
+ name = "*" + name;
+ if (name.charAt(name.length() - 1) != '*')
+ name += "*";
+ }
+ name = name.replace('?', '_');
+ String selectBoxValue = select.getValue();
+ if (selectBoxValue.equals(USER_NAME))
+ query.setUserName(name);
+ if (selectBoxValue.equals(LAST_NAME))
+ query.setLastName(name);
+ if (selectBoxValue.equals(FIRST_NAME))
+ query.setFirstName(name);
+ if (selectBoxValue.equals(EMAIL))
+ query.setEmail(name);
+ }
+ search(query);
+
+ if (getChild(UIGrid.class).getUIPageIterator().getAvailable() == 0)
{
- if (name.charAt(0) != '*')
- name = "*" + name;
- if (name.charAt(name.length() - 1) != '*')
- name += "*";
+ UIApplication uiApp = Util.getPortalRequestContext().getUIApplication();
+ uiApp.addMessage(new ApplicationMessage("UISearchForm.msg.empty", null));
}
- name = name.replace('?', '_');
- String selectBoxValue = select.getValue();
- if (selectBoxValue.equals(USER_NAME))
- query.setUserName(name);
- if (selectBoxValue.equals(LAST_NAME))
- query.setLastName(name);
- if (selectBoxValue.equals(FIRST_NAME))
- query.setFirstName(name);
- if (selectBoxValue.equals(EMAIL))
- query.setEmail(name);
- search(query);
}
@SuppressWarnings("unused")
@@ -176,7 +173,9 @@
OrganizationService service = uiListUsers.getApplicationComponent(OrganizationService.class);
if (service.getUserHandler().findUserByName(username) == null)
{
- uiListUsers.search(new Query());
+ UIApplication uiApplication = event.getRequestContext().getUIApplication();
+ uiApplication.addMessage(new ApplicationMessage("UIListUsers.msg.user-is-deleted",
+ null, ApplicationMessage.WARNING));
return;
}
uiListUsers.setRendered(false);
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIOrganizationPortlet.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIOrganizationPortlet.java 2012-02-13 21:48:05 UTC (rev 8424)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIOrganizationPortlet.java 2012-02-14 13:18:59 UTC (rev 8425)
@@ -70,8 +70,10 @@
{
public void execute(Event<UIOrganizationPortlet> event) throws Exception
{
- UIListUsers uiListUsers = event.getSource().findFirstComponentOfType(UIListUsers.class);
- uiListUsers.search(new Query());
+ //Actually we don't need to do anything here
+ //UIListUsers will have the lasteast data in it's processRender method
+// UIListUsers uiListUsers = event.getSource().findFirstComponentOfType(UIListUsers.class);
+// uiListUsers.search(new Query());
}
}
}
\ No newline at end of file
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java 2012-02-13 21:48:05 UTC (rev 8424)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java 2012-02-14 13:18:59 UTC (rev 8425)
@@ -143,12 +143,9 @@
Util.getPortalRequestContext().ignoreAJAXUpdateOnPortlets(true);
}
- UIUserManagement userManagement = uiUserInfo.getParent();
- UIListUsers listUser = userManagement.getChild(UIListUsers.class);
UIAccountEditInputSet accountInput = uiUserInfo.getChild(UIAccountEditInputSet.class);
UIUserProfileInputSet userProfile = uiUserInfo.getChild(UIUserProfileInputSet.class);
uiUserInfo.setRenderSibling(UIListUsers.class);
- listUser.search(new Query());
accountInput.reset();
userProfile.reset();
event.getRequestContext().setProcessRender(true);
@@ -160,12 +157,9 @@
public void execute(Event<UIUserInfo> event) throws Exception
{
UIUserInfo userInfo = event.getSource();
- UIUserManagement userManagement = userInfo.getParent();
- UIListUsers listUser = userManagement.getChild(UIListUsers.class);
UIAccountEditInputSet accountInput = userInfo.getChild(UIAccountEditInputSet.class);
UIUserProfileInputSet userProfile = userInfo.getChild(UIUserProfileInputSet.class);
userInfo.setRenderSibling(UIListUsers.class);
- listUser.search(new Query());
accountInput.reset();
userProfile.reset();
event.getRequestContext().setProcessRender(true);
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/OrganizationPortlet_en.properties
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/OrganizationPortlet_en.properties 2012-02-13 21:48:05 UTC (rev 8424)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/OrganizationPortlet_en.properties 2012-02-14 13:18:59 UTC (rev 8425)
@@ -79,7 +79,8 @@
UIListUsers.label.option.lastName=#{word.lastName}
UIListUsers.label.option.email=#{word.email}
UIListUsers.msg.DeleteSuperUser={0} is Super User, it can not be deleted
-UIListUsers.deleteUser=Are you sure you want to delete {0} user?
+UIListUsers.deleteUser=Are you sure you want to delete {0} user?
+UIListUsers.msg.user-is-deleted=This user may be deleted.
UIListMembershipType.deleteMemberShip=Are you sure you want to delete this membership?
Modified: epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml 2012-02-13 21:48:05 UTC (rev 8424)
+++ epp/portal/branches/EPP_5_2_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml 2012-02-14 13:18:59 UTC (rev 8425)
@@ -80,6 +80,9 @@
<short-title>Account Portlet</short-title>
<keywords>Administration</keywords>
</portlet-info>
+ <supported-publishing-event>
+ <name>NewAccountAdded</name>
+ </supported-publishing-event>
</portlet>
<portlet>
12 years, 10 months
gatein SVN: r8424 - portal/trunk/docs/reference-guide/en-US/modules/AuthenticationAndIdentity.
by do-not-reply@jboss.org
Author: mposolda
Date: 2012-02-13 16:48:05 -0500 (Mon, 13 Feb 2012)
New Revision: 8424
Modified:
portal/trunk/docs/reference-guide/en-US/modules/AuthenticationAndIdentity/SSO.xml
Log:
GTNPORTAL-2352 Added needed section for SSO integration with GateIn Tomcat bundle
Modified: portal/trunk/docs/reference-guide/en-US/modules/AuthenticationAndIdentity/SSO.xml
===================================================================
--- portal/trunk/docs/reference-guide/en-US/modules/AuthenticationAndIdentity/SSO.xml 2012-02-13 21:43:33 UTC (rev 8423)
+++ portal/trunk/docs/reference-guide/en-US/modules/AuthenticationAndIdentity/SSO.xml 2012-02-13 21:48:05 UTC (rev 8424)
@@ -545,6 +545,22 @@
</itemizedlist>
</step>
<step>
+ <para>
+ In Tomcat, edit <filename>GATEIN_HOME/webapps/portal.war/META-INF/context.xml</filename> and add
+ <literal>ServletAccessValve</literal> into configuration as first sub-element of <literal>Context</literal>:
+ </para>
+ <programlisting>
+<![CDATA[
+<Context path='/portal' docBase='portal' ... >
+
+ ]]><emphasis role="bold"><![CDATA[<Valve className='org.gatein.sso.agent.tomcat.ServletAccessValve' />]]></emphasis><![CDATA[
+
+ ...
+</Context>
+]]>
+ </programlisting>
+ </step>
+ <step>
<para>
The installation can be tested at this point:
</para>
@@ -821,7 +837,7 @@
In Tomcat, edit <filename>GATEIN_HOME/conf/jaas.conf</filename> and uncomment this section:
</para>
<programlisting>org.gatein.sso.agent.login.SSOLoginModule required;
-org.exoplatform.services.security.j2ee.TomcatLoginModule requiredtm
+org.exoplatform.services.security.j2ee.TomcatLoginModule required
portalContainerName=portal
realmName=gatein-domain;
</programlisting>
@@ -829,6 +845,22 @@
</itemizedlist>
</step>
<step>
+ <para>
+ In Tomcat, edit <filename>GATEIN_HOME/webapps/portal.war/META-INF/context.xml</filename> and add
+ <literal>ServletAccessValve</literal> into configuration as first sub-element of <literal>Context</literal>:
+ </para>
+ <programlisting>
+ <![CDATA[
+<Context path='/portal' docBase='portal' ... >
+
+ ]]><emphasis role="bold"><![CDATA[<Valve className='org.gatein.sso.agent.tomcat.ServletAccessValve' />]]></emphasis><![CDATA[
+
+ ...
+</Context>
+]]>
+ </programlisting>
+ </step>
+ <step>
<para>
The installation can be tested at this point.
</para>
@@ -1129,7 +1161,7 @@
<itemizedlist>
<listitem>
<para>
- In JBoss AS, edit gatein.ear/META-INF/gatein-jboss-beans.xml and uncomment this section
+ In JBoss AS, edit <filename>gatein.ear/META-INF/gatein-jboss-beans.xml</filename> and uncomment this section
</para>
<programlisting>
<![CDATA[
@@ -1149,7 +1181,7 @@
</listitem>
<listitem>
<para>
- If you are running &PRODUCT; in Tomcat, edit $GATEIN_HOME/conf/jaas.conf, uncomment on this section and comment other parts:
+ If you are running &PRODUCT; in Tomcat, edit <filename>GATEIN_HOME/conf/jaas.conf</filename>, uncomment on this section and comment other parts:
</para>
<programlisting>org.gatein.sso.agent.login.SSOLoginModule required;
org.exoplatform.services.security.j2ee.TomcatLoginModule required
@@ -1159,6 +1191,24 @@
</listitem>
</itemizedlist>
+ </step>
+ <step>
+ <para>
+ In Tomcat, edit <filename>GATEIN_HOME/webapps/portal.war/META-INF/context.xml</filename> and add
+ <literal>ServletAccessValve</literal> into configuration as first sub-element of <literal>Context</literal>:
+ </para>
+ <programlisting>
+ <![CDATA[
+<Context path='/portal' docBase='portal' ... >
+
+ ]]><emphasis role="bold"><![CDATA[<Valve className='org.gatein.sso.agent.tomcat.ServletAccessValve' />]]></emphasis><![CDATA[
+
+ ...
+</Context>
+]]>
+ </programlisting>
+ </step>
+ <step>
<para>
At this point the installation can be tested:
</para>
12 years, 10 months
gatein SVN: r8423 - components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat.
by do-not-reply@jboss.org
Author: mposolda
Date: 2012-02-13 16:43:33 -0500 (Mon, 13 Feb 2012)
New Revision: 8423
Modified:
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccess.java
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccessValve.java
Log:
GTNSSO-5 Adding copyright
Modified: components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccess.java
===================================================================
--- components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccess.java 2012-02-13 21:00:56 UTC (rev 8422)
+++ components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccess.java 2012-02-13 21:43:33 UTC (rev 8423)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, 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.sso.agent.tomcat;
import javax.servlet.http.HttpServletRequest;
Modified: components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccessValve.java
===================================================================
--- components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccessValve.java 2012-02-13 21:00:56 UTC (rev 8422)
+++ components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccessValve.java 2012-02-13 21:43:33 UTC (rev 8423)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2012, 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.sso.agent.tomcat;
import org.apache.catalina.connector.Request;
@@ -10,8 +32,8 @@
import java.io.IOException;
/**
- * Valve for adding HttpServletRequest and HttpServletResponse into threadLocal so that it can be accessed from
- * Login Modules during authentication.
+ * Valve for adding {@link javax.servlet.http.HttpServletRequest} and {@link javax.servlet.http.HttpServletResponse} into threadLocal
+ * so that it can be accessed from Login Modules during authentication.
*
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
12 years, 10 months
gatein SVN: r8421 - in components/sso/trunk/agent/src/main/java/org/gatein/sso/agent: login and 1 other directories.
by do-not-reply@jboss.org
Author: mposolda
Date: 2012-02-13 09:25:23 -0500 (Mon, 13 Feb 2012)
New Revision: 8421
Added:
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccess.java
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccessValve.java
Modified:
components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/login/SSOLoginModule.java
Log:
GTNSSO-5 SSO is now working with GateIn on Tomcat
Modified: components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/login/SSOLoginModule.java
===================================================================
--- components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/login/SSOLoginModule.java 2012-02-13 12:10:57 UTC (rev 8420)
+++ components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/login/SSOLoginModule.java 2012-02-13 14:25:23 UTC (rev 8421)
@@ -35,14 +35,14 @@
import org.exoplatform.services.security.Identity;
import org.exoplatform.services.security.UsernameCredential;
import org.exoplatform.services.security.jaas.AbstractLoginModule;
+import org.gatein.sso.agent.tomcat.ServletAccess;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
public final class SSOLoginModule extends AbstractLoginModule
{
- private static final Log log = ExoLogger.getLogger(SSOLoginModule.class
- .getName());
+ private static final Log log = ExoLogger.getLogger(SSOLoginModule.class);
/** JACC get context method. */
private static Method getContextMethod;
@@ -75,26 +75,22 @@
String password = new String(((PasswordCallback) callbacks[1])
.getPassword());
-
- //
- // For clustered config check credentials stored and propagated in session. This won't work in tomcat because
- // of lack of JACC PolicyContext so the code must be a bit defensive
+
+ // Check credentials stored and propagated in session.
String username = null;
- if (getContextMethod != null && password.startsWith("wci-ticket"))
- {
- HttpServletRequest request;
- try
- {
- request = (HttpServletRequest)getContextMethod.invoke(null, "javax.servlet.http.HttpServletRequest");
- username = (String)request.getSession().getAttribute("username");
- }
- catch(Throwable e)
- {
- log.error(this,e);
- log.error("LoginModule error. Turn off session credentials checking with proper configuration option of " +
- "LoginModule set to false");
- }
- }
+ HttpServletRequest request = getCurrentHttpServletRequest();
+
+ if (request == null)
+ {
+ log.debug("HttpServletRequest is null. SSOLoginModule will be ignored.");
+ return false;
+ }
+
+ if (password.startsWith("wci-ticket"))
+ {
+ username = (String)request.getSession().getAttribute("username");
+ }
+
if (username == null)
{
@@ -145,8 +141,40 @@
}
@Override
- protected Log getLogger()
+ protected Log getLogger()
{
return log;
}
+
+ protected HttpServletRequest getCurrentHttpServletRequest()
+ {
+ HttpServletRequest request = null;
+
+ // JBoss way
+ if (getContextMethod != null)
+ {
+ try
+ {
+ request = (HttpServletRequest)getContextMethod.invoke(null, "javax.servlet.http.HttpServletRequest");
+ }
+ catch(Throwable e)
+ {
+ log.error("LoginModule error. Turn off session credentials checking with proper configuration option of " +
+ "LoginModule set to false");
+ log.error(this, e);
+ }
+ }
+ // Tomcat way (Assumed that ServletAccessValve has been configured in context.xml)
+ else
+ {
+ request = ServletAccess.getRequest();
+ }
+
+ if (log.isTraceEnabled())
+ {
+ log.trace("Returning HttpServletRequest " + request);
+ }
+
+ return request;
+ }
}
\ No newline at end of file
Added: components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccess.java
===================================================================
--- components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccess.java (rev 0)
+++ components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccess.java 2012-02-13 14:25:23 UTC (rev 8421)
@@ -0,0 +1,57 @@
+package org.gatein.sso.agent.tomcat;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+public class ServletAccess
+{
+
+ private static ThreadLocal<Holder> holderThreadLocal = new ThreadLocal<Holder>();
+
+ public static void setRequestAndResponse(HttpServletRequest request, HttpServletResponse response)
+ {
+ holderThreadLocal.set(new Holder(request, response));
+ }
+
+ public static void resetRequestAndResponse()
+ {
+ holderThreadLocal.set(null);
+ }
+
+ public static HttpServletRequest getRequest()
+ {
+ Holder holder = holderThreadLocal.get();
+ if (holder != null)
+ {
+ return holder.servletRequest;
+ }
+
+ return null;
+ }
+
+ public static HttpServletResponse getResponse()
+ {
+ Holder holder = holderThreadLocal.get();
+ if (holder != null)
+ {
+ return holder.servletResponse;
+ }
+
+ return null;
+ }
+
+ private static class Holder
+ {
+ private final HttpServletRequest servletRequest;
+ private final HttpServletResponse servletResponse;
+
+ private Holder(HttpServletRequest servletRequest, HttpServletResponse servletResponse)
+ {
+ this.servletRequest = servletRequest;
+ this.servletResponse = servletResponse;
+ }
+ }
+}
Added: components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccessValve.java
===================================================================
--- components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccessValve.java (rev 0)
+++ components/sso/trunk/agent/src/main/java/org/gatein/sso/agent/tomcat/ServletAccessValve.java 2012-02-13 14:25:23 UTC (rev 8421)
@@ -0,0 +1,45 @@
+package org.gatein.sso.agent.tomcat;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.valves.ValveBase;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
+
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+/**
+ * Valve for adding HttpServletRequest and HttpServletResponse into threadLocal so that it can be accessed from
+ * Login Modules during authentication.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+public class ServletAccessValve extends ValveBase
+{
+ private static final Logger log = LoggerFactory.getLogger(ServletAccessValve.class);
+
+ @Override
+ public void invoke(Request request, Response response) throws IOException, ServletException
+ {
+ ServletAccess.setRequestAndResponse(request, response);
+ if (log.isTraceEnabled())
+ {
+ log.trace("Current HttpServletRequest and HttpServletResponse added to ThreadLocal.");
+ }
+
+ try
+ {
+ getNext().invoke(request, response);
+ }
+ finally
+ {
+ ServletAccess.resetRequestAndResponse();
+ if (log.isTraceEnabled())
+ {
+ log.trace("Cleaning ThreadLocal");
+ }
+ }
+ }
+
+}
12 years, 10 months
gatein SVN: r8420 - in portal/trunk: examples/portlets/resourceserving and 11 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2012-02-13 07:10:57 -0500 (Mon, 13 Feb 2012)
New Revision: 8420
Added:
portal/trunk/examples/portlets/resourceserving/
portal/trunk/examples/portlets/resourceserving/pom.xml
portal/trunk/examples/portlets/resourceserving/src/
portal/trunk/examples/portlets/resourceserving/src/main/
portal/trunk/examples/portlets/resourceserving/src/main/java/
portal/trunk/examples/portlets/resourceserving/src/main/java/org/
portal/trunk/examples/portlets/resourceserving/src/main/java/org/gatein/
portal/trunk/examples/portlets/resourceserving/src/main/java/org/gatein/portal/
portal/trunk/examples/portlets/resourceserving/src/main/java/org/gatein/portal/samples/
portal/trunk/examples/portlets/resourceserving/src/main/java/org/gatein/portal/samples/resourceserving/
portal/trunk/examples/portlets/resourceserving/src/main/java/org/gatein/portal/samples/resourceserving/ResourceServingDemoPortlet.java
portal/trunk/examples/portlets/resourceserving/src/main/webapp/
portal/trunk/examples/portlets/resourceserving/src/main/webapp/WEB-INF/
portal/trunk/examples/portlets/resourceserving/src/main/webapp/WEB-INF/portlet.xml
portal/trunk/examples/portlets/resourceserving/src/main/webapp/WEB-INF/web.xml
Modified:
portal/trunk/examples/portlets/pom.xml
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
Log:
GTNPORTAL-2351 : Portlet resource serving does not handle status code other than 200 OK
Modified: portal/trunk/examples/portlets/pom.xml
===================================================================
--- portal/trunk/examples/portlets/pom.xml 2012-02-10 14:43:12 UTC (rev 8419)
+++ portal/trunk/examples/portlets/pom.xml 2012-02-13 12:10:57 UTC (rev 8420)
@@ -20,6 +20,7 @@
<module>jsphellouser</module>
<module>simplesthelloworld</module>
<module>struts-jpetstore</module>
+ <module>resourceserving</module>
</modules>
</project>
Property changes on: portal/trunk/examples/portlets/resourceserving
___________________________________________________________________
Added: svn:ignore
+ .idea
*.iml
target
Added: portal/trunk/examples/portlets/resourceserving/pom.xml
===================================================================
--- portal/trunk/examples/portlets/resourceserving/pom.xml (rev 0)
+++ portal/trunk/examples/portlets/resourceserving/pom.xml 2012-02-13 12:10:57 UTC (rev 8420)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (C) 2011 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.
+ -->
+
+<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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <!--
+ the parent isn't required, you can drop it if you add a groupId
+ and version
+ -->
+ <parent>
+ <groupId>org.gatein.portal.examples.portlets</groupId>
+ <artifactId>parent</artifactId>
+ <version>3.2.0-CR02-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>resource-serving</artifactId>
+ <packaging>war</packaging>
+ <name>GateIn Portal Examples - Resource Serving Portlet</name>
+ <description />
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: portal/trunk/examples/portlets/resourceserving/src/main/java/org/gatein/portal/samples/resourceserving/ResourceServingDemoPortlet.java
===================================================================
--- portal/trunk/examples/portlets/resourceserving/src/main/java/org/gatein/portal/samples/resourceserving/ResourceServingDemoPortlet.java (rev 0)
+++ portal/trunk/examples/portlets/resourceserving/src/main/java/org/gatein/portal/samples/resourceserving/ResourceServingDemoPortlet.java 2012-02-13 12:10:57 UTC (rev 8420)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2011 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.gatein.portal.samples.resourceserving;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.portlet.ResourceURL;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
+ */
+public class ResourceServingDemoPortlet extends GenericPortlet
+{
+
+ /** . */
+ private static final String HTML = "html", EXCEPTION = "exception", NOT_FOUND = "404", NO_OP = "noop";
+
+ /** . */
+ private static String[] msg = {"HTML", "Exception", "Not Found", "No op"};
+
+ /** . */
+ private static String[] behaviors = {HTML, EXCEPTION, NOT_FOUND, NO_OP};
+
+ @Override
+ protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
+ ResourceURL url = response.createResourceURL();
+ response.setContentType("text/html");
+ PrintWriter writer = response.getWriter();
+ writer.print("<p>This portlet shows how a resource serving portlet can modify the response</p>");
+ writer.print("<ul>");
+ for (int i = 0;i < msg.length;i++)
+ {
+ url.setParameter("behavior", behaviors[i]);
+ writer.print("<li><a href='" + url + "'>" + msg[i] + "</a></li>");
+ }
+ writer.print("</ul>");
+ }
+
+ @Override
+ public void serveResource(ResourceRequest request, ResourceResponse response) throws PortletException, IOException
+ {
+ String behavior = request.getParameter("behavior");
+ if (HTML.equals(behavior))
+ {
+ response.setContentType("text/html");
+ PrintWriter writer = response.getWriter();
+ writer.print("<html><body>Hello World</body><html>");
+ }
+ else if (EXCEPTION.equals(behavior))
+ {
+ throw new PortletException("Don't freak out");
+ }
+ else if (NOT_FOUND.equals(behavior))
+ {
+ response.setProperty(ResourceResponse.HTTP_STATUS_CODE, "404");
+ PrintWriter writer = response.getWriter();
+ writer.print("<html><body>Not Found</body><html>");
+ }
+ else
+ {
+ // Do nothing
+ }
+ }
+}
Added: portal/trunk/examples/portlets/resourceserving/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- portal/trunk/examples/portlets/resourceserving/src/main/webapp/WEB-INF/portlet.xml (rev 0)
+++ portal/trunk/examples/portlets/resourceserving/src/main/webapp/WEB-INF/portlet.xml 2012-02-13 12:10:57 UTC (rev 8420)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright (C) 2011 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.
+ -->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+version="2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd
+ http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
+ <portlet>
+ <description xml:lang="EN">A portlet that demonstrate resource serving basics</description>
+ <portlet-name>ResourceServingDemoPortlet</portlet-name>
+ <display-name xml:lang="EN">Resource Serving Demo</display-name>
+ <portlet-class>org.gatein.portal.samples.resourceserving.ResourceServingDemoPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title>Resource Serving Demo Portlet</title>
+ <keywords>Sample</keywords>
+ </portlet-info>
+ </portlet>
+</portlet-app>
\ No newline at end of file
Added: portal/trunk/examples/portlets/resourceserving/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/trunk/examples/portlets/resourceserving/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ portal/trunk/examples/portlets/resourceserving/src/main/webapp/WEB-INF/web.xml 2012-02-13 12:10:57 UTC (rev 8420)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!--
+ ~ Copyright (C) 2011 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.
+ -->
+
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.5">
+</web-app>
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2012-02-10 14:43:12 UTC (rev 8419)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2012-02-13 12:10:57 UTC (rev 8420)
@@ -33,11 +33,13 @@
import java.util.Map;
import javax.portlet.PortletMode;
+import javax.portlet.ResourceResponse;
import javax.portlet.WindowState;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
+import org.exoplatform.commons.utils.Safe;
import org.exoplatform.portal.Constants;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.webui.page.UIPage;
@@ -68,6 +70,7 @@
import org.gatein.pc.api.invocation.response.ErrorResponse;
import org.gatein.pc.api.invocation.response.HTTPRedirectionResponse;
import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
+import org.gatein.pc.api.invocation.response.ResponseProperties;
import org.gatein.pc.api.invocation.response.SecurityErrorResponse;
import org.gatein.pc.api.invocation.response.SecurityResponse;
import org.gatein.pc.api.invocation.response.UpdateNavigationalStateResponse;
@@ -365,11 +368,13 @@
log.trace("Serve Resource for portlet: " + uiPortlet.getPortletContext());
String resourceId = null;
+ //
+ PortalRequestContext context = (PortalRequestContext)event.getRequestContext();
+ HttpServletResponse response = context.getResponse();
+
+ //
try
{
- PortalRequestContext context = (PortalRequestContext)event.getRequestContext();
- HttpServletResponse response = context.getResponse();
-
//Set the NavigationalState
String navState = context.getRequestParameter(ExoPortletInvocationContext.NAVIGATIONAL_STATE_PARAM_NAME);
if (navState != null)
@@ -386,90 +391,120 @@
//
PortletInvocationResponse portletResponse = uiPortlet.invoke(resourceInvocation);
- // todo: handle the error response better than this.
+ //
+ int statusCode;
+ MultiValuedPropertyMap<String> transportHeaders;
+ String contentType;
+ Object content;
if (!(portletResponse instanceof ContentResponse))
{
if (portletResponse instanceof ErrorResponse)
{
ErrorResponse errorResponse = (ErrorResponse)portletResponse;
- if (errorResponse.getCause() != null)
+ Throwable cause = errorResponse.getCause();
+ if (cause != null)
{
- throw (Exception)errorResponse.getCause();
+ log.trace("Got error response from portlet", cause);
}
else if (errorResponse.getMessage() != null)
{
- throw new Exception("Received an error response with message : " + errorResponse.getMessage());
+ log.trace("Got error response from portlet:" + errorResponse.getMessage());
}
else
{
- throw new Exception("Received an error response.");
+ log.trace("Got error response from portlet");
}
-
}
else
{
- throw new Exception("Unexpected response type [" + portletResponse
- + "]. Expected a ContentResponse or an ErrorResponse.");
+ log.trace("Unexpected response type [" + portletResponse + "]. Expected a ContentResponse or an ErrorResponse.");
}
+ statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+ contentType = null;
+ transportHeaders = null;
+ content = null;
}
-
- ContentResponse piResponse = (ContentResponse)portletResponse;
-
- //
- //Manage headers
- if (piResponse.getProperties() != null && piResponse.getProperties().getTransportHeaders() != null)
+ else
{
- MultiValuedPropertyMap<String> transportHeaders = piResponse.getProperties().getTransportHeaders();
- Map<String, String> headers = new HashMap<String, String>();
+ //
+ ContentResponse piResponse = (ContentResponse)portletResponse;
+ ResponseProperties properties = piResponse.getProperties();
+ transportHeaders = properties != null ? properties.getTransportHeaders() : null;
- for (String key : transportHeaders.keySet())
+ // Look at status code if there is one and honour it
+ String status = transportHeaders != null ? transportHeaders.getValue(ResourceResponse.HTTP_STATUS_CODE) : null;
+ if (status != null)
{
- for (String value : transportHeaders.getValues(key))
+ try
{
- headers.put(key, value);
+ statusCode = Integer.parseInt(status);
}
+ catch (NumberFormatException e)
+ {
+ statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+ }
}
- context.setHeaders(headers);
+ else
+ {
+ statusCode = HttpServletResponse.SC_OK;
+ }
+
+ //
+ contentType = piResponse.getContentType();
+
+ //
+ log.trace("Try to get a resource of type: " + contentType + " for the portlet: " + uiPortlet.getPortletContext());
+ if (piResponse.getChars() != null)
+ {
+ content = piResponse.getChars();
+ }
+ else if (piResponse.getBytes() != null)
+ {
+ content = piResponse.getBytes();
+ }
+ else
+ {
+ content = null;
+ }
}
- String contentType = piResponse.getContentType();
+ //
+ response.setStatus(statusCode);
- if (contentType == null)
+ // Set content type if any
+ if (contentType != null)
{
- return;
+ response.setContentType(contentType);
}
- log.trace("Try to get a resource of type: " + contentType + " for the portlet: "
- + uiPortlet.getPortletContext());
- response.setContentType(contentType);
- if (piResponse.getChars() != null)
+ // Send headers if any
+ if (transportHeaders != null)
{
- OutputStream stream = response.getOutputStream();
- stream.write(piResponse.getChars().getBytes(response.getCharacterEncoding()));
+ sendHeaders(transportHeaders, context);
}
- else
+
+ // Send body if any
+ if (content instanceof String)
{
- if (piResponse.getBytes() != null)
+ context.getWriter().write((String)content);
+ }
+ else if (content instanceof byte[])
+ {
+ byte[] bytes = (byte[]) content;
+ response.setContentLength(bytes.length);
+ OutputStream stream = response.getOutputStream();
+ try
{
- OutputStream stream = response.getOutputStream();
- stream.write(piResponse.getBytes());
+ stream.write(bytes);
}
- else
+ finally
{
- if (piResponse.getChars() != null)
- {
- log.error("Received a content type of " + contentType + " but it contains no bytes of data. Chars were unexpectantly returned instead : " + piResponse.getChars());
- }
- else
- {
- log.error("Received a content type of " + contentType + " but it contains no bytes of data.");
- }
+ Safe.close(stream);
}
-
-
}
- context.getResponse().flushBuffer();
+ //
+ response.flushBuffer();
}
catch (Exception e)
{
@@ -483,6 +518,29 @@
event.getRequestContext().setResponseComplete(true);
}
}
+
+ /**
+ * Send any header to the client
+ *
+ * @param headers the headers
+ * @param context the context
+ * @throws IOException any io exception
+ */
+ private void sendHeaders(MultiValuedPropertyMap<String> headers, PortalRequestContext context) throws IOException
+ {
+ Map<String, String> map = new HashMap<String, String>();
+ for (String key : headers.keySet())
+ {
+ for (String value : headers.getValues(key))
+ {
+ map.put(key, value);
+ }
+ }
+
+ // We need to remove it if it there
+ map.remove(ResourceResponse.HTTP_STATUS_CODE);
+ context.setHeaders(map);
+ }
}
/**
12 years, 10 months
gatein SVN: r8419 - in portal/trunk: docs/reference-guide/en-US/modules/Configuration and 1 other directories.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2012-02-10 09:43:12 -0500 (Fri, 10 Feb 2012)
New Revision: 8419
Added:
portal/trunk/docs/reference-guide/en-US/modules/Configuration/ValidatorConfiguration.xml
Modified:
portal/trunk/docs/reference-guide/en-US/modules/Configuration.xml
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/validator/UserConfigurableValidator.java
Log:
- GTNPORTAL-1673: Added documentation.
Added: portal/trunk/docs/reference-guide/en-US/modules/Configuration/ValidatorConfiguration.xml
===================================================================
--- portal/trunk/docs/reference-guide/en-US/modules/Configuration/ValidatorConfiguration.xml (rev 0)
+++ portal/trunk/docs/reference-guide/en-US/modules/Configuration/ValidatorConfiguration.xml 2012-02-10 14:43:12 UTC (rev 8419)
@@ -0,0 +1,164 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+ <!ENTITY % BOOK_ENTITIES SYSTEM "../../Reference_Guide.ent">
+ %BOOK_ENTITIES;
+ ]>
+<section id="sect-Reference_Guide-Validator_Configuration">
+ <title>Configuration of custom data validators</title>
+
+ <section id="sect-Reference_Guide-Validator_Configuration-Overview">
+ <title>Overview</title>
+
+ <para>&PRODUCT; includes a user-configurable validator that can be applied to
+ input fields of different bundled portlets. Currently, this validator is only used to configure the
+ validation of user name formats in the user account, user registration and group membership portlets, though
+ the architecture allows for configurable validation to be used in different contexts if needed.
+ </para>
+ <para>
+ The validator can be configured via properties in the
+ <filename>configuration.properties</filename>
+ file found in the &PRODUCT_NAME; configuration directory. By default, this directory is found at
+ <filename>$JBOSS_HOME/server/default/conf/gatein/</filename>
+ if you are using JBoss Application Server or
+ <filename>$TOMCAT_HOME/gatein/conf/</filename>
+ if you are using Tomcat.
+ </para>
+
+ <para>
+ The architecture supports several configurations that can be activated and associated to specific instances of
+ the user-configurable validator when they are created and assigned to fields in portlets. We will only concern
+ ourselves with the currently supported use cases, which are creation/modification of a user name during
+ registration/modification of a user and group membership assignments.
+ </para>
+
+ </section>
+
+ <section id="sect-Reference_Guide-Validator_Configuration-Configuration">
+ <title>Validator configuration</title>
+
+ <para>
+ A configuration is created by adding an entry in
+ <filename>configuration.properties</filename>
+ using the
+ <literal>gatein.validators.</literal>
+ prefix followed by the name of the configuration, a period '.' and the name of the validation aspect you want
+ to configure. The user-configurable validator currently supports four different aspects per configuration, as
+ follows, where
+ <literal>{configuration}</literal>
+ refers to the configuration name:
+ <itemizedlist>
+ <listitem>
+ <para><literal>gatein.validators.{configuration}.length.min</literal>: minimal length of the validated
+ field
+ </para>
+ </listitem>
+ <listitem>
+ <para><literal>gatein.validators.{configuration}.length.max</literal>: maximal length of the validated
+ field
+ </para>
+ </listitem>
+ <listitem>
+ <para><literal>gatein.validators.{configuration}.regexp</literal>: regular expression to which values of
+ the validated field must conform
+ </para>
+ </listitem>
+ <listitem>
+ <para><literal>gatein.validators.{configuration}.format.message</literal>: information message to display
+ when the value of the validated field doesn't conform to the
+ specified regular expression
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+
+ <para>
+ Only two configurations are currently supported by &PRODUCT_NAME;, one, named
+ <literal>username</literal>, to configure validation of user names when they are created/modified and the
+ other, named
+ <literal>groupmembership</literal>,
+ to configure validation of user names in the context of group memberships.
+ </para>
+
+ <para>
+ For example, if you want to make sure that your users use an email address as their user name, you could use
+ the following configuration:
+ </para>
+ <example>
+ <para>
+ <programlisting>
+ # validators
+ gatein.validators.username.regexp=^[A-Za-z0-9._%+-]+(a)[A-Za-z0-9.-]+\.[A-za-z]{2,4}$
+ gatein.validators.username.format.message=Username must be a valid email address.
+ </programlisting>
+ </para>
+ </example>
+
+ <note>
+ <para>
+ If you don't change the configuration of the validator, user names will be validated as follows:
+ <itemizedlist>
+ <listitem>
+ <para>Length must be between 3 and 30 characters.</para>
+ </listitem>
+ <listitem>
+ <para>Only lowercase letters, numbers, undescores (_) and period (.) can be used.</para>
+ </listitem>
+ <listitem>
+ <para>No consecutive undescores (_) or period (.) can be used.</para>
+ </listitem>
+ <listitem>
+ <para>Must start with a letter.</para>
+ </listitem>
+ <listitem>
+ <para>Must end with a letter or number.</para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </note>
+ </section>
+
+ <section id="sect-Reference_Guide-Validator_Developer-Configuration">
+ <title>Developer information</title>
+
+ <para>
+ The user-configurable validator is implemented by the
+ <literal>org.exoplatform.webui.form.validator.UserConfigurableValidator</literal>
+ class. Please refer to its documentation for more details.
+ </para>
+
+ <para>
+ To use a specific validator configuration to validate a given field value, add the validator to the field as
+ follows, where
+ <literal>configurationName</literal>
+ is a
+ <literal>String</literal>
+ representing the name of the configuration to use:
+ <programlisting>
+ addValidator(UserConfigurableValidator.class, configurationName))
+ </programlisting>
+ </para>
+ <para>
+ The validator instance can then be configured by adding the relevant information in <filename>configuration.properties</filename>, for example:
+ <programlisting>
+ # validators
+ gatein.validators.configurationName.length.min=5
+ gatein.validators.configurationName.length.max=10
+ gatein.validators.configurationName.regexp=^u\d{4,9}$
+ gatein.validators.configurationName.format.message=Username must start with ''u'' and be followed by 4 to 9 digits.
+ </programlisting>
+ </para>
+
+ <para>
+ Alternatively, a resource key can also be passed to the
+ <literal>addValidator</literal>
+ method to specify which localized message should be used in case a validation error occurs, for example as
+ follows:
+ <literal>configurationName</literal>
+ <programlisting>
+ addValidator(UserConfigurableValidator.class, UserConfigurableValidator.GROUPMEMBERSHIP,
+ UserConfigurableValidator.GROUP_MEMBERSHIP_LOCALIZATION_KEY);
+ </programlisting>
+ </para>
+ </section>
+</section>
Modified: portal/trunk/docs/reference-guide/en-US/modules/Configuration.xml
===================================================================
--- portal/trunk/docs/reference-guide/en-US/modules/Configuration.xml 2012-02-09 23:49:41 UTC (rev 8418)
+++ portal/trunk/docs/reference-guide/en-US/modules/Configuration.xml 2012-02-10 14:43:12 UTC (rev 8419)
@@ -8,4 +8,5 @@
<xi:include href="Configuration/DatabaseConfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Configuration/EMailServiceConfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="Configuration/HTTPSConfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="Configuration/ValidatorConfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</chapter>
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/validator/UserConfigurableValidator.java
===================================================================
--- portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/validator/UserConfigurableValidator.java 2012-02-09 23:49:41 UTC (rev 8418)
+++ portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/validator/UserConfigurableValidator.java 2012-02-10 14:43:12 UTC (rev 8419)
@@ -40,7 +40,7 @@
/**
* A user-configurable validator. Several aspects of this validator can be configured via properties in the
- * configuration.properties file found in the GateIn configuration directory (${gatein.conf.dir}. The validator
+ * configuration.properties file found in the GateIn configuration directory (${gatein.conf.dir}). The validator
* supports several configurations that can be activated when a validator instance is created by passing it the name of
* the configuration to be activated. A configuration is created by adding an entry in configuration.properties using
* the {@link #KEY_PREFIX} prefix followed by the name of the configuration, a period '.' and the name of the
12 years, 10 months
gatein SVN: r8418 - epp/docs/branches/5.2/Installation_Guide/en-US.
by do-not-reply@jboss.org
Author: smumford
Date: 2012-02-09 18:49:41 -0500 (Thu, 09 Feb 2012)
New Revision: 8418
Modified:
epp/docs/branches/5.2/Installation_Guide/en-US/Post_Installation.xml
Log:
Corrected java command in 'Set suckerPassword for JBoss Messaging'
Modified: epp/docs/branches/5.2/Installation_Guide/en-US/Post_Installation.xml
===================================================================
--- epp/docs/branches/5.2/Installation_Guide/en-US/Post_Installation.xml 2012-02-09 19:14:27 UTC (rev 8417)
+++ epp/docs/branches/5.2/Installation_Guide/en-US/Post_Installation.xml 2012-02-09 23:49:41 UTC (rev 8418)
@@ -120,7 +120,7 @@
<para>
Insert the same password you stored in the <filename>messaging-jboss-beans.xml</filename> file into the following command:
</para>
-<programlisting><replaceable>JAVA_HOME</replaceable>/bin/java -cp <replaceable>JBOSS_HOME</replaceable>/client/jboss-messaging-client.jar org.jboss.messaging.util.SecurityUtil <replaceable>PLAIN_TEXT_PASSWORD</replaceable>
+<programlisting><replaceable>/path/to/java/executable</replaceable> -cp <replaceable>JBOSS_HOME</replaceable>/client/jboss-messaging-client.jar org.jboss.messaging.util.SecurityUtil <replaceable>PLAIN_TEXT_PASSWORD</replaceable>
</programlisting>
</step>
<step>
12 years, 10 months