JBoss Portal SVN: r5808 - trunk/core/src/main/org/jboss/portal/core/aspects/controller
by portal-commits@lists.jboss.org
Author: roy.russo(a)jboss.com
Date: 2006-12-12 13:40:49 -0500 (Tue, 12 Dec 2006)
New Revision: 5808
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
Log:
JBPORTAL-1157 - Create links to dashboard configurator
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2006-12-12 17:22:50 UTC (rev 5807)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2006-12-12 18:40:49 UTC (rev 5808)
@@ -27,18 +27,20 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerInterceptor;
-import org.jboss.portal.core.model.portal.command.RenderPageCommand;
import org.jboss.portal.core.controller.command.SignOutCommand;
-import org.jboss.portal.core.model.portal.command.ViewDashboardCommand;
import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
-import org.jboss.portal.core.model.portal.PortalContainer;
+import org.jboss.portal.core.model.instance.command.InvokePortletInstanceRenderCommand;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalContainer;
import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.command.RenderPageCommand;
+import org.jboss.portal.core.model.portal.command.ViewDashboardCommand;
import org.jboss.portal.identity.User;
+import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.server.request.URLContext;
@@ -65,6 +67,7 @@
*/
public class PageCustomizerInterceptor extends ControllerInterceptor
{
+ private PortalObjectId dashboardId = PortalObjectId.parse("/dashboard", PortalObjectId.CANONICAL_FORMAT);
/** . */
private static final String RESOURCE_PREFIX = "PAGENAME_";
@@ -93,7 +96,6 @@
{
PageRendition rendition = (PageRendition)resp;
- // No tab in dashboard mode TODO: why not?
if (cmd instanceof RenderPageCommand)
{
RenderPageCommand rpc = (RenderPageCommand)cmd;
@@ -162,7 +164,7 @@
String label;
if (dashboard)
{
- RenderPageCommand _rpc = new RenderPageCommand(new PortalObjectId(new String[]{"default","default"}));
+ RenderPageCommand _rpc = new RenderPageCommand(new PortalObjectId(new String[]{"default", "default"}));
pageURL = cc.getControllerContext().renderURL(_rpc, null, null);
label = "Pages";
}
@@ -208,12 +210,9 @@
}
}
- // TODO: add checks for shared/private pages
SignOutCommand cmd = new SignOutCommand();
String logoutURL = cc.getControllerContext().renderURL(cmd, null, null);
- //sb.append("<a href=\"#\" class=\"addcontent\">Add Content</a>");
-
User user = (User)cc.getControllerContext().getServerInvocation().getRequest().getUser();
if (user != null)
{
@@ -234,34 +233,34 @@
sb.append(" | ");
sb.append("<a href=\"").append(showadminURL).append("\">Admin</a>");
}
- else
+/* else
{
sb.append(" | ");
sb.append("<a href=\"").append(showDefaultURL).append("\">Main</a>");
- }
+ }*/
- // For now it is not implemented, we don't want to have feedback such as "Add Content does not work"
- boolean featureImplemented = false;
- if (dashboard && featureImplemented)
+ if (dashboard)
{
+ PortletRequestDecoder decoder = new PortletRequestDecoder();
+ decoder.decode(cc.getControllerContext().getServerInvocation().getServerContext().getQueryParameterMap(), cc.getControllerContext().getServerInvocation().getServerContext().getBodyParameterMap());
+
+ InvokePortletInstanceRenderCommand command = new InvokePortletInstanceRenderCommand("ConfiguratorPortletInstance", decoder.getNavigationalstate());
+ String configureURL = cc.getControllerContext().renderURL(command, null, null);
+
sb.append(" | ");
- sb.append("<a href=\"#\">Add Content</a>");
- sb.append(" | ");
- sb.append("<a href=\"#\">Edit Page</a>");
- sb.append(" | ");
- sb.append("<a href=\"#\">Add Page</a>");
+ sb.append("<a href=\"").append(configureURL).append("\">Edit Content</a>");
}
sb.append(" | ");
-
+
//inject CMS Admin link
- if(user != null && showadminURL == null)
+ if (user != null && showadminURL == null)
{
- sb.append("<a href=\"").append("/portal/portal/cms").append("\">CMS Admin Tool</a>");
+ sb.append("<a href=\"").append("/portal/portal/cms").append("\">CMS Admin Tool</a>");
}
-
+
sb.append(" | ");
-
+
sb.append("<a href=\"").append(logoutURL).append("\">Logout</a>");
}
return sb;
@@ -284,7 +283,6 @@
navElements.add(portalObject);
}
}
-
sortTabs(navElements);
StringBuffer html = new StringBuffer();
19 years, 5 months
JBoss Portal SVN: r5807 - in trunk/core/src: main/org/jboss/portal/core/portlet/dashboard resources/portal-core-war/WEB-INF/jsp/dashboard
by portal-commits@lists.jboss.org
Author: roy.russo(a)jboss.com
Date: 2006-12-12 12:22:50 -0500 (Tue, 12 Dec 2006)
New Revision: 5807
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
Log:
JBPORTAL-1142 - added error handling in dashboard configure
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-12-12 04:59:21 UTC (rev 5806)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-12-12 17:22:50 UTC (rev 5807)
@@ -59,11 +59,6 @@
*/
public class Configurator extends JBossPortlet
{
-
- private static final int MOVE_UP = 0;
-
- private static final int MOVE_DOWN = 1;
-
private Logger log = Logger.getLogger(Configurator.class);
private InstanceContainer instanceContainer;
@@ -100,7 +95,7 @@
private PortalObjectId dashboardId = PortalObjectId.parse("/dashboard", PortalObjectId.CANONICAL_FORMAT);
protected void doView(JBossRenderRequest req, JBossRenderResponse resp)
- throws PortletException, PortletSecurityException, IOException
+ throws PortletException, IOException
{
// Generic page loader.
String op = req.getParameter("op");
@@ -109,6 +104,8 @@
op = "editPage";
}
+ String errorMessage = (String)req.getParameter("errorMsg");
+
Portal portal = (Portal)portalObjectContainer.getObject(dashboardId).getChild(req.getUser().getUserName());
Page page;
if (req.getParameter("editPageSelect") != null)
@@ -136,7 +133,8 @@
}
catch (Exception e)
{
- e.printStackTrace();
+ errorMessage = "Error loading dashboard settings.";
+ log.error(errorMessage, e);
}
// page select box
@@ -154,12 +152,19 @@
req.setAttribute("pages", pages);
req.setAttribute("currentPage", page.getName());
+ if (errorMessage != null)
+ {
+ req.setAttribute("errorMsg", errorMessage);
+ }
+
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/dashboard/editpage.jsp");
rd.include(req, resp);
}
protected void processAction(JBossActionRequest actionRequest, JBossActionResponse actionResponse)
{
+ String errorMessage = null;
+
Portal portal = (Portal)portalObjectContainer.getObject(dashboardId).getChild(actionRequest.getUser().getUserName());
Page page;
@@ -198,7 +203,8 @@
}
catch (Exception e)
{
- // todo
+ errorMessage = "Error adding window to region";
+ log.error(errorMessage, e);
}
actionResponse.setRenderParameter("editPageSelect", editPage);
}
@@ -218,14 +224,7 @@
removeWindows = actionRequest.getParameterValues(region + "_instances");
}
}
- }
- catch (Exception e)
- {
- // todo
- }
- try
- {
for (int i = 0; i < removeWindows.length; i++)
{
page.destroyChild((String)removeWindows[i]);
@@ -233,7 +232,8 @@
}
catch (Exception e)
{
- // todo
+ errorMessage = "Error removing window from region";
+ log.error(errorMessage, e);
}
actionResponse.setRenderParameter("editPageSelect", editPage);
}
@@ -273,7 +273,8 @@
}
catch (Exception e)
{
- // todo
+ errorMessage = "Error positioning windows";
+ log.error(errorMessage, e);
}
actionResponse.setRenderParameter("editPageSelect", editPage);
}
@@ -285,11 +286,25 @@
try
{
+ if (pageName.startsWith(" "))
+ {
+ errorMessage = "Page name cannot be blank";
+ throw new Exception(errorMessage);
+ }
+ if (portal.getChild(pageName) != null)
+ {
+ errorMessage = "Duplicate page name found";
+ throw new Exception(errorMessage);
+ }
pageContainer.createPage(pageName);
}
catch (Exception e)
{
- // todo - name taken
+ if (errorMessage == null)
+ {
+ errorMessage = "Error creating new page: " + pageName;
+ }
+ log.error(errorMessage, e);
}
actionResponse.setRenderParameter("editPageSelect", pageName);
@@ -300,12 +315,20 @@
String pageName = actionRequest.getParameter("pagename");
try
{
- // TODO: check for default page.
+ if (portal.getDefaultPage().getName().equalsIgnoreCase(pageName))
+ {
+ errorMessage = "Cannot delete default page";
+ throw new Exception(errorMessage);
+ }
portal.destroyChild(pageName);
}
catch (Exception e)
{
- // do something
+ if (errorMessage == null)
+ {
+ errorMessage = "Error deleting page: " + pageName;
+ }
+ log.error(errorMessage, e);
}
actionResponse.setRenderParameter("op", "editPage");
@@ -315,6 +338,13 @@
actionResponse.setRenderParameter("editPageSelect", editPage);
actionResponse.setRenderParameter("op", "editPage");
}
+
+ // req/res doesnt allow nulls
+ if (errorMessage == null)
+ {
+ errorMessage = "";
+ }
+ actionResponse.setRenderParameter("errorMsg", errorMessage);
}
private int doWindowNaming()
@@ -365,7 +395,6 @@
if (sign == 0)
{
sign = w1.getName().compareTo(w2.getName());
- //sign = w1.getId().compareTo(w2.getId());
}
return sign;
}
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-12 04:59:21 UTC (rev 5806)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-12 17:22:50 UTC (rev 5807)
@@ -21,6 +21,7 @@
Map windowMap = (Map)request.getAttribute("windowMap");
String currentPage = (String)request.getAttribute("currentPage");
+ String errorMessage = (String)request.getAttribute("errorMsg");
%>
<script type="text/javascript" language="JavaScript">
@@ -52,6 +53,19 @@
//alert("OP: '" + this.instancesForm.op.value + "' toRegion: '" + this.instancesForm.toRegion.value + "' fromRegion: '" + this.instancesForm.fromRegion.value + "' sortRegion: '" + this.instancesForm.sortRegion.value + "'");
}
</script>
+
+<%
+ if (errorMessage != null)
+ {
+%>
+<div align="center">
+ <font color="red"><b><%= errorMessage %>
+ </b></font>
+</div>
+<%
+ }
+%>
+
<table width="100%">
<th colspan="2" class="portlet-section-header" align="center">Edit Page '<%= currentPage %>'</th>
<tr>
19 years, 5 months
JBoss Portal SVN: r5806 - in trunk: . cms cms/src/main/org/jboss/portal/cms cms/src/main/org/jboss/portal/cms/hibernate/state cms/src/main/org/jboss/portal/cms/impl/interceptors cms/src/main/org/jboss/portal/cms/impl/jcr cms/src/main/org/jboss/portal/cms/impl/jcr/command cms/src/main/org/jboss/portal/cms/impl/jcr/composite cms/src/main/org/jboss/portal/cms/security cms/src/main/org/jboss/portal/test/cms/commands cms/src/resources/hibernate cms/src/resources/portal-cms-sar/default-content/de
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2006-12-11 23:59:21 -0500 (Mon, 11 Dec 2006)
New Revision: 5806
Added:
trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ACLEnforcer.java
trunk/cms/src/main/org/jboss/portal/cms/security/
trunk/cms/src/main/org/jboss/portal/cms/security/AuthorizationProvider.java
trunk/cms/src/main/org/jboss/portal/cms/security/Criteria.java
trunk/cms/src/main/org/jboss/portal/cms/security/PermRoleAssoc.java
trunk/cms/src/main/org/jboss/portal/cms/security/PermUserAssoc.java
trunk/cms/src/main/org/jboss/portal/cms/security/Permission.java
trunk/cms/src/main/org/jboss/portal/cms/security/PermissionManager.java
trunk/cms/src/main/org/jboss/portal/cms/security/PortalSecurityContext.java
trunk/cms/src/main/org/jboss/portal/cms/security/SecurityContext.java
trunk/cms/src/main/org/jboss/portal/test/cms/commands/CMSInterceptorStackFactory.java
trunk/cms/src/main/org/jboss/portal/test/cms/commands/SecureCommandTestCase.java
trunk/cms/src/main/org/jboss/portal/test/cms/commands/TestSecureFileGet.java
trunk/cms/src/resources/portal-cms-sar/default-content/default/images/
trunk/cms/src/resources/portal-cms-sar/default-content/default/images/back.gif
trunk/cms/src/resources/portal-cms-sar/default-content/default/images/check.gif
trunk/cms/src/resources/portal-cms-sar/default-content/default/images/homeimg_cornerelement.gif
trunk/cms/src/resources/portal-cms-sar/default-content/default/images/homeimg_jbosslogo.gif
trunk/cms/src/resources/portal-cms-sar/default-content/default/images/homeimg_main.jpg
trunk/cms/src/resources/portal-cms-sar/default-content/default/images/logo.gif
trunk/cms/src/resources/portal-cms-sar/default-content/default/private/
trunk/cms/src/resources/portal-cms-sar/default-content/default/private/license.html
trunk/cms/src/resources/portal-cms-sar/default-content/default/project.html
trunk/cms/src/resources/portal-cms-sar/default-content/default/support.html
trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/
trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/code.html
trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/confidential/
trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/confidential/license.html
trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/license.html
trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/ehcache.xml
Modified:
trunk/
trunk/cms/build.xml
trunk/cms/src/main/org/jboss/portal/cms/CMSException.java
trunk/cms/src/main/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/composite/NewFileCommand.java
trunk/cms/src/resources/hibernate/domain.hbm.xml
trunk/cms/src/resources/portal-cms-sar/default-content/default/index.html
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java
trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java
trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/domain.hbm.xml
trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/hibernate.cfg.xml
trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/main.jsp
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/securenode.jsp
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp
trunk/core/src/resources/portal-core-war/WEB-INF/portlet-instances.xml
Log:
Fine grained security integration into PortalCMS - [JBPORTAL-532],[JBPORTAL-328]
Property changes on: trunk
___________________________________________________________________
Name: svn:ignore
- .project
.classpath
thirdparty
eclipseBin
+ .project
.classpath
thirdparty
eclipseBin
myworkspace
Modified: trunk/cms/build.xml
===================================================================
--- trunk/cms/build.xml 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/build.xml 2006-12-12 04:59:21 UTC (rev 5806)
@@ -127,6 +127,8 @@
<path refid="jboss.portal-common.classpath"/>
<path refid="jboss.portal-jems.classpath"/>
<path refid="jboss.portal-test.classpath"/>
+ <!-- fine grained security integration -->
+ <path refid="jboss.portal-identity.classpath"/>
<!-- clustered testcases related -->
<path refid="jboss.portal-portlet.classpath"/>
<path refid="jboss.portlet-api.classpath"/>
@@ -380,19 +382,22 @@
<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileCreate"/>
<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileUpdate"/>
<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileArchiveUpload"/>
- <test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileGet"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileGet"/>
<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileGetVersion"/>
<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileGetList"/>
<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileCopy"/>
<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileCreateFailed"/>
- <test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileDelete"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFileDelete"/>
<!-- cms folder command tests -->
<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderCopy"/>
<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderCreate"/>
<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderDelete"/>
<test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderGet"/>
- <test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderUpdate"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestFolderUpdate"/>
+
+ <!-- cms fine grained security related tests -->
+ <!--test todir="${test.reports}" name="org.jboss.portal.test.cms.commands.TestSecureFileGet"/-->
</x-test>
<x-classpath>
<path refid="apache.logging.classpath"/>
Modified: trunk/cms/src/main/org/jboss/portal/cms/CMSException.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/CMSException.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/CMSException.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -26,7 +26,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class CMSException extends Exception
+public class CMSException extends RuntimeException
{
/** The serialVersionUID */
private static final long serialVersionUID = 3646107693814633408L;
Modified: trunk/cms/src/main/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -470,7 +470,8 @@
{
session = Tools.getOpenSession();
tx = session.beginTransaction();
-
+
+
InputStream in = new ByteArrayInputStream(nodeData);
//setup the propertyState
@@ -1306,7 +1307,7 @@
Session session = Tools.getOpenSession();
try
{
- List rs = session.createQuery(query).setCacheable(true).setString(0, id).list();
+ List rs = session.createQuery(query).setString(0, id).list();
Iterator iter = rs.iterator();
return iter.hasNext();
}
@@ -1361,7 +1362,7 @@
Session session = Tools.getCurrentSession();
try
{
- List rs = session.createQuery(blobSelectData).setCacheable(true).setString(0, blobId).list();
+ List rs = session.createQuery(blobSelectData).setString(0, blobId).list();
Iterator iter = rs.iterator();
java.sql.Blob blob = (java.sql.Blob)iter.next();
InputStream is = blob.getBinaryStream();
@@ -1393,7 +1394,7 @@
try
{
- Query query = session.createQuery(blobSelect).setCacheable(true);
+ Query query = session.createQuery(blobSelect);
if (schemaObjectPrefix.equalsIgnoreCase(HibernateStoreConstants.versionPrefix))
{
query.setString(0, blobId);
@@ -1459,7 +1460,7 @@
Session session = Tools.getCurrentSession();
try
{
- Query query = session.createQuery(nodeBinValSelect).setCacheable(true).setString(0, blobId);
+ Query query = session.createQuery(nodeBinValSelect).setString(0, blobId);
Object result = query.uniqueResult();
if (result != null)
{
Added: trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,453 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.jboss.portal.cms.impl.interceptors;
+
+import org.w3c.dom.*;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.InitialContext;
+
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.CMSInterceptor;
+import org.jboss.portal.cms.impl.jcr.JCRCommand;
+import org.jboss.portal.cms.impl.jcr.JCRCMS;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.cms.hibernate.state.Tools;
+import org.jboss.portal.common.invocation.InvocationException;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.Query;
+
+import org.jboss.portal.cms.security.*;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.db.RoleImpl;
+import org.jboss.portal.identity.RoleModule;
+
+/**
+ * ACLInterceptor is plugged into the CMS system to enforce fine grained security access control
+ * on resources stored in the CMS system.
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Nov 27, 2006
+ *
+ */
+public class ACLInterceptor extends CMSInterceptor
+{
+ /**
+ *
+ */
+ private AuthorizationProvider authorizationProvider = null;
+
+ /**
+ * default security policy that the cms service should be booted with
+ */
+ private String defaultPolicy = null;
+
+ /**
+ *
+ */
+ private RoleModule roleModule = null;
+
+ /**
+ *
+ */
+ private String jndiName = null;
+
+ /**
+ *
+ * @return
+ */
+ public String getAuthorizationProviderClass()
+ {
+ String authorizationProviderStr = null;
+ if(this.authorizationProvider!=null)
+ {
+ authorizationProviderStr = authorizationProvider.getClass().getName();
+ }
+ return authorizationProviderStr;
+ }
+
+ /**
+ *
+ * @param authorizationProviderStr
+ */
+ public void setAuthorizationProviderClass(String authorizationProviderStr)
+ {
+ try
+ {
+ this.authorizationProvider = (AuthorizationProvider)Thread.currentThread().
+ getContextClassLoader().loadClass(authorizationProviderStr).newInstance();
+ }
+ catch(Exception e)
+ {
+ this.authorizationProvider = null;
+ this.stop();
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getDefaultPolicy()
+ {
+ return this.defaultPolicy;
+ }
+
+ /**
+ *
+ * @param defaultPolicy
+ */
+ public void setDefaultPolicy(String defaultPolicy)
+ {
+ this.defaultPolicy = defaultPolicy;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public RoleModule getRoleModule()
+ {
+ return this.roleModule;
+ }
+
+ /**
+ *
+ * @param roleModule
+ */
+ public void setRoleModule(RoleModule roleModule)
+ {
+ this.roleModule = roleModule;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getJNDIName()
+ {
+ return this.jndiName;
+ }
+
+ /**
+ *
+ * @param jndiName
+ */
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ /**
+ *
+ */
+ protected Object invoke(JCRCommand invocation) throws Exception, InvocationException
+ {
+ Session session = Tools.getOpenSession();
+ Transaction tx = session.beginTransaction();
+
+ //make the acl check before this command is executed
+ User user = (User)JCRCMS.getUserInfo().get();
+
+
+ //setup the security context with enough information for the authorization provider
+ //to be able to make an enforcement decision
+ PortalSecurityContext securityContext = new PortalSecurityContext(user);
+ securityContext.setAttribute("command",invocation);
+
+
+ //perform access check
+ boolean allowAccess = this.authorizationProvider.hasAccess(securityContext);
+ tx.commit();
+ Tools.closeSession(session);
+
+ if(allowAccess)
+ {
+ Object response = invocation.invokeNext();
+
+ //also filter lists of files and folders based on access allowed on these resources
+ response = this.applyFilter(response,securityContext);
+
+ return response;
+ }
+ else
+ {
+ throw new CMSException("Access to this resource is denied");
+ }
+ }
+
+ /**
+ * Filters any files/folders based on the user's access. The filter is applied to folders/files
+ * returned by invoking a CMS command
+ *
+ * @param response
+ * @return
+ */
+ private Object applyFilter(Object response,PortalSecurityContext securityContext)
+ {
+ Session session = Tools.getOpenSession();
+ Transaction tx = session.beginTransaction();
+ Object filteredResponse = response;
+
+ try
+ {
+
+
+ if(filteredResponse instanceof Folder)
+ {
+ Folder folder = (Folder)filteredResponse;
+ List filteredFolders = new ArrayList();
+ List filteredFiles = new ArrayList();
+ securityContext.removeAttribute("command");
+ for(Iterator itr=folder.getFolders().iterator();itr.hasNext();)
+ {
+ Folder cour = (Folder)itr.next();
+ securityContext.setAttribute("applyFilter",cour.getBasePath());
+ boolean allow = this.authorizationProvider.hasAccess(securityContext);
+ if(allow)
+ {
+ filteredFolders.add(cour);
+ }
+ }
+ for(Iterator itr=folder.getFiles().iterator();itr.hasNext();)
+ {
+ File cour = (File)itr.next();
+ securityContext.setAttribute("applyFilter",cour.getBasePath());
+ boolean allow = this.authorizationProvider.hasAccess(securityContext);
+ if(allow)
+ {
+ filteredFiles.add(cour);
+ }
+ }
+ folder.setFolders(filteredFolders);
+ folder.setFiles(filteredFiles);
+ }
+ }
+ catch(Exception e)
+ {
+ tx.rollback();
+ }
+ finally
+ {
+ tx.commit();
+ Tools.closeSession(session);
+ }
+
+ return filteredResponse;
+ }
+
+ /**
+ *
+ */
+ public void startService() throws Exception
+ {
+ super.startService();
+
+ Tools.init(this.jndiName);
+
+
+ //check and see if cms permissions exist...if not, boot it with the default policy
+ //specified in the configuration
+ if(!this.isBootRequired())
+ {
+ return;
+ }
+
+ //go ahead and boot the cms access policy with default policy specified in the configuration
+ InputStream is = null;
+ try
+ {
+ //process the specified defaultPolicy
+ is = new ByteArrayInputStream(this.defaultPolicy.getBytes());
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is);
+
+ NodeList criteria = document.getElementsByTagName("criteria");
+ if(criteria!=null)
+ {
+ for(int i=0;i<criteria.getLength();i++)
+ {
+ Element criteriaElem = (Element)criteria.item(i);
+ String name = criteriaElem.getAttribute("name");
+ String value = criteriaElem.getAttribute("value");
+
+ //permission setup
+ NodeList permissions = criteriaElem.getElementsByTagName("permission");
+ if(permissions!=null)
+ {
+ Session session = null;
+ Transaction tx = null;
+ Collection parsedPermissions = this.parseDefaultPermissions(permissions);
+ try
+ {
+ session = Tools.getOpenSession();
+ tx = session.beginTransaction();
+ for(Iterator itr=parsedPermissions.iterator();itr.hasNext();)
+ {
+ Permission permission = (Permission)itr.next();
+ permission.addCriteria(new Criteria(name,value));
+ PermissionManager.getInstance().store(permission);
+ }
+ tx.commit();
+ }
+ catch(Exception e)
+ {
+ tx.rollback();
+ }
+ finally
+ {
+ Tools.closeSession(session);
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ if(is!=null)
+ {
+ is.close();
+ }
+ }
+ }
+
+ /**
+ * Parses and produces Permission objects for the default policy
+ *
+ * @param permissions
+ * @return
+ */
+ private Collection parseDefaultPermissions(NodeList permissions) throws Exception
+ {
+ Collection parsedPermissions = new ArrayList();
+ for(int i=0;i<permissions.getLength();i++)
+ {
+ Element permissionElement = (Element)permissions.item(i);
+ String name = permissionElement.getAttribute("name");
+ String action = permissionElement.getAttribute("action");
+ Permission permission = new Permission(name,action);
+
+ //parse the roles listed under this permission element
+ NodeList roles = permissionElement.getElementsByTagName("role");
+ for(int j=0;j<roles.getLength();j++)
+ {
+ Element roleElement = (Element)roles.item(j);
+ String roleName = roleElement.getAttribute("name");
+ Role role = this.getRole(roleName);
+ PermRoleAssoc roleAssoc = new PermRoleAssoc();
+ if(role.getId()!=null)
+ {
+ //makes sure this is not Anonymous
+ roleAssoc.setRoleId(((Long)role.getId()).longValue());
+ }
+ permission.addRoleAssoc(roleAssoc);
+ }
+
+ parsedPermissions.add(permission);
+ }
+ return parsedPermissions;
+ }
+
+ /**
+ * Returns the Role object specified in the default policy
+ *
+ * @param name
+ * @return
+ */
+ private Role getRole(String name) throws Exception
+ {
+ Role role = null;
+
+ //since this is at app start up and not on user thread...need to create a transaction context.
+ InitialContext context = new InitialContext();
+ SessionFactory sessionFactory = (SessionFactory)context.lookup("java:/portal/UserSessionFactory");
+ Session session = sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+ try
+ {
+ role = this.roleModule.findRoleByName(name);
+ }
+ catch(Exception e)
+ {
+ role = new RoleImpl();
+ }
+ finally
+ {
+ if(tx!=null)
+ {
+ tx.rollback();
+ }
+ if(session!=null)
+ {
+ session.close();
+ }
+ }
+
+ return role;
+ }
+
+ /**
+ * Returns if cms permissions need to be booted with the default policy from configuration
+ *
+ * @return
+ */
+ private boolean isBootRequired()
+ {
+ boolean bootRequired = false;
+
+ String hsqlQuery = "select count(permission) from org.jboss.portal.cms.security.Permission as permission";
+ Session session = Tools.getOpenSession();
+ Transaction tx = session.beginTransaction();
+ try
+ {
+ Query query = session.createQuery(hsqlQuery);
+ long count = ((Long)query.list().get(0)).longValue();
+ if(count<=0)
+ {
+ bootRequired = true;
+ }
+ }
+ finally
+ {
+ if(tx!=null)
+ {
+ tx.rollback();
+ }
+ Tools.closeSession(session);
+ }
+
+ return bootRequired;
+ }
+}
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -46,6 +46,8 @@
import org.jboss.portal.common.net.URLVisitor;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.util.XML;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserModule;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.util.StopWatch;
import org.w3c.dom.DOMImplementation;
@@ -65,6 +67,7 @@
import java.util.LinkedList;
import java.util.Locale;
+
/**
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -89,6 +92,8 @@
private InterceptorStackFactory stackFactory;
private Element config;
+
+ private UserModule userModule = null;
private InvocationHandler handler = new InvocationHandler()
@@ -99,6 +104,15 @@
return cmd.execute();
}
};
+
+ /**
+ * Used for storing the logged in user information
+ */
+ protected static ThreadLocal userInfo = new ThreadLocal();
+ public static ThreadLocal getUserInfo()
+ {
+ return JCRCMS.userInfo;
+ }
public JCRCMS()
{
@@ -169,6 +183,24 @@
{
this.doChecking = doChecking;
}
+
+ /**
+ *
+ * @return
+ */
+ public UserModule getUserModule()
+ {
+ return this.userModule;
+ }
+
+ /**
+ *
+ * @param userModule
+ */
+ public void setUserModule(UserModule userModule)
+ {
+ this.userModule = userModule;
+ }
/** CMS Start */
public void startService() throws Exception
@@ -262,12 +294,22 @@
// /**
/** Loads content from sar and adds it to the repo. */
- public void createContent() throws IOException
+ public void createContent() throws Exception
{
log.info("Creating default CMS content.");
+
// Get the content
URL root = Thread.currentThread().getContextClassLoader().getResource(defaultContentLocation);
+
+ //make the user executing these to create the default content, an 'Admin' user
+ //without this, the fine grained security won't allow the creation
+ org.hibernate.Session session = org.jboss.portal.cms.hibernate.state.Tools.getOpenSession();
+ org.hibernate.Transaction tx = session.beginTransaction();
+ User user = this.userModule.findUserByUserName("admin");
+ this.getUserInfo().set(user);
+ tx.rollback();
+ org.jboss.portal.cms.hibernate.state.Tools.closeSession(session);
// Iterate over the content
URLVisitor visitor = new URLVisitor()
Added: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ACLEnforcer.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ACLEnforcer.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ACLEnforcer.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,621 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.jboss.portal.cms.impl.jcr.command;
+
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.HashSet;
+import java.util.StringTokenizer;
+
+import org.jboss.portal.cms.impl.jcr.command.*;
+import org.jboss.portal.cms.impl.jcr.composite.*;
+import org.jboss.portal.cms.impl.jcr.*;
+import org.jboss.portal.cms.security.AuthorizationProvider;
+import org.jboss.portal.cms.security.PortalSecurityContext;
+import org.jboss.portal.cms.security.SecurityContext;
+import org.jboss.portal.cms.security.Permission;
+import org.jboss.portal.cms.security.PermissionManager;
+import org.jboss.portal.cms.security.Criteria;
+import org.jboss.portal.identity.User;
+
+/**
+ * ACLEnforcer checks proper access privileges for actions before
+ * the Command objects are allowed to execute and do their job on the CMS
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Nov 28, 2006
+ *
+ */
+public class ACLEnforcer implements AuthorizationProvider
+{
+ private Collection readCommands = new ArrayList(); //a list of commands that perform read action on the cms
+ private Collection writeCommands = new ArrayList();//a list of commands that perform write action on the cms
+ private Collection manageCommands = new ArrayList();//a list of commands that perform manage action on the cms
+
+ private static final int read = 0;
+ private static final int write = 1;
+ private static final int manage = 2;
+
+
+ /**
+ *
+ *
+ */
+ public ACLEnforcer()
+ {
+ super();
+
+ String packageName = "org.jboss.portal.cms.impl.jcr.command.";
+
+ //load the read related commands
+ readCommands.add(packageName+"FolderGetListCommand");
+ readCommands.add(packageName+"FolderGetCommand");
+ readCommands.add(packageName+"FileGetListCommand");
+ readCommands.add(packageName+"FileGetCommand");
+
+ //load the write related commands
+ writeCommands.add(packageName+"ContentCreateCommand");
+ writeCommands.add(packageName+"FileCreateCommand");
+ writeCommands.add(packageName+"FolderCreateCommand");
+ writeCommands.add(packageName+"FileUpdateCommand");
+ writeCommands.add(packageName+"StoreArchiveCommand");
+ writeCommands.add(packageName+"ContentCreateNewVersionCommand");
+ writeCommands.add("org.jboss.portal.cms.impl.jcr.composite.NewFileCommand");
+ writeCommands.add("org.jboss.portal.cms.impl.jcr.composite.UpdateFileCommand");
+
+
+ //load the manage related commands
+ manageCommands.add(packageName+"CopyCommand");
+ manageCommands.add(packageName+"DeleteCommand");
+ manageCommands.add(packageName+"MoveCommand");
+ manageCommands.add(packageName+"RenameCommand");
+ }
+
+
+ /**
+ *
+ * @param securityContext
+ * @return
+ */
+ public boolean hasAccess(SecurityContext context)
+ {
+ boolean hasAccess = true;
+ PortalSecurityContext portalSecurityContext = (PortalSecurityContext)context;
+ User loggedInUser = (User)portalSecurityContext.getIdentity();
+ JCRCommand command = (JCRCommand)portalSecurityContext.getAttribute("command");
+
+ int actionCode = -1;
+ if(command != null)
+ {
+ actionCode = this.getActionCode(command);
+ }
+ switch(actionCode)
+ {
+ case read:
+ hasAccess = this.hasReadAccess(loggedInUser,command);
+ break;
+
+ case write:
+ hasAccess = this.hasWriteAccess(loggedInUser,command);
+ break;
+
+ case manage:
+ hasAccess = this.hasManageAccess(loggedInUser,command);
+ break;
+
+ default:
+ //check if a filter needs to be applied here......
+ //only show resources that the user has write or more access to
+ if(context.getAttribute("applyFilter")!=null)
+ {
+ String path = (String)context.getAttribute("applyFilter");
+ hasAccess = this.computeToolAccess(loggedInUser,path);
+ }
+ break;
+ }
+
+ return hasAccess;
+ }
+
+ /**
+ *
+ * @param command
+ * @return
+ */
+ private int getActionCode(JCRCommand command)
+ {
+ int actionCode = -1;
+
+ if(this.readCommands.contains(command.getClass().getName()))
+ {
+ actionCode = read;
+ }
+ else if(this.writeCommands.contains(command.getClass().getName()))
+ {
+ actionCode = write;
+ }
+ else if(this.manageCommands.contains(command.getClass().getName()))
+ {
+ actionCode = manage;
+ }
+ return actionCode;
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param user
+ * @param command
+ * @return
+ */
+ private boolean hasReadAccess(User user,JCRCommand command)
+ {
+ boolean hasReadAccess = false;
+
+ String path = null;
+ if(command instanceof FolderGetListCommand)
+ {
+ path = ((FolderGetListCommand)command).sFolderPath;
+ }
+ else if(command instanceof FolderGetCommand)
+ {
+ path = ((FolderGetCommand)command).msPath;
+ }
+ else if(command instanceof FileGetCommand)
+ {
+ path = ((FileGetCommand)command).path;
+ }
+ else if(command instanceof FileGetListCommand)
+ {
+ path = ((FileGetListCommand)command).sFilePath;
+ }
+
+ hasReadAccess = this.computeAccess(user,path,"read");
+ if(!hasReadAccess)
+ {
+ //make sure implied write is not available
+ hasReadAccess = this.computeAccess(user,path,"write");
+ if(!hasReadAccess)
+ {
+ //make sure implied manage is not available
+ hasReadAccess = this.computeAccess(user,path,"manage");
+ }
+ }
+
+ return hasReadAccess;
+ }
+ //-------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param user
+ * @param command
+ * @return
+ */
+ private boolean hasWriteAccess(User user,JCRCommand command)
+ {
+ boolean hasWriteAccess = false;
+
+ String path = null;
+ if(command instanceof ContentCreateCommand)
+ {
+ path = ((ContentCreateCommand)command).mFile.getBasePath();
+ }
+ else if(command instanceof FileCreateCommand)
+ {
+ path = ((FileCreateCommand)command).mFile.getBasePath();
+ }
+ else if(command instanceof FolderCreateCommand)
+ {
+ path = ((FolderCreateCommand)command).mFolder.getBasePath();
+ }
+ else if(command instanceof FileUpdateCommand)
+ {
+ path = ((FileUpdateCommand)command).mFile.getBasePath();
+ }
+ else if(command instanceof StoreArchiveCommand)
+ {
+ path = ((StoreArchiveCommand)command).msRootPath;
+ }
+ else if(command instanceof NewFileCommand)
+ {
+ path = ((NewFileCommand)command).getPath();
+ }
+ else if(command instanceof UpdateFileCommand)
+ {
+ path = ((UpdateFileCommand)command).getPath();
+ }
+
+ hasWriteAccess = this.computeAccess(user,path,"write");
+ if(!hasWriteAccess)
+ {
+ //make sure implied manage is not available
+ hasWriteAccess = this.computeAccess(user,path,"manage");
+ }
+
+ return hasWriteAccess;
+ }
+ //-----------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param user
+ * @param command
+ * @return
+ */
+ private boolean hasManageAccess(User user,JCRCommand command)
+ {
+ boolean hasManageAccess = false;
+
+ String path = null;
+ if(command instanceof CopyCommand)
+ {
+ path = ((CopyCommand)command).msFromPath;
+ }
+ else if(command instanceof DeleteCommand)
+ {
+ path = ((DeleteCommand)command).msPath;
+ }
+ else if(command instanceof MoveCommand)
+ {
+ path = ((MoveCommand)command).msFromPath;
+ }
+ else if(command instanceof RenameCommand)
+ {
+ path = ((RenameCommand)command).msPath;
+ }
+
+ hasManageAccess = this.computeAccess(user,path,"manage");
+
+ return hasManageAccess;
+ }
+ //-----------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ private boolean computeAccess(User user,String path,String action)
+ {
+ boolean hasAccess = false;
+
+ //to prevent any administration issues, if the user is the 'admin'
+ //treat him like a super user with access to everything in the cms
+ if(user!= null && user.getUserName()!=null && user.getUserName().equals("admin"))
+ {
+ return true;
+ }
+
+
+ //get the permissions available for the user in question
+ Collection userPermissions = this.getPermissions(user);
+
+ //check against permissions that are explicitly specified on this node (file or folder)
+ Collection specificPermissions = this.getPermissions(path);
+ for(Iterator itr=specificPermissions.iterator();itr.hasNext();)
+ {
+ Permission specificPermission = (Permission)itr.next();
+ if(specificPermission.getService().equals("cms") && specificPermission.getAction().equals(action))
+ {
+ for(Iterator itr2=userPermissions.iterator();itr2.hasNext();)
+ {
+ Permission userPermission = (Permission)itr2.next();
+ if(userPermission.getService().equals("cms") && userPermission.getAction().equals(action))
+ {
+ String pathCriteria = userPermission.findCriteriaValue("path");
+ if(pathCriteria.equals(path))
+ {
+ //this means this user has read access to this path
+ hasAccess = true;
+ }
+ }
+ }
+ }
+ }
+
+ if(specificPermissions!=null && !specificPermissions.isEmpty())
+ {
+ //explicit permissions on this node have been specified....
+ //which override any permissions that could be inherited via the path hierarchy
+ return hasAccess;
+ }
+
+
+ //check against the full path of this resource and make sure,
+ //there aren't any specific node permissions specified on any node along the path
+ //that excludes this user from having access for this action
+ StringTokenizer st = new StringTokenizer(path,"/");
+ StringBuffer buffer = new StringBuffer("/");
+ boolean explicitPermissionsFound = false;
+ while(st.hasMoreTokens())
+ {
+ buffer.append(st.nextToken());
+ String currentNode = buffer.toString();
+ Collection permissions = this.getPermissions(currentNode);
+
+ //this is for forming the path using the next token
+ if(st.hasMoreTokens())
+ {
+ buffer.append("/");
+ }
+ else
+ {
+ continue;
+ }
+
+
+ //perform processing for permissions explicitly set on this node
+ //in the path hierarchy
+ if(permissions!=null && !permissions.isEmpty())
+ {
+ explicitPermissionsFound = true;
+
+ //specific node permissions found on one of the nodes in the path...
+ //make sure the current user is listed to have access to this.
+ boolean accessFound = false;
+ for(Iterator itr=permissions.iterator();itr.hasNext();)
+ {
+ Permission nodePermission = (Permission)itr.next();
+ if(nodePermission.getService().equals("cms") && nodePermission.getAction().equals(action))
+ {
+ for(Iterator itr2=userPermissions.iterator();itr2.hasNext();)
+ {
+ Permission userPermission = (Permission)itr2.next();
+ if(userPermission.getService().equals("cms") && userPermission.getAction().equals(action))
+ {
+ String pathCriteria = userPermission.findCriteriaValue("path");
+ if(pathCriteria.equals(currentNode))
+ {
+ //this means this user has read access to this path
+ accessFound = true;
+ }
+ }
+ }
+ }
+ if(accessFound)
+ {
+ break;
+ }
+ }
+ if(!accessFound)
+ {
+ //the user does not have access through the path hierarchy
+ return false;
+ }
+ }
+ }
+
+ //if i am here the user has access to this node via path hierarchy inheritance
+ if(explicitPermissionsFound)
+ {
+ //and without the hierarchy access *not being overriden* by any *explicit permissions*
+ //on nodes in the hierarchy
+ hasAccess = true;
+ }
+ else
+ {
+ //there were no permissions found anywhere throughout the resource's path hierarchy
+ hasAccess = false;
+ }
+
+ return hasAccess;
+ }
+
+ /**
+ * This is used to filter out cms resources in the CMS Admin tool, so that the user
+ * can see only the resources that he has write/manage access to
+ *
+ * @param user
+ * @param path
+ * @return
+ */
+ private boolean computeToolAccess(User user,String path)
+ {
+ boolean toolAccess = false;
+
+ //to prevent any administration issues, if the user is the 'admin'
+ //treat him like a super user with access to everything in the cms
+ if(user!= null && user.getUserName()!=null && user.getUserName().equals("admin"))
+ {
+ return true;
+ }
+
+ //get the permissions available for the user in question
+ Collection userPermissions = this.getPermissions(user);
+
+ //check against permissions that are explicitly specified on this node (file or folder)
+ Collection specificPermissions = this.getPermissions(path);
+ for(Iterator itr=specificPermissions.iterator();itr.hasNext();)
+ {
+ Permission specificPermission = (Permission)itr.next();
+ if( (specificPermission.getService().equals("cms")) &&
+ (specificPermission.getAction().equals("write") || specificPermission.getAction().equals("manage"))
+ )
+ {
+ for(Iterator itr2=userPermissions.iterator();itr2.hasNext();)
+ {
+ Permission userPermission = (Permission)itr2.next();
+ if( (userPermission.getService().equals("cms")) &&
+ (userPermission.getAction().equals("write") || userPermission.getAction().equals("manage"))
+ )
+ {
+ String pathCriteria = userPermission.findCriteriaValue("path");
+ if(pathCriteria.equals(path))
+ {
+ //this means this user has read access to this path
+ toolAccess = true;
+ }
+ }
+ }
+ }
+ }
+
+ if(specificPermissions!=null && !specificPermissions.isEmpty())
+ {
+ //explicit permissions on this node have been specified....
+ //which override any permissions that could be inherited via the path hierarchy
+ return toolAccess;
+ }
+
+ //if i am here...calculate based on permissions inherited via path hierarchy
+ Collection writeOrMoreCriteria = this.getWriteOrMore(userPermissions);
+ for(Iterator itr=writeOrMoreCriteria.iterator();itr.hasNext();)
+ {
+ Criteria cour = (Criteria)itr.next();
+ if(this.doesPathMatchPattern(path,cour.getValue()))
+ {
+
+ toolAccess = true;
+ break;
+ }
+ }
+
+ return toolAccess;
+ }
+ //----------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param user
+ * @return
+ */
+ private Collection getPermissions(User user)
+ {
+ Collection permissions = null;
+ long userId = 0;
+ if(user!=null)
+ {
+ //this is not an anonymous access
+ userId = ((Long)user.getId()).longValue();
+ permissions = PermissionManager.getInstance().findPermissionsByUser(userId);
+ }
+ else
+ {
+ //this is an anonymous access
+ permissions = PermissionManager.getInstance().findPermissionsByRole(0);
+ }
+ return permissions;
+ }
+
+ /**
+ *
+ * @param user
+ * @return
+ */
+ private Collection getPermissions(String path)
+ {
+ Criteria criteria = new Criteria("path",path);
+ return PermissionManager.getInstance().findPermissionsByCriteria(criteria);
+ }
+
+ /**
+ *
+ * @param allPermissions
+ * @return
+ */
+ private Collection getWriteOrMore(Collection allPermissions)
+ {
+ Collection writeOrMore = new HashSet();
+
+ if(allPermissions!=null)
+ {
+ for(Iterator itr=allPermissions.iterator();itr.hasNext();)
+ {
+ Permission cour = (Permission)itr.next();
+ if( (cour.getService().equals("cms")) &&
+ ( cour.getAction().equals("write") || cour.getAction().equals("manage") )
+ )
+ {
+ writeOrMore.addAll(cour.getCriteria());
+ }
+ }
+ }
+
+ return writeOrMore;
+ }
+
+ /**
+ * @param path
+ * @param pattern
+ * @return
+ */
+ private boolean doesPathMatchPattern(String path,String pattern)
+ {
+ boolean match = true;
+
+ //format the path first before starting to match it with the specified pattern
+ if(!path.startsWith("/"))
+ {
+ path = "/" + path;
+ }
+ if(!path.endsWith("/"))
+ {
+ path = path + "/";
+ }
+
+ StringTokenizer patternTokenizer = new StringTokenizer(pattern,"/");
+ StringTokenizer pathTokenizer = new StringTokenizer(path,"/");
+ StringBuffer pathMatched = new StringBuffer("/");
+ StringBuffer patternMatched = new StringBuffer();
+ if(pattern.startsWith("/"))
+ {
+ patternMatched.append("/");
+ }
+ while(
+ patternTokenizer.hasMoreTokens() &&
+ pathTokenizer.hasMoreTokens()
+ )
+ {
+ String patternToken = patternTokenizer.nextToken();
+ String pathToken = pathTokenizer.nextToken();
+
+ //setup token tracking
+ pathMatched.append(pathToken+"/");
+ if(patternTokenizer.hasMoreTokens())
+ {
+ patternMatched.append(patternToken+"/");
+ }
+ else
+ {
+ patternMatched.append(patternToken);
+ }
+
+ //perform token matching
+ if(!match){continue;}
+ int wildCardIndex = patternToken.indexOf('*');
+ //if wildCard is not relevant
+ if(wildCardIndex<=0)
+ {
+ //if wildCardIndex == 0 then this token matches...
+ if(wildCardIndex!=0 && !pathToken.equals(patternToken))
+ {
+ match = false;
+ }
+ }
+ else
+ {
+ String wildPath = pathToken.substring(0,wildCardIndex);
+ String wildPattern = patternToken.substring(0,wildCardIndex);
+ if(!wildPath.equals(wildPattern))
+ {
+ match = false;
+ }
+ }
+ }
+
+ return match;
+ }
+}
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/composite/NewFileCommand.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/composite/NewFileCommand.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/composite/NewFileCommand.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -30,17 +30,33 @@
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
-/** @author <a href="mailto:theute@jboss.org">Thomas Heute</a> */
+/** @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah@jboss.com">Sohil Shah</a> - Nov 28, 2006
+ **/
public class NewFileCommand extends JCRCompositeCommand
{
/** The serialVersionUID */
private static final long serialVersionUID = -6134173065175936408L;
+
+ //
+ private String path = null;
+
+ /**
+ *
+ * @return
+ */
+ public String getPath()
+ {
+ return this.path;
+ }
public NewFileCommand(File file, Content content)
{
// setAttribute("file", file);
// setAttribute("content", content);
+ this.path = file.getBasePath();
+
Command saveFileCMD = new FileCreateCommand(file);
commands.add(saveFileCMD);
Command saveContentCMD = new ContentCreateCommand(file);
Added: trunk/cms/src/main/org/jboss/portal/cms/security/AuthorizationProvider.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/security/AuthorizationProvider.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/security/AuthorizationProvider.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.jboss.portal.cms.security;
+
+/**
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Nov 27, 2006
+ *
+ */
+public interface AuthorizationProvider
+{
+ /**
+ * Checks if the currently logged in user has the necessary privileges to access the resources
+ * encapsulated within the securityContext
+ *
+ * @param context security context containing the information used to enforce access control
+ * @return true - access should be granted, false - access should not be granted
+ */
+ public boolean hasAccess(SecurityContext context);
+}
Added: trunk/cms/src/main/org/jboss/portal/cms/security/Criteria.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/security/Criteria.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/security/Criteria.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,127 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.jboss.portal.cms.security;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Nov 29, 2006
+ *
+ */
+public class Criteria implements Serializable
+{
+ /**
+ *
+ */
+ private long id = 0;
+ private String name = null;
+ private String value = null;
+
+ /**
+ *
+ *
+ */
+ public Criteria()
+ {
+
+ }
+
+ /**
+ *
+ *
+ */
+ public Criteria(String name,String value)
+ {
+ this();
+ this.name = name;
+ this.value = value;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public long getId()
+ {
+ return this.id;
+ }
+
+ /**
+ *
+ * @param key
+ */
+ public void setId(long id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * @return Returns the context.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * @param context The context to set.
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+
+ /**
+ * @return Returns the value.
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /**
+ * @param value The value to set.
+ */
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ /**
+ *
+ */
+ public boolean equals(Object obj)
+ {
+ boolean equals = false;
+ if(obj instanceof Criteria)
+ {
+ Criteria input = (Criteria)obj;
+ if(input.name.equals(this.name) && input.value.equals(this.value))
+ {
+ equals = true;
+ }
+ }
+ return equals;
+ }
+}
Added: trunk/cms/src/main/org/jboss/portal/cms/security/PermRoleAssoc.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/security/PermRoleAssoc.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/security/PermRoleAssoc.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,95 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.jboss.portal.cms.security;
+
+/**
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Dec 7, 2006
+ *
+ */
+public class PermRoleAssoc
+{
+ private long id = 0;
+ private long roleId = 0;
+
+ /**
+ *
+ *
+ */
+ public PermRoleAssoc()
+ {
+ super();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public long getId()
+ {
+ return id;
+ }
+
+ /**
+ *
+ * @param id
+ */
+ public void setId(long id)
+ {
+ this.id = id;
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ public long getRoleId()
+ {
+ return roleId;
+ }
+
+ /**
+ *
+ * @param roleId
+ */
+ public void setRoleId(long roleId)
+ {
+ this.roleId = roleId;
+ }
+
+ public boolean equals(Object obj)
+ {
+ boolean equals = false;
+
+ if(obj instanceof PermRoleAssoc)
+ {
+ PermRoleAssoc input = (PermRoleAssoc)obj;
+ if(input.roleId == this.roleId)
+ {
+ equals = true;
+ }
+ }
+
+ return equals;
+ }
+}
Added: trunk/cms/src/main/org/jboss/portal/cms/security/PermUserAssoc.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/security/PermUserAssoc.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/security/PermUserAssoc.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,95 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.jboss.portal.cms.security;
+
+/**
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Dec 7, 2006
+ *
+ */
+public class PermUserAssoc
+{
+ private long id = 0;
+ private long userId = 0;
+
+ /**
+ *
+ *
+ */
+ public PermUserAssoc()
+ {
+ super();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public long getId()
+ {
+ return id;
+ }
+
+ /**
+ *
+ * @param id
+ */
+ public void setId(long id)
+ {
+ this.id = id;
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ public long getUserId()
+ {
+ return userId;
+ }
+
+ /**
+ *
+ * @param roleId
+ */
+ public void setUserId(long userId)
+ {
+ this.userId = userId;
+ }
+
+ public boolean equals(Object obj)
+ {
+ boolean equals = false;
+
+ if(obj instanceof PermUserAssoc)
+ {
+ PermUserAssoc input = (PermUserAssoc)obj;
+ if(input.userId == this.userId)
+ {
+ equals = true;
+ }
+ }
+
+ return equals;
+ }
+}
Added: trunk/cms/src/main/org/jboss/portal/cms/security/Permission.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/security/Permission.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/security/Permission.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,376 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.jboss.portal.cms.security;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.security.BasicPermission;
+
+/**
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Nov 28, 2006
+ *
+ */
+public class Permission extends BasicPermission
+{
+ /**
+ *
+ */
+ private long id = 0; //unique id for this permission object in the storage (typically database)
+ private String service = null;
+ private String action = null;
+ private boolean isNegated = false;
+
+ /**
+ *
+ */
+ private Set criteria = null;
+ private Set roleAssoc = null;
+ private Set userAssoc = null;
+
+ /**
+ *
+ *
+ */
+ public Permission()
+ {
+ this("null");
+ }
+
+
+ /**
+ *
+ * @param name
+ */
+ public Permission(String service)
+ {
+ super(service);
+ this.service = service;
+ }
+
+ /**
+ *
+ * @param name
+ * @param actions
+ */
+ public Permission(String service,String actions)
+ {
+ super(service,actions);
+ this.service = service;
+ this.action = actions;
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ public long getId()
+ {
+ return this.id;
+ }
+
+ /**
+ *
+ * @param id
+ */
+ public void setId(long id)
+ {
+ this.id = id;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Set getCriteria()
+ {
+ return this.criteria;
+ }
+
+ /**
+ *
+ * @param criteria
+ */
+ public void setCriteria(Set criteria)
+ {
+ this.criteria = criteria;
+ }
+
+ /**
+ *
+ * @param criteria
+ */
+ public void addCriteria(Criteria criteria)
+ {
+ if(this.criteria == null)
+ {
+ this.criteria = new HashSet();
+ }
+ this.criteria.add(criteria);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getService()
+ {
+ return this.service;
+ }
+
+
+ /**
+ *
+ * @param name
+ */
+ public void setService(String service)
+ {
+ this.service = service;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getAction()
+ {
+ return this.action;
+ }
+
+ /**
+ *
+ * @param action
+ */
+ public void setAction(String action)
+ {
+ this.action = action;
+ }
+
+
+ /**
+ * Finds the specified criteria value for the criteriaId
+ *
+ * @param criteriaId
+ * @return value of the criteria
+ */
+ public String findCriteriaValue(String criteriaId)
+ {
+ String value = null;
+ if(this.criteria!=null)
+ {
+ for(Iterator itr=this.criteria.iterator();itr.hasNext();)
+ {
+ Criteria cour = (Criteria)itr.next();
+ if(criteriaId.equals(cour.getName()))
+ {
+ value = cour.getValue();
+ }
+ }
+ }
+ return value;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public boolean isNegated()
+ {
+ return isNegated;
+ }
+
+ /**
+ *
+ * @param isNegated
+ */
+ public void setNegated(boolean isNegated)
+ {
+ this.isNegated = isNegated;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Set getRoleAssoc()
+ {
+ return roleAssoc;
+ }
+
+ /**
+ *
+ * @param roleAssoc
+ */
+ public void setRoleAssoc(Set roleAssoc)
+ {
+ this.roleAssoc = roleAssoc;
+ }
+
+ /**
+ *
+ * @param roleAssoc
+ */
+ public void addRoleAssoc(PermRoleAssoc roleAssoc)
+ {
+ if(this.roleAssoc == null)
+ {
+ this.roleAssoc = new HashSet();
+ }
+ this.roleAssoc.add(roleAssoc);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Set getRoleAssocIds()
+ {
+ Set ids = new HashSet();
+ if(this.roleAssoc!=null)
+ {
+ for(Iterator itr=this.roleAssoc.iterator();itr.hasNext();)
+ {
+ PermRoleAssoc cour = (PermRoleAssoc)itr.next();
+ ids.add(new Long(cour.getRoleId()));
+ }
+ }
+ return ids;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Set getUserAssoc()
+ {
+ return userAssoc;
+ }
+
+ /**
+ *
+ * @param userAssoc
+ */
+ public void setUserAssoc(Set userAssoc)
+ {
+ this.userAssoc = userAssoc;
+ }
+
+ /**
+ *
+ * @param userAssoc
+ */
+ public void addUserAssoc(PermUserAssoc userAssoc)
+ {
+ if(this.userAssoc == null)
+ {
+ this.userAssoc = new HashSet();
+ }
+ this.userAssoc.add(userAssoc);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Set getUserAssocIds()
+ {
+ Set ids = new HashSet();
+ if(this.userAssoc!=null)
+ {
+ for(Iterator itr=this.userAssoc.iterator();itr.hasNext();)
+ {
+ PermUserAssoc cour = (PermUserAssoc)itr.next();
+ ids.add(new Long(cour.getUserId()));
+ }
+ }
+ return ids;
+ }
+
+
+ /**
+ *
+ */
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("-----------------------------\n");
+ buffer.append("ID="+this.id+"\n");
+ buffer.append("Service="+this.service+"\n");
+ buffer.append("Action="+this.action+"\n");
+ buffer.append("Negated="+this.isNegated+"\n");
+
+ //print role association
+ if(this.roleAssoc!=null)
+ {
+ for(Iterator itr=this.roleAssoc.iterator();itr.hasNext();)
+ {
+ PermRoleAssoc cour = (PermRoleAssoc)itr.next();
+ buffer.append("Role ="+cour.getRoleId()+"\n");
+ }
+ }
+
+ //print user association
+ if(this.userAssoc!=null)
+ {
+ for(Iterator itr=this.userAssoc.iterator();itr.hasNext();)
+ {
+ PermUserAssoc cour = (PermUserAssoc)itr.next();
+ buffer.append("User ="+cour.getUserId()+"\n");
+ }
+ }
+
+ //print criteria
+ if(this.criteria!=null)
+ {
+ for(Iterator itr=this.criteria.iterator();itr.hasNext();)
+ {
+ Criteria cour = (Criteria)itr.next();
+ buffer.append("Criteria ="+cour.getName()+","+cour.getValue()+"\n");
+ }
+ }
+
+ buffer.append("-----------------------------\n");
+
+ return buffer.toString();
+ }
+
+
+ /**
+ *
+ */
+ public boolean equals(Object obj)
+ {
+ boolean equals = false;
+ if(obj instanceof Permission)
+ {
+ Permission input = (Permission)obj;
+ if(input.id == this.id)
+ {
+ equals = true;
+ }
+ }
+ return equals;
+ }
+}
Added: trunk/cms/src/main/org/jboss/portal/cms/security/PermissionManager.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/security/PermissionManager.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/security/PermissionManager.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,240 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.jboss.portal.cms.security;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+
+
+import org.jboss.portal.cms.hibernate.state.Tools;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.Role;
+
+/**
+ * PermissionManager is used to manage (create,read,update,delete) permissions stored in the database
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Dec 1, 2006
+ *
+ */
+public class PermissionManager
+{
+ /**
+ * the singleton instance. This is a stateless component
+ */
+ private static PermissionManager singleton = null;
+
+ /**
+ *
+ *
+ */
+ private PermissionManager()
+ {
+ super();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static PermissionManager getInstance()
+ {
+ if(PermissionManager.singleton==null)
+ {
+ PermissionManager.singleton = new PermissionManager();
+ }
+ return PermissionManager.singleton;
+ }
+
+
+ //PermissionManager API--------------------------------------------------------------------------------------------------------------
+ /**
+ * Stores a permission and its associations into peristent storage
+ *
+ * @param permission - Permission to be persisted
+ * @param roles - Roles associated with this permission
+ * @param users - Individual users associated with this permission
+ */
+ public void store(Permission permission,Collection roles,Collection users)
+ {
+ //setup the role association
+ if(roles != null)
+ {
+ Set roleAssoc = new HashSet();
+ for(Iterator itr=roles.iterator();itr.hasNext();)
+ {
+ Role role = (Role)itr.next();
+ PermRoleAssoc cour = new PermRoleAssoc();
+ if(role.getId()!=null)
+ {
+ cour.setRoleId(((Long)role.getId()).longValue());
+ }
+ roleAssoc.add(cour);
+ }
+ permission.setRoleAssoc(roleAssoc);
+ }
+ else
+ {
+ permission.setRoleAssoc(null);
+ }
+
+
+ //setup the user association
+ if(users != null)
+ {
+ Set userAssoc = new HashSet();
+ for(Iterator itr=users.iterator();itr.hasNext();)
+ {
+ User user = (User)itr.next();
+ PermUserAssoc cour = new PermUserAssoc();
+ cour.setUserId(((Long)user.getId()).longValue());
+ userAssoc.add(cour);
+ }
+ permission.setUserAssoc(userAssoc);
+ }
+ else
+ {
+ permission.setUserAssoc(null);
+ }
+
+ //persist this into the database
+ this.store(permission);
+ }
+
+ /**
+ * Stores a permission and its associations into peristent storage
+ *
+ * @param permission - Permission to be persisted
+ */
+ public void store(Permission permission)
+ {
+ //persist this into the database
+ Session session = Tools.getCurrentSession();
+ session.saveOrUpdate(permission);
+ }
+
+ /**
+ * Deletes the specified permissions from the database
+ *
+ * @param permissions
+ */
+ public void remove(Collection permissions)
+ {
+ Session session = Tools.getCurrentSession();
+ if(permissions!=null)
+ {
+ for(Iterator itr=permissions.iterator();itr.hasNext();)
+ {
+ Permission permission = (Permission)itr.next();
+ session.delete(permission);
+ }
+ }
+ }
+
+
+ /**
+ * Returns all permissions associated with the specified user
+ *
+ * @param user
+ * @return
+ */
+ public Collection findPermissionsByUser(long userId)
+ {
+ Collection permissions = new HashSet();
+
+ String lookupByUser = "SELECT permission from Permission permission JOIN permission.userAssoc user WHERE user.userId=?";
+ String lookupByRole = "SELECT * from jbp_cms_perm p,jbp_cms_perm_role r,jbp_role_membership m WHERE " +
+ "p.id=r.cms_perm_id AND " +
+ "r.role_id=m.jbp_rid AND " +
+ "m.jbp_uid=?";
+
+ Session session = Tools.getCurrentSession();
+
+ //perform lookup by explicitly specified users
+ Query userQuery = session.createQuery(lookupByUser);
+ userQuery.setLong(0,userId);
+ userQuery.setCacheable(true);
+ permissions.addAll(userQuery.list());
+
+
+ //perform lookup based on role membership
+ Query roleQuery = session.createSQLQuery(lookupByRole).addEntity(Permission.class);
+ roleQuery.setLong(0,userId);
+ roleQuery.setCacheable(true);
+ permissions.addAll(roleQuery.list());
+
+ return permissions;
+ }
+
+ /**
+ * Returns all permissions associated with the specified role
+ *
+ * @param role
+ * @return
+ */
+ public Collection findPermissionsByRole(long roleId)
+ {
+ Collection permissions = new HashSet();
+
+ String lookupByRole = "SELECT permission from Permission permission JOIN permission.roleAssoc role WHERE role.roleId=?";
+
+ Session session = Tools.getCurrentSession();
+
+ //perform lookup by explicitly specified users
+ Query roleQuery = session.createQuery(lookupByRole);
+ roleQuery.setLong(0,roleId);
+ roleQuery.setCacheable(true);
+ permissions.addAll(roleQuery.list());
+
+
+ return permissions;
+ }
+
+ /**
+ * Return all permissions that match the specified criteria
+ *
+ * @param criteria
+ * @return
+ */
+ public Collection findPermissionsByCriteria(Criteria criteria)
+ {
+ Collection permissions = new HashSet();
+
+ String lookupByCriteria = "SELECT permission from Permission permission JOIN permission.criteria criteria WHERE criteria.name=? AND criteria.value=?";
+
+ Session session = Tools.getCurrentSession();
+
+ //perform lookup by explicitly specified users
+ Query criteriaQuery = session.createQuery(lookupByCriteria);
+ criteriaQuery.setString(0,criteria.getName());
+ criteriaQuery.setString(1,criteria.getValue());
+ criteriaQuery.setCacheable(true);
+ permissions.addAll(criteriaQuery.list());
+
+
+ return permissions;
+ }
+}
Added: trunk/cms/src/main/org/jboss/portal/cms/security/PortalSecurityContext.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/security/PortalSecurityContext.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/security/PortalSecurityContext.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,108 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.jboss.portal.cms.security;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.portal.identity.User;
+
+/**
+ * An implementation of SecurityContext for the core Portal Engine
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Nov 27, 2006
+ *
+ */
+public class PortalSecurityContext implements SecurityContext
+{
+ private Map contextMap = null;
+
+ /**
+ * signifies the user currently logged in to the system
+ */
+ private User portalUser = null;
+
+
+ /**
+ *
+ *
+ */
+ public PortalSecurityContext(User portalUser)
+ {
+ super();
+ this.portalUser = portalUser;
+ this.contextMap = new HashMap();
+ }
+
+ /**
+ * This method returns the Identity of the user logged into the portal. The return value is of type
+ * org.jboss.portal.identity.User
+ *
+ * @return Identity related information associated with the user logged into the portal
+ */
+ public Object getIdentity()
+ {
+ return this.portalUser;
+ }
+
+ /**
+ * Returns value corresponding to the specified attribute name
+ *
+ * @param name
+ * @return
+ */
+ public Object getAttribute(String name)
+ {
+ return this.contextMap.get(name);
+ }
+
+ /**
+ * Sets a specified value corresponding to the specified name in the context
+ *
+ * @param name
+ * @param value
+ */
+ public void setAttribute(String name,Object value)
+ {
+ this.contextMap.put(name,value);
+ }
+
+ /**
+ * Removes the specified attribute
+ *
+ * @param name
+ */
+ public void removeAttribute(String name)
+ {
+ this.contextMap.remove(name);
+ }
+
+ /**
+ * Returns an array of Strings consisting of all keys/names stored in the context
+ *
+ * @return
+ */
+ public String[] getAttributeNames()
+ {
+ return (String[])this.contextMap.keySet().toArray();
+ }
+}
Added: trunk/cms/src/main/org/jboss/portal/cms/security/SecurityContext.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/security/SecurityContext.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/cms/security/SecurityContext.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,69 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.jboss.portal.cms.security;
+
+/**
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Nov 27, 2006
+ *
+ */
+public interface SecurityContext
+{
+ /**
+ * This method returns the Identity of the user logged into the portal.
+ *
+ * @return Identity related information associated with the user logged into the portal
+ */
+ public Object getIdentity();
+
+ /**
+ * Returns value corresponding to the specified attribute name
+ *
+ * @param name
+ * @return
+ */
+ public Object getAttribute(String name);
+
+
+ /**
+ * Sets a specified value corresponding to the specified name in the context
+ *
+ * @param name
+ * @param value
+ */
+ public void setAttribute(String name,Object value);
+
+ /**
+ * Removes the specified attribute
+ *
+ * @param name
+ */
+ public void removeAttribute(String name);
+
+
+ /**
+ * Returns an array of Strings consisting of all keys/names stored in the context
+ *
+ * @return
+ */
+ public String[] getAttributeNames();
+}
Added: trunk/cms/src/main/org/jboss/portal/test/cms/commands/CMSInterceptorStackFactory.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/test/cms/commands/CMSInterceptorStackFactory.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/test/cms/commands/CMSInterceptorStackFactory.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.jboss.portal.test.cms.commands;
+
+import org.jboss.portal.server.impl.invocation.JBossInterceptorStackFactory;
+import org.jboss.portal.common.invocation.InterceptorStack;
+
+public class CMSInterceptorStackFactory extends JBossInterceptorStackFactory
+{
+
+ public CMSInterceptorStackFactory()
+ {
+ super();
+ }
+
+ public void setInterceptorStack(InterceptorStack stack)
+ {
+ this.stack = stack;
+ }
+
+}
Added: trunk/cms/src/main/org/jboss/portal/test/cms/commands/SecureCommandTestCase.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/test/cms/commands/SecureCommandTestCase.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/test/cms/commands/SecureCommandTestCase.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., 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.jboss.portal.test.cms.commands;
+
+import org.jboss.portal.cms.impl.interceptors.ACLInterceptor;
+import org.jboss.portal.common.invocation.Interceptor;
+import org.jboss.portal.server.impl.invocation.JBossInterceptorStack;
+
+/**
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Nov 30, 2006
+ *
+ */
+public class SecureCommandTestCase extends AbstractCommandTestCase
+{
+ /**
+ *
+ *
+ */
+ public SecureCommandTestCase()
+ {
+ super();
+ }
+
+ /**
+ *
+ */
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ //setup the interceptor stack
+ CMSInterceptorStackFactory stackFactory = new CMSInterceptorStackFactory();
+ ACLInterceptor aclInterceptor = new ACLInterceptor();
+ aclInterceptor.setAuthorizationProviderClass("org.jboss.portal.cms.impl.jcr.command.ACLEnforcer");
+ Interceptor[] interceptors = new Interceptor[1];
+ interceptors[0] = aclInterceptor;
+ JBossInterceptorStack stack = new JBossInterceptorStack(interceptors);
+ stackFactory.setInterceptorStack(stack);
+
+ service.setStackFactory(stackFactory);
+ }
+}
Added: trunk/cms/src/main/org/jboss/portal/test/cms/commands/TestSecureFileGet.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/test/cms/commands/TestSecureFileGet.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/main/org/jboss/portal/test/cms/commands/TestSecureFileGet.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.jboss.portal.test.cms.commands;
+
+import junit.framework.TestSuite;
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.impl.ContentImpl;
+import org.jboss.portal.cms.impl.FileImpl;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.cms.model.File;
+
+import java.util.Locale;
+import java.util.Map;
+
+
+/**
+ *
+ * @author Sohil Shah - sohil.shah(a)jboss.com - Nov 30, 2006
+ *
+ */
+public class TestSecureFileGet extends SecureCommandTestCase
+{
+ String rejectPath = "/default/private/license.html";
+ String allowedPath = "/default/images/check.gif";
+
+
+ /**
+ *
+ *
+ */
+ public TestSecureFileGet()
+ {
+ }
+
+ /**
+ *
+ *
+ */
+ public static TestSuite suite() throws Exception
+ {
+ return createTestSuite(TestSecureFileGet.class);
+ }
+
+ /** Tests retrieval of the version labeled LIVE. */
+ public void testFileGet() throws CMSException
+ {
+ //first run against non-access scenario
+ try
+ {
+ Command getCMD = service.getCommandFactory().createFileGetCommand(rejectPath,Locale.ENGLISH);
+ File newfile = (File)service.execute(getCMD);
+ }
+ catch(CMSException cme)
+ {
+ //assert and make sure access was not granted
+ String cmeMessage = cme.toString();
+ boolean accessGranted = true;
+ if(cmeMessage.indexOf("Access to this resource is denied")!=-1)
+ {
+ accessGranted = false;
+ }
+ this.assertEquals(false,accessGranted);
+ }
+
+ //now run against scenario where access should be granted
+ try
+ {
+ Command getCMD = service.getCommandFactory().createFileGetCommand(allowedPath,Locale.ENGLISH);
+ File newfile = (File)service.execute(getCMD);
+ }
+ catch(CMSException cme)
+ {
+ //assert and make sure access was granted
+ String cmeMessage = cme.toString();
+ boolean accessGranted = true;
+ if(cmeMessage.indexOf("Access to this resource is denied")!=-1)
+ {
+ accessGranted = false;
+ }
+ this.assertEquals(true,accessGranted);
+ }
+ }
+}
Modified: trunk/cms/src/resources/hibernate/domain.hbm.xml
===================================================================
--- trunk/cms/src/resources/hibernate/domain.hbm.xml 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/resources/hibernate/domain.hbm.xml 2006-12-12 04:59:21 UTC (rev 5806)
@@ -274,5 +274,96 @@
type="long"
not-null="true"/>
</class>
+
+ <!-- mapping to persist CMS Fine Grained Security related objects -->
+ <class name="org.jboss.portal.cms.security.PermRoleAssoc" table="jbp_cms_perm_role">
+ <id
+ name="id"
+ column="ID"
+ type="java.lang.Long">
+ <generator class="native"/>
+ </id>
+ <property
+ name="roleId"
+ column="ROLE_ID"
+ type="long"
+ not-null="true"
+ />
+ </class>
+ <class name="org.jboss.portal.cms.security.PermUserAssoc" table="jbp_cms_perm_user">
+ <id
+ name="id"
+ column="ID"
+ type="java.lang.Long">
+ <generator class="native"/>
+ </id>
+ <property
+ name="userId"
+ column="USER_ID"
+ type="long"
+ not-null="true"
+ />
+ </class>
+ <class name="org.jboss.portal.cms.security.Permission" table="jbp_cms_perm">
+ <id
+ name="id"
+ column="ID"
+ type="java.lang.Long">
+ <generator class="native"/>
+ </id>
+ <!-- one-to-many association with the criteria object -->
+ <set name="criteria" lazy="true" table="jbp_cms_perm_criteria" cascade="all">
+ <key column="CMS_PERM_ID"/>
+ <one-to-many class="org.jboss.portal.cms.security.Criteria"/>
+ </set>
+ <!-- many-to-many association with the role object -->
+ <set name="roleAssoc" lazy="true" cascade="all">
+ <key column="CMS_PERM_ID"/>
+ <one-to-many class="org.jboss.portal.cms.security.PermRoleAssoc"/>
+ </set>
+ <!-- many-to-many association with the user object -->
+ <set name="userAssoc" lazy="true" cascade="all">
+ <key column="CMS_PERM_ID"/>
+ <one-to-many class="org.jboss.portal.cms.security.PermUserAssoc"/>
+ </set>
+ <property
+ name="name"
+ column="NAME"
+ type="string"
+ not-null="true"
+ />
+ <property
+ name="action"
+ column="ACTION"
+ type="string"
+ not-null="true"
+ />
+ <property
+ name="negated"
+ column="NEGATED"
+ type="boolean"
+ not-null="true"
+ />
+ </class>
+ <class name="org.jboss.portal.cms.security.Criteria" table="jbp_cms_perm_criteria">
+ <id
+ name="id"
+ column="ID"
+ type="java.lang.Long">
+ <generator class="native"/>
+ </id>
+ <property
+ name="name"
+ column="NAME"
+ type="string"
+ not-null="true"
+ />
+ <property
+ name="value"
+ column="VALUE"
+ type="string"
+ not-null="true"
+ />
+ </class>
</hibernate-mapping>
Added: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/back.gif
===================================================================
(Binary files differ)
Property changes on: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/back.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/check.gif
===================================================================
(Binary files differ)
Property changes on: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/check.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/homeimg_cornerelement.gif
===================================================================
(Binary files differ)
Property changes on: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/homeimg_cornerelement.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/homeimg_jbosslogo.gif
===================================================================
(Binary files differ)
Property changes on: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/homeimg_jbosslogo.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/homeimg_main.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/homeimg_main.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/logo.gif
===================================================================
(Binary files differ)
Property changes on: trunk/cms/src/resources/portal-cms-sar/default-content/default/images/logo.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/cms/src/resources/portal-cms-sar/default-content/default/index.html
===================================================================
--- trunk/cms/src/resources/portal-cms-sar/default-content/default/index.html 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/resources/portal-cms-sar/default-content/default/index.html 2006-12-12 04:59:21 UTC (rev 5806)
@@ -1 +1,102 @@
-This is the default index.html page for JBoss Portal JCR CMS.
\ No newline at end of file
+<style type="text/css">
+ #welcomelogo {
+ float: left;
+ margin: 30px 0px 30px 15px;
+ }
+
+ #welcometext {
+ margin: 30px 50px 30px 225px;
+ }
+
+ #welcomegreybox {
+ background-color: #f4f4f4;
+ padding: 15px;
+ margin-bottom: 30px;
+ }
+
+ #welcomegreyboxTD {
+ border-left: 1px solid #d5d5d5;
+ padding-left: 15px;
+ }
+
+ #welcomegreybox h3 {
+ color: #5078aa;
+ font: bold 13px Helvetica, Arial, sans-serif;
+ }
+</style>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="560"><img src="default/images/homeimg_main.jpg" width="560" height="160"/></td>
+ <td align="right" valign="top" bgcolor="#7AB5E0"><img src="default/images/homeimg_cornerelement.gif" width="2"
+ height="2"/></td>
+ </tr>
+</table>
+<div id="welcomelogo"><img src="default/images/homeimg_jbosslogo.gif" width="143" height="64"/></div>
+<p id="welcometext">JBoss Portal provides an open source platform for hosting and serving a portal Web interface,
+ publishing and managing its content, and customizing its experience. While most packaged Portal frameworks help
+ enterprises launch Portals more quickly, only JBoss Portal delivers the benefits of a zero-cost open source license
+ combined with a flexible and scalable underling platform.</p>
+
+<div id="welcomegreybox">
+ <table width="100%">
+ <tr>
+ <td valign="top"><h3>Support Services</h3>
+
+ <p>JBoss Inc. offers various support services tailored to fit your needs. <a href="default/support.html">Explore</a>
+ support and service options for JBoss Portal.</p></td>
+ <td valign="top" id="welcomegreyboxTD"><h3>PortletSwap</h3>
+
+ <p><a href="http://www.portletswap.com" target="_blank">Portletswap.com</a> is an open community sponsored
+ by JBoss, Inc. to facilitate the exchange of portlets and layouts for use in JBoss Portal.</p></td>
+ <td valign="top" id="welcomegreyboxTD"><h3>Project Information</h3>
+
+ <p>Learn more about the <a href="default/project.html">JBoss Portal project</a>, on-going development, open
+ issues, and our
+ user and developer communities.</p></td>
+ </tr>
+ </table>
+
+</div>
+<p>Thank you for downloading and deploying JBoss Portal. We hope your enjoy working with it as much as we enjoy
+ developing it!</p>
+<p>Baci e abbracci,<br/>
+ The JBoss Portal Team.</p>
+
+<!--
+<table width="100%" border="0" cellpadding="2">
+<tr>
+<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font">JBoss Portal provides an open source platform for hosting and serving a portal's Web interface, publishing and managing its content, and customizing its experience. While most packaged Portal frameworks help enterprises launch Portals more quickly, only JBoss Portal delivers the benefits of a zero-cost open source license combined with a flexible and scalable underlying platform.</font></td>
+<td valign="top" align="right"><img src="default/images/jboss_logo.gif"></td>
+<tr>
+<td colspan="2"><table width="100%" border="0">
+<tr>
+<td align="left" valign="top" width="64" class="portlet-section-alternate"><a href="default/support.html"><img src="default/images/support.gif" border="0"></a></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font"><b>Support Services</b><br/>
+JBoss Inc. offers various support services tailored to fit your needs. <a href="default/support.html">Click here</a> to explore support and service options related to JBoss Portal.
+</font></td>
+</tr>
+<tr>
+<td align="left" valign="top" width="64" class="portlet-section-alternate"><a href="http://www.portletswap.com" target="_blank"><img src="default/images/plugin.gif" border="0"></a></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font"><b>PortletSwap</b><br/>
+<a href="http://www.portletswap.com" target="_blank">PortletSwap.com</a> is a open community sponsored by JBoss, Inc. to facilitate the exchange of portlets and layouts for use in JBoss Portal. <a href="http://www.portletswap.com" target="_blank">Click here</a> to visit PortletSwap.com.
+</font></td>
+</tr>
+<tr>
+<td align="left" valign="top" width="64" class="portlet-section-alternate"><a href="default/project.html"><img src="default/images/project.gif" border="0"></a></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font"><b>Project Information</b><br/>
+<a href="default/project.html">Click here</a> to learn more about the JBoss Portal project, on-going development, open issues, and our vibrant user and developer communities.
+</font></td>
+</tr>
+</table>
+</tr>
+<tr>
+<td colspan="2" align="left" class="portlet-section-body"><font class="portlet-font">
+Thank you for downloading and deploying JBoss Portal. We hope you enjoy working with it as much as we enjoy developing it!
+<br/><br/>
+Bacci e Abracci,<br/>
+The JBoss Portal Team.
+</font></td>
+</tr>
+</table>
+-->
Added: trunk/cms/src/resources/portal-cms-sar/default-content/default/private/license.html
===================================================================
--- trunk/cms/src/resources/portal-cms-sar/default-content/default/private/license.html 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/resources/portal-cms-sar/default-content/default/private/license.html 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,38 @@
+<!-- begin: portlet content -->
+<table width="100%" border="0" cellpadding="2">
+<tr>
+<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font">JBoss Inc. delivers the Professional Support, Consulting, and Training that you need whether you are testing a proof of concept, deploying a mission-critical application, or rolling out JEMS across your enterprise. </font></td>
+<td valign="top" align="right"><img src="default/images/jboss_logo.gif"></td>
+</tr>
+<tr>
+<td colspan="2">
+<table width="100%" border="0" cellpadding="2">
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/profsupport" target="_blank">Professional Support</a>
+<br/>
+The JBoss Subscription is a set of services and tools that assist you during every stage of the application lifecycle - from design and development, thru testing and deployment, to on-going management and monitoring of your enterprise application deployments. JBoss Subscriptions allow you to reduce business, legal, and technical risks while enabling you to more effectively utilize your team's resources. A JBoss Subscription will ensure that you achieve a much greater success rate for all of your JEMS-based projects.
+</font></td>
+</tr>
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/consulting" target="_blank">Consulting Services</a>
+<br/>
+JBoss offers short-term on-site JEMS consulting engagements that provide you expert assistance at various stages of the application lifecycle. All engagements are delivered by certified JEMS consultants.
+</font></td>
+</tr>
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/training" target="_blank">Training and Certification</a>
+<br/>
+A Certified JBoss Web Developer is capable of implementing presentation tier components for J2EE applications. They have the base knowledge on Servlet and JSP technology, Portlet specification, Tomcat Servlet container and JBoss Portal. A Certified JBoss Developer for web tier is able to implement and deploy presentation components (Web Archives) on Tomcat server and Portlet components on JBoss Portal implementation.
+</font></td>
+</tr>
+</table>
+</table>
+<br/>
+<a href="default/index.html"><img src="default/images/back.gif" border="0" alt="back"></a>
+<!-- end: portlet content -->
\ No newline at end of file
Added: trunk/cms/src/resources/portal-cms-sar/default-content/default/project.html
===================================================================
--- trunk/cms/src/resources/portal-cms-sar/default-content/default/project.html 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/resources/portal-cms-sar/default-content/default/project.html 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,69 @@
+<!-- begin: portlet content -->
+<table width="100%" border="0" cellpadding="2">
+ <tr>
+ <td valign="top" align="left" class="portlet-section-body"><font class="portlet-font">JBoss Inc. delivers the
+ Professional Support, Consulting, and Training that you need whether you are testing a proof of concept,
+ deploying a mission-critical application, or rolling out JEMS across your enterprise. </font></td>
+ <td valign="top" align="right"><img src="default/images/jboss_logo.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <table width="100%" border="0" cellpadding="2">
+ <tr>
+ <td class="portlet-section-alternate" width="16" valign="top" align="left"><img
+ src="default/images/check.gif"></td>
+ <td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+ <a href="http://labs.jboss.com/portal/jbossportal/index.html" target="_blank">JBoss Portal Home</a>
+ <br/>
+ The Epicenter of everything JBoss Portal.</font></td>
+ </tr>
+ <tr>
+ <td class="portlet-section-alternate" width="16" valign="top" align="left"><img
+ src="default/images/check.gif"></td>
+ <td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+ <a href="http://labs.jboss.com/portal/jbossportal/docs/index.html" target="_blank">Documentation</a>
+ <br/>
+ Here you will find user documentation, reference documentation, tutorials, and javadoc.</font></td>
+ </tr>
+ <tr>
+ <td class="portlet-section-alternate" width="16" valign="top" align="left"><img
+ src="default/images/check.gif"></td>
+ <td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+ <a href="http://www.jboss.com/index.html?module=bb&op=viewforum&f=215" target="_blank">Forums</a>
+ <br/>
+ Our forums are the main channel of communication between all community
+ members. If you have any questions or concerns, please use
+ our <a href="http://www.jboss.org/index.html?module=bb&op=viewforum&f=215" target="_blank">User
+ Forums</a>, <a href="/index.html?module=bb&op=viewforum&f=205" target="_blank">Developer
+ Forums</a>, or <a href="http://jboss.org/index.html?module=bb&op=viewforum&f=232" target="_blank">WSRP Forums</a> to voice them. Project developers and community members are always there to help.
+ </font></td>
+ </tr>
+ <tr>
+ <td class="portlet-section-alternate" width="16" valign="top" align="left"><img
+ src="default/images/check.gif"></td>
+ <td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+ <a href="http://www.jboss.com/wiki/Wiki.jsp?page=JBossPortal" target="_blank">Wiki</a>
+ <br/>
+ Our wiki knowledge base is a user and developer contributed collection of important resources regarding
+ JBoss Portal.</font></td>
+ </tr>
+ <tr>
+ <td class="portlet-section-alternate" width="16" valign="top" align="left"><img
+ src="default/images/check.gif"></td>
+ <td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+ <a href="http://jira.jboss.com/jira/secure/BrowseProject.jspa?id=10050" target="_blank">Jira</a>
+ <br/>
+ JBoss Portal uses the JIRA tracking and project management system to organize and prioritize tasks.<br>
+ <a href="http://jira.jboss.com/jira/secure/BrowseProject.jspa?id=10050" target="_blank">JBoss Portal</a>
+ | <a
+ href="http://jira.jboss.com/jira/browse/JBPORTAL?report=com.atlassian.jira.plug..."
+ target="_blank">Open Issues</a>
+ | <a
+ href="http://jira.jboss.com/jira/browse/JBPORTAL?report=com.atlassian.jira.plug..."
+ target="_blank">Roadmap</a></font></td>
+ </tr>
+ </table>
+</table>
+<br/>
+<a href="default/index.html"><img src="default/images/back.gif" border="0" alt="back"></a>
+<!-- end: portlet content -->
Added: trunk/cms/src/resources/portal-cms-sar/default-content/default/support.html
===================================================================
--- trunk/cms/src/resources/portal-cms-sar/default-content/default/support.html 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/cms/src/resources/portal-cms-sar/default-content/default/support.html 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,38 @@
+<!-- begin: portlet content -->
+<table width="100%" border="0" cellpadding="2">
+<tr>
+<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font">JBoss Inc. delivers the Professional Support, Consulting, and Training that you need whether you are testing a proof of concept, deploying a mission-critical application, or rolling out JEMS across your enterprise. </font></td>
+<td valign="top" align="right"><img src="default/images/jboss_logo.gif"></td>
+</tr>
+<tr>
+<td colspan="2">
+<table width="100%" border="0" cellpadding="2">
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/profsupport" target="_blank">Professional Support</a>
+<br/>
+The JBoss Subscription is a set of services and tools that assist you during every stage of the application lifecycle - from design and development, thru testing and deployment, to on-going management and monitoring of your enterprise application deployments. JBoss Subscriptions allow you to reduce business, legal, and technical risks while enabling you to more effectively utilize your team's resources. A JBoss Subscription will ensure that you achieve a much greater success rate for all of your JEMS-based projects.
+</font></td>
+</tr>
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/consulting" target="_blank">Consulting Services</a>
+<br/>
+JBoss offers short-term on-site JEMS consulting engagements that provide you expert assistance at various stages of the application lifecycle. All engagements are delivered by certified JEMS consultants.
+</font></td>
+</tr>
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/training" target="_blank">Training and Certification</a>
+<br/>
+A Certified JBoss Web Developer is capable of implementing presentation tier components for J2EE applications. They have the base knowledge on Servlet and JSP technology, Portlet specification, Tomcat Servlet container and JBoss Portal. A Certified JBoss Developer for web tier is able to implement and deploy presentation components (Web Archives) on Tomcat server and Portlet components on JBoss Portal implementation.
+</font></td>
+</tr>
+</table>
+</table>
+<br/>
+<a href="default/index.html"><img src="default/images/back.gif" border="0" alt="back"></a>
+<!-- end: portlet content -->
\ No newline at end of file
Added: trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/code.html
===================================================================
--- trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/code.html 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/code.html 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,38 @@
+<!-- begin: portlet content -->
+<table width="100%" border="0" cellpadding="2">
+<tr>
+<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font"><b>Document2: This is a protected document. This is used to test the fine grained access control</b></font></td>
+<td valign="top" align="right"><img src="default/images/jboss_logo.gif"></td>
+</tr>
+<tr>
+<td colspan="2">
+<table width="100%" border="0" cellpadding="2">
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/profsupport" target="_blank">Professional Support</a>
+<br/>
+The JBoss Subscription is a set of services and tools that assist you during every stage of the application lifecycle - from design and development, thru testing and deployment, to on-going management and monitoring of your enterprise application deployments. JBoss Subscriptions allow you to reduce business, legal, and technical risks while enabling you to more effectively utilize your team's resources. A JBoss Subscription will ensure that you achieve a much greater success rate for all of your JEMS-based projects.
+</font></td>
+</tr>
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/consulting" target="_blank">Consulting Services</a>
+<br/>
+JBoss offers short-term on-site JEMS consulting engagements that provide you expert assistance at various stages of the application lifecycle. All engagements are delivered by certified JEMS consultants.
+</font></td>
+</tr>
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/training" target="_blank">Training and Certification</a>
+<br/>
+A Certified JBoss Web Developer is capable of implementing presentation tier components for J2EE applications. They have the base knowledge on Servlet and JSP technology, Portlet specification, Tomcat Servlet container and JBoss Portal. A Certified JBoss Developer for web tier is able to implement and deploy presentation components (Web Archives) on Tomcat server and Portlet components on JBoss Portal implementation.
+</font></td>
+</tr>
+</table>
+</table>
+<br/>
+<a href="default/index.html"><img src="default/images/back.gif" border="0" alt="back"></a>
+<!-- end: portlet content -->
\ No newline at end of file
Added: trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/confidential/license.html
===================================================================
--- trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/confidential/license.html 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/confidential/license.html 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,38 @@
+<!-- begin: portlet content -->
+<table width="100%" border="0" cellpadding="2">
+<tr>
+<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font"><b>Document3: This is a protected document. This is used to test the fine grained access control</b></font></td>
+<td valign="top" align="right"><img src="default/images/jboss_logo.gif"></td>
+</tr>
+<tr>
+<td colspan="2">
+<table width="100%" border="0" cellpadding="2">
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/profsupport" target="_blank">Professional Support</a>
+<br/>
+The JBoss Subscription is a set of services and tools that assist you during every stage of the application lifecycle - from design and development, thru testing and deployment, to on-going management and monitoring of your enterprise application deployments. JBoss Subscriptions allow you to reduce business, legal, and technical risks while enabling you to more effectively utilize your team's resources. A JBoss Subscription will ensure that you achieve a much greater success rate for all of your JEMS-based projects.
+</font></td>
+</tr>
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/consulting" target="_blank">Consulting Services</a>
+<br/>
+JBoss offers short-term on-site JEMS consulting engagements that provide you expert assistance at various stages of the application lifecycle. All engagements are delivered by certified JEMS consultants.
+</font></td>
+</tr>
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/training" target="_blank">Training and Certification</a>
+<br/>
+A Certified JBoss Web Developer is capable of implementing presentation tier components for J2EE applications. They have the base knowledge on Servlet and JSP technology, Portlet specification, Tomcat Servlet container and JBoss Portal. A Certified JBoss Developer for web tier is able to implement and deploy presentation components (Web Archives) on Tomcat server and Portlet components on JBoss Portal implementation.
+</font></td>
+</tr>
+</table>
+</table>
+<br/>
+<a href="default/index.html"><img src="default/images/back.gif" border="0" alt="back"></a>
+<!-- end: portlet content -->
\ No newline at end of file
Added: trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/license.html
===================================================================
--- trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/license.html 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/bin/portal-cms-sar/portal/cms/conf/default-content/default/private/license.html 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,38 @@
+<!-- begin: portlet content -->
+<table width="100%" border="0" cellpadding="2">
+<tr>
+<td valign="top" align="left" class="portlet-section-body"><font class="portlet-font"><b>Document1: This is a protected document. This is used to test the fine grained access control</b></font></td>
+<td valign="top" align="right"><img src="default/images/jboss_logo.gif"></td>
+</tr>
+<tr>
+<td colspan="2">
+<table width="100%" border="0" cellpadding="2">
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/profsupport" target="_blank">Professional Support</a>
+<br/>
+The JBoss Subscription is a set of services and tools that assist you during every stage of the application lifecycle - from design and development, thru testing and deployment, to on-going management and monitoring of your enterprise application deployments. JBoss Subscriptions allow you to reduce business, legal, and technical risks while enabling you to more effectively utilize your team's resources. A JBoss Subscription will ensure that you achieve a much greater success rate for all of your JEMS-based projects.
+</font></td>
+</tr>
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/consulting" target="_blank">Consulting Services</a>
+<br/>
+JBoss offers short-term on-site JEMS consulting engagements that provide you expert assistance at various stages of the application lifecycle. All engagements are delivered by certified JEMS consultants.
+</font></td>
+</tr>
+<tr>
+<td class="portlet-section-alternate" width="16" valign="top" align="left"><img src="default/images/check.gif"></td>
+<td align="left" valign="top" class="portlet-section-alternate"><font class="portlet-font">
+<a href="http://www.jboss.com/services/training" target="_blank">Training and Certification</a>
+<br/>
+A Certified JBoss Web Developer is capable of implementing presentation tier components for J2EE applications. They have the base knowledge on Servlet and JSP technology, Portlet specification, Tomcat Servlet container and JBoss Portal. A Certified JBoss Developer for web tier is able to implement and deploy presentation components (Web Archives) on Tomcat server and Portlet components on JBoss Portal implementation.
+</font></td>
+</tr>
+</table>
+</table>
+<br/>
+<a href="default/index.html"><img src="default/images/back.gif" border="0" alt="back"></a>
+<!-- end: portlet content -->
\ No newline at end of file
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -253,6 +253,15 @@
}
sb.append(" | ");
+
+ //inject CMS Admin link
+ if(user != null && showadminURL == null)
+ {
+ sb.append("<a href=\"").append("/portal/portal/cms").append("\">CMS Admin Tool</a>");
+ }
+
+ sb.append(" | ");
+
sb.append("<a href=\"").append(logoutURL).append("\">Logout</a>");
}
return sb;
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -23,6 +23,7 @@
package org.jboss.portal.core.aspects.server;
import org.jboss.logging.Logger;
+import org.jboss.portal.cms.impl.jcr.JCRCMS;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.core.CoreConstants;
import org.jboss.portal.identity.NoSuchUserException;
@@ -170,6 +171,10 @@
{
// Attach the request user to the invocation
invocation.getRequest().setUser(user);
+
+ //setup the portal user information to be used by the CMS Business Layer
+ //for fine grained access control enforcement
+ JCRCMS.getUserInfo().set(user);
// Continue the invocation
invocation.invokeNext();
Modified: trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -148,7 +148,16 @@
}
catch (CMSException e)
{
- log.error("CMS error", e);
+ if(e.toString().indexOf("Access to this resource is denied")!=-1)
+ {
+ ParametersStateString parameters = new ParametersStateString();
+ parameters.setValue("path", portalRequestPath);
+ return new InvokePortletWindowRenderCommand(targetWindowId, Mode.VIEW, null, parameters);
+ }
+ else
+ {
+ log.error("CMS error", e);
+ }
}
return null; // TODO: 404?
}
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/cms/CMSPortlet.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -140,11 +140,12 @@
public void doView(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
{
+ String path = null;
try
{
// String linkMode = req.getPreferences().getValue("linkMode", LINK_MODE_PORTLET);
// boolean useCMSLink = LINK_MODE_CMS.equals(linkMode);
- String path = req.getParameter("path");
+ path = req.getParameter("path");
if (path == null)
{
PortletPreferences prefs = req.getPreferences();
@@ -245,7 +246,26 @@
}
catch (CMSException e)
{
- log.error("CMS error", e);
+ if(e.toString().indexOf("Access to this resource is denied")!=-1)
+ {
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+ String sHTML = "";
+ if(path==null || path.trim().length()==0)
+ {
+ sHTML = "<h2>Access Denied</h2>You are not allowed to access the following resource";
+ }
+ else
+ {
+ sHTML = "<h2>Access Denied</h2>You are not allowed to access the following resource - "+path;
+ }
+ writer.write(sHTML);
+ writer.close();
+ }
+ else
+ {
+ log.error("CMS error", e);
+ }
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java 2006-12-12 04:59:21 UTC (rev 5806)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.core.portlet.cms.admin;
+import javax.portlet.PortletRequest;
+
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.portlet.PortletFileUpload;
@@ -37,6 +39,10 @@
import org.jboss.portal.cms.model.Folder;
import org.jboss.portal.cms.util.FileUtil;
import org.jboss.portal.cms.util.NodeUtil;
+import org.jboss.portal.cms.security.PermissionManager;
+import org.jboss.portal.cms.security.Permission;
+import org.jboss.portal.cms.security.Criteria;
+
import org.jboss.portal.core.cms.StreamContentCommand;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.identity.IdentityException;
@@ -50,22 +56,31 @@
import org.jboss.portlet.JBossRenderRequest;
import org.jboss.portlet.JBossRenderResponse;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.db.RoleImpl;
+
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletSession;
import javax.portlet.UnavailableException;
import java.io.IOException;
import java.io.InputStream;
+import java.io.PrintWriter;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.Vector;
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.HashSet;
/**
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:sohil.shah@jboss.com">Sohil Shah</a>
*/
public class CMSAdminPortlet extends JBossPortlet
{
@@ -96,13 +111,52 @@
protected void doView(final JBossRenderRequest rReq, final JBossRenderResponse rRes)
throws PortletException, IOException, UnavailableException
{
+ //check and make sure the CMSAdminPortlet is accessible to the current user
+ if(!this.isPortletAccessible(rReq))
+ {
+ rRes.setContentType("text/html");
+ PrintWriter writer = rRes.getWriter();
+ String sHTML = "<h2>Access Denied</h2>";
+ writer.write(sHTML);
+ writer.close();
+ return;
+ }
+
+
+ //now if the security console is being launched...make sure proper access is fulfilled
+ String op = rReq.getParameter("op");
+ if(op!=null && CMSAdminConstants.OP_CONFIRMSECURE.equals(op))
+ {
+ if(!this.isSecurityConsoleAccessible(rReq))
+ {
+ rRes.setContentType("text/html");
+ PrintWriter writer = rRes.getWriter();
+ String sHTML = "<h2>Access Denied</h2>";
+ writer.write(sHTML);
+ writer.close();
+ return;
+ }
+ }
+
+
try
{
- internalDoView(rReq, rRes);
+ if(rReq.getParameter("accessDenied")!=null)
+ {
+ throw new PortletException("Access to this resource is denied");
+ }
+ internalDoView(rReq, rRes);
}
catch (CMSException e)
{
- throw new PortletException(e);
+ if(e.toString().indexOf("Access to this resource is denied")!=-1)
+ {
+ throw new PortletException("Access to this resource is denied");
+ }
+ else
+ {
+ throw new PortletException(e);
+ }
}
}
@@ -380,15 +434,33 @@
{
String sPath = rReq.getParameter("path");
String sConfirm = rReq.getParameter("confirm");
+ String returnOp = rReq.getParameter("returnOp");
Set roleSet;
Set userSet;
+ Set readRoleSet;
+ Set readUserSet;
+ Set writeRoleSet;
+ Set writeUserSet;
+ Set manageRoleSet;
+ Set manageUserSet;
try
{
roleSet = roleModule.findRoles();
userSet = userModule.findUsers(0, 1000);
- // TODO: get roles/users from DB and mark certain ones selected.
+ Collection permissions = PermissionManager.getInstance().
+ findPermissionsByCriteria(new Criteria("path",sPath));
+
+ readRoleSet = this.processRolePermissions(permissions,"read");
+ readUserSet = this.processUserPermissions(permissions,"read");
+
+ writeRoleSet = this.processRolePermissions(permissions,"write");
+ writeUserSet = this.processUserPermissions(permissions,"write");
+
+ manageRoleSet = this.processRolePermissions(permissions,"manage");
+ manageUserSet = this.processUserPermissions(permissions,"manage");
+
}
catch (IdentityException ie)
{
@@ -400,6 +472,15 @@
rReq.setAttribute("roles", roleSet);
rReq.setAttribute("users", userSet);
+ rReq.setAttribute("readRoleSet",readRoleSet);
+ rReq.setAttribute("readUserSet",readUserSet);
+ rReq.setAttribute("writeRoleSet",writeRoleSet);
+ rReq.setAttribute("writeUserSet",writeUserSet);
+ rReq.setAttribute("manageRoleSet",manageRoleSet);
+ rReq.setAttribute("manageUserSet",manageUserSet);
+
+ //operation to return from the security console
+ rReq.setAttribute("returnOp",returnOp);
if (sConfirm != null)
{
@@ -412,13 +493,33 @@
public void processAction(final JBossActionRequest aReq, final JBossActionResponse aRes) throws PortletException
{
+ //now if the security console is being launched...make sure proper access is fulfilled
+ String op = aReq.getParameter("op");
+ if(op!=null && CMSAdminConstants.OP_SECURE.equals(op))
+ {
+ if(!this.isSecurityConsoleAccessible(aReq))
+ {
+ aRes.setRenderParameter("op", CMSAdminConstants.OP_CONFIRMSECURE);
+ aRes.setRenderParameter("path", aReq.getParameter("path"));
+ aRes.setRenderParameter("confirm", "Access to the Security Console was Denied");
+ return;
+ }
+ }
+
try
{
internalProcessAction(aReq, aRes);
}
catch (CMSException e)
{
- throw new PortletException(e);
+ if(e.toString().indexOf("Access to this resource is denied")!=-1)
+ {
+ aRes.setRenderParameter("accessDenied","true");
+ }
+ else
+ {
+ throw new PortletException(e);
+ }
}
}
@@ -901,14 +1002,26 @@
}
else if (CMSAdminConstants.OP_SECURE.equals(op))
{
- String[] selectedRoles = aReq.getParameterValues("secureroles");
- String[] selectedUsers = aReq.getParameterValues("secureusers");
-
- // TODO: assign roles/users to node
-
- aRes.setRenderParameter("op", CMSAdminConstants.OP_CONFIRMSECURE);
- aRes.setRenderParameter("path", aReq.getParameter("path"));
- aRes.setRenderParameter("confirm", "Security settings updated successfully.");
+ boolean success = false;
+ try
+ {
+ this.storePermissions(aReq);
+ success = true;
+ }
+ catch(Exception e)
+ {
+ aRes.setRenderParameter("confirm", "An error occurred while setting the permissions.("+e.toString()+")");
+ success = false;
+ }
+
+ if(success)
+ {
+ aRes.setRenderParameter("confirm", "Security settings updated successfully.");
+ }
+
+ aRes.setRenderParameter("op", CMSAdminConstants.OP_CONFIRMSECURE);
+ aRes.setRenderParameter("path", aReq.getParameter("path"));
+ aRes.setRenderParameter("returnOp", aReq.getParameter("returnOp"));
}
}
else
@@ -947,8 +1060,225 @@
ControllerContext cc = req.getControllerContext();
return cc.renderURL(cmd, NON_SECURE_NON_AUTH_URL_CONTEXT, RELATIVE_SERVLET_ENCODED_URL_FORMAT);
}
-
+
static final URLContext NON_SECURE_NON_AUTH_URL_CONTEXT = URLContext.newInstance(false, false);
static final URLFormat RELATIVE_SERVLET_ENCODED_URL_FORMAT = URLFormat.newInstance(true, true);
+
+ //fine-grained access related ui control logic-------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @param aReq
+ */
+ private void storePermissions(JBossActionRequest aReq) throws Exception
+ {
+ String path = aReq.getParameter("path");
+ String[] readRoles = aReq.getParameterValues("secureroles:read");
+ String[] readUsers = aReq.getParameterValues("secureusers:read");
+ String[] writeRoles = aReq.getParameterValues("secureroles:write");
+ String[] writeUsers = aReq.getParameterValues("secureusers:write");
+ String[] manageRoles = aReq.getParameterValues("secureroles:manage");
+ String[] manageUsers = aReq.getParameterValues("secureusers:manage");
+
+
+ if(
+ (readRoles==null || readRoles.length==0) &&
+ (readUsers==null || readUsers.length==0) &&
+ (writeRoles==null || writeRoles.length==0) &&
+ (writeUsers==null || writeUsers.length==0) &&
+ (manageRoles==null || manageRoles.length==0) &&
+ (manageUsers==null || manageUsers.length==0)
+ )
+ {
+ //remove all direct permissions on this node
+ Collection oldPermissions = PermissionManager.getInstance().findPermissionsByCriteria(new Criteria("path",path));
+ PermissionManager.getInstance().remove(oldPermissions);
+ return;
+ }
+
+ //cleanup the old permissions on this node, before new ones are created
+ Collection oldPermissions = PermissionManager.getInstance().findPermissionsByCriteria(new Criteria("path",path));
+ PermissionManager.getInstance().remove(oldPermissions);
+
+ //setup the read permission on this node
+ this.storePermission("read",path,readRoles,readUsers);
+
+ //setup the write permission on this node
+ this.storePermission("write",path,writeRoles,writeUsers);
+
+ //setup the manage permission on this node
+ this.storePermission("manage",path,manageRoles,manageUsers);
+ }
+
+ /**
+ *
+ * @param permission
+ * @param action
+ * @param criteria
+ * @param roles
+ * @param users
+ */
+ private void storePermission(String action,String path,String[] roles,String[] users) throws Exception
+ {
+ Permission permission = new Permission("cms",action);
+ permission.addCriteria(new Criteria("path",path));
+
+ Set rolesSet = null;
+ if(roles!=null && roles.length>0)
+ {
+ rolesSet = new HashSet();
+ for(int i=0;i<roles.length;i++)
+ {
+ int roleId = Integer.parseInt(roles[i]);
+ Role role = null;
+ if(roleId>0)
+ {
+ role = this.roleModule.findRoleById(roles[i]);
+ }
+ else
+ {
+ role = new RoleImpl();
+ }
+ rolesSet.add(role);
+ }
+ }
+
+ Set usersSet = null;
+ if(users!=null && users.length>0)
+ {
+ usersSet = new HashSet();
+ for(int i=0;i<users.length;i++)
+ {
+ User user = this.userModule.findUserById(users[i]);
+ usersSet.add(user);
+ }
+ }
+
+ PermissionManager.getInstance().store(permission,rolesSet,usersSet);
+ }
+
+ /**
+ *
+ * @param permissions
+ * @param action
+ * @return
+ */
+ private Set processRolePermissions(Collection permissions,String action)
+ {
+ Set rolePermissions = new HashSet();
+
+ if(permissions!=null)
+ {
+ for(Iterator itr=permissions.iterator();itr.hasNext();)
+ {
+ Permission permission = (Permission)itr.next();
+ if(permission.getService().equals("cms") && permission.getAction().equals(action))
+ {
+ rolePermissions.addAll(permission.getRoleAssocIds());
+ }
+ }
+ }
+
+ return rolePermissions;
+ }
+
+ /**
+ *
+ * @param permissions
+ * @param action
+ * @return
+ */
+ private Set processUserPermissions(Collection permissions,String action)
+ {
+ Set userPermissions = new HashSet();
+
+ if(permissions!=null)
+ {
+ for(Iterator itr=permissions.iterator();itr.hasNext();)
+ {
+ Permission permission = (Permission)itr.next();
+ if(permission.getService().equals("cms") && permission.getAction().equals(action))
+ {
+ userPermissions.addAll(permission.getUserAssocIds());
+ }
+ }
+ }
+
+ return userPermissions;
+ }
+
+ /**
+ *
+ * @param aReq
+ * @return
+ */
+ private boolean isPortletAccessible(PortletRequest portletRequest)
+ {
+ try
+ {
+ boolean isPortletAccessible = false;
+
+ if(portletRequest.getUserPrincipal()!=null)
+ {
+ User user = this.userModule.findUserByUserName(portletRequest.getUserPrincipal().getName());
+ Collection permissions = PermissionManager.getInstance().findPermissionsByUser(((Long)user.getId()).longValue());
+ if(permissions != null)
+ {
+ for(Iterator itr=permissions.iterator();itr.hasNext();)
+ {
+ Permission permission = (Permission)itr.next();
+ if( (permission.getService().equals("cms")) &&
+ (permission.getAction().equals("write") || permission.getAction().equals("manage"))
+ )
+ {
+ isPortletAccessible = true;
+ }
+ }
+ }
+ }
+
+ return isPortletAccessible;
+ }
+ catch(Exception e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ *
+ * @param aReq
+ * @return
+ */
+ private boolean isSecurityConsoleAccessible(PortletRequest portletRequest)
+ {
+ try
+ {
+ boolean isAccessible = false;
+
+ if(portletRequest.getUserPrincipal()!=null)
+ {
+ User user = this.userModule.findUserByUserName(portletRequest.getUserPrincipal().getName());
+ Set roles = this.roleModule.getRoles(user);
+ if(roles!=null)
+ {
+ for(Iterator itr=roles.iterator();itr.hasNext();)
+ {
+ Role role = (Role)itr.next();
+ if(role.getName().equalsIgnoreCase("admin"))
+ {
+ isAccessible = true;
+ break;
+ }
+ }
+ }
+ }
+
+ return isAccessible;
+ }
+ catch(Exception e)
+ {
+ return false;
+ }
+ }
}
\ No newline at end of file
Modified: trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2006-12-12 04:59:21 UTC (rev 5806)
@@ -57,15 +57,13 @@
<depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
<depends>portal:service=JAASLoginModule</depends>
<depends>portal:service=Hibernate,type=CMS</depends>
- <!--
- //this is not needed anymore. this cache is redundant because of JBossCache PM
- <depends optional-attribute-name="StackFactory" proxy-type="attribute">portal:service=InterceptorStackFactory,type=Cms</depends>
- -->
+ <depends optional-attribute-name="StackFactory" proxy-type="attribute">portal:service=InterceptorStackFactory,type=Cms</depends>
+ <depends optional-attribute-name="UserModule" proxy-type="attribute">portal:service=Module,type=User</depends>
<attribute name="DoChecking">true</attribute>
<attribute name="DefaultContentLocation">portal/cms/conf/default-content/default/</attribute>
<attribute name="DefaultLocale">en</attribute>
<attribute name="RepositoryName">PortalRepository</attribute>
- <attribute name="HomeDir">${jboss.server.data.dir}${/}portal${/}cms${/}conf</attribute>
+ <attribute name="HomeDir">${jboss.server.data.dir}${/}portal${/}cms${/}conf</attribute>
<attribute name="Config">
<Repository>
<!--
@@ -108,7 +106,7 @@
<!--
persistence manager of the workspace.
- Use XMLPersistenceManager for LocalFileSystem Store and HibernatePersistentManager .
+ Use XMLPersistenceManager for LocalFileSystem Store and JBossCachePersistenceManager .
-->
<!-- HibernatePersistentManager: uses RDBMS + Hibernate for storage -->
@@ -155,7 +153,7 @@
<!--
Configures the persistence manager to be used for persisting version state.
- Use XMLPersistenceManager for LocalFileSystem Store and HibernatePersistentManager for HibernateStore.
+ Use XMLPersistenceManager for LocalFileSystem Store and JBossCachePersistenceManager for HibernateStore.
-->
<!-- HibernatePersistentManager: uses RDBMS + Hibernate for storage -->
@@ -422,6 +420,108 @@
<attribute name="CacheLoaderAsynchronous">false</attribute-->
</mbean>
+
+ <!-- interceptor factory where all cms interceptors are registered -->
+ <mbean
+ code="org.jboss.portal.server.impl.invocation.JBossInterceptorStackFactory"
+ name="portal:service=InterceptorStackFactory,type=Cms"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends-list optional-attribute-name="InterceptorNames">
+ <depends-list-element>portal:service=Interceptor,type=Cms,name=ACL</depends-list-element>
+ </depends-list>
+ </mbean>
+
+ <!-- ACL Security Interceptor -->
+ <mbean
+ code="org.jboss.portal.cms.impl.interceptors.ACLInterceptor"
+ name="portal:service=Interceptor,type=Cms,name=ACL"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="JNDIName">java:portal/cms/CMSSessionFactory</attribute>
+ <attribute name="AuthorizationProviderClass">org.jboss.portal.cms.impl.jcr.command.ACLEnforcer</attribute>
+ <attribute name="DefaultPolicy">
+ <![CDATA[
+ <policy>
+ <!-- permissions on the root cms node -->
+ <criteria name="path" value="/">
+ <permission name="cms" action="read">
+ <role name="Anonymous"/>
+ </permission>
+ <permission name="cms" action="write">
+ <role name="User"/>
+ </permission>
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ <!-- permissions on the default cms node -->
+ <criteria name="path" value="/default">
+ <permission name="cms" action="read">
+ <role name="Anonymous"/>
+ </permission>
+ <permission name="cms" action="write">
+ <role name="User"/>
+ </permission>
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ <!-- permissions on the private/protected node -->
+ <criteria name="path" value="/default/private">
+ <permission name="cms" action="manage">
+ <role name="Admin"/>
+ </permission>
+ </criteria>
+ </policy>
+ ]]>
+ </attribute>
+ <depends optional-attribute-name="RoleModule" proxy-type="attribute">
+ portal:service=Module,type=Role
+ </depends>
+ </mbean>
+
+ <!-- logging interceptor -->
+ <!--mbean
+ code="org.jboss.portal.cms.impl.interceptors.LogInterceptor"
+ name="portal:service=Interceptor,type=Cms,name=Log"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean-->
+
+ <!--
+ <mbean
+ code="org.jboss.portal.cms.impl.interceptors.CacheInterceptor"
+ name="portal:service=Interceptor,type=Cms,name=Cache"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends>portal:service=CMSTreeCacheService</depends>
+ </mbean>
+ //this is not needed anymore. this cache is redundant since there is a JBossCache PM
+ <mbean
+ code="org.jboss.portal.cms.impl.cache.CMSTreeCacheServiceImpl"
+ name="portal:service=CMSTreeCacheService"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends optional-attribute-name="Cache" proxy-type="attribute">
+ <mbean
+ code="org.jboss.cache.TreeCache"
+ name="portal:service=CMSTreeCache">
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
+ <attribute name="CacheMode">REPL_ASYNC</attribute>
+ <attribute name="IsolationLevel">NONE</attribute>
+ </mbean>
+ </depends>
+ <attribute name="JNDIName">java:/portal/cms/CMSTreeCache</attribute>
+ </mbean>
+ -->
<!--
| Uncomment in clustered mode : TreeCache configuration for the clustered JackRabbit in-memory cache...
| This helps with node synching, but there are other aspects of JackRabbit like versioning subsystem
@@ -498,55 +598,4 @@
<attribute name="UseRegionBasedMarshalling">false</attribute>
</mbean-->
-
-
- <!--mbean
- code="org.jboss.portal.cms.impl.interceptors.LogInterceptor"
- name="portal:service=Interceptor,type=Cms,name=Log"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
- </mbean-->
-
- <!--
- //this is not needed anymore. this cache is redundant since there is a JBossCache PM
- <mbean
- code="org.jboss.portal.cms.impl.cache.CMSTreeCacheServiceImpl"
- name="portal:service=CMSTreeCacheService"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
- <depends optional-attribute-name="Cache" proxy-type="attribute">
- <mbean
- code="org.jboss.cache.TreeCache"
- name="portal:service=CMSTreeCache">
- <depends>jboss:service=Naming</depends>
- <depends>jboss:service=TransactionManager</depends>
- <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
- <attribute name="CacheMode">REPL_ASYNC</attribute>
- <attribute name="IsolationLevel">NONE</attribute>
- </mbean>
- </depends>
- <attribute name="JNDIName">java:/portal/cms/CMSTreeCache</attribute>
- </mbean>
-
- <mbean
- code="org.jboss.portal.cms.impl.interceptors.CacheInterceptor"
- name="portal:service=Interceptor,type=Cms,name=Cache"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
- <depends>portal:service=CMSTreeCacheService</depends>
- </mbean>
- <mbean
- code="org.jboss.portal.server.impl.invocation.JBossInterceptorStackFactory"
- name="portal:service=InterceptorStackFactory,type=Cms"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
- <xmbean/>
- <depends-list optional-attribute-name="InterceptorNames">
- <depends-list-element>portal:service=Interceptor,type=Cms,name=Cache</depends-list-element>
- </depends-list>
- </mbean>
- -->
</server>
Modified: trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/domain.hbm.xml
===================================================================
--- trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/domain.hbm.xml 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/domain.hbm.xml 2006-12-12 04:59:21 UTC (rev 5806)
@@ -274,5 +274,103 @@
type="long"
not-null="true"/>
</class>
+
+ <!-- mapping to persist CMS Fine Grained Security related objects -->
+ <class name="org.jboss.portal.cms.security.PermRoleAssoc" table="jbp_cms_perm_role">
+ <cache usage="read-write"/>
+ <id
+ name="id"
+ column="ID"
+ type="java.lang.Long">
+ <generator class="native"/>
+ </id>
+ <property
+ name="roleId"
+ column="ROLE_ID"
+ type="long"
+ not-null="true"
+ />
+ </class>
+ <class name="org.jboss.portal.cms.security.PermUserAssoc" table="jbp_cms_perm_user">
+ <cache usage="read-write"/>
+ <id
+ name="id"
+ column="ID"
+ type="java.lang.Long">
+ <generator class="native"/>
+ </id>
+ <property
+ name="userId"
+ column="USER_ID"
+ type="long"
+ not-null="true"
+ />
+ </class>
+ <class name="org.jboss.portal.cms.security.Criteria" table="jbp_cms_perm_criteria">
+ <cache usage="read-write"/>
+ <id
+ name="id"
+ column="ID"
+ type="java.lang.Long">
+ <generator class="native"/>
+ </id>
+ <property
+ name="name"
+ column="NAME"
+ type="string"
+ not-null="true"
+ />
+ <property
+ name="value"
+ column="VALUE"
+ type="string"
+ not-null="true"
+ />
+ </class>
+ <class name="org.jboss.portal.cms.security.Permission" table="jbp_cms_perm">
+ <cache usage="read-write"/>
+ <id
+ name="id"
+ column="ID"
+ type="java.lang.Long">
+ <generator class="native"/>
+ </id>
+ <!-- one-to-many association with the criteria object -->
+ <set name="criteria" lazy="false" table="jbp_cms_perm_criteria" cascade="all-delete-orphan">
+ <cache usage="read-write"/>
+ <key column="CMS_PERM_ID"/>
+ <one-to-many class="org.jboss.portal.cms.security.Criteria"/>
+ </set>
+ <!-- many-to-many association with the role object -->
+ <set name="roleAssoc" lazy="false" cascade="all-delete-orphan">
+ <cache usage="read-write"/>
+ <key column="CMS_PERM_ID"/>
+ <one-to-many class="org.jboss.portal.cms.security.PermRoleAssoc"/>
+ </set>
+ <!-- many-to-many association with the user object -->
+ <set name="userAssoc" lazy="false" cascade="all-delete-orphan">
+ <cache usage="read-write"/>
+ <key column="CMS_PERM_ID"/>
+ <one-to-many class="org.jboss.portal.cms.security.PermUserAssoc"/>
+ </set>
+ <property
+ name="service"
+ column="NAME"
+ type="string"
+ not-null="true"
+ />
+ <property
+ name="action"
+ column="ACTION"
+ type="string"
+ not-null="true"
+ />
+ <property
+ name="negated"
+ column="NEGATED"
+ type="boolean"
+ not-null="true"
+ />
+ </class>
</hibernate-mapping>
Added: trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/ehcache.xml
===================================================================
--- trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/ehcache.xml 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/ehcache.xml 2006-12-12 04:59:21 UTC (rev 5806)
@@ -0,0 +1,61 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<ehcache>
+
+ <!-- Sets the path to the directory where cache .data files are created.
+
+ If the path is a Java System Property it is replaced by
+ its value in the running VM.
+
+ The following properties are translated:
+ user.home - User's home directory
+ user.dir - User's current working directory
+ java.io.tmpdir - Default temp file path -->
+ <diskStore path="java.io.tmpdir/cms"/>
+
+
+ <!--Default Cache configuration. These will applied to caches programmatically created through
+ the CacheManager.
+
+ The following attributes are required for defaultCache:
+
+ maxInMemory - Sets the maximum number of objects that will be created in memory
+ eternal - Sets whether elements are eternal. If eternal, timeouts are ignored and the element
+ is never expired.
+ timeToIdleSeconds - Sets the time to idle for an element before it expires. Is only used
+ if the element is not eternal. Idle time is now - last accessed time
+ timeToLiveSeconds - Sets the time to live for an element before it expires. Is only used
+ if the element is not eternal. TTL is now - creation time
+ overflowToDisk - Sets whether elements can overflow to disk when the in-memory cache
+ has reached the maxInMemory limit.
+
+ -->
+ <defaultCache
+ maxElementsInMemory="10000"
+ eternal="false"
+ timeToIdleSeconds="120"
+ timeToLiveSeconds="120"
+ overflowToDisk="false"
+ />
+</ehcache>
Modified: trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/hibernate.cfg.xml
===================================================================
--- trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/hibernate.cfg.xml 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/resources/portal-cms-sar/conf/hibernate/cms/hibernate.cfg.xml 2006-12-12 04:59:21 UTC (rev 5806)
@@ -28,18 +28,21 @@
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:@portal.datasource.name@</property>
- <property name="show_sql">@portal.sql.show@</property>
- <property name="cache.use_second_level_cache">false</property>
- <property name="cache.use_query_cache">false</property>
+ <property name="show_sql">@portal.sql.show@</property>
+
+ <!-- caching properties -->
+ <property name="cache.use_second_level_cache">true</property>
+ <property name="cache.use_query_cache">true</property>
+ <property name="cache.provider_configuration_file_resource_path">conf/hibernate/cms/ehcache.xml</property>
+ <property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<!-- managed environment transaction configuration -->
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<!-- Force the dialect instead of using autodetection -->
- <!--
- <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
- -->
+ <!--property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property-->
+ <!--property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property-->
<!-- Mapping files -->
<mapping resource="conf/hibernate/cms/domain.hbm.xml"/>
Modified: trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/resources/portal-core-sar/conf/data/default-object.xml 2006-12-12 04:59:21 UTC (rev 5806)
@@ -406,7 +406,85 @@
<role-name>Admin</role-name>
<action-name>viewrecursive</action-name>
</policy-permission>
- </security-constraint>
+ </security-constraint>
</portal>
</deployment>
+
+
+ <!-- cms administration tool page with the fine grained access control integrated -->
+ <deployment>
+ <parent-ref/>
+ <if-exists>keep</if-exists>
+ <portal>
+ <portal-name>cms</portal-name>
+ <properties>
+ <!--
+ | Set the layout for the default portal, see also portal-layouts.xml.
+ -->
+ <property>
+ <name>layout.id</name>
+ <value>generic</value>
+ </property>
+ <!--
+ | Set the theme for the default portal, see also portal-themes.xml.
+ -->
+ <property>
+ <name>theme.id</name>
+ <value>renaissance</value>
+ </property>
+ <!--
+ | Set the default render set name (used by the render tag in layouts), see also portal-renderSet.xml
+ -->
+ <property>
+ <name>theme.renderSetId</name>
+ <value>divRenderer</value>
+ </property>
+ <!--
+ | Set the default strategy name (used by the strategy interceptor), see also portal-strategies.xml
+ -->
+ <property>
+ <name>layout.strategyId</name>
+ <value>maximizedRegion</value>
+ </property>
+ <!--
+ | The default page name, if the property is not explicited then the default page name is "default"
+ -->
+ <property>
+ <name>portal.defaultObjectName</name>
+ <value>default</value>
+ </property>
+ </properties>
+ <supported-modes>
+ <mode>view</mode>
+ <mode>edit</mode>
+ <mode>help</mode>
+ </supported-modes>
+ <supported-window-states>
+ <window-state>normal</window-state>
+ <window-state>minimized</window-state>
+ <window-state>maximized</window-state>
+ </supported-window-states>
+ <page>
+ <page-name>default</page-name>
+ <window>
+ <window-name>CMSAdminPortletWindow</window-name>
+ <instance-ref>CMSAdminPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>JSPPortletWindow</window-name>
+ <instance-ref>JSPPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>UserPortletWindow</window-name>
+ <instance-ref>UserPortletInstance</instance-ref>
+ <region>left</region>
+ <height>1</height>
+ </window>
+ </page>
+ </portal>
+ </deployment>
</deployments>
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/main.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/main.jsp 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/main.jsp 2006-12-12 04:59:21 UTC (rev 5806)
@@ -92,6 +92,7 @@
<li><a href="<portlet:renderURL>
<portlet:param name="op" value="<%= CMSAdminConstants.OP_CONFIRMSECURE %>"/>
<portlet:param name="path" value="<%= sCurrPath %>"/>
+ <portlet:param name="returnOp" value="<%= CMSAdminConstants.OP_MAIN %>"/>
</portlet:renderURL>">${n:i18n("CMS_SECURE")}</a></li>
<%
if (!"/".equals(sCurrPath))
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/securenode.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/securenode.jsp 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/securenode.jsp 2006-12-12 04:59:21 UTC (rev 5806)
@@ -15,11 +15,20 @@
Set roleSet = (Set)request.getAttribute("roles");
Set userSet = (Set)request.getAttribute("users");
String sConfirm = (String)request.getAttribute("confirm");
+ String returnOp = (String)request.getAttribute("returnOp");
+
+ Set readRoleSet = (Set)request.getAttribute("readRoleSet");
+ Set readUserSet = (Set)request.getAttribute("readUserSet");
+ Set writeRoleSet = (Set)request.getAttribute("writeRoleSet");
+ Set writeUserSet = (Set)request.getAttribute("writeUserSet");
+ Set manageRoleSet = (Set)request.getAttribute("manageRoleSet");
+ Set manageUserSet = (Set)request.getAttribute("manageUserSet");
%>
<form action="<portlet:actionURL>
<portlet:param name="op" value="<%= CMSAdminConstants.OP_SECURE %>"/>
<portlet:param name="path" value="<%= sCurrPath %>"/>
+ <portlet:param name="returnOp" value="<%= returnOp %>"/>
</portlet:actionURL>" method="post">
<table width="100%">
<th colspan="2" align="center" class="portlet-section-header">${n:i18n("TITLE_SECURECONFIRM")}</th>
@@ -53,15 +62,18 @@
</tr>
<tr>
<td>
- <select name="secureroles" multiple="multiple">
- <option value="Anonymous">Anonymous</option>
+ <select name="secureroles:read" multiple="multiple">
+ <option value="0" <%if(readRoleSet.contains(new Long(0))){%>selected<%}%>>
+ Anonymous
+ </option>
<%
Iterator iterator = roleSet.iterator();
while (iterator.hasNext())
{
Role role = (Role)iterator.next();
%>
- <option value="<%= role.getId() %>"><%= role.getDisplayName() %>
+ <option value="<%= role.getId() %>" <%if(readRoleSet.contains(role.getId())){%>selected<%}%>>
+ <%= role.getDisplayName() %>
</option>
<%
}
@@ -77,14 +89,15 @@
</tr>
<tr>
<td>
- <select name="secureusers" multiple="multiple">
+ <select name="secureusers:read" multiple="multiple">
<%
Iterator iteratorUser = userSet.iterator();
while (iteratorUser.hasNext())
{
User user = (User)iteratorUser.next();
%>
- <option value="<%= user.getId() %>"><%= user.getUserName() %>
+ <option value="<%= user.getId() %>" <%if(readUserSet.contains(user.getId())){%>selected<%}%>>
+ <%= user.getUserName() %>
</option>
<%
}
@@ -109,15 +122,18 @@
</tr>
<tr>
<td>
- <select name="secureroles" multiple="multiple">
- <option value="Anonymous">Anonymous</option>
+ <select name="secureroles:write" multiple="multiple">
+ <option value="0" <%if(writeRoleSet.contains(new Long(0))){%>selected<%}%>>
+ Anonymous
+ </option>
<%
iterator = roleSet.iterator();
while (iterator.hasNext())
{
Role role = (Role)iterator.next();
%>
- <option value="<%= role.getId() %>"><%= role.getDisplayName() %>
+ <option value="<%= role.getId() %>" <%if(writeRoleSet.contains(role.getId())){%>selected<%}%>>
+ <%= role.getDisplayName() %>
</option>
<%
}
@@ -133,14 +149,15 @@
</tr>
<tr>
<td>
- <select name="secureusers" multiple="multiple">
+ <select name="secureusers:write" multiple="multiple">
<%
iteratorUser = userSet.iterator();
while (iteratorUser.hasNext())
{
User user = (User)iteratorUser.next();
%>
- <option value="<%= user.getId() %>"><%= user.getUserName() %>
+ <option value="<%= user.getId() %>" <%if(writeUserSet.contains(user.getId())){%>selected<%}%>>
+ <%= user.getUserName() %>
</option>
<%
}
@@ -165,15 +182,18 @@
</tr>
<tr>
<td>
- <select name="secureroles" multiple="multiple">
- <option value="Anonymous">Anonymous</option>
+ <select name="secureroles:manage" multiple="multiple">
+ <option value="0" <%if(manageRoleSet.contains(new Long(0))){%>selected<%}%>>
+ Anonymous
+ </option>
<%
iterator = roleSet.iterator();
while (iterator.hasNext())
{
Role role = (Role)iterator.next();
%>
- <option value="<%= role.getId() %>"><%= role.getDisplayName() %>
+ <option value="<%= role.getId() %>" <%if(manageRoleSet.contains(role.getId())){%>selected<%}%>>
+ <%= role.getDisplayName() %>
</option>
<%
}
@@ -189,14 +209,15 @@
</tr>
<tr>
<td>
- <select name="secureusers" multiple="multiple">
+ <select name="secureusers:manage" multiple="multiple">
<%
iteratorUser = userSet.iterator();
while (iteratorUser.hasNext())
{
User user = (User)iteratorUser.next();
%>
- <option value="<%= user.getId() %>"><%= user.getUserName() %>
+ <option value="<%= user.getId() %>" <%if(manageUserSet.contains(user.getId())){%>selected<%}%>>
+ <%= user.getUserName() %>
</option>
<%
}
@@ -221,7 +242,7 @@
</form>
<a href="<portlet:renderURL>
- <portlet:param name="op" value="<%= CMSAdminConstants.OP_MAIN %>"/>
+ <portlet:param name="op" value="<%= returnOp %>"/>
<portlet:param name="path"
value="<%= sCurrPath %>"/>
</portlet:renderURL>">
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp 2006-12-12 04:59:21 UTC (rev 5806)
@@ -118,6 +118,7 @@
<li><a href="<portlet:renderURL>
<portlet:param name="op" value="<%= CMSAdminConstants.OP_CONFIRMSECURE %>"/>
<portlet:param name="path" value="<%= sCurrPath %>"/>
+ <portlet:param name="returnOp" value="<%= CMSAdminConstants.OP_VIEWFILE %>"/>
</portlet:renderURL>">${n:i18n("CMS_SECURE")}</a></li>
</ul>
</li>
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/portlet-instances.xml
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/portlet-instances.xml 2006-12-12 01:24:50 UTC (rev 5805)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/portlet-instances.xml 2006-12-12 04:59:21 UTC (rev 5806)
@@ -51,12 +51,14 @@
<instance>
<instance-id>CMSAdminPortletInstance</instance-id>
<portlet-ref>CMSAdminPortlet</portlet-ref>
- <security-constraint>
+
+ <!--security-constraint>
<policy-permission>
<role-name>Admin</role-name>
<action-name>view</action-name>
</policy-permission>
- </security-constraint>
+ </security-constraint-->
+
</instance>
</deployment>
<deployment>
19 years, 5 months
JBoss Portal SVN: r5805 - in trunk: build/ide/intellij/idea60/modules/core core core/src/main/org/jboss/portal/core/impl/portlet/state core/src/main/org/jboss/portal/test/core/state core/src/resources/portal-core-sar/conf/hibernate/portlet core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/state jems/src/main/org/jboss/portal/jems/hibernate tools/etc/buildfragments wsrp wsrp/src/main/org/jboss/portal/test/wsrp/registration wsrp/src/main/org/jboss/portal/wsrp/producer/registr
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2006-12-11 20:24:50 -0500 (Mon, 11 Dec 2006)
New Revision: 5805
Added:
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/RegistrationStatusUserType.java
trunk/core/src/main/org/jboss/portal/test/core/state/RegistrationPersistenceManagerTestCase.java
trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/state/registration-persistence-manager-beans.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/AbstractRegistrationPersistenceManagerTestCase.java
Modified:
trunk/build/ide/intellij/idea60/modules/core/core.iml
trunk/core/build.xml
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentConsumer.java
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentConsumerGroup.java
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java
trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentStateStore.java
trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java
trunk/core/src/resources/portal-core-sar/conf/hibernate/portlet/domain.hbm.xml
trunk/jems/src/main/org/jboss/portal/jems/hibernate/QNameUserType.java
trunk/tools/etc/buildfragments/modules.ent
trunk/wsrp/build.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationPersistenceManagerTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationStatus.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerGroupImpl.java
Log:
Fix and test the RegistrationPersistenceManager implemented with hibernate (without the portlet clone integration yet)
Modified: trunk/build/ide/intellij/idea60/modules/core/core.iml
===================================================================
--- trunk/build/ide/intellij/idea60/modules/core/core.iml 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/build/ide/intellij/idea60/modules/core/core.iml 2006-12-12 01:24:50 UTC (rev 5805)
@@ -258,6 +258,15 @@
</orderEntry>
<orderEntry type="module" module-name="wsrp" />
<orderEntry type="module" module-name="api" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../thirdparty/jbossas/core-libs/lib/namespace.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Modified: trunk/core/build.xml
===================================================================
--- trunk/core/build.xml 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/core/build.xml 2006-12-12 01:24:50 UTC (rev 5805)
@@ -603,6 +603,9 @@
<zest todir="${test.reports}" name="org.jboss.portal.test.core.state.ProducerTestCase"
outfile="TEST-ProducerTestCase">
</zest>
+ <zest todir="${test.reports}" name="org.jboss.portal.test.core.state.RegistrationPersistenceManagerTestCase"
+ outfile="TEST-RegistrationPersistenceManagerTestCase">
+ </zest>
<test todir="${test.reports}"
name="org.jboss.portal.test.core.deployment.JBossApplicationMetaDataFactoryTestCase"/>
<test todir="${test.reports}"
Modified: trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentConsumer.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentConsumer.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentConsumer.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -30,7 +30,6 @@
import org.jboss.portal.wsrp.producer.registration.api.DuplicateRegistrationException;
import java.util.Collection;
-import java.util.Map;
import java.util.Collections;
import java.util.Set;
import java.util.HashSet;
@@ -44,7 +43,8 @@
// Persistent fields
- private String key;
+ private Long key;
+ private String persistentId;
private String persistentName;
private RegistrationStatus persistentStatus;
private String persistentAgent;
@@ -60,9 +60,10 @@
* @param id
* @param name
*/
- PersistentConsumer(String id, String name)
+ public PersistentConsumer(String id, String name)
{
- this.key = id;
+ this.key = null;
+ this.persistentId = id;
this.persistentName = name;
this.persistentStatus = RegistrationStatus.PENDING;
this.relatedRegistrations = new HashSet();
@@ -76,6 +77,7 @@
PersistentConsumer()
{
this.key = null;
+ this.persistentId = null;
this.persistentName = null;
this.persistentStatus = null;
this.relatedRegistrations = null;
@@ -85,16 +87,26 @@
// Hibernate
- public String getKey()
+ public Long getKey()
{
return key;
}
- public void setKey(String key)
+ public void setKey(Long key)
{
this.key = key;
}
+ public String getPersistentId()
+ {
+ return persistentId;
+ }
+
+ public void setPersistentId(String persistentId)
+ {
+ this.persistentId = persistentId;
+ }
+
public String getPersistentName()
{
return persistentName;
@@ -174,7 +186,7 @@
public String getId()
{
- return key;
+ return persistentId;
}
public ConsumerCapabilities getCapabilities()
Modified: trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentConsumerGroup.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentConsumerGroup.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentConsumerGroup.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -26,6 +26,8 @@
import org.jboss.portal.wsrp.producer.registration.api.RegistrationException;
import org.jboss.portal.wsrp.producer.registration.api.Consumer;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
+import org.jboss.portal.jems.hibernate.ContextObject;
+import org.hibernate.Session;
import java.util.Collection;
import java.util.Map;
@@ -36,11 +38,12 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class PersistentConsumerGroup implements ConsumerGroup
+public class PersistentConsumerGroup implements ConsumerGroup, ContextObject
{
// Persistent fields
+ private Long key;
private String persistentName;
private RegistrationStatus persistentStatus;
@@ -48,19 +51,49 @@
private Map relatedConsumers;
- public PersistentConsumerGroup(String name)
+ // Context
+
+ private PersistentStateStore context;
+
+ public PersistentConsumerGroup(PersistentStateStore context, String name)
{
+ this.key = null;
this.persistentName = name;
this.relatedConsumers = new HashMap();
this.persistentStatus = RegistrationStatus.PENDING;
+ this.context = context;
}
- public PersistentConsumerGroup()
+ /**
+ * Hibernate constructor.
+ */
+ PersistentConsumerGroup()
{
+ this.key = null;
+ this.persistentName = null;
+ this.persistentStatus = null;
+ this.relatedConsumers = null;
}
+ // ContextObject
+
+ public void setContext(Object context)
+ {
+ this.context = (PersistentStateStore)context;
+ }
+
// Hibernate
+ public Long getKey()
+ {
+ return key;
+ }
+
+ public void setKey(Long key)
+ {
+ this.key = key;
+ }
+
public String getPersistentName()
{
return persistentName;
@@ -105,21 +138,33 @@
public Consumer getConsumer(String consumerId) throws IllegalArgumentException, RegistrationException
{
+ if (consumerId == null)
+ {
+ throw new IllegalArgumentException("No null consumer id accepted");
+ }
+
+ //
return (Consumer)relatedConsumers.get(consumerId);
}
public void addConsumer(Consumer consumer) throws RegistrationException
{
- validateImplementation(consumer);
+ PersistentConsumer pconsumer = validateImplementation(consumer);
//
if (relatedConsumers.containsKey(consumer.getId()))
{
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Consumer already attached " + consumer.getId());
}
//
- relatedConsumers.put(consumer.getId(), consumer);
+ Session session = context.getCurrentSession();
+
+ // Create the relationship
+ relatedConsumers.put(consumer.getId(), pconsumer);
+ pconsumer.setRelatedGroup(this);
+ session.saveOrUpdate(this);
+ session.saveOrUpdate(consumer);
}
public void removeConsumer(Consumer consumer) throws RegistrationException
Modified: trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentRegistration.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -67,7 +67,7 @@
this.properties = new Properties();
}
- PersistentRegistration(Map properties, RegistrationStatus status)
+ public PersistentRegistration(Map properties, RegistrationStatus status)
{
this.key = null;
this.persistentHandle = null;
Modified: trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentStateStore.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentStateStore.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/PersistentStateStore.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -27,6 +27,7 @@
import org.hibernate.SessionFactory;
import org.jboss.portal.common.value.Value;
import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.jems.hibernate.ObjectContextualizer;
import org.jboss.portal.portlet.state.InvalidStateIdException;
import org.jboss.portal.portlet.state.NoSuchStateException;
import org.jboss.portal.portlet.state.PropertyMap;
@@ -40,6 +41,7 @@
import org.jboss.portal.wsrp.producer.registration.api.Registration;
import org.jboss.portal.wsrp.producer.registration.api.NoSuchRegistrationException;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
+import org.jboss.portal.wsrp.producer.registration.api.DuplicateRegistrationException;
import javax.naming.InitialContext;
import java.util.Iterator;
@@ -59,6 +61,9 @@
/** . */
protected String sessionFactoryJNDIName;
+ /** . */
+ protected ObjectContextualizer contextualizer;
+
public String getSessionFactoryJNDIName()
{
return sessionFactoryJNDIName;
@@ -200,10 +205,13 @@
protected void startService() throws Exception
{
sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+ contextualizer = new ObjectContextualizer(this);
+ contextualizer.attach(sessionFactory);
}
protected void stopService() throws Exception
{
+ contextualizer = null;
sessionFactory = null;
}
@@ -282,10 +290,17 @@
// Get hibernate session
Session session = getCurrentSession();
+ PersistentConsumerGroup group = null;
+ // Detect duplicate
+ if (findGroupByName(session, name) != null)
+ {
+ throw new DuplicateRegistrationException("Group " + name + " already exists");
+ }
+
// Create and persist
- PersistentConsumerGroup group = new PersistentConsumerGroup(name);
- session.persist(session);
+ group = new PersistentConsumerGroup(this, name);
+ session.persist(group);
//
return group;
@@ -337,6 +352,7 @@
// Delete the registration
session.delete(registration);
+ session.flush();
}
public Consumer getConsumerById(String consumerId) throws RegistrationException
@@ -350,19 +366,23 @@
public Registration addRegistrationFor(String consumerId, Map registrationProperties) throws RegistrationException
{
+ if (registrationProperties == null)
+ {
+ throw new IllegalArgumentException("No null registration properties accepted");
+ }
+
// Get hibernate session
Session session = getCurrentSession();
// Perform lookup
PersistentConsumer consumer = getConsumerById(session, consumerId);
- // Create and persist registration
+ // Create and persist registration and build relationship
PersistentRegistration registration = new PersistentRegistration(registrationProperties, RegistrationStatus.PENDING);
- session.persist(registration);
-
- // Build relationship
registration.setRelatedConsumer(consumer);
consumer.getRelatedRegistrations().add(registration);
+ session.persist(registration);
+ session.saveOrUpdate(consumer);
//
return registration;
@@ -460,7 +480,9 @@
}
//
- return (PersistentConsumer)session.get(PersistentConsumer.class, consumerId);
+ Query query = session.createQuery("from PersistentConsumer where persistentId=:consumerId");
+ query.setString("consumerId", consumerId);
+ return (PersistentConsumer)query.uniqueResult();
}
private PersistentConsumerGroup getGroupByName(Session session, String groupName) throws IllegalArgumentException, NoSuchRegistrationException
@@ -485,6 +507,8 @@
}
//
- return (PersistentConsumerGroup)session.get(PersistentConsumerGroup.class, groupName);
+ Query query = session.createQuery("from PersistentConsumerGroup where persistentName=:groupName");
+ query.setString("groupName", groupName);
+ return (PersistentConsumerGroup)query.uniqueResult();
}
}
Added: trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/RegistrationStatusUserType.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/RegistrationStatusUserType.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/core/src/main/org/jboss/portal/core/impl/portlet/state/RegistrationStatusUserType.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -0,0 +1,142 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.jboss.portal.core.impl.portlet.state;
+
+import org.hibernate.usertype.UserType;
+import org.hibernate.HibernateException;
+import org.hibernate.Hibernate;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.PreparedStatement;
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class RegistrationStatusUserType implements UserType
+{
+
+ /** . */
+ private static final int[] SQL_TYPES = {Hibernate.INTEGER.sqlType()};
+
+ public int[] sqlTypes()
+ {
+ return SQL_TYPES;
+ }
+
+ public Class returnedClass()
+ {
+ return RegistrationStatus.class;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException
+ {
+ if (x == y)
+ {
+ return true;
+ }
+ else if (x == null || y == null)
+ {
+ return false;
+ }
+ else
+ {
+ return x.equals(y);
+ }
+ }
+
+ public int hashCode(Object x) throws HibernateException
+ {
+ return x.hashCode();
+ }
+
+ public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException
+ {
+ int value = resultSet.getInt(names[0]);
+ if (resultSet.wasNull())
+ {
+ return null;
+ }
+
+ //
+ switch (value)
+ {
+ case 1:
+ return RegistrationStatus.VALID;
+ case 2:
+ return RegistrationStatus.INVALID;
+ default:
+ return RegistrationStatus.PENDING;
+ }
+ }
+
+ public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException
+ {
+ if (value == null)
+ {
+ statement.setNull(index, SQL_TYPES[0]);
+ }
+ else
+ {
+ RegistrationStatus status = (RegistrationStatus)value;
+ int i = 0;
+ if (status == RegistrationStatus.VALID)
+ {
+ i = 1;
+ }
+ else if (status == RegistrationStatus.INVALID)
+ {
+ i = 2;
+ }
+ statement.setInt(index, i);
+ }
+ }
+
+ public Object deepCopy(Object value) throws HibernateException
+ {
+ return value;
+ }
+
+ public boolean isMutable()
+ {
+ return false;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException
+ {
+ return (RegistrationStatus)value;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException
+ {
+ return cached;
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException
+ {
+ return original;
+ }
+}
Modified: trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/core/src/main/org/jboss/portal/test/core/state/ProducerTestCase.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -30,6 +30,7 @@
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
import org.jboss.portal.Mode;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
import org.jboss.portal.common.junit.TransactionAssert;
import org.jboss.portal.common.test.TestParametrization;
import org.jboss.portal.common.test.junit.JUnitAdapter;
@@ -37,6 +38,8 @@
import org.jboss.portal.common.value.StringValue;
import org.jboss.portal.core.impl.portlet.state.PersistentStateStore;
import org.jboss.portal.core.impl.portlet.state.ProducerPortletInvoker;
+import org.jboss.portal.core.impl.portlet.state.PersistentRegistration;
+import org.jboss.portal.core.impl.portlet.state.PersistentConsumer;
import org.jboss.portal.portlet.NoSuchPortletException;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.portlet.PortletContext;
@@ -61,10 +64,13 @@
import org.jboss.portal.test.framework.TestRuntimeContext;
import org.jboss.portal.test.framework.embedded.DataSourceSupport;
import org.jboss.portal.test.framework.embedded.HibernateSupport;
+import org.hibernate.Session;
+import javax.xml.namespace.QName;
import java.net.URL;
import java.util.Collections;
import java.util.List;
+import java.util.HashMap;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -250,8 +256,32 @@
runtimeContext.stop();
}
- public void testCloneNonExistingPortletWithinTx() throws Exception
+ public void testABC()
{
+ TransactionAssert.beginTransaction();
+ Session session = hibernateSupport.getCurrentSession();
+ PersistentConsumer consumer = new PersistentConsumer("myconsumer", "myconsumer");
+ session.persist(consumer);
+ Long consumerPK = consumer.getKey();
+ TransactionAssert.commitTransaction();
+
+ TransactionAssert.beginTransaction();
+ session = hibernateSupport.getCurrentSession();
+ consumer = (PersistentConsumer)session.get(PersistentConsumer.class, consumerPK);
+ HashMap properties = new HashMap();
+ properties.put(new QName("a", "b"), "abc");
+ properties.put(new QName("b"), "def");
+ PersistentRegistration reg = new PersistentRegistration(properties, RegistrationStatus.PENDING);
+ reg.setPersistentHandle("handle");
+ reg.setRelatedConsumer(consumer);
+ consumer.getRelatedRegistrations().add(reg);
+ session.persist(reg);
+ session.flush();
+ TransactionAssert.commitTransaction();
+ }
+
+ public void _testCloneNonExistingPortletWithinTx() throws Exception
+ {
try
{
TransactionAssert.beginTransaction();
@@ -279,7 +309,7 @@
// todo check state
}
- public void testCloneNullPortletWithinTx() throws Exception
+ public void _testCloneNullPortletWithinTx() throws Exception
{
try
{
@@ -293,7 +323,7 @@
}
}
- public void testCloneExistingPortletWithinTx() throws Exception
+ public void _testCloneExistingPortletWithinTx() throws Exception
{
// Clone a POP
TransactionAssert.beginTransaction();
@@ -341,7 +371,7 @@
TransactionAssert.commitTransaction();
}
- public void testDestroyNonExistingPortletWithinTx() throws Exception
+ public void _testDestroyNonExistingPortletWithinTx() throws Exception
{
TransactionAssert.beginTransaction();
List failures = producer.destroyClones(Collections.singletonList(PortletContext.createPortletContext("_1")));
@@ -349,7 +379,7 @@
TransactionAssert.commitTransaction();
}
- public void testDestroyNullPortletWithinTx() throws Exception
+ public void _testDestroyNullPortletWithinTx() throws Exception
{
try
{
@@ -364,7 +394,7 @@
}
/*
- public void testDestroyInvalidPortletWithinTx() throws Exception
+ public void _testDestroyInvalidPortletWithinTx() throws Exception
{
try
{
@@ -379,7 +409,7 @@
}
*/
- public void testDestroyPortletWithinTx() throws Exception
+ public void _testDestroyPortletWithinTx() throws Exception
{
// Clone a POP 2 times
TransactionAssert.beginTransaction();
@@ -418,7 +448,7 @@
TransactionAssert.commitTransaction();
}
- public void testInvokeCloneBeforeWritePOPWithinTx() throws Exception
+ public void _testInvokeCloneBeforeWritePOPWithinTx() throws Exception
{
TransactionAssert.beginTransaction();
PortletInvocation action = new ActionInvocation(new ActionContextImpl(Mode.VIEW));
@@ -444,7 +474,7 @@
TransactionAssert.commitTransaction();
}
- public void testInvokeReadWritePOPWithinTx() throws Exception
+ public void _testInvokeReadWritePOPWithinTx() throws Exception
{
TransactionAssert.beginTransaction();
PortletInvocation action = new ActionInvocation(new ActionContextImpl(Mode.VIEW));
@@ -462,7 +492,7 @@
TransactionAssert.commitTransaction();
}
- public void testInvokeReadOnlyPOPWithinTx() throws Exception
+ public void _testInvokeReadOnlyPOPWithinTx() throws Exception
{
TransactionAssert.beginTransaction();
PortletInvocation action = new ActionInvocation(new ActionContextImpl(Mode.VIEW));
@@ -480,7 +510,7 @@
TransactionAssert.commitTransaction();
}
- public void testInvokeCloneBeforeWriteCCPWithinTx() throws Exception
+ public void _testInvokeCloneBeforeWriteCCPWithinTx() throws Exception
{
TransactionAssert.beginTransaction();
PortletContext cloningPortletId = producer.createClone(PortletContext.createPortletContext("CloningPortlet"));
@@ -519,7 +549,7 @@
TransactionAssert.commitTransaction();
}
- public void testInvokeReadWriteCCPWithinTx() throws Exception
+ public void _testInvokeReadWriteCCPWithinTx() throws Exception
{
TransactionAssert.beginTransaction();
PortletContext cloningPortletId = producer.createClone(PortletContext.createPortletContext("CloningPortlet"));
@@ -549,7 +579,7 @@
TransactionAssert.commitTransaction();
}
- public void testInvokeReadOnlyCCPWithinTx() throws Exception
+ public void _testInvokeReadOnlyCCPWithinTx() throws Exception
{
TransactionAssert.beginTransaction();
PortletContext cloneFailedCloningPortletId = producer.createClone(PortletContext.createPortletContext("CloneFailedCloningPortlet"));
@@ -571,7 +601,7 @@
TransactionAssert.commitTransaction();
}
- public void testInvokeCloneBeforeWritePOPWithinTxThrowsException() throws Exception
+ public void _testInvokeCloneBeforeWritePOPWithinTxThrowsException() throws Exception
{
TransactionAssert.beginTransaction();
PortletInvocation action = new ActionInvocation(new ActionContextImpl(Mode.VIEW));
@@ -597,18 +627,18 @@
TransactionAssert.commitTransaction();
}
- public void testGetProperties()
+ public void _testGetProperties()
{
}
- public void testSetProperties()
+ public void _testSetProperties()
{
}
/** todo : should check the portlet metadata as well */
- public void testGetPortlet() throws Exception
+ public void _testGetPortlet() throws Exception
{
// Clone a POP
TransactionAssert.beginTransaction();
Added: trunk/core/src/main/org/jboss/portal/test/core/state/RegistrationPersistenceManagerTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/state/RegistrationPersistenceManagerTestCase.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/core/src/main/org/jboss/portal/test/core/state/RegistrationPersistenceManagerTestCase.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -0,0 +1,155 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.jboss.portal.test.core.state;
+
+import junit.framework.TestSuite;
+import org.apache.log4j.Appender;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.SimpleLayout;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+import org.jboss.portal.common.test.TestParametrization;
+import org.jboss.portal.common.test.junit.JUnitAdapter;
+import org.jboss.portal.common.test.junit.POJOJUnitTest;
+import org.jboss.portal.common.junit.TransactionAssert;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.embedded.HibernateSupport;
+import org.jboss.portal.test.framework.TestRuntimeContext;
+import org.jboss.portal.test.wsrp.registration.AbstractRegistrationPersistenceManagerTestCase;
+import org.jboss.portal.core.impl.portlet.state.PersistentStateStore;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPersistenceManager;
+
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5776 $
+ */
+public class RegistrationPersistenceManagerTestCase extends AbstractRegistrationPersistenceManagerTestCase
+{
+
+ static
+ {
+ Appender appender = new ConsoleAppender(new SimpleLayout());
+ Logger.getRoot().addAppender(appender);
+ Logger.getRoot().setLevel(Level.DEBUG);
+ Logger.getLogger("org.hibernate").setLevel(Level.ERROR);
+ }
+
+ public static TestSuite suite() throws Exception
+ {
+ TestParametrization parametrization = JUnitAdapter.getParametrization();
+ URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+ parametrization.setParameterValue("DataSourceConfig", DataSourceSupport.Config.fromXML2(configsURL));
+ POJOJUnitTest abc = new POJOJUnitTest(RegistrationPersistenceManagerTestCase.class);
+ JUnitAdapter adapter = new JUnitAdapter(abc, parametrization);
+ TestSuite suite = new TestSuite();
+ suite.addTest(adapter);
+ return suite;
+ }
+
+ /** . */
+ private TestRuntimeContext runtimeContext;
+
+ /** . */
+ private DataSourceSupport.Config dataSourceConfigParameter;
+
+ /** . */
+ private HibernateSupport hibernateSupport;
+
+ /** . */
+ private PersistentStateStore persistenceManager;
+
+ public String getName()
+ {
+ return super.getName() + ",ds=" + dataSourceConfigParameter.getName();
+ }
+
+ public HibernateSupport getHibernateSupport()
+ {
+ return hibernateSupport;
+ }
+
+ public void setHibernateSupport(HibernateSupport hibernateSupport)
+ {
+ this.hibernateSupport = hibernateSupport;
+ }
+
+ public PersistentStateStore getPersistenceManager()
+ {
+ return persistenceManager;
+ }
+
+ public void setPersistenceManager(PersistentStateStore persistenceManager)
+ {
+ this.persistenceManager = persistenceManager;
+ }
+
+ public DataSourceSupport.Config getDataSourceConfigParameter()
+ {
+ return dataSourceConfigParameter;
+ }
+
+ public void setDataSourceConfigParameter(DataSourceSupport.Config dataSourceConfigParameter)
+ {
+ this.dataSourceConfigParameter = dataSourceConfigParameter;
+ }
+
+ public void setUp() throws Exception
+ {
+ runtimeContext = new TestRuntimeContext("org/jboss/portal/test/core/state/registration-persistence-manager-beans.xml");
+ runtimeContext.addBean("TestBean", this);
+ runtimeContext.addBean("DataSourceConfig", dataSourceConfigParameter);
+ runtimeContext.addBean("HibernateConfig", HibernateSupport.getConfig(dataSourceConfigParameter.getName()));
+ runtimeContext.start();
+
+ //
+ super.setUp();
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ // Cleanup any pending transaction
+ TransactionAssert.endTransaction();
+
+ //
+ runtimeContext.stop();
+ }
+
+ public RegistrationPersistenceManager getManager()
+ {
+ return persistenceManager;
+ }
+
+ public void startInteraction()
+ {
+ TransactionAssert.beginTransaction();
+ }
+
+ public void stopInteraction()
+ {
+ TransactionAssert.commitTransaction();
+ }
+}
Modified: trunk/core/src/resources/portal-core-sar/conf/hibernate/portlet/domain.hbm.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/hibernate/portlet/domain.hbm.xml 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/core/src/resources/portal-core-sar/conf/hibernate/portlet/domain.hbm.xml 2006-12-12 01:24:50 UTC (rev 5805)
@@ -135,4 +135,122 @@
not-null="true"
unique="false"/>
</class>
+
+ <class
+ name="org.jboss.portal.core.impl.portlet.state.PersistentConsumerGroup"
+ table="JBP_PORTLET_GROUP">
+ <cache usage="@portal.hibernate.cache.usage@"/>
+ <id
+ name="key"
+ column="PK"
+ type="java.lang.Long">
+ <generator class="native">
+ <param name="sequence">portlet_seq</param>
+ </generator>
+ </id>
+ <property
+ name="persistentName"
+ column="ID"
+ type="java.lang.String"
+ not-null="true"
+ unique="true"/>
+ <property
+ name="persistentStatus"
+ column="STATUS"
+ type="org.jboss.portal.core.impl.portlet.state.RegistrationStatusUserType"/>
+ <map
+ name="relatedConsumers"
+ inverse="true">
+ <cache usage="@portal.hibernate.cache.usage@"/>
+ <key column="GROUP_PK"/>
+ <map-key
+ type="string"
+ column="ID"/>
+ <one-to-many class="org.jboss.portal.core.impl.portlet.state.PersistentConsumer"/>
+ </map>
+ </class>
+ <class
+ name="org.jboss.portal.core.impl.portlet.state.PersistentConsumer"
+ table="JBP_PORTLET_CONSUMER">
+ <cache usage="@portal.hibernate.cache.usage@"/>
+ <id
+ name="key"
+ column="PK"
+ type="java.lang.Long">
+ <generator class="native">
+ <param name="sequence">portlet_seq</param>
+ </generator>
+ </id>
+ <property
+ name="persistentId"
+ column="ID"
+ type="java.lang.String"
+ not-null="true"
+ unique="true"/>
+ <property
+ name="persistentName"
+ column="NAME"
+ type="java.lang.String"/>
+ <property
+ name="persistentAgent"
+ column="AGENT"
+ type="java.lang.String"/>
+ <property
+ name="persistentStatus"
+ column="STATUS"
+ type="org.jboss.portal.core.impl.portlet.state.RegistrationStatusUserType"/>
+ <many-to-one
+ name="relatedGroup"
+ column="GROUP_PK"
+ class="org.jboss.portal.core.impl.portlet.state.PersistentConsumerGroup"/>
+ <set
+ name="relatedRegistrations"
+ inverse="true">
+ <cache usage="@portal.hibernate.cache.usage@"/>
+ <key column="CONSUMER_PK"/>
+ <one-to-many class="org.jboss.portal.core.impl.portlet.state.PersistentRegistration"/>
+ </set>
+ </class>
+ <class
+ name="org.jboss.portal.core.impl.portlet.state.PersistentRegistration"
+ table="JBP_PORTLET_REGISTRATION">
+ <cache usage="@portal.hibernate.cache.usage@"/>
+ <id
+ name="key"
+ column="PK"
+ type="java.lang.Long">
+ <generator class="native">
+ <param name="sequence">portlet_seq</param>
+ </generator>
+ </id>
+ <map
+ name="persistentProperties"
+ sort="unsorted"
+ inverse="false"
+ cascade="all-delete-orphan"
+ fetch="join">
+ <cache usage="@portal.hibernate.cache.usage@"/>
+ <key column="REGISTRATION_PK"/>
+ <map-key
+ type="org.jboss.portal.jems.hibernate.QNameUserType"
+ column="QNAME"/>
+ <element
+ type="string"
+ column="VALUE"/>
+ </map>
+ <property
+ name="persistentHandle"
+ column="HANDLE"
+ type="java.lang.String"/>
+ <property
+ name="persistentStatus"
+ column="STATUS"
+ type="org.jboss.portal.core.impl.portlet.state.RegistrationStatusUserType"/>
+ <many-to-one
+ name="relatedConsumer"
+ column="CONSUMER_PK"
+ class="org.jboss.portal.core.impl.portlet.state.PersistentConsumer"
+ not-null="true"
+ update="false"/>
+ </class>
</hibernate-mapping>
Added: trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/state/registration-persistence-manager-beans.xml
===================================================================
--- trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/state/registration-persistence-manager-beans.xml 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/core/src/resources/portal-core-test-jar/org/jboss/portal/test/core/state/registration-persistence-manager-beans.xml 2006-12-12 01:24:50 UTC (rev 5805)
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="DataSourceConfig" class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>DataSourceConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="HibernateConfig" class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>HibernateConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="JNDISupport" class="org.jboss.portal.test.framework.embedded.JNDISupport">
+ </bean>
+
+ <bean name="TransactionManagerSupport" class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport">
+ </bean>
+
+ <bean name="ConnectionManagerSupport" class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
+ <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
+ </bean>
+
+ <bean name="DataSourceSupport" class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
+ <property name="transactionManager"><inject bean="TransactionManagerSupport" property="transactionManager"/></property>
+ <property name="connectionManagerReference"><inject bean="ConnectionManagerSupport" property="connectionManagerReference"/></property>
+ <property name="config"><inject bean="DataSourceConfig"/></property>
+ </bean>
+
+ <bean name="HibernateSupport" class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <property name="config"><inject bean="HibernateConfig"/></property>
+ <property name="mappings">
+ <list elementClass="java.lang.String">
+ <value>conf/hibernate/portlet/domain.hbm.xml</value>
+ </list>
+ </property>
+ <property name="jNDIName">java:/SessionFactory</property>
+ </bean>
+
+ <bean name="PersistenceManager" class="org.jboss.portal.core.impl.portlet.state.PersistentStateStore">
+ <property name="sessionFactoryJNDIName">java:/SessionFactory</property>
+ </bean>
+
+ <bean name="TestBean" class="org.jboss.portal.test.core.state.RegistrationPersistenceManagerTestCase">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory"/>
+ <parameter>TestBean</parameter>
+ </constructor>
+ <property name="hibernateSupport"><inject bean="HibernateSupport"/></property>
+ <property name="persistenceManager"><inject bean="PersistenceManager"/></property>
+ </bean>
+</deployment>
Modified: trunk/jems/src/main/org/jboss/portal/jems/hibernate/QNameUserType.java
===================================================================
--- trunk/jems/src/main/org/jboss/portal/jems/hibernate/QNameUserType.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/jems/src/main/org/jboss/portal/jems/hibernate/QNameUserType.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -43,7 +43,7 @@
{
/** . */
- private static final int[] SQL_TYPES = {Hibernate.STRING.sqlType(),Hibernate.STRING.sqlType()};
+ private static final int[] SQL_TYPES = {Hibernate.STRING.sqlType()};
public int[] sqlTypes()
{
@@ -78,38 +78,37 @@
public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException
{
- // Test nullity on local part
- String localPart = resultSet.getString(names[1]);
+ // Test nullity
+ String value = resultSet.getString(names[0]);
if (resultSet.wasNull())
{
return null;
}
- // The namespace URI
- String namespaceURI = resultSet.getString(names[0]);
-
- // Oracle considers that the empty string is null (very nice feature, clap clap), so we replace null by empty string
- if (namespaceURI == null)
+ //
+ int pos = value.indexOf(':');
+ if (pos == -1)
{
- namespaceURI = "";
+ return new QName(value);
}
-
- //
- return new QName(namespaceURI, localPart);
+ else
+ {
+ String namespaceURI = value.substring(0, pos);
+ String localPart = value.substring(pos + 1);
+ return new QName(namespaceURI, localPart);
+ }
}
public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException
{
if (value == null)
{
- statement.setNull(index, Types.VARCHAR);
- statement.setNull(index + 1, Types.VARCHAR);
+ statement.setNull(index, SQL_TYPES[0]);
}
else
{
QName qname = (QName)value;
- statement.setString(index, qname.getNamespaceURI());
- statement.setString(index + 1, qname.getLocalPart());
+ statement.setString(index, qname.getNamespaceURI() + ":" + qname.getLocalPart());
}
}
Modified: trunk/tools/etc/buildfragments/modules.ent
===================================================================
--- trunk/tools/etc/buildfragments/modules.ent 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/tools/etc/buildfragments/modules.ent 2006-12-12 01:24:50 UTC (rev 5805)
@@ -103,6 +103,7 @@
<property name="jboss.portal-wsrp.lib" value="${jboss.portal-wsrp.root}/lib"/>
<path id="jboss.portal-wsrp.classpath">
<pathelement path="${jboss.portal-wsrp.lib}/portal-wsrp-lib.jar"/>
+ <pathelement path="${jboss.portal-wsrp.lib}/portal-wsrp-test-lib.jar"/>
</path>
<!-- security -->
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/wsrp/build.xml 2006-12-12 01:24:50 UTC (rev 5805)
@@ -229,6 +229,11 @@
</fileset>
<!--<fileset dir="${build.resources}/portal-wsrp-lib-jar"/>-->
</jar>
+ <jar jarfile="${build.lib}/portal-wsrp-test-lib.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/portal/test/**"/>
+ </fileset>
+ </jar>
<jar jarfile="${build.lib}/portal-wsrp.jse">
<fileset dir="${build.resources}/portal-wsrp-war"/>
</jar>
Added: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/AbstractRegistrationPersistenceManagerTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/AbstractRegistrationPersistenceManagerTestCase.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/AbstractRegistrationPersistenceManagerTestCase.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -0,0 +1,400 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.jboss.portal.test.wsrp.registration;
+
+import junit.framework.TestCase;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPersistenceManager;
+import org.jboss.portal.wsrp.producer.registration.api.ConsumerGroup;
+import org.jboss.portal.wsrp.producer.registration.api.DuplicateRegistrationException;
+import org.jboss.portal.wsrp.producer.registration.api.NoSuchRegistrationException;
+import org.jboss.portal.wsrp.producer.registration.api.Consumer;
+import org.jboss.portal.wsrp.producer.registration.api.Registration;
+
+import javax.xml.namespace.QName;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 5787 $
+ * @since 2.6
+ */
+public abstract class AbstractRegistrationPersistenceManagerTestCase extends TestCase
+{
+
+ /** . */
+ private Map registrationProperties;
+
+ public abstract RegistrationPersistenceManager getManager();
+
+ public void startInteraction()
+ {
+ }
+
+ public void stopInteraction()
+ {
+ }
+
+ public void setUp() throws Exception
+ {
+ registrationProperties = new HashMap();
+ registrationProperties.put(new QName("prop1"), "value1");
+ registrationProperties.put(new QName("prop2"), "value2");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ registrationProperties = null;
+ }
+
+ public void testGetGroupThrowsIAE() throws Exception
+ {
+ startInteraction();
+ try
+ {
+ getManager().getConsumerGroup(null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ stopInteraction();
+ }
+
+ public void testAddGroup() throws Exception
+ {
+ startInteraction();
+ ConsumerGroup group = getManager().createConsumerGroup("Foo");
+ assertNotNull(group);
+ assertEquals("Foo", group.getName());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(group.getConsumers()));
+ stopInteraction();
+
+ // Test by retrieving the same consumer
+ startInteraction();
+ group = getManager().getConsumerGroup("Foo");
+ assertNotNull(group);
+ assertEquals("Foo", group.getName());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(group.getConsumers()));
+ stopInteraction();
+
+ // Test by retrieving the consumer list
+ startInteraction();
+ Collection groups = getManager().getConsumerGroups();
+ assertNotNull(groups);
+ assertEquals(1, groups.size());
+ group = (ConsumerGroup)groups.iterator().next();
+ assertNotNull(group);
+ assertEquals("Foo", group.getName());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(group.getConsumers()));
+ stopInteraction();
+ }
+
+ public void testAddDuplicateGroup() throws Exception
+ {
+ startInteraction();
+ getManager().createConsumerGroup("Foo");
+ try
+ {
+ getManager().createConsumerGroup("Foo");
+ fail();
+ }
+ catch (DuplicateRegistrationException expected)
+ {
+ }
+ stopInteraction();
+ }
+
+ public void testAddGroupThrowsIAE() throws Exception
+ {
+ startInteraction();
+ try
+ {
+ getManager().createConsumerGroup(null);
+ }
+ catch (IllegalArgumentException expected)
+ {
+ assertEquals(Collections.EMPTY_SET, new HashSet(getManager().getConsumerGroups()));
+ }
+ stopInteraction();
+ }
+
+ public void testRemoveGroup() throws Exception
+ {
+ startInteraction();
+ getManager().createConsumerGroup("Foo");
+ stopInteraction();
+
+ startInteraction();
+ getManager().removeConsumerGroup("Foo");
+ assertNull(getManager().getConsumerGroup("Foo"));
+ assertEquals(Collections.EMPTY_SET, new HashSet(getManager().getConsumerGroups()));
+ stopInteraction();
+ }
+
+ public void testRemoveGroupThrowsIAE() throws Exception
+ {
+ startInteraction();
+ try
+ {
+ getManager().removeConsumerGroup(null);
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ stopInteraction();
+ }
+
+ public void testRemoveNonExistingGroup() throws Exception
+ {
+ startInteraction();
+ try
+ {
+ getManager().removeConsumerGroup("Foo");
+ }
+ catch (NoSuchRegistrationException expected)
+ {
+ }
+ stopInteraction();
+ }
+
+ public void testGetConsumerThrowsIAE() throws Exception
+ {
+ startInteraction();
+ try
+ {
+ ConsumerGroup group = getManager().createConsumerGroup("Foo");
+ group.getConsumer(null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ stopInteraction();
+ }
+
+ public void testAddConsumer() throws Exception
+ {
+ startInteraction();
+ ConsumerGroup group = getManager().createConsumerGroup("Foo");
+ stopInteraction();
+
+ startInteraction();
+ Consumer consumer = getManager().createConsumer("Bar", "Bar");
+ group.addConsumer(consumer);
+ assertNotNull(consumer);
+ assertEquals("Bar", consumer.getName());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(consumer.getRegistrations()));
+ assertEquals("Foo", consumer.getGroup().getName());
+ stopInteraction();
+
+ // Test by retrieving the same consumer
+ startInteraction();
+ consumer = group.getConsumer("Bar");
+ assertNotNull(consumer);
+ assertEquals("Bar", consumer.getName());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(consumer.getRegistrations()));
+ assertEquals("Foo", consumer.getGroup().getName());
+ stopInteraction();
+
+ // Test by retrieving the consumer list
+ startInteraction();
+ Collection consumers = group.getConsumers();
+ assertNotNull(consumers);
+ assertEquals(1, consumers.size());
+ consumer = (Consumer)consumers.iterator().next();
+ assertNotNull(consumer);
+ assertEquals("Bar", consumer.getName());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(consumer.getRegistrations()));
+ assertEquals("Foo", consumer.getGroup().getName());
+ stopInteraction();
+ }
+
+ public void testAddDuplicateConsumer() throws Exception
+ {
+ startInteraction();
+ ConsumerGroup group = getManager().createConsumerGroup("Foo");
+ Consumer consumer = getManager().createConsumer("Bar", "Bar");
+ group.addConsumer(consumer);
+ stopInteraction();
+
+ startInteraction();
+ try
+ {
+ group.addConsumer(consumer);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ stopInteraction();
+ }
+
+ public void testAddConsumerThrowsIAE() throws Exception
+ {
+ startInteraction();
+ ConsumerGroup group = getManager().createConsumerGroup("Foo");
+ try
+ {
+ group.addConsumer(null);
+ }
+ catch (IllegalArgumentException expected)
+ {
+ assertEquals(Collections.EMPTY_SET, new HashSet(group.getConsumers()));
+ }
+ stopInteraction();
+ }
+
+ public void testRemoveConsumer() throws Exception
+ {
+ startInteraction();
+ ConsumerGroup group = getManager().createConsumerGroup("Foo");
+ Consumer consumer = getManager().createConsumer("Bar", "Bar");
+ group.addConsumer(consumer);
+ group.removeConsumer(consumer);
+ assertNull(group.getConsumer("Bar"));
+ assertEquals(Collections.EMPTY_SET, new HashSet(group.getConsumers()));
+ stopInteraction();
+ }
+
+ public void testRemoveConsumerThrowsIAE() throws Exception
+ {
+ startInteraction();
+ ConsumerGroup group = getManager().createConsumerGroup("Foo");
+ try
+ {
+ group.removeConsumer(null);
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ stopInteraction();
+ }
+
+ public void testAddRegistration() throws Exception
+ {
+ startInteraction();
+ ConsumerGroup group = getManager().createConsumerGroup("Foo");
+ Consumer consumer = getManager().createConsumer("Bar", "Bar");
+ group.addConsumer(consumer);
+ stopInteraction();
+
+ startInteraction();
+ consumer = getManager().getConsumerById("Bar");
+ Registration reg1 = getManager().addRegistrationFor("Bar", registrationProperties);
+ assertNotNull(reg1);
+ String regId = reg1.getId();
+ assertNotNull(regId);
+ assertEquals(consumer, reg1.getConsumer());
+ Map expectedProps = new HashMap();
+ expectedProps.put(new QName("prop1"), "value1");
+ expectedProps.put(new QName("prop2"), "value2");
+ assertEquals(expectedProps, reg1.getProperties());
+ stopInteraction();
+
+ // Retrieve it from the list of consumer registrations
+ startInteraction();
+ consumer = getManager().getConsumerById("Bar");
+ Collection registrations = consumer.getRegistrations();
+ assertNotNull(registrations);
+ assertEquals(1, registrations.size());
+ Registration reg3 = (Registration)registrations.iterator().next();
+ assertEquals(regId, reg3.getId());
+ assertEquals(consumer, reg3.getConsumer());
+ assertEquals(expectedProps, reg3.getProperties());
+ stopInteraction();
+
+ // Retrieve the same registration from the registry
+ startInteraction();
+ Registration reg2 = getManager().getRegistration(regId);
+ consumer = getManager().getConsumerById("Bar");
+ assertNotNull(reg2);
+ assertEquals(regId, reg2.getId());
+ assertEquals(consumer, reg2.getConsumer());
+ assertEquals(expectedProps, reg2.getProperties());
+ stopInteraction();
+ }
+
+ public void testAddRegistrationThrowsIAE() throws Exception
+ {
+ startInteraction();
+ ConsumerGroup group = getManager().createConsumerGroup("Foo");
+ Consumer consumer = getManager().createConsumer("Bar", "Bar");
+ group.addConsumer(consumer);
+
+ try
+ {
+ getManager().addRegistrationFor(consumer.getId(), null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ stopInteraction();
+ }
+
+ public void testRemoveRegistrationThrowsIAE() throws Exception
+ {
+ startInteraction();
+ try
+ {
+ getManager().removeRegistration(null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ stopInteraction();
+ }
+
+ public void testRemoveRegistration() throws Exception
+ {
+ startInteraction();
+ ConsumerGroup group = getManager().createConsumerGroup("Foo");
+ Consumer consumer = getManager().createConsumer("Bar", "Bar");
+ group.addConsumer(consumer);
+ Registration reg = getManager().addRegistrationFor("Bar", registrationProperties);
+ String regId = reg.getId();
+ getManager().removeRegistration(regId);
+ stopInteraction();
+
+ // remove registration is the only method on RegistrationPersistenceManager that needs to "cascade"
+ // this is needed because there is no remove method on Consumer, hence the manager needs to remove the
+ // registration from its consumer since it's the only class that has access to the specific consumer impl
+ startInteraction();
+ consumer = getManager().getConsumerById("Bar");
+ Collection registrations = consumer.getRegistrations();
+ assertNotNull(registrations);
+ assertEquals(0, registrations.size());
+ stopInteraction();
+
+ //
+ startInteraction();
+ assertEquals(null, getManager().getRegistration(regId));
+ stopInteraction();
+ }
+}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationPersistenceManagerTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationPersistenceManagerTestCase.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationPersistenceManagerTestCase.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -23,309 +23,38 @@
package org.jboss.portal.test.wsrp.registration;
-import junit.framework.TestCase;
-import org.jboss.portal.wsrp.producer.registration.api.Consumer;
-import org.jboss.portal.wsrp.producer.registration.api.ConsumerGroup;
-import org.jboss.portal.wsrp.producer.registration.api.DuplicateRegistrationException;
-import org.jboss.portal.wsrp.producer.registration.api.NoSuchRegistrationException;
-import org.jboss.portal.wsrp.producer.registration.api.Registration;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationPersistenceManager;
import org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl;
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
* @version $Revision$
* @since 2.6
*/
-public class RegistrationPersistenceManagerTestCase extends TestCase
+public class RegistrationPersistenceManagerTestCase extends AbstractRegistrationPersistenceManagerTestCase
{
+
+ /** . */
private RegistrationPersistenceManager manager;
- private Map registrationProperties;
- public void setUp()
+ public void setUp() throws Exception
{
manager = new RegistrationPersistenceManagerImpl();
- registrationProperties = new HashMap();
- registrationProperties.put(new QName("prop1"), "value1");
- registrationProperties.put(new QName("prop2"), "value2");
+
+ //
+ super.setUp();
}
protected void tearDown() throws Exception
{
- manager = null;
- registrationProperties = null;
- }
+ super.tearDown();
- public void testGetGroupThrowsIAE() throws Exception
- {
- try
- {
- manager.getConsumerGroup(null);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- }
- }
-
- public void testAddGroup() throws Exception
- {
- ConsumerGroup group = manager.createConsumerGroup("Foo");
- assertNotNull(group);
- assertEquals("Foo", group.getName());
- assertEquals(Collections.EMPTY_LIST, new ArrayList(group.getConsumers()));
-
- // Test by retrieving the same consumer
- group = manager.getConsumerGroup("Foo");
- assertNotNull(group);
- assertEquals("Foo", group.getName());
- assertEquals(Collections.EMPTY_LIST, new ArrayList(group.getConsumers()));
-
- // Test by retrieving the consumer list
- Collection groups = manager.getConsumerGroups();
- assertNotNull(groups);
- assertEquals(1, groups.size());
- group = (ConsumerGroup)groups.iterator().next();
- assertNotNull(group);
- assertEquals("Foo", group.getName());
- assertEquals(Collections.EMPTY_LIST, new ArrayList(group.getConsumers()));
- }
-
- public void testAddDuplicateGroup() throws Exception
- {
- manager.createConsumerGroup("Foo");
- try
- {
- manager.createConsumerGroup("Foo");
- fail();
- }
- catch (DuplicateRegistrationException expected)
- {
- }
- }
-
- public void testAddGroupThrowsIAE() throws Exception
- {
- try
- {
- manager.createConsumerGroup(null);
- }
- catch (IllegalArgumentException expected)
- {
- assertEquals(Collections.EMPTY_SET, new HashSet(manager.getConsumerGroups()));
- }
- }
-
- public void testRemoveGroup() throws Exception
- {
- manager.createConsumerGroup("Foo");
- manager.removeConsumerGroup("Foo");
- assertNull(manager.getConsumerGroup("Foo"));
- assertEquals(Collections.EMPTY_SET, new HashSet(manager.getConsumerGroups()));
- }
-
- public void testRemoveGroupThrowsIAE() throws Exception
- {
- try
- {
- manager.removeConsumerGroup(null);
- }
- catch (IllegalArgumentException expected)
- {
- }
- }
-
- public void testRemoveNonExistingGroup() throws Exception
- {
- try
- {
- manager.removeConsumerGroup("Foo");
- }
- catch (NoSuchRegistrationException expected)
- {
- }
- }
-
- public void testGetConsumerThrowsIAE() throws Exception
- {
- try
- {
- ConsumerGroup group = manager.createConsumerGroup("Foo");
- group.getConsumer(null);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- }
- }
-
- public void testAddConsumer() throws Exception
- {
- ConsumerGroup group = manager.createConsumerGroup("Foo");
-
- Consumer consumer = manager.createConsumer("Bar", "Bar");
- group.addConsumer(consumer);
- assertNotNull(consumer);
- assertEquals("Bar", consumer.getName());
- assertEquals(Collections.EMPTY_LIST, new ArrayList(consumer.getRegistrations()));
- assertEquals("Foo", consumer.getGroup().getName());
-
- // Test by retrieving the same consumer
- consumer = group.getConsumer("Bar");
- assertNotNull(consumer);
- assertEquals("Bar", consumer.getName());
- assertEquals(Collections.EMPTY_LIST, new ArrayList(consumer.getRegistrations()));
- assertEquals("Foo", consumer.getGroup().getName());
-
- // Test by retrieving the consumer list
- Collection consumers = group.getConsumers();
- assertNotNull(consumers);
- assertEquals(1, consumers.size());
- consumer = (Consumer)consumers.iterator().next();
- assertNotNull(consumer);
- assertEquals("Bar", consumer.getName());
- assertEquals(Collections.EMPTY_LIST, new ArrayList(consumer.getRegistrations()));
- assertEquals("Foo", consumer.getGroup().getName());
- }
-
- public void testAddDuplicateConsumer() throws Exception
- {
- ConsumerGroup group = manager.createConsumerGroup("Foo");
- Consumer consumer = manager.createConsumer("Bar", "Bar");
- group.addConsumer(consumer);
-
- try
- {
- group.addConsumer(consumer);
- fail();
- }
- catch (DuplicateRegistrationException expected)
- {
- }
- }
-
- public void testAddConsumerThrowsIAE() throws Exception
- {
- ConsumerGroup group = manager.createConsumerGroup("Foo");
- try
- {
- group.addConsumer(null);
- }
- catch (IllegalArgumentException expected)
- {
- assertEquals(Collections.EMPTY_SET, new HashSet(group.getConsumers()));
- }
- }
-
- public void testRemoveConsumer() throws Exception
- {
- ConsumerGroup group = manager.createConsumerGroup("Foo");
- Consumer consumer = manager.createConsumer("Bar", "Bar");
- group.addConsumer(consumer);
- group.removeConsumer(consumer);
- assertNull(group.getConsumer("Bar"));
- assertEquals(Collections.EMPTY_SET, new HashSet(group.getConsumers()));
- }
-
- public void testRemoveConsumerThrowsIAE() throws Exception
- {
- ConsumerGroup group = manager.createConsumerGroup("Foo");
- try
- {
- group.removeConsumer(null);
- }
- catch (IllegalArgumentException expected)
- {
- }
- }
-
- public void testAddRegistration() throws Exception
- {
- ConsumerGroup group = manager.createConsumerGroup("Foo");
- Consumer consumer = manager.createConsumer("Bar", "Bar");
- group.addConsumer(consumer);
-
//
- Registration reg1 = manager.addRegistrationFor("Bar", registrationProperties);
- assertNotNull(reg1);
- String regId = reg1.getId();
- assertNotNull(regId);
- assertEquals(consumer, reg1.getConsumer());
- Map expectedProps = new HashMap();
- expectedProps.put(new QName("prop1"), "value1");
- expectedProps.put(new QName("prop2"), "value2");
- assertEquals(expectedProps, reg1.getProperties());
-
- // Retrieve it from the list of consumer registrations
- Collection registrations = consumer.getRegistrations();
- assertNotNull(registrations);
- assertEquals(1, registrations.size());
- Registration reg3 = (Registration)registrations.iterator().next();
- assertEquals(regId, reg3.getId());
- assertEquals(consumer, reg3.getConsumer());
- assertEquals(expectedProps, reg3.getProperties());
-
- // Retrieve the same registration from the registry
- Registration reg2 = manager.getRegistration(regId);
- assertNotNull(reg2);
- assertEquals(regId, reg2.getId());
- assertEquals(consumer, reg2.getConsumer());
- assertEquals(expectedProps, reg2.getProperties());
+ this.manager = null;
}
- public void testAddRegistrationThrowsIAE() throws Exception
+ public RegistrationPersistenceManager getManager()
{
- ConsumerGroup group = manager.createConsumerGroup("Foo");
- Consumer consumer = manager.createConsumer("Bar", "Bar");
- group.addConsumer(consumer);
-
- try
- {
- manager.addRegistrationFor(consumer.getId(), null);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- }
+ return manager;
}
-
- public void testRemoveRegistrationThrowsIAE() throws Exception
- {
- try
- {
- manager.removeRegistration(null);
- fail();
- }
- catch (IllegalArgumentException expected)
- {
- }
- }
-
- public void testRemoveRegistration() throws Exception
- {
- ConsumerGroup group = manager.createConsumerGroup("Foo");
- Consumer consumer = manager.createConsumer("Bar", "Bar");
- group.addConsumer(consumer);
- Registration reg = manager.addRegistrationFor("Bar", registrationProperties);
- String regId = reg.getId();
- manager.removeRegistration(regId);
-
- // remove registration is the only method on RegistrationPersistenceManager that needs to "cascade"
- // this is needed because there is no remove method on Consumer, hence the manager needs to remove the
- // registration from its consumer since it's the only class that has access to the specific consumer impl
- Collection registrations = consumer.getRegistrations();
- assertNotNull(registrations);
- assertEquals(0, registrations.size());
-
- //
- assertEquals(null, manager.getRegistration(regId));
- }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationStatus.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationStatus.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationStatus.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -22,13 +22,15 @@
******************************************************************************/
package org.jboss.portal.wsrp.producer.registration.api;
+import java.io.Serializable;
+
/**
* Type safe enumeration that describes the status of a registration.
*
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision:5641 $
*/
-public class RegistrationStatus
+public class RegistrationStatus implements Serializable
{
/** The registration is valid. */
public static final RegistrationStatus VALID = new RegistrationStatus();
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerGroupImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerGroupImpl.java 2006-12-11 21:32:57 UTC (rev 5804)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerGroupImpl.java 2006-12-12 01:24:50 UTC (rev 5805)
@@ -124,7 +124,7 @@
String identity = consumer.getId();
if (consumers.containsKey(identity))
{
- throw new DuplicateRegistrationException("ConsumerGroup named '" + name
+ throw new IllegalArgumentException("ConsumerGroup named '" + name
+ "' already contains a Consumer named '" + consumer.getName() + "' (identity: '" + identity + "')");
}
19 years, 5 months
JBoss Portal SVN: r5804 - in trunk/core/src: main/org/jboss/portal/core/portlet/dashboard resources/portal-core-war/WEB-INF/jsp/dashboard
by portal-commits@lists.jboss.org
Author: roy.russo(a)jboss.com
Date: 2006-12-11 16:32:57 -0500 (Mon, 11 Dec 2006)
New Revision: 5804
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
Log:
JBPORTAL-1138 - delete page feature in dashboard configurator
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-12-11 20:52:39 UTC (rev 5803)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-12-11 21:32:57 UTC (rev 5804)
@@ -173,6 +173,7 @@
{
page = (Page)portal.getChild(editPage);
}
+ editPage = page.getName();
if ("copy".equals(op))
{
@@ -294,6 +295,26 @@
actionResponse.setRenderParameter("editPageSelect", pageName);
actionResponse.setRenderParameter("op", "editPage");
}
+ else if ("delete".equals(op))
+ {
+ String pageName = actionRequest.getParameter("pagename");
+ try
+ {
+ // TODO: check for default page.
+ portal.destroyChild(pageName);
+ }
+ catch (Exception e)
+ {
+ // do something
+ }
+
+ actionResponse.setRenderParameter("op", "editPage");
+ }
+ else
+ {
+ actionResponse.setRenderParameter("editPageSelect", editPage);
+ actionResponse.setRenderParameter("op", "editPage");
+ }
}
private int doWindowNaming()
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-11 20:52:39 UTC (rev 5803)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-11 21:32:57 UTC (rev 5804)
@@ -75,10 +75,20 @@
for (int i = 0; i < pages.size(); i++)
{
Page onePage = (Page)pages.get(i);
+ if (onePage.getName().equals(currentPage))
+ {
%>
+ <option selected="true" value="<%= onePage.getName() %>"><%= onePage.getName() %>
+ </option>
+ <%
+ }
+ else
+ {
+ %>
<option value="<%= onePage.getName() %>"><%= onePage.getName() %>
</option>
<%
+ }
}
%>
</select>
@@ -181,6 +191,24 @@
</td>
</tr>
</table>
-</td>
-</tr>
-</table>
\ No newline at end of file
+<hr/>
+<%
+ if (!"default".equals(currentPage))
+ {
+%>
+<table width="100%">
+ <tr>
+ <td align="left">
+ <form action="<portlet:actionURL><portlet:param name="op" value="delete"></portlet:param>
+ </portlet:actionURL>" method="POST" style="padding:0;margin:0">
+ <input type="hidden" name="pagename" value="<%= currentPage %>"/>
+ <input type="submit" name="submit" value="Delete this Page"/>
+ <br/>
+ <font color="red">You cannot undo this action!</font>
+ </form>
+ </td>
+ </tr>
+</table>
+<%
+ }
+%>
\ No newline at end of file
19 years, 5 months
JBoss Portal SVN: r5803 - trunk/wsrp/src/main/org/jboss/portal/wsrp/producer
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-12-11 15:52:39 -0500 (Mon, 11 Dec 2006)
New Revision: 5803
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
Log:
- Finished implementing InstanceContext so that we can detect if the PortletContext was modified during the invocation.
- Fixed incorrect modification of the PortletContext (in essence, this file shouldn't have been commited last time ^_^;)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-12-11 20:32:31 UTC (rev 5802)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/MarkupHandler.java 2006-12-11 20:52:39 UTC (rev 5803)
@@ -392,9 +392,16 @@
updateResponse.setNewWindowState(WSRPUtils.convertJSR168WindowStateNameToWSRPName(getNewStateOrNull(renderResult, false)));
StateString ns = renderResult.getNavigationalState();
updateResponse.setNavigationalState(ns != null ? ns.getStringValue() : null);
- PortletContext updatedPortletContext = WSRPTypeFactory.createPortletContext(instanceContext.getId());
- updateResponse.setPortletContext(updatedPortletContext);
+ // deal with implicit cloning and state modification
+ if (instanceContext.wasModified())
+ {
+ PortletContext updatedPortletContext = WSRPTypeFactory.createPortletContext(instanceContext.getId());
+ updatedPortletContext.setPortletState(instanceContext.getState());
+ updateResponse.setPortletContext(updatedPortletContext);
+ }
+
+
return WSRPTypeFactory.createBlockingInteractionResponse(updateResponse);
}
else
@@ -902,6 +909,7 @@
class WSRPInstanceContext implements InstanceContext
{
private String id;
+ private byte[] state;
private final AccessMode accessMode;
private boolean wasModified = false;
@@ -926,6 +934,21 @@
public void onStateEvent(StateEvent event)
{
+ org.jboss.portal.portlet.PortletContext portletContext = event.getPortletContext();
+ ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "PortletContext");
+ wasModified = true;
+ id = portletContext.getId();
+ state = portletContext.getState();
}
+
+ public boolean wasModified()
+ {
+ return wasModified;
+ }
+
+ public byte[] getState()
+ {
+ return state;
+ }
}
}
19 years, 5 months
JBoss Portal SVN: r5802 - in trunk/core/src: main/org/jboss/portal/core/portlet/dashboard resources/portal-core-war/WEB-INF/jsp/dashboard
by portal-commits@lists.jboss.org
Author: roy.russo(a)jboss.com
Date: 2006-12-11 15:32:31 -0500 (Mon, 11 Dec 2006)
New Revision: 5802
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
Log:
- dashboard configuration retooling.
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-12-11 18:39:47 UTC (rev 5801)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-12-11 20:32:31 UTC (rev 5802)
@@ -25,11 +25,11 @@
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.PageContainer;
+import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.ThemeConstants;
@@ -109,57 +109,37 @@
op = "editPage";
}
- Portal portal;
+ Portal portal = (Portal)portalObjectContainer.getObject(dashboardId).getChild(req.getUser().getUserName());
+ Page page;
if (req.getParameter("editPageSelect") != null)
{
String editPageSelect = req.getParameter("editPageSelect");
- portal = (Portal)portalObjectContainer.getObject(dashboardId).getChild(editPageSelect);
+ page = (Page)portal.getChild(editPageSelect);
}
else
{
- portal = (Portal)portalObjectContainer.getObject(dashboardId).getChild(req.getUser().getUserName());
+ page = (Page)portal.getDefaultPage();
}
List available_instances = (List)instanceContainer.getInstances();
- List left_instances = new ArrayList();
- List center_instances = new ArrayList();
- List right_instances = new ArrayList();
+ resp.setContentType("text/html");
try
{
- Map windowMap = getWindows(portal.getDefaultPage());
+ Map windowMap = getWindows(page);
+
List regions = new ArrayList(windowMap.keySet());
Collections.sort(regions);
- for (Iterator i = regions.iterator(); i.hasNext();)
- {
- String region = (String)i.next();
-
- TreeSet windows = (TreeSet)windowMap.get(region);
- for (Iterator j = windows.iterator(); j.hasNext();)
- {
- Window window = (Window)j.next();
- if (region.equals("left"))
- {
- left_instances.add(window);
- //System.out.println(window.getInstanceRef() + ":" + window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER));
- }
- else if (region.equals("center"))
- {
- center_instances.add(window);
- }
- else if (region.equals("right"))
- {
- right_instances.add(window);
- }
- }
- }
+ req.setAttribute("windowMap", windowMap);
+ req.setAttribute("regions", regions);
}
catch (Exception e)
{
e.printStackTrace();
}
+ // page select box
List pages = new ArrayList();
for (Iterator j = portal.getChildren().iterator(); j.hasNext();)
{
@@ -170,31 +150,35 @@
}
}
- resp.setContentType("text/html");
req.setAttribute("available_instances", available_instances);
- req.setAttribute("left_instances", left_instances);
- req.setAttribute("center_instances", center_instances);
- req.setAttribute("right_instances", right_instances);
req.setAttribute("pages", pages);
- req.setAttribute("currentPage", portal.getName());
+ req.setAttribute("currentPage", page.getName());
+
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/dashboard/editpage.jsp");
rd.include(req, resp);
}
protected void processAction(JBossActionRequest actionRequest, JBossActionResponse actionResponse)
{
+ Portal portal = (Portal)portalObjectContainer.getObject(dashboardId).getChild(actionRequest.getUser().getUserName());
+ Page page;
+
String op = actionRequest.getParameter("op");
String editPage = actionRequest.getParameter("editPageSelect"); // the current page we're editting
- if (editPage == null)
+ if (editPage == null || "default".equalsIgnoreCase(editPage))
{
- editPage = actionRequest.getUser().getUserName();
+ page = (Page)portal.getDefaultPage();
}
+ else
+ {
+ page = (Page)portal.getChild(editPage);
+ }
+
if ("copy".equals(op))
{
String toRegion = actionRequest.getParameter("toRegion");
String[] copyInstance = actionRequest.getParameterValues("available_instances");
- Page page = (Page)portalObjectContainer.getObject(dashboardId).getChild(editPage);
try
{
for (int i = 0; i < copyInstance.length; i++)
@@ -221,20 +205,24 @@
{
String fromRegion = actionRequest.getParameter("fromRegion");
String[] removeWindows = null;
- if ("left".equals(fromRegion))
+ try
{
- removeWindows = actionRequest.getParameterValues("left_instances");
+ Map windowMap = getWindows(page);
+ List regions = new ArrayList(windowMap.keySet());
+ for (int i = 0; i < regions.size(); i++)
+ {
+ String region = (String)regions.get(i);
+ if (region.equalsIgnoreCase(fromRegion))
+ {
+ removeWindows = actionRequest.getParameterValues(region + "_instances");
+ }
+ }
}
- else if ("center".equals(fromRegion))
+ catch (Exception e)
{
- removeWindows = actionRequest.getParameterValues("center_instances");
+ // todo
}
- else if ("right".equals(fromRegion))
- {
- removeWindows = actionRequest.getParameterValues("right_instances");
- }
- Page page = (Page)portalObjectContainer.getObject(dashboardId).getChild(editPage);
try
{
for (int i = 0; i < removeWindows.length; i++)
@@ -252,40 +240,47 @@
{
String sortRegion = actionRequest.getParameter("sortRegion");
String[] moveWindows = null;
- if ("left".equals(sortRegion))
+ try
{
- moveWindows = actionRequest.getParameterValues("left_instances");
- }
- else if ("center".equals(sortRegion))
- {
- moveWindows = actionRequest.getParameterValues("center_instances");
- }
- else if ("right".equals(sortRegion))
- {
- moveWindows = actionRequest.getParameterValues("right_instances");
- }
-
- Page page = (Page)portalObjectContainer.getObject(dashboardId).getChild(editPage);
- for (int i = 0; i < moveWindows.length; i++)
- {
- Window window = page.getWindow(moveWindows[i]);
- if ("up".equals(op))
+ Map windowMap = getWindows(page);
+ List regions = new ArrayList(windowMap.keySet());
+ for (int i = 0; i < regions.size(); i++)
{
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(getOrder(window) - 1));
+ String region = (String)regions.get(i);
+ if (region.equalsIgnoreCase(sortRegion))
+ {
+ moveWindows = actionRequest.getParameterValues(region + "_instances");
+ }
}
- else if ("down".equals(op))
+
+ SortedSet windows = (SortedSet)windowMap.get(sortRegion);
+
+ for (int i = 0; i < moveWindows.length; i++)
{
- window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(getOrder(window) + 1));
+ Window window = page.getWindow(moveWindows[i]);
+ if ("up".equals(op))
+ {
+ int order = getMoveUpOrder(window, windows);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(order));
+ }
+ else if ("down".equals(op))
+ {
+ int order = getMoveDownOrder(window, windows);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(order));
+ }
}
}
+ catch (Exception e)
+ {
+ // todo
+ }
actionResponse.setRenderParameter("editPageSelect", editPage);
}
else if ("newpage".equals(op))
{
String pageName = actionRequest.getParameter("pagename");
- Page page = (Page)portalObjectContainer.getObject(dashboardId).getChild(actionRequest.getUser().getUserName());
- PageContainer pageContainer = page.getPortal();
+ PageContainer pageContainer = (PageContainer)page.getPortal();
try
{
@@ -299,11 +294,6 @@
actionResponse.setRenderParameter("editPageSelect", pageName);
actionResponse.setRenderParameter("op", "editPage");
}
- else if ("editPage".equals(op))
- {
- actionResponse.setRenderParameter("editPageSelect", editPage);
- actionResponse.setRenderParameter("op", op);
- }
}
private int doWindowNaming()
@@ -353,7 +343,8 @@
int sign = getOrder(w1) - getOrder(w2);
if (sign == 0)
{
- sign = w1.getId().compareTo(w2.getId());
+ sign = w1.getName().compareTo(w2.getName());
+ //sign = w1.getId().compareTo(w2.getId());
}
return sign;
}
@@ -370,4 +361,50 @@
return Integer.MAX_VALUE;
}
}
+
+ private static int getMoveUpOrder(Window window, SortedSet set)
+ {
+ Window previous = null;
+ for (Iterator i = set.iterator(); i.hasNext();)
+ {
+ Window current = (Window)i.next();
+
+ if (current.getName().equalsIgnoreCase(window.getName()))
+ {
+ if (previous == null)
+ {
+ return getOrder(current);
+ }
+ else
+ {
+ return (getOrder(previous) - 1);
+ }
+ }
+ previous = current;
+ }
+ return 0;
+ }
+
+ private int getMoveDownOrder(Window window, SortedSet set)
+ {
+ for (Iterator i = set.iterator(); i.hasNext();)
+ {
+ Window current = (Window)i.next();
+
+ if (current.getName().equalsIgnoreCase(window.getName()))
+ {
+ Window next = (Window)i.next();
+
+ if (next == null)
+ {
+ return getOrder(current);
+ }
+ else
+ {
+ return (getOrder(next) + 1);
+ }
+ }
+ }
+ return 0;
+ }
}
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-11 18:39:47 UTC (rev 5801)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-11 20:32:31 UTC (rev 5802)
@@ -16,12 +16,8 @@
<%
List available_instances = (List)request.getAttribute("available_instances");
- List left_instances = (List)request.getAttribute("left_instances");
- List center_instances = (List)request.getAttribute("center_instances");
- List right_instances = (List)request.getAttribute("right_instances");
List pages = (List)request.getAttribute("pages");
- //List regions = (List)request.getAttribute("regions");
Map windowMap = (Map)request.getAttribute("windowMap");
String currentPage = (String)request.getAttribute("currentPage");
19 years, 5 months
JBoss Portal SVN: r5801 - trunk/core/src/resources/portal-server-war/WEB-INF
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2006-12-11 13:39:47 -0500 (Mon, 11 Dec 2006)
New Revision: 5801
Modified:
trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
Log:
more meaningful comment
Modified: trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
===================================================================
--- trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2006-12-11 18:38:35 UTC (rev 5800)
+++ trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2006-12-11 18:39:47 UTC (rev 5801)
@@ -97,7 +97,7 @@
<url-pattern>/authsec/*</url-pattern>
</servlet-mapping>
- <!-- Force the mapping of the index.jsp because of the default servlet replacement -->
+ <!-- Force the mapping of the jsp and images because of the default servlet replacement -->
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>/login.jsp</url-pattern>
@@ -106,7 +106,6 @@
<servlet-name>jsp</servlet-name>
<url-pattern>/error.jsp</url-pattern>
</servlet-mapping>
-
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/images/login_bottom.png</url-pattern>
19 years, 5 months
JBoss Portal SVN: r5800 - trunk/core/src/resources/portal-server-war/images
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2006-12-11 13:38:35 -0500 (Mon, 11 Dec 2006)
New Revision: 5800
Added:
trunk/core/src/resources/portal-server-war/images/login_bottom.png
trunk/core/src/resources/portal-server-war/images/login_bottom_left.png
trunk/core/src/resources/portal-server-war/images/login_bottom_right.png
trunk/core/src/resources/portal-server-war/images/login_left.png
trunk/core/src/resources/portal-server-war/images/login_right.png
trunk/core/src/resources/portal-server-war/images/login_top.png
trunk/core/src/resources/portal-server-war/images/login_top_left.png
trunk/core/src/resources/portal-server-war/images/login_top_right.png
Log:
forgot to add the new images
Added: trunk/core/src/resources/portal-server-war/images/login_bottom.png
===================================================================
(Binary files differ)
Property changes on: trunk/core/src/resources/portal-server-war/images/login_bottom.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/src/resources/portal-server-war/images/login_bottom_left.png
===================================================================
(Binary files differ)
Property changes on: trunk/core/src/resources/portal-server-war/images/login_bottom_left.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/src/resources/portal-server-war/images/login_bottom_right.png
===================================================================
(Binary files differ)
Property changes on: trunk/core/src/resources/portal-server-war/images/login_bottom_right.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/src/resources/portal-server-war/images/login_left.png
===================================================================
(Binary files differ)
Property changes on: trunk/core/src/resources/portal-server-war/images/login_left.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/src/resources/portal-server-war/images/login_right.png
===================================================================
(Binary files differ)
Property changes on: trunk/core/src/resources/portal-server-war/images/login_right.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/src/resources/portal-server-war/images/login_top.png
===================================================================
(Binary files differ)
Property changes on: trunk/core/src/resources/portal-server-war/images/login_top.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/src/resources/portal-server-war/images/login_top_left.png
===================================================================
(Binary files differ)
Property changes on: trunk/core/src/resources/portal-server-war/images/login_top_left.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/core/src/resources/portal-server-war/images/login_top_right.png
===================================================================
(Binary files differ)
Property changes on: trunk/core/src/resources/portal-server-war/images/login_top_right.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
19 years, 5 months
JBoss Portal SVN: r5799 - in trunk/core/src/resources/portal-server-war: . WEB-INF
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2006-12-11 12:59:32 -0500 (Mon, 11 Dec 2006)
New Revision: 5799
Added:
trunk/core/src/resources/portal-server-war/images/
Modified:
trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
trunk/core/src/resources/portal-server-war/login.jsp
Log:
update login page, patch provided by Noel Rocher
Modified: trunk/core/src/resources/portal-server-war/WEB-INF/web.xml
===================================================================
--- trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2006-12-11 17:30:18 UTC (rev 5798)
+++ trunk/core/src/resources/portal-server-war/WEB-INF/web.xml 2006-12-11 17:59:32 UTC (rev 5799)
@@ -107,6 +107,39 @@
<url-pattern>/error.jsp</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/images/login_bottom.png</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/images/login_bottom_left.png</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/images/login_bottom_right.png</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/images/login_left.png</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/images/login_right.png</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/images/login_top.png</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/images/login_top_left.png</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>/images/login_top_right.png</url-pattern>
+ </servlet-mapping>
+
<session-config>
<session-timeout>15</session-timeout>
</session-config>
Modified: trunk/core/src/resources/portal-server-war/login.jsp
===================================================================
--- trunk/core/src/resources/portal-server-war/login.jsp 2006-12-11 17:30:18 UTC (rev 5798)
+++ trunk/core/src/resources/portal-server-war/login.jsp 2006-12-11 17:59:32 UTC (rev 5799)
@@ -23,61 +23,78 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
<html>
<head>
<style>
body {
background-color: #FFFFFF;
}
-
td {
color: #000000;
font-family: verdana, arial, sans-serif;
font-size: 12px;
line-height: 130%;
}
-
- table.form {
- background-color: #DFE8ED;
- border-style: dashed;
- border-color: #98B7C6;
- border-width: 1px;
-
- }
</style>
</head>
<body OnLoad="document.loginform.j_username.focus();">
-<table width="100%" height="100%" cellpadding="0" cellspacing="1">
+<table width="100%" height="600" cellpadding="0" cellspacing="1" >
<tr>
<td valign="middle" align="center">
+ <form method="POST" action="<%= response.encodeURL("j_security_check") %>" name="loginform" id="loginForm">
- <form method="POST" action="<%= response.encodeURL("j_security_check") %>" name="loginform" id="loginForm">
- <b>JBoss Portal Login</b><br><br>
- <table width="350" height="200" cellpadding="0" cellspacing="0" class="form">
- <tr>
- <td align="right" width="100">
- Username:
- </td>
- <td align="left">
- <input type="text" name="j_username" value=""/>
- </td>
- </tr>
- <tr>
- <td align="right" width="100">
- Password:
- </td>
- <td align="left">
- <input type="password" name="j_password" value=""/>
- </td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <input type="submit" name="login" value="Login"/>
- </td>
- </tr>
- </table>
+ <% String prefix = request.getContextPath(); %>
+
+ <table cellspacing="0" cellpadding="0">
+ <tr>
+ <td ><img src="<%= prefix %>/images/login_top_left.png" /></td>
+ <td style="background-image:url('<%= prefix %>/images/login_top.png')"></td>
+ <td><img src="<%= prefix %>/images/login_top_right.png" /></td>
+ </tr>
+ <tr>
+ <td style="background-image:url('<%= prefix %>/images/login_left.png')"></td>
+ <!-- REAL CONTENT CELL : begin -->
+ <td style="background-color:#b4b4b4" align="center">
+ <b>JBoss Portal Login</b><br/><br/>
+ <table>
+ <tr>
+ <td align="right" width="50">
+ Username:
+ </td>
+ <td align="left">
+ <input type="text" name="j_username" value=""/>
+ </td>
+ </tr>
+ <tr>
+ <td align="right" width="50">
+ Password:
+ </td>
+ <td align="left">
+ <input type="password" name="j_password" value=""/>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" align="right">
+ <input type="submit" name="login" value="Login"/>
+ </td>
+ </tr>
+ </table>
+
+ </td>
+ <!-- REAL CONTENT CELL : end -->
+ <td style="background-image:url('<%= prefix %>/images/login_right.png')"></td>
+ </tr>
+ <tr>
+ <td><img src="<%= prefix %>/images/login_bottom_left.png" /></td>
+ <td style="background-image:url('<%= prefix %>/images/login_bottom.png')"></td>
+ <td><img src="<%= prefix %>/images/login_bottom_right.png" /></td>
+ </tr>
+ </table>
+
+
</form>
</td>
@@ -86,4 +103,3 @@
</body>
</html>
-
19 years, 5 months