JBoss Portal SVN: r5726 - 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-11-27 15:33:29 -0500 (Mon, 27 Nov 2006)
New Revision: 5726
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-993
- Add page functionality added.
- Can now perform operations on newly added pages.
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-11-27 19:16:41 UTC (rev 5725)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-11-27 20:33:29 UTC (rev 5726)
@@ -24,6 +24,7 @@
import org.jboss.logging.Logger;
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.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.Window;
@@ -95,13 +96,29 @@
protected void doView(JBossRenderRequest req, JBossRenderResponse resp)
throws PortletException, PortletSecurityException, IOException
{
+ // Generic page loader.
+ String op = req.getParameter("op");
+ if (op == null)
+ {
+ op = "editPage";
+ }
+
+ Page page = null;
+ if (req.getParameter("editPageSelect") != null)
+ {
+ String editPageSelect = req.getParameter("editPageSelect");
+ page = portalObjectContainer.getContext().getPortal("dashboard").getPage(editPageSelect);
+ }
+ else
+ {
+ page = portalObjectContainer.getContext().getPortal("dashboard").getPage(req.getUser().getUserName());
+ }
+
List available_instances = (List)instanceContainer.getInstances();
-
List left_instances = new ArrayList();
List center_instances = new ArrayList();
List right_instances = new ArrayList();
- Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(req.getUser().getUserName());
try
{
Map windowMap = getWindows(page);
@@ -119,7 +136,7 @@
if (region.equals("left"))
{
left_instances.add(window);
- System.out.println(window.getInstanceRef() + ":" + window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER));
+ //System.out.println(window.getInstanceRef() + ":" + window.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER));
}
else if (region.equals("center"))
{
@@ -137,11 +154,23 @@
e.printStackTrace();
}
+ List pages = new ArrayList();
+ for (Iterator j = page.getPortal().getChildren().iterator(); j.hasNext();)
+ {
+ PortalObject object = (PortalObject)j.next();
+ if (object.getType() == PortalObject.TYPE_PAGE)
+ {
+ pages.add(object);
+ }
+ }
+
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", page.getName());
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/dashboard/editpage.jsp");
rd.include(req, resp);
}
@@ -149,12 +178,17 @@
protected void processAction(JBossActionRequest actionRequest, JBossActionResponse actionResponse)
{
String op = actionRequest.getParameter("op");
+ String editPage = actionRequest.getParameter("editPageSelect"); // the current page we're editting
+ if (editPage == null)
+ {
+ editPage = actionRequest.getUser().getUserName();
+ }
if ("copy".equals(op))
{
String toRegion = actionRequest.getParameter("toRegion");
String[] copyInstance = actionRequest.getParameterValues("available_instances");
- Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(actionRequest.getUser().getUserName());
+ Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(editPage);
try
{
for (int i = 0; i < copyInstance.length; i++)
@@ -175,6 +209,7 @@
{
// todo
}
+ actionResponse.setRenderParameter("editPageSelect", editPage);
}
else if ("remove".equals(op))
{
@@ -193,7 +228,7 @@
removeWindows = actionRequest.getParameterValues("right_instances");
}
- Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(actionRequest.getUser().getUserName());
+ Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(editPage);
try
{
for (int i = 0; i < removeWindows.length; i++)
@@ -205,6 +240,7 @@
{
// todo
}
+ actionResponse.setRenderParameter("editPageSelect", editPage);
}
else if ("up".equals(op) || "down".equals(op))
{
@@ -223,7 +259,7 @@
moveWindows = actionRequest.getParameterValues("right_instances");
}
- Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(actionRequest.getUser().getUserName());
+ Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(editPage);
for (int i = 0; i < moveWindows.length; i++)
{
Window window = page.getWindow(moveWindows[i]);
@@ -236,7 +272,32 @@
window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(getOrder(window) + 1));
}
}
+ actionResponse.setRenderParameter("editPageSelect", editPage);
}
+ else if ("newpage".equals(op))
+ {
+ String pageName = actionRequest.getParameter("pagename");
+
+ Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(actionRequest.getUser().getUserName());
+ PageContainer pageContainer = (PageContainer)page.getPortal();
+
+ try
+ {
+ pageContainer.createPage(pageName);
+ }
+ catch (Exception e)
+ {
+ // todo - name taken
+ }
+
+ actionResponse.setRenderParameter("editPageSelect", pageName);
+ actionResponse.setRenderParameter("op", "editPage");
+ }
+ else if ("editPage".equals(op))
+ {
+ actionResponse.setRenderParameter("editPageSelect", editPage);
+ actionResponse.setRenderParameter("op", op);
+ }
}
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-11-27 19:16:41 UTC (rev 5725)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-11-27 20:33:29 UTC (rev 5726)
@@ -1,6 +1,7 @@
<%@ page import="org.jboss.portal.core.model.instance.Instance" %>
+<%@ page import="org.jboss.portal.core.model.portal.Page" %>
+<%@ page import="org.jboss.portal.core.model.portal.Window" %>
<%@ page import="java.util.List" %>
-<%@ page import="org.jboss.portal.core.model.portal.Window" %>
<%@ page language="java" extends="org.jboss.portal.core.servlet.jsp.PortalJsp" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ taglib uri="/WEB-INF/portal-lib.tld" prefix="n" %>
@@ -13,6 +14,8 @@
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");
+ String currentPage = (String)request.getAttribute("currentPage");
%>
<script type="text/javascript" language="JavaScript">
@@ -34,13 +37,18 @@
this.instancesForm.sortRegion.value = region;
}
+ function newPage(op)
+ {
+ this.instancesForm.op.value = op;
+ }
+
function debug()
{
//alert("OP: '" + this.instancesForm.op.value + "' toRegion: '" + this.instancesForm.toRegion.value + "' fromRegion: '" + this.instancesForm.fromRegion.value + "' sortRegion: '" + this.instancesForm.sortRegion.value + "'");
}
</script>
<table width="100%">
-<th colspan="2" class="portlet-section-header" align="center">Edit Page</th>
+<th colspan="2" class="portlet-section-header" align="center">Edit Page '<%= currentPage %>'</th>
<tr>
<td class="portlet-section-body" align="left">
Use this to manage the content on your page. You can control the page title, select number of columns, and add,
@@ -55,10 +63,19 @@
<tr>
<td class="portlet-section-body" align="left"><b>Select a page to edit:</b><br/>
- <form action="" method="POST" style="padding:0;margin:0">
- <select name="pagename">
- <option value="">Home</option>
- <option value="">Blah</option>
+ <form action="<portlet:actionURL><portlet:param name="op" value="editPage"></portlet:param>
+ </portlet:actionURL>" method="POST" style="padding:0;margin:0">
+ <select name="editPageSelect">
+ <%
+ for (int i = 0; i < pages.size(); i++)
+ {
+ Page onePage = (Page)pages.get(i);
+ %>
+ <option value="<%= onePage.getName() %>"><%= onePage.getName() %>
+ </option>
+ <%
+ }
+ %>
</select>
<input type="submit" name="submit" value="Go" class="portlet-form-button"/>
</form>
@@ -77,16 +94,26 @@
<input type="hidden" name="toRegion"/>
<input type="hidden" name="fromRegion"/>
<input type="hidden" name="sortRegion"/>
+<input type="hidden" name="editPageSelect" value="<%= currentPage %>"/>
<table width="100%">
<tr>
-<td>
+<td valign="top" class="portlet-section-alternate" width="250">
<table>
<tr>
- <td>title/layout table</td>
+ <td valign="top">
+ <b>Title and Layout</b>
+ <br/>
+ Title the page and select the number of columns for the layout
+ <hr/>
+ <b>Page Title:</b><br/>
+ <input type="text" class="portlet-form-input-field" name="pagename">
+ <br/>
+ <input type="submit" name="save" value="Save" class="portlet-form-button" onclick="newPage('newpage');"/>
+ </td>
</tr>
</table>
</td>
-<td class="portlet-section-body" valign="top"><b>Available Content</b><br/>
+<td class="portlet-section-body" valign="top" align="right"><b>Available Content</b><br/>
<select name="available_instances" multiple="true" size="20">
<%
for (int i = 0; i < available_instances.size(); i++)
@@ -115,7 +142,6 @@
for (int i = 0; i < left_instances.size(); i++)
{
Window window = (Window)left_instances.get(i);
- //String instance = (String)left_instances.get(i);
%>
<option value="<%= window.getName() %>"><%= window.getInstanceRef() %>
</option>
@@ -143,7 +169,6 @@
for (int i = 0; i < center_instances.size(); i++)
{
Window window = (Window)center_instances.get(i);
- //String instance = (String)center_instances.get(i);
%>
<option value="<%= window.getName() %>"><%= window.getInstanceRef() %>
</option>
@@ -169,7 +194,6 @@
for (int i = 0; i < right_instances.size(); i++)
{
Window window = (Window)right_instances.get(i);
- //String instance = (String)right_instances.get(i);
%>
<option value="<%= window.getName() %>"><%= window.getInstanceRef() %>
</option>
@@ -189,14 +213,6 @@
</form>
</td>
</tr>
-<!--
-<tr>
- <td class="portlet-section-alternate" width="100%" colspan="4" align="center">
- <input type="submit" name="save" value="Save" class="portlet-form-button"/>
- <input type="submit" name="delete" value="Delete" class="portlet-form-button"/>
- </td>
-</tr>
--->
</table>
</td>
</tr>
17 years, 5 months
JBoss Portal SVN: r5725 - 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-11-27 14:16:41 -0500 (Mon, 27 Nov 2006)
New Revision: 5725
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-993 - move window functionality added.
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-11-27 18:30:43 UTC (rev 5724)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-11-27 19:16:41 UTC (rev 5725)
@@ -27,6 +27,8 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.theme.LayoutService;
+import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portlet.JBossActionRequest;
import org.jboss.portlet.JBossActionResponse;
@@ -39,8 +41,14 @@
import javax.portlet.PortletSecurityException;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
/**
* @author <a href="mailto:roy.russo@jboss.com">Roy Russo</a>
@@ -54,6 +62,8 @@
private PortalObjectContainer portalObjectContainer;
+ private LayoutService layoutService;
+
private static final int MOVE_UP = 0;
private static final int MOVE_DOWN = 1;
@@ -66,6 +76,8 @@
portalObjectContainer = (PortalObjectContainer)getPortletContext().getAttribute("PortalObjectContainer");
+ layoutService = (LayoutService)getPortletContext().getAttribute("LayoutService");
+
if (instanceContainer == null)
{
throw new PortletException("No InstanceContainer found");
@@ -74,6 +86,10 @@
{
throw new PortletException("No PortalObjectContainer found");
}
+ if (layoutService == null)
+ {
+ throw new PortletException("No LayoutService found");
+ }
}
protected void doView(JBossRenderRequest req, JBossRenderResponse resp)
@@ -84,28 +100,42 @@
List left_instances = new ArrayList();
List center_instances = new ArrayList();
List right_instances = new ArrayList();
+
Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(req.getUser().getUserName());
- for (Iterator i = page.getChildren().iterator(); i.hasNext();)
+ try
{
- PortalObject object = (PortalObject)i.next();
- if (object.getType() == PortalObject.TYPE_WINDOW)
+ Map windowMap = getWindows(page);
+ List regions = new ArrayList(windowMap.keySet());
+ Collections.sort(regions);
+
+ for (Iterator i = regions.iterator(); i.hasNext();)
{
- Window window = (Window)object;
- String region = object.getProperty(ThemeConstants.PORTAL_PROP_REGION);
- if (region.equals("left"))
+ String region = (String)i.next();
+
+ TreeSet windows = (TreeSet)windowMap.get(region);
+ for (Iterator j = windows.iterator(); j.hasNext();)
{
- left_instances.add(window.getInstanceRef());
+ 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);
+ }
}
- else if (region.equals("center"))
- {
- center_instances.add(window.getInstanceRef());
- }
- else if (region.equals("right"))
- {
- right_instances.add(window.getInstanceRef());
- }
}
}
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
resp.setContentType("text/html");
req.setAttribute("available_instances", available_instances);
@@ -149,44 +179,26 @@
else if ("remove".equals(op))
{
String fromRegion = actionRequest.getParameter("fromRegion");
- String[] removeInstances = null;
+ String[] removeWindows = null;
if ("left".equals(fromRegion))
{
- removeInstances = actionRequest.getParameterValues("left_instances");
+ removeWindows = actionRequest.getParameterValues("left_instances");
}
else if ("center".equals(fromRegion))
{
- removeInstances = actionRequest.getParameterValues("center_instances");
+ removeWindows = actionRequest.getParameterValues("center_instances");
}
else if ("right".equals(fromRegion))
{
- removeInstances = actionRequest.getParameterValues("right_instances");
+ removeWindows = actionRequest.getParameterValues("right_instances");
}
Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(actionRequest.getUser().getUserName());
- List removeWindows = new ArrayList();
- for (Iterator i = page.getChildren().iterator(); i.hasNext();)
- {
- PortalObject object = (PortalObject)i.next();
- if (object.getType() == PortalObject.TYPE_WINDOW)
- {
- Window window = (Window)object;
- String region = object.getProperty(ThemeConstants.PORTAL_PROP_REGION);
- String instance = window.getInstanceRef();
- for (int j = 0; j < removeInstances.length; j++)
- {
- if (instance.equalsIgnoreCase(removeInstances[j]) && fromRegion.equalsIgnoreCase(region))
- {
- removeWindows.add(window.getName());
- }
- }
- }
- }
try
{
- for (int i = 0; i < removeWindows.size(); i++)
+ for (int i = 0; i < removeWindows.length; i++)
{
- page.destroyChild((String)removeWindows.get(i));
+ page.destroyChild((String)removeWindows[i]);
}
}
catch (Exception e)
@@ -194,23 +206,36 @@
// todo
}
}
- else if ("up".equals(op))
+ else if ("up".equals(op) || "down".equals(op))
{
String sortRegion = actionRequest.getParameter("sortRegion");
- String[] moveRegion = null;
+ String[] moveWindows = null;
if ("left".equals(sortRegion))
{
- moveRegion = actionRequest.getParameterValues("left_instances");
+ moveWindows = actionRequest.getParameterValues("left_instances");
}
else if ("center".equals(sortRegion))
{
- moveRegion = actionRequest.getParameterValues("center_instances");
+ moveWindows = actionRequest.getParameterValues("center_instances");
}
else if ("right".equals(sortRegion))
{
- moveRegion = actionRequest.getParameterValues("right_instances");
+ moveWindows = actionRequest.getParameterValues("right_instances");
}
+ Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(actionRequest.getUser().getUserName());
+ for (int i = 0; i < moveWindows.length; i++)
+ {
+ Window window = page.getWindow(moveWindows[i]);
+ if ("up".equals(op))
+ {
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(getOrder(window) - 1));
+ }
+ else if ("down".equals(op))
+ {
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, Integer.toString(getOrder(window) + 1));
+ }
+ }
}
}
@@ -218,4 +243,64 @@
{
return (int)(100 * Math.random());
}
+
+ /** Returns a <Region,<Window>SortedSet>Map. */
+ private Map getWindows(Page page) throws Exception
+ {
+ // Get the layout
+ String layoutId = page.getProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
+ PortalLayout layout = layoutService.getLayout(layoutId, false);
+
+ LinkedHashMap windows = new LinkedHashMap();
+ for (Iterator i = layout.getLayoutInfo().getRegionNames().iterator(); i.hasNext();)
+ {
+ String region = (String)i.next();
+ windows.put(region, new TreeSet(comparator));
+ }
+ windows.put("unknown", new TreeSet(comparator));
+
+ for (Iterator j = page.getChildren().iterator(); j.hasNext();)
+ {
+ PortalObject object = (PortalObject)j.next();
+ if (object.getType() == PortalObject.TYPE_WINDOW)
+ {
+ String region = object.getProperty(ThemeConstants.PORTAL_PROP_REGION);
+ if (!windows.containsKey(region))
+ {
+ region = "unknown";
+ }
+ SortedSet set = (SortedSet)windows.get(region);
+ set.add(object);
+ }
+ }
+ return windows;
+ }
+
+ /** Compares two windows according to their order. */
+ private static final Comparator comparator = new Comparator()
+ {
+ public int compare(Object o1, Object o2)
+ {
+ Window w1 = (Window)o1;
+ Window w2 = (Window)o2;
+ int sign = getOrder(w1) - getOrder(w2);
+ if (sign == 0)
+ {
+ sign = w1.getId().compareTo(w2.getId());
+ }
+ return sign;
+ }
+ };
+
+ private static int getOrder(Window w)
+ {
+ try
+ {
+ return Integer.parseInt(w.getDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER));
+ }
+ catch (NumberFormatException e)
+ {
+ return Integer.MAX_VALUE;
+ }
+ }
}
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-11-27 18:30:43 UTC (rev 5724)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-11-27 19:16:41 UTC (rev 5725)
@@ -1,5 +1,6 @@
<%@ page import="org.jboss.portal.core.model.instance.Instance" %>
<%@ page import="java.util.List" %>
+<%@ page import="org.jboss.portal.core.model.portal.Window" %>
<%@ page language="java" extends="org.jboss.portal.core.servlet.jsp.PortalJsp" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ taglib uri="/WEB-INF/portal-lib.tld" prefix="n" %>
@@ -113,9 +114,10 @@
<%
for (int i = 0; i < left_instances.size(); i++)
{
- String instance = (String)left_instances.get(i);
+ Window window = (Window)left_instances.get(i);
+ //String instance = (String)left_instances.get(i);
%>
- <option value="<%= instance %>"><%= instance%>
+ <option value="<%= window.getName() %>"><%= window.getInstanceRef() %>
</option>
<%
}
@@ -140,9 +142,10 @@
<%
for (int i = 0; i < center_instances.size(); i++)
{
- String instance = (String)center_instances.get(i);
+ Window window = (Window)center_instances.get(i);
+ //String instance = (String)center_instances.get(i);
%>
- <option value="<%= instance %>"><%= instance%>
+ <option value="<%= window.getName() %>"><%= window.getInstanceRef() %>
</option>
<%
}
@@ -165,9 +168,10 @@
<%
for (int i = 0; i < right_instances.size(); i++)
{
- String instance = (String)right_instances.get(i);
+ Window window = (Window)right_instances.get(i);
+ //String instance = (String)right_instances.get(i);
%>
- <option value="<%= instance %>"><%= instance%>
+ <option value="<%= window.getName() %>"><%= window.getInstanceRef() %>
</option>
<%
}
17 years, 5 months
JBoss Portal SVN: r5724 - in trunk/wsrp/src/main/org/jboss/portal: test/wsrp/v1/producer wsrp/producer wsrp/producer/registration/api wsrp/producer/registration/impl
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-11-27 13:30:43 -0500 (Mon, 27 Nov 2006)
New Revision: 5724
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Registration.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java
Log:
- Implemented deregister.
- Added hook on Registration to clear associated state (to be implemented).
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2006-11-27 18:29:16 UTC (rev 5723)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2006-11-27 18:30:43 UTC (rev 5724)
@@ -25,7 +25,10 @@
import org.jboss.portal.common.junit.ExtendedAssert;
import org.jboss.portal.wsrp.WSRPConstants;
+import org.jboss.portal.wsrp.WSRPTypeFactory;
+import org.jboss.portal.wsrp.core.GetMarkup;
import org.jboss.portal.wsrp.core.GetServiceDescription;
+import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
@@ -83,34 +86,40 @@
registrationService.register(regData);
}
- /*public void testDeregister() throws Exception
+ public void testDeregister() throws Exception
{
// initiate registration
- initRegistrationInfo();
+ configureRegistrationSettings(false);
RegistrationContext rc = registerConsumer();
// deregister
registrationService.deregister(rc);
- // Try to get service description with the deregistered context
- GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
- gs.setRegistrationContext(rc);
+ // try to get markup, portlet handle doesn't matter since it should fail before trying to retrieve the portlet
+ GetMarkup getMarkup = WSRPTypeFactory.createDefaultMarkupRequest("foo");
+ getMarkup.getMarkupParams().setMarkupCharacterSets(new String[]{WSRPConstants.DEFAULT_CHARACTER_SET});
try
{
- serviceDescriptionService.getServiceDescription(gs);
+ markupService.getMarkup(getMarkup);
ExtendedAssert.fail("Consumer tried to access info with a de-registered context. Operations should fail.");
}
catch (InvalidRegistrationFault invalidRegistrationFault)
{
// expected
}
- }*/
+ // Get description should still work?
+ GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
+ gs.setRegistrationContext(rc);
+
+ ExtendedAssert.assertNotNull(serviceDescriptionService.getServiceDescription(gs));
+ }
+
/*public void testModifyRegistration() throws Exception
{
// initiate registration
- initRegistrationInfo();
+ configureRegistrationSettings(false);
RegistrationContext rc = registerConsumer();
// now modify Producer's set of required registration info
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-27 18:29:16 UTC (rev 5723)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-27 18:30:43 UTC (rev 5724)
@@ -24,6 +24,7 @@
package org.jboss.portal.wsrp.producer;
import org.jboss.logging.Logger;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.wsrp.WSRPTypeFactory;
import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
@@ -38,6 +39,7 @@
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
import org.jboss.portal.wsrp.producer.registration.api.Consumer;
import org.jboss.portal.wsrp.producer.registration.api.ConsumerCapabilities;
+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.RegistrationException;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
@@ -110,7 +112,30 @@
{
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(deregister, "RegistrationContext");
- return null; // todo: implement
+ String registrationHandle = deregister.getRegistrationHandle();
+ if (ParameterValidation.isNullOrEmpty(registrationHandle))
+ {
+ throwInvalidRegistrationFault("Null or empty registration handle");
+ }
+
+ log.debug("Attempting to deregister registration with handle '" + registrationHandle + "'");
+
+ try
+ {
+ producer.getRegistrationManager().removeRegistration(registrationHandle);
+ }
+ catch (NoSuchRegistrationException e)
+ {
+ log.debug(e);
+ throwInvalidRegistrationFault(e.getLocalizedMessage());
+ }
+ catch (RegistrationException e)
+ {
+ log.debug(e);
+ throw WSRPUtils.createOperationFailedFault(e);
+ }
+
+ return new ReturnAny();
}
public RegistrationState modifyRegistration(ModifyRegistration modifyRegistration) throws MissingParametersFault,
@@ -139,7 +164,7 @@
try
{
Registration reg = producer.getRegistrationManager().getRegistration(regHandle);
- return RegistrationStatus.VALID.equals(reg.getStatus());
+ return reg != null && RegistrationStatus.VALID.equals(reg.getStatus());
}
catch (RegistrationException e)
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Registration.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Registration.java 2006-11-27 18:29:16 UTC (rev 5723)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Registration.java 2006-11-27 18:30:43 UTC (rev 5724)
@@ -93,4 +93,7 @@
* @param status the new status
*/
void setStatus(RegistrationStatus status);
+
+ /** Clears any state (cloned portlet information, session, etc) associated with this Registration */
+ void clearAssociatedState();
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java 2006-11-27 18:29:16 UTC (rev 5723)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationImpl.java 2006-11-27 18:30:43 UTC (rev 5724)
@@ -148,4 +148,9 @@
this.status = status;
}
+ public void clearAssociatedState()
+ {
+ //todo: implement
+ }
+
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java 2006-11-27 18:29:16 UTC (rev 5723)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java 2006-11-27 18:30:43 UTC (rev 5724)
@@ -35,6 +35,7 @@
import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationPersistenceManager;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationPolicy;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
import java.util.ArrayList;
import java.util.Collection;
@@ -243,17 +244,12 @@
removeRegistration(registration);
}
- public void removeRegistration(Registration registration) throws RegistrationException, NoSuchRegistrationException
+ public void removeRegistration(Registration registration) throws RegistrationException
{
ParameterValidation.throwIllegalArgExceptionIfNull(registration, "Registration");
- String handle = registration.getRegistrationHandle();
- Consumer consumer = getConsumerFor(handle);
- if (consumer == null)
- {
- throw new NoSuchRegistrationException("Could not locate a Consumer for Registration with handle '" + handle
- + "' (id: '" + registration.getId() + "')");
- }
+ registration.setStatus(RegistrationStatus.INVALID); // just in case...
+ registration.clearAssociatedState();
persistenceManager.removeRegistration(registration.getId());
registrations.remove(registration.getRegistrationHandle());
17 years, 5 months
JBoss Portal SVN: r5723 - trunk/common/src/main/org/jboss/portal/common/util
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-11-27 13:29:16 -0500 (Mon, 27 Nov 2006)
New Revision: 5723
Modified:
trunk/common/src/main/org/jboss/portal/common/util/ParameterValidation.java
Log:
Added isNullOrEmpty method.
Modified: trunk/common/src/main/org/jboss/portal/common/util/ParameterValidation.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/ParameterValidation.java 2006-11-27 17:06:21 UTC (rev 5722)
+++ trunk/common/src/main/org/jboss/portal/common/util/ParameterValidation.java 2006-11-27 18:29:16 UTC (rev 5723)
@@ -31,12 +31,18 @@
{
public static void throwIllegalArgExceptionIfNullOrEmpty(String valueToCheck, String valueName, String contextName)
{
- if (valueToCheck == null || valueToCheck.length() == 0)
+ if (isNullOrEmpty(valueToCheck))
{
throw new IllegalArgumentException(contextName != null ? contextName + " r" : "R" + "equires a non-null, non-empty " + valueName);
}
}
+ /** @since 2.6 */
+ public static boolean isNullOrEmpty(String valueToCheck)
+ {
+ return valueToCheck == null || valueToCheck.length() == 0;
+ }
+
public static void throwIllegalArgExceptionIfNull(Object objectToTest, String name)
{
if (objectToTest == null)
17 years, 5 months
JBoss Portal SVN: r5722 - 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-11-27 12:06:21 -0500 (Mon, 27 Nov 2006)
New Revision: 5722
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-993 - assign/remove windows functionality added to page editor.
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-11-26 02:55:41 UTC (rev 5721)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-11-27 17:06:21 UTC (rev 5722)
@@ -29,10 +29,10 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
import org.jboss.portlet.JBossPortlet;
import org.jboss.portlet.JBossRenderRequest;
import org.jboss.portlet.JBossRenderResponse;
-import org.jboss.portlet.JBossActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
@@ -54,6 +54,9 @@
private PortalObjectContainer portalObjectContainer;
+ private static final int MOVE_UP = 0;
+ private static final int MOVE_DOWN = 1;
+
public void init()
throws PortletException
{
@@ -115,6 +118,104 @@
protected void processAction(JBossActionRequest actionRequest, JBossActionResponse actionResponse)
{
- System.out.println("blah");
+ String op = actionRequest.getParameter("op");
+ if ("copy".equals(op))
+ {
+ String toRegion = actionRequest.getParameter("toRegion");
+ String[] copyInstance = actionRequest.getParameterValues("available_instances");
+
+ Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(actionRequest.getUser().getUserName());
+ try
+ {
+ for (int i = 0; i < copyInstance.length; i++)
+ {
+ String windowName = "" + doWindowNaming();
+ while (page.getWindow(windowName) != null)
+ {
+ windowName = "" + doWindowNaming();
+ }
+
+ Window window = page.createWindow(windowName);
+ window.setInstanceRef((String)copyInstance[i]);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_REGION, toRegion);
+ window.setDeclaredProperty(ThemeConstants.PORTAL_PROP_ORDER, "" + Integer.MAX_VALUE);
+ }
+ }
+ catch (Exception e)
+ {
+ // todo
+ }
+ }
+ else if ("remove".equals(op))
+ {
+ String fromRegion = actionRequest.getParameter("fromRegion");
+ String[] removeInstances = null;
+ if ("left".equals(fromRegion))
+ {
+ removeInstances = actionRequest.getParameterValues("left_instances");
+ }
+ else if ("center".equals(fromRegion))
+ {
+ removeInstances = actionRequest.getParameterValues("center_instances");
+ }
+ else if ("right".equals(fromRegion))
+ {
+ removeInstances = actionRequest.getParameterValues("right_instances");
+ }
+
+ Page page = portalObjectContainer.getContext().getPortal("dashboard").getPage(actionRequest.getUser().getUserName());
+ List removeWindows = new ArrayList();
+ for (Iterator i = page.getChildren().iterator(); i.hasNext();)
+ {
+ PortalObject object = (PortalObject)i.next();
+ if (object.getType() == PortalObject.TYPE_WINDOW)
+ {
+ Window window = (Window)object;
+ String region = object.getProperty(ThemeConstants.PORTAL_PROP_REGION);
+ String instance = window.getInstanceRef();
+ for (int j = 0; j < removeInstances.length; j++)
+ {
+ if (instance.equalsIgnoreCase(removeInstances[j]) && fromRegion.equalsIgnoreCase(region))
+ {
+ removeWindows.add(window.getName());
+ }
+ }
+ }
+ }
+ try
+ {
+ for (int i = 0; i < removeWindows.size(); i++)
+ {
+ page.destroyChild((String)removeWindows.get(i));
+ }
+ }
+ catch (Exception e)
+ {
+ // todo
+ }
+ }
+ else if ("up".equals(op))
+ {
+ String sortRegion = actionRequest.getParameter("sortRegion");
+ String[] moveRegion = null;
+ if ("left".equals(sortRegion))
+ {
+ moveRegion = actionRequest.getParameterValues("left_instances");
+ }
+ else if ("center".equals(sortRegion))
+ {
+ moveRegion = actionRequest.getParameterValues("center_instances");
+ }
+ else if ("right".equals(sortRegion))
+ {
+ moveRegion = actionRequest.getParameterValues("right_instances");
+ }
+
+ }
}
+
+ private int doWindowNaming()
+ {
+ return (int)(100 * Math.random());
+ }
}
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-11-26 02:55:41 UTC (rev 5721)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-11-27 17:06:21 UTC (rev 5722)
@@ -35,7 +35,7 @@
function debug()
{
- alert("OP: '" + this.instancesForm.op.value + "' toRegion: '" + this.instancesForm.toRegion.value + "' fromRegion: '" + this.instancesForm.fromRegion.value + "' sortRegion: '" + this.instancesForm.sortRegion.value + "'");
+ //alert("OP: '" + this.instancesForm.op.value + "' toRegion: '" + this.instancesForm.toRegion.value + "' fromRegion: '" + this.instancesForm.fromRegion.value + "' sortRegion: '" + this.instancesForm.sortRegion.value + "'");
}
</script>
<table width="100%">
@@ -132,15 +132,15 @@
<tr>
<td>
<input type="submit" class="portlet-form-button" name=">" value=">"
- onclick="sortPortlet('copy','center');"/><br/><input
+ onclick="assignPortlet('copy','center');"/><br/><input
type="submit" class="portlet-form-button" name="<" value="<"
- onclick="sortPortlet('remove','center');"/></td>
+ onclick="unassignPortlet('remove','center');"/></td>
<td class="portlet-section-body" valign="top"><b>Middle Column</b><br/>
<select name="center_instances" multiple="true" size="6">
<%
- for (int i = 0; i < right_instances.size(); i++)
+ for (int i = 0; i < center_instances.size(); i++)
{
- String instance = (String)right_instances.get(i);
+ String instance = (String)center_instances.get(i);
%>
<option value="<%= instance %>"><%= instance%>
</option>
@@ -163,9 +163,9 @@
<td class="portlet-section-body" valign="top"><b>Right Column</b><br/>
<select name="right_instances" multiple="true" size="6">
<%
- for (int i = 0; i < center_instances.size(); i++)
+ for (int i = 0; i < right_instances.size(); i++)
{
- String instance = (String)center_instances.get(i);
+ String instance = (String)right_instances.get(i);
%>
<option value="<%= instance %>"><%= instance%>
</option>
@@ -185,12 +185,14 @@
</form>
</td>
</tr>
+<!--
<tr>
<td class="portlet-section-alternate" width="100%" colspan="4" align="center">
<input type="submit" name="save" value="Save" class="portlet-form-button"/>
<input type="submit" name="delete" value="Delete" class="portlet-form-button"/>
</td>
</tr>
+-->
</table>
</td>
</tr>
17 years, 5 months
JBoss Portal SVN: r5721 - in trunk/wsrp: . src/main/org/jboss/portal/test/wsrp/framework src/main/org/jboss/portal/test/wsrp/registration src/main/org/jboss/portal/test/wsrp/v1/producer src/main/org/jboss/portal/wsrp src/main/org/jboss/portal/wsrp/producer src/main/org/jboss/portal/wsrp/producer/registration/api src/main/org/jboss/portal/wsrp/producer/registration/impl
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-11-25 21:55:41 -0500 (Sat, 25 Nov 2006)
New Revision: 5721
Modified:
trunk/wsrp/build.xml
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java
Log:
- It's now possible to access the RegistrationManager via the producer's public interface.
- Added clear method on RegistrationManager and associated test case (needed to properly reset state between tests).
- Fixed incorrect behavior of GSD wrt providing or not the portlet descriptions.
- Fixed incorrect behavior where invalid consumer agent would still result in successful registration.
- Code clean up.
- Added registration configuration tests to global tests.
Modified: trunk/wsrp/build.xml
===================================================================
--- trunk/wsrp/build.xml 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/build.xml 2006-11-26 02:55:41 UTC (rev 5721)
@@ -542,10 +542,10 @@
<antcall target="agent-deploy"/>
<antcall target="producer-test"/>
<antcall target="consumer-test"/>
- <antcall target="registration-configuration-test"/>
<antcall target="deployment-test"/>
<antcall target="other-test"/>
<antcall target="registration-test"/>
+ <antcall target="registration-configuration-test"/>
<antcall target="agent-undeploy"/>
<server:stop name="default"/>
<antcall target="reports"/>
@@ -557,6 +557,7 @@
<antcall target="deployment-test"/>
<antcall target="other-test"/>
<antcall target="registration-test"/>
+ <antcall target="registration-configuration-test"/>
</target>
<!-- WSRP Producer tests -->
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -71,6 +71,7 @@
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
import org.jboss.portal.wsrp.producer.registration.api.ProducerRegistrationRequirements;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
@@ -366,6 +367,12 @@
public ProducerRegistrationRequirements getProducerRegistrationRequirements()
{
- return null; // todo: implement
+ throw new UnsupportedOperationException("getProducerRegistrationRequirements not implemented");
}
+
+
+ public RegistrationManager getRegistrationManager()
+ {
+ throw new UnsupportedOperationException("getRegistrationManager not implemented");
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -319,7 +319,6 @@
{
String consumerName = "consumer";
Consumer consumer = manager.createConsumer(consumerName);
- String consumerIdentity = consumer.getIdentity();
Registration reg = manager.addRegistrationTo(consumerName, registrationProperties, false);
String handle = reg.getRegistrationHandle();
@@ -369,4 +368,20 @@
{
}
}
+
+ public void testClear() throws Exception
+ {
+ manager.createConsumer("c1");
+ manager.createConsumer("c2");
+ manager.addConsumerToGroupNamed("c1g1", "g1", true, true);
+ manager.createConsumerGroup("g2");
+ Registration r1 = manager.addRegistrationTo("c1", registrationProperties, false);
+ Registration r2 = manager.addRegistrationTo("c3", registrationProperties, true);
+
+ manager.clear();
+ assertTrue(manager.getConsumerGroups().isEmpty());
+ assertTrue(manager.getConsumers().isEmpty());
+ assertNull(manager.getRegistration(r1.getRegistrationHandle()));
+ assertNull(manager.getRegistration(r2.getRegistrationHandle()));
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/RegistrationTestCase.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -25,20 +25,11 @@
import org.jboss.portal.common.junit.ExtendedAssert;
import org.jboss.portal.wsrp.WSRPConstants;
-import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.core.GetServiceDescription;
-import org.jboss.portal.wsrp.core.InvalidRegistrationFault;
-import org.jboss.portal.wsrp.core.ModelDescription;
-import org.jboss.portal.wsrp.core.ModifyRegistration;
import org.jboss.portal.wsrp.core.OperationFailedFault;
-import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
-import org.jboss.portal.wsrp.core.ServiceDescription;
-import org.jboss.portal.wsrp.producer.registration.api.RegistrationPropertyDescription;
-import javax.xml.namespace.QName;
-
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
* @version $Revision$
@@ -74,7 +65,7 @@
*/
public void testConsumerAgent() throws Exception
{
- initRegistrationInfo();
+ configureRegistrationSettings(false);
RegistrationData regData = createBaseRegData();
regData.setConsumerAgent("invalid consumer agent");
@@ -92,7 +83,7 @@
registrationService.register(regData);
}
- public void testDeregister() throws Exception
+ /*public void testDeregister() throws Exception
{
// initiate registration
initRegistrationInfo();
@@ -114,9 +105,9 @@
{
// expected
}
- }
+ }*/
- public void testModifyRegistration() throws Exception
+ /*public void testModifyRegistration() throws Exception
{
// initiate registration
initRegistrationInfo();
@@ -161,33 +152,18 @@
registrationService.modifyRegistration(new ModifyRegistration(rc, regData));
gs.setRegistrationContext(rc);
checkServiceDescriptionWithOnlyBasicPortlet(gs);
- }
+ }*/
public void testRegister() throws Exception
{
- RegistrationPropertyDescription regProp = initRegistrationInfo();
+ configureRegistrationSettings(false);
// service description request without registration info
GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
- //Invoke the Web Service
- ServiceDescription sd = serviceDescriptionService.getServiceDescription(gs);
-
- ExtendedAssert.assertNotNull(sd);
- ExtendedAssert.assertTrue(sd.isRequiresRegistration());
-
- // Check registration properties
- ModelDescription registrationPropertyDescription = sd.getRegistrationPropertyDescription();
- ExtendedAssert.assertNotNull(registrationPropertyDescription);
- PropertyDescription[] propertyDescriptions = registrationPropertyDescription.getPropertyDescriptions();
- ExtendedAssert.assertNotNull(propertyDescriptions);
- ExtendedAssert.assertEquals(1, propertyDescriptions.length);
- assertEquals(WSRPUtils.convertToPropertyDescription(regProp), propertyDescriptions[0]);
-
- // No offered portlets without registration!
- ExtendedAssert.assertNull(sd.getOfferedPortlets());
-
RegistrationContext registrationContext = registerConsumer();
+ ExtendedAssert.assertNotNull(registrationContext);
+ ExtendedAssert.assertNotNull(registrationContext.getRegistrationHandle());
gs.setRegistrationContext(registrationContext);
@@ -197,6 +173,7 @@
public void tearDown() throws Exception
{
producer.getProducerRegistrationRequirements().clearRegistrationProperties();
+ producer.getRegistrationManager().clear();
super.tearDown();
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ReleaseSessionTestCase.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -202,7 +202,7 @@
public void testReleasedSessionWithRegistration() throws Exception
{
- initRegistrationInfo();
+ configureRegistrationSettings(false);
testReleasedSession();
registrationService.deregister(getRegistrationContext());
}
@@ -223,7 +223,7 @@
public void testNullReleaseSessionsWithRegistration() throws Exception
{
- initRegistrationInfo();
+ configureRegistrationSettings(false);
testNullReleaseSessions();
registrationService.deregister(getRegistrationContext());
}
@@ -272,7 +272,7 @@
private void releaseSessionsWithRegistration(RegistrationContext regContext, String[] sessionIDs,
Class exceptionClass, String message) throws Exception
{
- initRegistrationInfo();
+ configureRegistrationSettings(false);
releaseSessions(regContext, sessionIDs, exceptionClass, message);
registrationService.deregister(regContext);
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/ServiceDescriptionTestCase.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -30,8 +30,12 @@
package org.jboss.portal.test.wsrp.v1.producer;
import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.core.GetServiceDescription;
+import org.jboss.portal.wsrp.core.ModelDescription;
+import org.jboss.portal.wsrp.core.PropertyDescription;
import org.jboss.portal.wsrp.core.ServiceDescription;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPropertyDescription;
/**
* Tests WSRP Service Description
@@ -49,7 +53,7 @@
super("ServiceDescriptionTestCase");
}
- public void testGetServiceDescriptionNoRegistration() throws Throwable
+ public void testGetServiceDescriptionNotRequiringRegistration() throws Throwable
{
producer.getProducerRegistrationRequirements().setRequiresRegistration(false);
@@ -64,6 +68,52 @@
ExtendedAssert.assertNull(sd.getRegistrationPropertyDescription());
}
+ public void testGetServiceDescriptionRequiringRegistrationNoOfferedPortlets() throws Throwable
+ {
+ RegistrationPropertyDescription regProp = configureRegistrationSettings(false);
+
+ // service description request without registration info
+ GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
+
+ //Invoke the Web Service
+ ServiceDescription sd = serviceDescriptionService.getServiceDescription(gs);
+ ExtendedAssert.assertNotNull(sd);
+ ExtendedAssert.assertTrue(sd.isRequiresRegistration());
+
+ // Check registration properties
+ checkRequiredRegistrationProperties(sd, regProp);
+
+ // No offered portlets without registration!
+ ExtendedAssert.assertNull(sd.getOfferedPortlets());
+ }
+
+
+ public void testGetServiceDescriptionRequiringRegistrationOfferedPortlets() throws Throwable
+ {
+ RegistrationPropertyDescription regProp = configureRegistrationSettings(true);
+
+ // service description request without registration info
+ GetServiceDescription gs = getNoRegistrationServiceDescriptionRequest();
+
+ //Invoke the Web Service, we should have the complete description
+ ServiceDescription sd = checkServiceDescriptionWithOnlyBasicPortlet(gs);
+ ExtendedAssert.assertNotNull(sd);
+ ExtendedAssert.assertTrue(sd.isRequiresRegistration());
+
+ // Check registration properties
+ checkRequiredRegistrationProperties(sd, regProp);
+ }
+
+ private void checkRequiredRegistrationProperties(ServiceDescription sd, RegistrationPropertyDescription regProp)
+ {
+ ModelDescription registrationPropertyDescription = sd.getRegistrationPropertyDescription();
+ ExtendedAssert.assertNotNull(registrationPropertyDescription);
+ PropertyDescription[] propertyDescriptions = registrationPropertyDescription.getPropertyDescriptions();
+ ExtendedAssert.assertNotNull(propertyDescriptions);
+ ExtendedAssert.assertEquals(1, propertyDescriptions.length);
+ assertEquals(WSRPUtils.convertToPropertyDescription(regProp), propertyDescriptions[0]);
+ }
+
public void testGetServiceDescriptionLiveDeployment() throws Throwable
{
try
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/v1/producer/V1ProducerBaseTest.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -153,10 +153,11 @@
return regData;
}
- protected RegistrationPropertyDescription initRegistrationInfo()
+ protected RegistrationPropertyDescription configureRegistrationSettings(boolean provideUnregisteredFullDescription)
{
// define expected registration infos
producer.getProducerRegistrationRequirements().setRequiresRegistration(true);
+ producer.getProducerRegistrationRequirements().setFullServiceDescriptionRequiresRegistration(provideUnregisteredFullDescription);
// fix-me: http://jira.jboss.com/jira/browse/JBPORTAL-821
RegistrationPropertyDescription regProp = new RegistrationPropertyDescription("regProp",
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPProducer.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -29,6 +29,7 @@
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
import org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType;
import org.jboss.portal.wsrp.producer.registration.api.ProducerRegistrationRequirements;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -98,4 +99,6 @@
boolean isSessionValid(String sessionId);
ProducerRegistrationRequirements getProducerRegistrationRequirements();
+
+ RegistrationManager getRegistrationManager();
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/WSRPUtils.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -336,4 +336,21 @@
return WSRPTypeFactory.createLocalizedString(LocaleInfo.getRFC3066LanguageTagFor(regLocalizedString.getLocale()),
regLocalizedString.getResourceName(), regLocalizedString.getValue());
}
+
+ public static void validateConsumerAgent(String consumerAgent) throws IllegalArgumentException
+ {
+ char periodChar = '.';
+ int period = consumerAgent.indexOf(periodChar);
+ if (period != -1)
+ {
+ consumerAgent = consumerAgent.substring(period);
+ period = consumerAgent.indexOf(periodChar);
+
+ if (period != -1)
+ {
+ return;
+ }
+ }
+ throw new IllegalArgumentException("'" + consumerAgent + "' is not a valid Consumer Agent.");
+ }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -80,7 +80,11 @@
{
log.debug("Attempting to register consumer named '" + consumerName + "', agent '" + consumerAgent + "'.");
+ // check that the consumer agent is valid before trying to register
+ WSRPUtils.validateConsumerAgent(consumerAgent);
+
registration = producer.getRegistrationManager().addRegistrationTo(consumerName, createRegistrationProperties(registrationData), true);
+ registration.setStatus(RegistrationStatus.VALID);
Consumer consumer = registration.getConsumer();
consumer.setConsumerAgent(consumerAgent);
ConsumerCapabilities capabilities = consumer.getCapabilities();
@@ -90,7 +94,7 @@
capabilities.setSupportedUserScopes(getListFromArray(registrationData.getConsumerUserScopes(), false));
capabilities.setSupportsGetMethod(registrationData.isMethodGetSupported());
}
- catch (RegistrationException e)
+ catch (Exception e)
{
log.debug(e);
throw WSRPUtils.createOperationFailedFault(e);
@@ -135,14 +139,7 @@
try
{
Registration reg = producer.getRegistrationManager().getRegistration(regHandle);
- if (RegistrationStatus.VALID.equals(reg.getStatus()))
- {
- return true;
- }
- else
- {
- return false;
- }
+ return RegistrationStatus.VALID.equals(reg.getStatus());
}
catch (RegistrationException e)
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -74,10 +74,9 @@
{
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(gs, "GetServiceDescription");
- if (producer.getProducerRegistrationRequirements().fullServiceDescriptionRequiresRegistration()
- && !producer.isRegistrationValid(gs.getRegistrationContext()))
+ if (!producer.isRegistrationValid(gs.getRegistrationContext()))
{
- return getRegistrationNotProvidedServiceDescription();
+ return getRegistrationNotProvidedServiceDescription(gs.getDesiredLocales());
}
log.debug("Returning complete service description");
return refreshServiceDescription(gs.getDesiredLocales());
@@ -135,23 +134,37 @@
ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
ServiceDescription serviceDescription = WSRPTypeFactory.createServiceDescription(requirements.requiresRegistration());
serviceDescription.setRequiresInitCookie(CookieProtocol.none);
- PortletDescription[] descriptions = (PortletDescription[])getOfferedPortletDescriptions(desiredLocales)
- .toArray(new PortletDescription[]{});
+ PortletDescription[] descriptions = getPortletDescriptions(desiredLocales);
serviceDescription.setOfferedPortlets(descriptions);
return serviceDescription;
}
+ private PortletDescription[] getPortletDescriptions(String[] desiredLocales)
+ {
+ return (PortletDescription[])getOfferedPortletDescriptions(desiredLocales)
+ .toArray(new PortletDescription[]{});
+ }
+
/**
* Retrieves the service description offered to unregistered consumers when registration is required.
*
+ * @param desiredLocales
* @return the service description offered to unregistered consumers when registration is required
*/
- protected ServiceDescription getRegistrationNotProvidedServiceDescription()
+ protected ServiceDescription getRegistrationNotProvidedServiceDescription(String[] desiredLocales)
{
- // todo: find out how to cache this
- log.debug("Using service description offered for unregistered consumers");
+ log.debug("Unregistered consumer while registration is required. Sending registration information.");
ProducerRegistrationRequirements requirements = producer.getProducerRegistrationRequirements();
- return new ServiceDescription(true, null, null, null, null, null, CookieProtocol.none,
+
+
+ PortletDescription[] offeredPortlets = null;
+ if (requirements.fullServiceDescriptionRequiresRegistration())
+ {
+ log.debug("Sending offered portlets description despite not being registered, per Producer configuration.");
+ offeredPortlets = getPortletDescriptions(desiredLocales);
+ }
+
+ return new ServiceDescription(true, offeredPortlets, null, null, null, null, CookieProtocol.none,
WSRPUtils.convertRegistrationPropertiesToModelDescription(requirements.getRegistrationProperties()),
producer.getSupportedLocales(), null, null);
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -53,7 +53,6 @@
import org.jboss.portal.wsrp.core.InvalidUserCategoryFault;
import org.jboss.portal.wsrp.core.MarkupResponse;
import org.jboss.portal.wsrp.core.MissingParametersFault;
-import org.jboss.portal.wsrp.core.ModelDescription;
import org.jboss.portal.wsrp.core.ModifyRegistration;
import org.jboss.portal.wsrp.core.OperationFailedFault;
import org.jboss.portal.wsrp.core.PerformBlockingInteraction;
@@ -122,15 +121,6 @@
private static final ProducerRegistrationRequirements DEFAULT_REGISTRATION_REQUIREMENTS =
new ProducerRegistrationRequirementsImpl(false, false, false);
- /**
- * The ServiceDescription that is returned to an unregistred Consumer when registration is required: no information
- * is provided apart from the fact that registration is required and what information is required to sucessfully
- * register.
- *
- * @see WSRPProducerImpl#requiredRegistrationInfo
- */
- private final ServiceDescription requiredRegistrationNotProvidedSD;
-
private int sessionExpirationTime = DEFAULT_SESSION_EXPIRATION_TIME;
private CookieProtocol requiresInitCookie = CookieProtocol.none;
@@ -138,16 +128,11 @@
/** Supported locales. */
private String[] supportedLocales = new String[]{"en", "en-US"};
- /** Required registration information to be provided by consumers to access this Producer's information and services. */
- private ModelDescription requiredRegistrationInfo;
-
/** Manages the sessions. */
private SessionManager sessionManager;
public WSRPProducerImpl()
{
- requiredRegistrationInfo = initRequiredRegistrationInfo();
- requiredRegistrationNotProvidedSD = initRegistrationNotProvidedServiceDescription();
markupHandler = new MarkupHandler(this);
serviceDescriptionHandler = new ServiceDescriptionHandler(this);
registrationHandler = new RegistrationHandler(this);
@@ -163,7 +148,7 @@
registrationRequirements = registrationConfiguration.getRegistrationRequirements();
}
- // still need to check for null, in case there wasn't no registration info in the descriptor
+ // still need to check for null, in case there wasn't any registration info in the descriptor
return registrationRequirements != null ? registrationRequirements : DEFAULT_REGISTRATION_REQUIREMENTS;
}
@@ -445,19 +430,6 @@
return serviceDescriptionHandler.getPortletDescription(handle, locales);
}
- // Contract with Invoker implementation *****************************************************************************
-
- /** Dispatch the invocation to the target by reflection */
- /*public Object invoke(Invocation invocation) throws Exception
- {
- Method method = invocation.getMethod();
- Object[] args = invocation.getArguments();
- log.debug("invoke invoked: method=" + method + " args=" + args);
- return method.invoke(this, args);
- }*/
-
- // Protected methods ************************************************************************************************
-
/**
* Checks that the specified registration information is valid if this Producer requires registration.
*
@@ -481,44 +453,7 @@
}
}
- /**
- * Retrieves the service description offered to unregistered consumers when registration is required.
- *
- * @return the service description offered to unregistered consumers when registration is required
- */
- protected ServiceDescription getRegistrationNotProvidedServiceDescription()
- {
- log.debug("Using service description offered for unregistered consumers");
- return requiredRegistrationNotProvidedSD;
- }
- // Private methods **************************************************************************************************
-
- /**
- * Initializes the information required to be able to sucessfully register with this Producer.
- * <p/>
- * todo: Decide how this information is passed to the server without having to code
- */
- private ModelDescription initRequiredRegistrationInfo()
- {
- return new ModelDescription();
- }
-
- /**
- * Initializes the ServiceDescription that is returned to Consumers trying to access this Producer's information
- * without valid registration information when one is required.
- * <p/>
- * todo: this should be loaded dynamically instead of statically
- *
- * @return the service description offered to unregistered consumers when registration is required
- */
- private ServiceDescription initRegistrationNotProvidedServiceDescription()
- {
- return new ServiceDescription(true, null, null, null, null, null, requiresInitCookie, requiredRegistrationInfo,
- supportedLocales, null, null);
- }
-
-
private Boolean remotableByDefault;
public Boolean isRemotableByDefault()
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -74,4 +74,6 @@
void removeConsumerGroup(String name) throws RegistrationException;
Collection getConsumers() throws RegistrationException;
+
+ void clear() throws RegistrationException;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -24,6 +24,7 @@
package org.jboss.portal.wsrp.producer.registration.impl;
import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.producer.registration.api.Consumer;
import org.jboss.portal.wsrp.producer.registration.api.ConsumerCapabilities;
import org.jboss.portal.wsrp.producer.registration.api.ConsumerGroup;
@@ -121,7 +122,7 @@
throw new IllegalStateException("Cannot modify the agent of a Consumer!");
}
- validate(consumerAgent);
+ WSRPUtils.validateConsumerAgent(consumerAgent);
this.consumerAgent = consumerAgent;
agentSet = true;
}
@@ -194,21 +195,4 @@
group.addConsumer(this);
}
}
-
- private void validate(String consumerAgent) throws IllegalArgumentException
- {
- char periodChar = '.';
- int period = consumerAgent.indexOf(periodChar);
- if (period != -1)
- {
- consumerAgent = consumerAgent.substring(period);
- period = consumerAgent.indexOf(periodChar);
-
- if (period != -1)
- {
- return;
- }
- }
- throw new IllegalArgumentException(consumerAgent + " is not a valid Consumer Agent.");
- }
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java 2006-11-25 19:35:00 UTC (rev 5720)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java 2006-11-26 02:55:41 UTC (rev 5721)
@@ -327,6 +327,21 @@
return persistenceManager.getConsumers();
}
+ public void clear() throws RegistrationException
+ {
+ Collection tmpColl = new ArrayList(getConsumers());
+ for (Iterator consumers = tmpColl.iterator(); consumers.hasNext();)
+ {
+ removeConsumer((Consumer)consumers.next());
+ }
+
+ tmpColl = new ArrayList(getConsumerGroups());
+ for (Iterator groups = tmpColl.iterator(); groups.hasNext();)
+ {
+ removeConsumerGroup((ConsumerGroup)groups.next());
+ }
+ }
+
private static class ConsumerRegistration
{
private Registration registration;
17 years, 5 months
JBoss Portal SVN: r5720 - in trunk/wsrp/src: main/org/jboss/portal/test/wsrp/registration main/org/jboss/portal/wsrp/producer main/org/jboss/portal/wsrp/producer/registration/api main/org/jboss/portal/wsrp/producer/registration/impl resources/portal-wsrp-sar/META-INF resources/tests/test-wsrp-producer-sar/META-INF
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2006-11-25 14:35:00 -0500 (Sat, 25 Nov 2006)
New Revision: 5720
Added:
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerCapabilitiesImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java
Modified:
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java
trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Consumer.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ConsumerCapabilities.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java
trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml
Log:
- RegistrationManager is now an interface for MBeans wiring.
- DefaultRegistrationPolicy and RegistrationPersistenceManagerImpl are now services and injected in RegistrationManager.
- Producer tests now work again (except for RegistrationTestCase which is being worked on).
- Implemented ConsumerCapabilities and moved consumer agent to Consumer.
- Added services wiring.
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerGroupTestCase.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -28,7 +28,9 @@
import org.jboss.portal.wsrp.producer.registration.api.ConsumerGroup;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationException;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPolicy;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
+import org.jboss.portal.wsrp.producer.registration.impl.RegistrationManagerImpl;
import org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl;
import org.jboss.portal.wsrp.producer.registration.policies.DefaultRegistrationPolicy;
@@ -46,9 +48,11 @@
protected void setUp() throws Exception
{
- manager = new RegistrationManager();
- manager.setPolicy(new DefaultRegistrationPolicy());
+ manager = new RegistrationManagerImpl();
+ RegistrationPolicy policy = new DefaultRegistrationPolicy();
+ manager.setPolicy(policy);
manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
+ policy.setManager(manager);
group = manager.createConsumerGroup(NAME);
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/ConsumerTestCase.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -27,7 +27,9 @@
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.RegistrationManager;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPolicy;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
+import org.jboss.portal.wsrp.producer.registration.impl.RegistrationManagerImpl;
import org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl;
import org.jboss.portal.wsrp.producer.registration.policies.DefaultRegistrationPolicy;
@@ -43,9 +45,11 @@
protected void setUp() throws Exception
{
- manager = new RegistrationManager();
- manager.setPolicy(new DefaultRegistrationPolicy());
+ manager = new RegistrationManagerImpl();
+ RegistrationPolicy policy = new DefaultRegistrationPolicy();
+ manager.setPolicy(policy);
manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
+ policy.setManager(manager);
consumer = manager.createConsumer("name");
}
Modified: trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/test/wsrp/registration/RegistrationManagerTestCase.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -32,6 +32,7 @@
import org.jboss.portal.wsrp.producer.registration.api.RegistrationException;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationPolicy;
+import org.jboss.portal.wsrp.producer.registration.impl.RegistrationManagerImpl;
import org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl;
import org.jboss.portal.wsrp.producer.registration.policies.DefaultRegistrationPolicy;
@@ -53,9 +54,11 @@
protected void setUp() throws Exception
{
- manager = new RegistrationManager();
- manager.setPolicy(new DefaultRegistrationPolicy());
+ manager = new RegistrationManagerImpl();
+ RegistrationPolicy policy = new DefaultRegistrationPolicy();
+ manager.setPolicy(policy);
manager.setPersistenceManager(new RegistrationPersistenceManagerImpl());
+ policy.setManager(manager);
registrationProperties = new HashMap();
registrationProperties.put(new QName("prop1"), "value1");
registrationProperties.put(new QName("prop2"), "value2");
@@ -136,13 +139,15 @@
public void testCreateConsumerWithGroupFromPolicy() throws RegistrationException
{
// use a different policy: now specifies that when creating a consumer, it should be added to a group with the same name
- manager.setPolicy(new DefaultRegistrationPolicy()
+ DefaultRegistrationPolicy policy = new DefaultRegistrationPolicy()
{
public String getGroupNameFor(String consumerName)
{
return consumerName;
}
- });
+ };
+ manager.setPolicy(policy);
+ policy.setManager(manager);
String name = "name";
Consumer consumer = manager.createConsumer(name);
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/RegistrationHandler.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -30,17 +30,25 @@
import org.jboss.portal.wsrp.core.MissingParametersFault;
import org.jboss.portal.wsrp.core.ModifyRegistration;
import org.jboss.portal.wsrp.core.OperationFailedFault;
+import org.jboss.portal.wsrp.core.Property;
import org.jboss.portal.wsrp.core.RegistrationContext;
import org.jboss.portal.wsrp.core.RegistrationData;
import org.jboss.portal.wsrp.core.RegistrationState;
import org.jboss.portal.wsrp.core.ReturnAny;
import org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType;
+import org.jboss.portal.wsrp.producer.registration.api.Consumer;
+import org.jboss.portal.wsrp.producer.registration.api.ConsumerCapabilities;
import org.jboss.portal.wsrp.producer.registration.api.Registration;
import org.jboss.portal.wsrp.producer.registration.api.RegistrationException;
-import org.jboss.portal.wsrp.producer.registration.api.RegistrationPolicy;
-import org.jboss.portal.common.FixMe;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationStatus;
+import javax.xml.namespace.QName;
import java.rmi.RemoteException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -51,23 +59,12 @@
{
private final Logger log = Logger.getLogger(getClass());
- private RegistrationPolicy policy;
RegistrationHandler(WSRPProducerImpl producer)
{
super(producer);
}
- public RegistrationPolicy getPolicy()
- {
- return policy;
- }
-
- public void setPolicy(RegistrationPolicy policy)
- {
- this.policy = policy;
- }
-
public RegistrationContext register(RegistrationData registrationData) throws MissingParametersFault, OperationFailedFault,
RemoteException
{
@@ -77,25 +74,31 @@
String consumerAgent = registrationData.getConsumerAgent();
WSRPUtils.throwMissingParametersFaultIfValueIsMissing(consumerAgent, "consumer agent", "RegistrationData");
- throwOperationFailedFaultIfInvalid(consumerAgent);
-// Registration registration;
-// try
-// {
-// log.debug("Attempting to register consumer named '" + consumerName + "', agent '" + consumerAgent + "'.");
-// // delegate to the policy the details on how to handle the registration
-// registration = policy.registerConsumerWith(registrationData);
-// }
-// catch (RegistrationException e)
-// {
-// log.debug(e);
-// throw WSRPUtils.createOperationFailedFault(e);
-// }
-//
-// RegistrationContext registrationContext = WSRPTypeFactory.createRegistrationContext(registration.getId());
-// log.debug("Registration completed without error.");
-// return registrationContext;
- throw new FixMe();
+ Registration registration;
+ try
+ {
+ log.debug("Attempting to register consumer named '" + consumerName + "', agent '" + consumerAgent + "'.");
+
+ registration = producer.getRegistrationManager().addRegistrationTo(consumerName, createRegistrationProperties(registrationData), true);
+ Consumer consumer = registration.getConsumer();
+ consumer.setConsumerAgent(consumerAgent);
+ ConsumerCapabilities capabilities = consumer.getCapabilities();
+ capabilities.setSupportedModes(getListFromArray(registrationData.getConsumerModes(), false));
+ capabilities.setSupportedWindowStates(getListFromArray(registrationData.getConsumerWindowStates(), false));
+ capabilities.setSupportedUserProfileData(getListFromArray(registrationData.getCustomUserProfileData(), false));
+ capabilities.setSupportedUserScopes(getListFromArray(registrationData.getConsumerUserScopes(), false));
+ capabilities.setSupportsGetMethod(registrationData.isMethodGetSupported());
+ }
+ catch (RegistrationException e)
+ {
+ log.debug(e);
+ throw WSRPUtils.createOperationFailedFault(e);
+ }
+
+ RegistrationContext registrationContext = WSRPTypeFactory.createRegistrationContext(registration.getId());
+ log.debug("Registration completed without error.");
+ return registrationContext;
}
public ReturnAny deregister(RegistrationContext deregister) throws OperationFailedFault, InvalidRegistrationFault,
@@ -112,34 +115,48 @@
return null; // todo: implement
}
- public boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault
+ public boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
{
-// if (policy.getMetaData().requiresRegistration())
-// {
-// log.debug("registration required: checking registration");
-// if (registrationContext == null)
-// {
-// log.debug("registration is required yet no RegistrationContext was provided!");
-// return false;
-// }
-//
-// String regHandle = registrationContext.getRegistrationHandle();
-// if (regHandle == null)
-// {
-// throwInvalidRegistrationFault("missing required registration handle!");
-// }
-//
-// return true;
-// }
-// else
-// {
-// if (registrationContext != null)
-// {
-// throwInvalidRegistrationFault("no registration necessary yet one was provided!");
-// }
-// return true;
-// }
- throw new FixMe();
+ if (producer.getProducerRegistrationRequirements().requiresRegistration())
+ {
+ log.debug("registration required: checking registration");
+ if (registrationContext == null)
+ {
+ log.debug("registration is required yet no RegistrationContext was provided!");
+ return false;
+ }
+
+ String regHandle = registrationContext.getRegistrationHandle();
+ if (regHandle == null)
+ {
+ throwInvalidRegistrationFault("missing required registration handle!");
+ }
+
+ try
+ {
+ Registration reg = producer.getRegistrationManager().getRegistration(regHandle);
+ if (RegistrationStatus.VALID.equals(reg.getStatus()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch (RegistrationException e)
+ {
+ throw WSRPUtils.createOperationFailedFault(e);
+ }
+ }
+ else
+ {
+ if (registrationContext != null)
+ {
+ throwInvalidRegistrationFault("no registration necessary yet one was provided!");
+ }
+ return true;
+ }
}
private boolean throwInvalidRegistrationFault(String message) throws InvalidRegistrationFault
@@ -148,21 +165,27 @@
new Exception("Invalid registration: " + message));
}
- private void throwOperationFailedFaultIfInvalid(String consumerAgent) throws OperationFailedFault
+ private Map createRegistrationProperties(RegistrationData registrationData)
{
- char periodChar = '.';
- int period = consumerAgent.indexOf(periodChar);
- if (period != -1)
+ Property[] regProperties = registrationData.getRegistrationProperties();
+ Map properties = new HashMap(regProperties.length);
+
+ for (int i = 0; i < regProperties.length; i++)
{
- consumerAgent = consumerAgent.substring(period);
- period = consumerAgent.indexOf(periodChar);
+ Property property = regProperties[i];
+ // todo: should be more detailed here... use the language, allow other value types...
+ properties.put(new QName(property.getName()), property.getStringValue());
+ }
- if (period != -1)
- {
- return;
- }
+ return properties;
+ }
+
+ private List getListFromArray(String[] array, boolean useEmptyForNull)
+ {
+ if (array == null)
+ {
+ return useEmptyForNull ? Collections.EMPTY_LIST : null;
}
- throw WSRPUtils.createOperationFailedFault(new IllegalArgumentException(consumerAgent
- + " is not a valid Consumer Agent."));
+ return Arrays.asList(array);
}
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/ServiceDescriptionHandler.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -23,8 +23,7 @@
package org.jboss.portal.wsrp.producer;
-import org.apache.log4j.Logger;
-import org.jboss.portal.common.FixMe;
+import org.jboss.logging.Logger;
import org.jboss.portal.common.util.LocaleInfo;
import org.jboss.portal.common.util.LocalizedString;
import org.jboss.portal.portlet.Portlet;
@@ -75,13 +74,13 @@
{
WSRPUtils.throwOperationFailedFaultIfValueIsMissing(gs, "GetServiceDescription");
-// if (producer.getRegistrationPolicy().getMetaData().fullServiceDescriptionRequiresRegistration() && !producer.isRegistrationValid(gs.getRegistrationContext()))
-// {
-// return getRegistrationNotProvidedServiceDescription();
-// }
-// log.debug("Returning complete service description");
-// return refreshServiceDescription(gs.getDesiredLocales());
- throw new FixMe();
+ if (producer.getProducerRegistrationRequirements().fullServiceDescriptionRequiresRegistration()
+ && !producer.isRegistrationValid(gs.getRegistrationContext()))
+ {
+ return getRegistrationNotProvidedServiceDescription();
+ }
+ log.debug("Returning complete service description");
+ return refreshServiceDescription(gs.getDesiredLocales());
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -75,6 +75,7 @@
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
import org.jboss.portal.wsrp.producer.registration.api.ProducerRegistrationRequirements;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
import org.jboss.portal.wsrp.producer.registration.config.RegistrationConfiguration;
import org.jboss.portal.wsrp.producer.registration.impl.ProducerRegistrationRequirementsImpl;
import org.jboss.portal.wsrp.servlet.ServletAccess;
@@ -115,6 +116,9 @@
/** Registration configuration service */
private RegistrationConfiguration registrationConfiguration;
+ /** Registration Manager */
+ private RegistrationManager registrationManager;
+
private static final ProducerRegistrationRequirements DEFAULT_REGISTRATION_REQUIREMENTS =
new ProducerRegistrationRequirementsImpl(false, false, false);
@@ -273,6 +277,16 @@
this.registrationConfiguration = registrationConfiguration;
}
+ public RegistrationManager getRegistrationManager()
+ {
+ return registrationManager;
+ }
+
+ public void setRegistrationManager(RegistrationManager registrationManager)
+ {
+ this.registrationManager = registrationManager;
+ }
+
// PortletManagement implementation *********************************************************************************
public PortletDescriptionResponse getPortletDescription(GetPortletDescription getPortletDescription)
@@ -451,12 +465,12 @@
* @return <code>true</code> if the registration (when registration is required) information is valid or if no
* registration is required, <code>false</code> otherwise (registration required, invalid information).
*/
- protected boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault
+ protected boolean isRegistrationValid(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
{
return registrationHandler.isRegistrationValid(registrationContext);
}
- protected void checkRegistration(RegistrationContext registrationContext) throws InvalidRegistrationFault
+ protected void checkRegistration(RegistrationContext registrationContext) throws InvalidRegistrationFault, OperationFailedFault
{
if (!isRegistrationValid(registrationContext))
{
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Consumer.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Consumer.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/Consumer.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -86,4 +86,8 @@
void setCapabilities(ConsumerCapabilities capabilities);
void setGroup(ConsumerGroup group) throws RegistrationException, DuplicateRegistrationException;
+
+ String getConsumerAgent();
+
+ void setConsumerAgent(String consumerAgent) throws IllegalArgumentException, IllegalStateException;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ConsumerCapabilities.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ConsumerCapabilities.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/ConsumerCapabilities.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -32,8 +32,6 @@
*/
public interface ConsumerCapabilities
{
- String getConsumerAgent();
-
boolean supportsGetMethod();
List getSupportedModes();
@@ -43,4 +41,14 @@
List getSupportedUserScopes();
List getSupportedUserProfileData();
+
+ void setSupportsGetMethod(boolean supportsGetMethod);
+
+ void setSupportedModes(List supportedModes);
+
+ void setSupportedWindowStates(List supportedWindowStates);
+
+ void setSupportedUserScopes(List supportedUserScopes);
+
+ void setSupportedUserProfileData(List supportedUserProfileData);
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/api/RegistrationManager.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -23,13 +23,7 @@
package org.jboss.portal.wsrp.producer.registration.api;
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
-import org.jboss.portal.common.util.ParameterValidation;
-
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
import java.util.Map;
/**
@@ -37,284 +31,47 @@
* @version $Revision$
* @since 2.6
*/
-public class RegistrationManager
+public interface RegistrationManager
{
- private RegistrationPolicy policy;
- private RegistrationPersistenceManager persistenceManager;
- private Map registrations;
+ RegistrationPolicy getPolicy();
+ void setPolicy(RegistrationPolicy policy);
- public RegistrationManager()
- {
- registrations = new ConcurrentHashMap();
- }
+ RegistrationPersistenceManager getPersistenceManager();
- public RegistrationPolicy getPolicy()
- {
- return policy;
- }
+ void setPersistenceManager(RegistrationPersistenceManager persistenceManager);
- public void setPolicy(RegistrationPolicy policy)
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(policy, "RegistrationPolicy");
- this.policy = policy;
- policy.setManager(this);
- }
+ Registration addRegistrationTo(String consumerName, Map registrationProperties, boolean createConsumerIfNeeded)
+ throws RegistrationException;
- public RegistrationPersistenceManager getPersistenceManager()
- {
- return persistenceManager;
- }
+ Consumer createConsumer(String name) throws RegistrationException, InvalidConsumerDataException;
- public void setPersistenceManager(RegistrationPersistenceManager persistenceManager)
- {
- this.persistenceManager = persistenceManager;
- }
+ Consumer addConsumerToGroupNamed(String consumerName, String groupName, boolean createGroupIfNeeded,
+ boolean createConsumerIfNeeded) throws RegistrationException;
- public Registration addRegistrationTo(String consumerName, Map registrationProperties, boolean createConsumerIfNeeded)
- throws RegistrationException
- {
- // the policy determines the identity of the consumer based on the given information (note that this might be obsoleted by using WS-Security)
- String identity = policy.getConsumerIdentityFrom(consumerName, registrationProperties);
+ ConsumerGroup createConsumerGroup(String groupName) throws RegistrationException;
- // validate the registration information
- policy.validateRegistrationDataFor(registrationProperties, identity);
+ void removeConsumer(String identity) throws RegistrationException, NoSuchRegistrationException;
- Consumer consumer = getOrCreateConsumer(identity, createConsumerIfNeeded, consumerName);
+ void removeConsumer(Consumer consumer) throws RegistrationException, NoSuchRegistrationException;
- // create the actual registration
- Registration registration = persistenceManager.addRegistrationFor(identity, registrationProperties);
+ Consumer getConsumerByIdentity(String identity) throws RegistrationException;
- // let the policy decide what the handle should be
- String handle = policy.createRegistrationHandleFor(registration.getId());
- registration.setRegistrationHandle(handle);
+ Consumer getConsumerFor(String registrationHandle) throws RegistrationException;
- // associate the handle to the consumer for easy retrieval
- registrations.put(handle, new ConsumerRegistration(registration, consumer));
+ Registration getRegistration(String registrationHandle) throws RegistrationException;
- return registration;
- }
+ void removeRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException;
- public Consumer createConsumer(String name) throws RegistrationException, InvalidConsumerDataException
- {
- // check with policy if we allow the consumer
- policy.validateConsumerName(name);
+ void removeRegistration(Registration registration) throws RegistrationException, NoSuchRegistrationException;
- String identity = policy.getConsumerIdentityFrom(name, Collections.EMPTY_MAP);
+ ConsumerGroup getConsumerGroup(String groupName) throws RegistrationException;
- Consumer consumer = persistenceManager.createConsumer(identity, name);
+ Collection getConsumerGroups() throws RegistrationException;
- // deal with group if needed
- // let the policy decide if there should be a group associated with the Consumer and if yes, with which id
- String groupName = policy.getGroupNameFor(consumer.getName());
- if (groupName != null)
- {
- addConsumerToGroupNamed(groupName, groupName, true, false);
- }
+ void removeConsumerGroup(ConsumerGroup group) throws RegistrationException;
- return consumer;
- }
+ void removeConsumerGroup(String name) throws RegistrationException;
- public Consumer addConsumerToGroupNamed(String consumerName, String groupName, boolean createGroupIfNeeded, boolean createConsumerIfNeeded) throws RegistrationException
- {
- // check with the policy if we allow the group name in case we need to create it
- if (createGroupIfNeeded)
- {
- policy.validateConsumerGroupName(groupName);
- }
-
- // check with policy if we allow the consumer name in case we need to create it
- if (createConsumerIfNeeded)
- {
- policy.validateConsumerName(consumerName);
- }
-
- ConsumerGroup group = getConsumerGroup(groupName);
- boolean justCreatedGroup = false;
- if (group == null)
- {
- if (createGroupIfNeeded)
- {
- createConsumerGroup(groupName);
- justCreatedGroup = true;
- }
- else
- {
- throw new NoSuchRegistrationException("There is no existing ConsumerGroup named '" + groupName + "'.");
- }
- }
-
- String identity = policy.getConsumerIdentityFrom(consumerName, Collections.EMPTY_MAP);
- try
- {
- getOrCreateConsumer(identity, createConsumerIfNeeded, consumerName);
- }
- catch (NoSuchRegistrationException e)
- {
- if (justCreatedGroup)
- {
- removeConsumerGroup(groupName);
- }
- }
-
- return persistenceManager.addConsumerToGroupNamed(identity, groupName);
- }
-
- public ConsumerGroup createConsumerGroup(String groupName) throws RegistrationException
- {
- // check with the policy if we allow the group
- policy.validateConsumerGroupName(groupName);
-
- return persistenceManager.createConsumerGroup(groupName);
- }
-
- public void removeConsumer(String identity) throws RegistrationException, NoSuchRegistrationException
- {
- Consumer consumer = getOrCreateConsumer(identity, false, null);
-
- ConsumerGroup group = consumer.getGroup();
- if (group != null)
- {
- group.removeConsumer(consumer);
- }
-
- // cascade delete the registrations
- for (Iterator i = new ArrayList(consumer.getRegistrations()).iterator(); i.hasNext();)
- {
- removeRegistration((Registration)i.next());
- }
-
- // let the registry do the actual deletion
- persistenceManager.removeConsumer(identity);
- }
-
- public void removeConsumer(Consumer consumer) throws RegistrationException, NoSuchRegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(consumer, "Consumer");
-
- removeConsumer(consumer.getIdentity());
- }
-
- public Consumer getConsumerByIdentity(String identity) throws RegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(identity, "identity", null);
- return persistenceManager.getConsumerByIdentity(identity);
- }
-
- public Consumer getConsumerFor(String registrationHandle) throws RegistrationException
- {
- return (Consumer)getConsumerOrRegistration(registrationHandle, true);
- }
-
- public Registration getRegistration(String registrationHandle) throws RegistrationException
- {
- return (Registration)getConsumerOrRegistration(registrationHandle, false);
- }
-
- public void removeRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException
- {
- Registration registration = getRegistration(registrationHandle);
- if (registration == null)
- {
- throw new NoSuchRegistrationException("There is no Registration with handle '" + registrationHandle + "'");
- }
- removeRegistration(registration);
- }
-
- public void removeRegistration(Registration registration) throws RegistrationException, NoSuchRegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(registration, "Registration");
- String handle = registration.getRegistrationHandle();
- Consumer consumer = getConsumerFor(handle);
-
- if (consumer == null)
- {
- throw new NoSuchRegistrationException("Could not locate a Consumer for Registration with handle '" + handle
- + "' (id: '" + registration.getId() + "')");
- }
-
- persistenceManager.removeRegistration(registration.getId());
- registrations.remove(registration.getRegistrationHandle());
- }
-
- public ConsumerGroup getConsumerGroup(String groupName) throws RegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(groupName, "ConsumerGroup name", null);
- return persistenceManager.getConsumerGroup(groupName);
- }
-
- private Consumer getOrCreateConsumer(String identity, boolean createConsumerIfNeeded, String consumerName)
- throws RegistrationException
- {
- Consumer consumer = getConsumerByIdentity(identity);
- if (consumer == null)
- {
- if (createConsumerIfNeeded)
- {
- consumer = createConsumer(consumerName);
- }
- else
- {
- throw new NoSuchRegistrationException("There is no Consumer named '" + consumerName + "'.");
- }
- }
- return consumer;
- }
-
- private Object getConsumerOrRegistration(String registrationHandle, boolean getConsumer)
- {
- ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationHandle, "registration handle", null);
- // this particular implementations uses a map though it could delegate to the registry and make a DB query to retrieve the info
- ConsumerRegistration cr = (ConsumerRegistration)registrations.get(registrationHandle);
-
- if (cr != null)
- {
- return (getConsumer ? (Object)cr.consumer : cr.registration);
- }
- else
- {
- return null;
- }
- }
-
- public Collection getConsumerGroups()
- {
- return persistenceManager.getConsumerGroups();
- }
-
- public void removeConsumerGroup(ConsumerGroup group) throws RegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(group, "ConsumerGroup");
-
- for (Iterator consumers = group.getConsumers().iterator(); consumers.hasNext();)
- {
- removeConsumer((Consumer)consumers.next());
- }
-
- persistenceManager.removeConsumerGroup(group.getName());
- }
-
- public void removeConsumerGroup(String name) throws RegistrationException
- {
- ParameterValidation.throwIllegalArgExceptionIfNull(name, "ConsumerGroup name");
- removeConsumerGroup(getConsumerGroup(name));
- }
-
- public Collection getConsumers()
- {
- return persistenceManager.getConsumers();
- }
-
- private static class ConsumerRegistration
- {
- private Registration registration;
- private Consumer consumer;
-
-
- public ConsumerRegistration(Registration registration, Consumer consumer)
- {
- this.registration = registration;
- this.consumer = consumer;
- }
- }
+ Collection getConsumers() throws RegistrationException;
}
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerCapabilitiesImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerCapabilitiesImpl.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerCapabilitiesImpl.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * 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.wsrp.producer.registration.impl;
+
+import org.jboss.portal.wsrp.producer.registration.api.ConsumerCapabilities;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class ConsumerCapabilitiesImpl implements ConsumerCapabilities
+{
+ private boolean supportsGetMethod;
+ private List supportedModes;
+ private List supportedWindowStates;
+ private List supportedUserScopes;
+ private List supportedUserProfileData;
+
+ public boolean supportsGetMethod()
+ {
+ return supportsGetMethod;
+ }
+
+ public List getSupportedModes()
+ {
+ return supportedModes;
+ }
+
+ public List getSupportedWindowStates()
+ {
+ return supportedWindowStates;
+ }
+
+ public List getSupportedUserScopes()
+ {
+ return supportedUserScopes;
+ }
+
+ public List getSupportedUserProfileData()
+ {
+ return supportedUserProfileData;
+ }
+
+ public void setSupportsGetMethod(boolean supportsGetMethod)
+ {
+ this.supportsGetMethod = supportsGetMethod;
+ }
+
+ public void setSupportedModes(List supportedModes)
+ {
+ this.supportedModes = supportedModes;
+ }
+
+ public void setSupportedWindowStates(List supportedWindowStates)
+ {
+ this.supportedWindowStates = supportedWindowStates;
+ }
+
+ public void setSupportedUserScopes(List supportedUserScopes)
+ {
+ this.supportedUserScopes = supportedUserScopes;
+ }
+
+ public void setSupportedUserProfileData(List supportedUserProfileData)
+ {
+ this.supportedUserProfileData = supportedUserProfileData;
+ }
+}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/ConsumerImpl.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -46,10 +46,12 @@
private String name;
private String identity;
+ private String consumerAgent;
private Set registrations;
private RegistrationStatus status;
private ConsumerGroup group;
private ConsumerCapabilities capabilities;
+ private boolean agentSet = false;
private ConsumerImpl()
@@ -71,6 +73,7 @@
{
registrations = new HashSet(7);
status = RegistrationStatus.PENDING;
+ capabilities = new ConsumerCapabilitiesImpl();
}
@@ -105,6 +108,24 @@
return identity;
}
+
+ public String getConsumerAgent()
+ {
+ return consumerAgent;
+ }
+
+ public void setConsumerAgent(String consumerAgent) throws IllegalArgumentException, IllegalStateException
+ {
+ if (agentSet)
+ {
+ throw new IllegalStateException("Cannot modify the agent of a Consumer!");
+ }
+
+ validate(consumerAgent);
+ this.consumerAgent = consumerAgent;
+ agentSet = true;
+ }
+
public ConsumerCapabilities getCapabilities()
{
return capabilities;
@@ -173,4 +194,21 @@
group.addConsumer(this);
}
}
+
+ private void validate(String consumerAgent) throws IllegalArgumentException
+ {
+ char periodChar = '.';
+ int period = consumerAgent.indexOf(periodChar);
+ if (period != -1)
+ {
+ consumerAgent = consumerAgent.substring(period);
+ period = consumerAgent.indexOf(periodChar);
+
+ if (period != -1)
+ {
+ return;
+ }
+ }
+ throw new IllegalArgumentException(consumerAgent + " is not a valid Consumer Agent.");
+ }
}
Added: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationManagerImpl.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -0,0 +1,342 @@
+/******************************************************************************
+ * 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.wsrp.producer.registration.impl;
+
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+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.InvalidConsumerDataException;
+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.RegistrationException;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationManager;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPersistenceManager;
+import org.jboss.portal.wsrp.producer.registration.api.RegistrationPolicy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ * @since 2.6
+ */
+public class RegistrationManagerImpl extends AbstractJBossService implements RegistrationManager
+{
+ private RegistrationPolicy policy;
+ private RegistrationPersistenceManager persistenceManager;
+ private Map registrations;
+
+
+ public RegistrationManagerImpl()
+ {
+ registrations = new ConcurrentHashMap();
+ }
+
+ public RegistrationPolicy getPolicy()
+ {
+ return policy;
+ }
+
+ public void setPolicy(RegistrationPolicy policy)
+ {
+ this.policy = policy;
+ }
+
+ public RegistrationPersistenceManager getPersistenceManager()
+ {
+ return persistenceManager;
+ }
+
+ public void setPersistenceManager(RegistrationPersistenceManager persistenceManager)
+ {
+ this.persistenceManager = persistenceManager;
+ }
+
+
+ protected void startService() throws Exception
+ {
+ super.startService();
+ policy.setManager(this);
+ }
+
+
+ protected void stopService() throws Exception
+ {
+ policy.setManager(null);
+ super.stopService();
+ }
+
+ public Registration addRegistrationTo(String consumerName, Map registrationProperties, boolean createConsumerIfNeeded)
+ throws RegistrationException
+ {
+ // the policy determines the identity of the consumer based on the given information (note that this might be obsoleted by using WS-Security)
+ String identity = policy.getConsumerIdentityFrom(consumerName, registrationProperties);
+
+ // validate the registration information
+ policy.validateRegistrationDataFor(registrationProperties, identity);
+
+ Consumer consumer = getOrCreateConsumer(identity, createConsumerIfNeeded, consumerName);
+
+ // create the actual registration
+ Registration registration = persistenceManager.addRegistrationFor(identity, registrationProperties);
+
+ // let the policy decide what the handle should be
+ String handle = policy.createRegistrationHandleFor(registration.getId());
+ registration.setRegistrationHandle(handle);
+
+ // associate the handle to the consumer for easy retrieval
+ registrations.put(handle, new ConsumerRegistration(registration, consumer));
+
+ return registration;
+ }
+
+ public Consumer createConsumer(String name) throws RegistrationException, InvalidConsumerDataException
+ {
+ // check with policy if we allow the consumer
+ policy.validateConsumerName(name);
+
+ String identity = policy.getConsumerIdentityFrom(name, Collections.EMPTY_MAP);
+
+ Consumer consumer = persistenceManager.createConsumer(identity, name);
+
+ // deal with group if needed
+ // let the policy decide if there should be a group associated with the Consumer and if yes, with which id
+ String groupName = policy.getGroupNameFor(consumer.getName());
+ if (groupName != null)
+ {
+ addConsumerToGroupNamed(groupName, groupName, true, false);
+ }
+
+ return consumer;
+ }
+
+ public Consumer addConsumerToGroupNamed(String consumerName, String groupName, boolean createGroupIfNeeded, boolean createConsumerIfNeeded) throws RegistrationException
+ {
+ // check with the policy if we allow the group name in case we need to create it
+ if (createGroupIfNeeded)
+ {
+ policy.validateConsumerGroupName(groupName);
+ }
+
+ // check with policy if we allow the consumer name in case we need to create it
+ if (createConsumerIfNeeded)
+ {
+ policy.validateConsumerName(consumerName);
+ }
+
+ ConsumerGroup group = getConsumerGroup(groupName);
+ boolean justCreatedGroup = false;
+ if (group == null)
+ {
+ if (createGroupIfNeeded)
+ {
+ createConsumerGroup(groupName);
+ justCreatedGroup = true;
+ }
+ else
+ {
+ throw new NoSuchRegistrationException("There is no existing ConsumerGroup named '" + groupName + "'.");
+ }
+ }
+
+ String identity = policy.getConsumerIdentityFrom(consumerName, Collections.EMPTY_MAP);
+ try
+ {
+ getOrCreateConsumer(identity, createConsumerIfNeeded, consumerName);
+ }
+ catch (NoSuchRegistrationException e)
+ {
+ if (justCreatedGroup)
+ {
+ removeConsumerGroup(groupName);
+ }
+ }
+
+ return persistenceManager.addConsumerToGroupNamed(identity, groupName);
+ }
+
+ public ConsumerGroup createConsumerGroup(String groupName) throws RegistrationException
+ {
+ // check with the policy if we allow the group
+ policy.validateConsumerGroupName(groupName);
+
+ return persistenceManager.createConsumerGroup(groupName);
+ }
+
+ public void removeConsumer(String identity) throws RegistrationException, NoSuchRegistrationException
+ {
+ Consumer consumer = getOrCreateConsumer(identity, false, null);
+
+ ConsumerGroup group = consumer.getGroup();
+ if (group != null)
+ {
+ group.removeConsumer(consumer);
+ }
+
+ // cascade delete the registrations
+ for (Iterator i = new ArrayList(consumer.getRegistrations()).iterator(); i.hasNext();)
+ {
+ removeRegistration((Registration)i.next());
+ }
+
+ // let the registry do the actual deletion
+ persistenceManager.removeConsumer(identity);
+ }
+
+ public void removeConsumer(Consumer consumer) throws RegistrationException, NoSuchRegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(consumer, "Consumer");
+
+ removeConsumer(consumer.getIdentity());
+ }
+
+ public Consumer getConsumerByIdentity(String identity) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(identity, "identity", null);
+ return persistenceManager.getConsumerByIdentity(identity);
+ }
+
+ public Consumer getConsumerFor(String registrationHandle) throws RegistrationException
+ {
+ return (Consumer)getConsumerOrRegistration(registrationHandle, true);
+ }
+
+ public Registration getRegistration(String registrationHandle) throws RegistrationException
+ {
+ return (Registration)getConsumerOrRegistration(registrationHandle, false);
+ }
+
+ public void removeRegistration(String registrationHandle) throws RegistrationException, NoSuchRegistrationException
+ {
+ Registration registration = getRegistration(registrationHandle);
+ if (registration == null)
+ {
+ throw new NoSuchRegistrationException("There is no Registration with handle '" + registrationHandle + "'");
+ }
+ removeRegistration(registration);
+ }
+
+ public void removeRegistration(Registration registration) throws RegistrationException, NoSuchRegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(registration, "Registration");
+ String handle = registration.getRegistrationHandle();
+ Consumer consumer = getConsumerFor(handle);
+
+ if (consumer == null)
+ {
+ throw new NoSuchRegistrationException("Could not locate a Consumer for Registration with handle '" + handle
+ + "' (id: '" + registration.getId() + "')");
+ }
+
+ persistenceManager.removeRegistration(registration.getId());
+ registrations.remove(registration.getRegistrationHandle());
+ }
+
+ public ConsumerGroup getConsumerGroup(String groupName) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(groupName, "ConsumerGroup name", null);
+ return persistenceManager.getConsumerGroup(groupName);
+ }
+
+ private Consumer getOrCreateConsumer(String identity, boolean createConsumerIfNeeded, String consumerName)
+ throws RegistrationException
+ {
+ Consumer consumer = getConsumerByIdentity(identity);
+ if (consumer == null)
+ {
+ if (createConsumerIfNeeded)
+ {
+ consumer = createConsumer(consumerName);
+ }
+ else
+ {
+ throw new NoSuchRegistrationException("There is no Consumer named '" + consumerName + "'.");
+ }
+ }
+ return consumer;
+ }
+
+ private Object getConsumerOrRegistration(String registrationHandle, boolean getConsumer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(registrationHandle, "registration handle", null);
+ // this particular implementations uses a map though it could delegate to the registry and make a DB query to retrieve the info
+ ConsumerRegistration cr = (ConsumerRegistration)registrations.get(registrationHandle);
+
+ if (cr != null)
+ {
+ return (getConsumer ? (Object)cr.consumer : cr.registration);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Collection getConsumerGroups()
+ {
+ return persistenceManager.getConsumerGroups();
+ }
+
+ public void removeConsumerGroup(ConsumerGroup group) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(group, "ConsumerGroup");
+
+ for (Iterator consumers = group.getConsumers().iterator(); consumers.hasNext();)
+ {
+ removeConsumer((Consumer)consumers.next());
+ }
+
+ persistenceManager.removeConsumerGroup(group.getName());
+ }
+
+ public void removeConsumerGroup(String name) throws RegistrationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(name, "ConsumerGroup name");
+ removeConsumerGroup(getConsumerGroup(name));
+ }
+
+ public Collection getConsumers()
+ {
+ return persistenceManager.getConsumers();
+ }
+
+ private static class ConsumerRegistration
+ {
+ private Registration registration;
+ private Consumer consumer;
+
+
+ public ConsumerRegistration(Registration registration, Consumer consumer)
+ {
+ this.registration = registration;
+ this.consumer = consumer;
+ }
+ }
+}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/producer/registration/impl/RegistrationPersistenceManagerImpl.java 2006-11-25 19:35:00 UTC (rev 5720)
@@ -24,6 +24,7 @@
package org.jboss.portal.wsrp.producer.registration.impl;
import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
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;
@@ -43,7 +44,7 @@
* @version $Revision$
* @since 2.6
*/
-public class RegistrationPersistenceManagerImpl implements RegistrationPersistenceManager
+public class RegistrationPersistenceManagerImpl extends AbstractJBossService implements RegistrationPersistenceManager
{
private long lastRegistrationId;
private Map consumers = new HashMap();
Modified: trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/resources/portal-wsrp-sar/META-INF/jboss-service.xml 2006-11-25 19:35:00 UTC (rev 5720)
@@ -80,14 +80,16 @@
<depends optional-attribute-name="Invoker"
proxy-type="attribute">portal:service=PortletInvoker,type=WSRPProducer</depends>
<depends optional-attribute-name="RegistrationConfiguration" proxy-type="attribute">portal.wsrp:service=RegistrationConfiguration</depends>
+ <depends optional-attribute-name="RegistrationManager" proxy-type="attribute">portal.wsrp:service=RegistrationManager</depends>
</mbean>
- <!-- Configure a consumer that is the portal itself -->
- <mbean
- code="org.jboss.portal.wsrp.deployment.WSRPDeployer"
- name="portal.wsrp:service=WSRPDeployer">
- <attribute name="DefaultWSRPLocation">default-wsrp.xml</attribute>
- <depends optional-attribute-name="FederatingPortletInvoker" proxy-type="attribute">portal:service=PortletInvoker,type=Federating</depends>
+ <!-- Registration manager -->
+ <mbean code="org.jboss.portal.wsrp.producer.registration.impl.RegistrationManagerImpl"
+ name="portal.wsrp:service=RegistrationManager" xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends optional-attribute-name="Policy" proxy-type="attribute">portal.wsrp:service=RegistrationPolicy</depends>
+ <depends optional-attribute-name="PersistenceManager" proxy-type="attribute">portal.wsrp:service=PersistenceManager</depends>
</mbean>
<!-- Registration policy -->
@@ -97,6 +99,13 @@
<xmbean/>
</mbean>
+ <!-- Persistence manager for registrations -->
+ <mbean code="org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl"
+ name="portal.wsrp:service=PersistenceManager" xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+
<!-- Registration configuration service -->
<mbean code="org.jboss.portal.wsrp.producer.registration.config.RegistrationConfigurationService"
name="portal.wsrp:service=RegistrationConfiguration" xmbean-dd=""
@@ -104,5 +113,13 @@
<xmbean/>
<attribute name="ConfigLocation">conf/config.xml</attribute>
</mbean>
+
+ <!-- Configure a consumer that is the portal itself -->
+ <mbean
+ code="org.jboss.portal.wsrp.deployment.WSRPDeployer"
+ name="portal.wsrp:service=WSRPDeployer">
+ <attribute name="DefaultWSRPLocation">default-wsrp.xml</attribute>
+ <depends optional-attribute-name="FederatingPortletInvoker" proxy-type="attribute">portal:service=PortletInvoker,type=Federating</depends>
+ </mbean>
</server>
Modified: trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml 2006-11-23 22:49:44 UTC (rev 5719)
+++ trunk/wsrp/src/resources/tests/test-wsrp-producer-sar/META-INF/jboss-service.xml 2006-11-25 19:35:00 UTC (rev 5720)
@@ -174,8 +174,32 @@
<depends optional-attribute-name="Invoker"
proxy-type="attribute">portal:service=PortletInvoker,type=Stateful</depends>
<attribute name="RemotableByDefault">true</attribute>
+ <depends optional-attribute-name="RegistrationManager" proxy-type="attribute">portal.wsrp:service=RegistrationManager</depends>
</mbean>
+ <!-- Registration manager -->
+ <mbean code="org.jboss.portal.wsrp.producer.registration.impl.RegistrationManagerImpl"
+ name="portal.wsrp:service=RegistrationManager" xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends optional-attribute-name="Policy" proxy-type="attribute">portal.wsrp:service=RegistrationPolicy</depends>
+ <depends optional-attribute-name="PersistenceManager" proxy-type="attribute">portal.wsrp:service=PersistenceManager</depends>
+ </mbean>
+
+ <!-- Use DefaultRegistrationPolicy for registration -->
+ <mbean code="org.jboss.portal.wsrp.producer.registration.policies.DefaultRegistrationPolicy"
+ name="portal.wsrp:service=RegistrationPolicy" xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+
+ <!-- Persistence manager for registrations -->
+ <mbean code="org.jboss.portal.wsrp.producer.registration.impl.RegistrationPersistenceManagerImpl"
+ name="portal.wsrp:service=PersistenceManager" xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+
<!-- Hack to get access to req/resp -->
<mbean
code="org.jboss.portal.wsrp.servlet.ServletAccessService"
17 years, 5 months
JBoss Portal SVN: r5719 - in trunk: core/src/main/org/jboss/portal/core/controller core/src/main/org/jboss/portal/core/controller/command core/src/main/org/jboss/portal/core/impl/model core/src/main/org/jboss/portal/core/model core/src/main/org/jboss/portal/core/model/portal/command core/src/main/org/jboss/portal/core/portlet/management core/src/resources/portal-core-sar/META-INF security/src/main/org/jboss/portal/security security/src/main/org/jboss/portal/security/impl/jacc security/src/m
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2006-11-23 17:49:44 -0500 (Thu, 23 Nov 2006)
New Revision: 5719
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java
trunk/core/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/security/src/main/org/jboss/portal/security/PortalPermissionCollection.java
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalPermissionCollection.java
trunk/security/src/main/org/jboss/portal/security/spi/auth/PortalAuthorizationManager.java
Log:
- encapsulate customization of instance based on the user + window in an interface
- fix signout bug
- add explicit Subject checking in portal security
- add dashboard permission in portal object manager bean
Modified: trunk/core/src/main/org/jboss/portal/core/controller/Controller.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/core/src/main/org/jboss/portal/core/controller/Controller.java 2006-11-23 22:49:44 UTC (rev 5719)
@@ -27,6 +27,7 @@
import org.jboss.portal.core.controller.command.mapper.URLFactory;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.CustomizationManager;
import org.jboss.portal.common.invocation.InterceptorStackFactory;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
import org.jboss.portal.jems.as.system.AbstractJBossService;
@@ -60,6 +61,19 @@
/** . */
protected PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
+ /** . */
+ protected CustomizationManager customizationManager;
+
+ public CustomizationManager getCustomizationManager()
+ {
+ return customizationManager;
+ }
+
+ public void setCustomizationManager(CustomizationManager customizationManager)
+ {
+ this.customizationManager = customizationManager;
+ }
+
public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
{
return portalAuthorizationManagerFactory;
Modified: trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java 2006-11-23 22:49:44 UTC (rev 5719)
@@ -24,9 +24,9 @@
import org.jboss.portal.core.controller.ControllerCommand;
import org.jboss.portal.core.controller.ControllerException;
-import org.jboss.portal.core.controller.portlet.SignOutResponse;
import org.jboss.portal.core.controller.command.info.ActionCommandInfo;
import org.jboss.portal.core.controller.command.info.CommandInfo;
+import org.jboss.portal.core.controller.command.response.SignOutResponse;
/**
* A global signout.
Added: trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2006-11-23 22:49:44 UTC (rev 5719)
@@ -0,0 +1,186 @@
+/******************************************************************************
+ * 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.model;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.core.model.CustomizationManager;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
+import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.User;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CustomizationManagerService extends AbstractJBossService implements CustomizationManager
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(CustomizationManager.class);
+
+ /** . */
+ private InstanceContainer instanceContainer;
+
+ /** . */
+ private PortalAuthorizationManagerFactory pamf;
+
+ /** . */
+ private UserModule userModule;
+
+ /** . */
+ private RoleModule roleModule;
+
+ public InstanceContainer getInstanceContainer()
+ {
+ return instanceContainer;
+ }
+
+ public void setInstanceContainer(InstanceContainer instanceContainer)
+ {
+ this.instanceContainer = instanceContainer;
+ }
+
+ public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
+ {
+ return pamf;
+ }
+
+ public void setPortalAuthorizationManagerFactory(PortalAuthorizationManagerFactory portalAuthorizationManagerFactory)
+ {
+ this.pamf = portalAuthorizationManagerFactory;
+ }
+
+ public UserModule getUserModule()
+ {
+ return userModule;
+ }
+
+ public void setUserModule(UserModule userModule)
+ {
+ this.userModule = userModule;
+ }
+
+ public RoleModule getRoleModule()
+ {
+ return roleModule;
+ }
+
+ public void setRoleModule(RoleModule roleModule)
+ {
+ this.roleModule = roleModule;
+ }
+
+ public Instance getInstance(Window window) throws IllegalArgumentException
+ {
+ return getInstance(window, null);
+ }
+
+ public Instance getInstance(Window window, User user) throws IllegalArgumentException
+ {
+ if (window == null)
+ {
+ throw new IllegalArgumentException("No window provided");
+ }
+
+ //
+ String instanceId = window.getInstanceRef();
+ if (instanceId == null)
+ {
+ return null;
+ }
+
+ // Get the instance
+ Instance instance = instanceContainer.getInstance(instanceId);
+ if (instance != null)
+ {
+ // If we are in the context of an existing user we get a customization for that user
+ if (user != null)
+ {
+ String userId = user.getId().toString();
+
+ // And if it is in a dashboard context we get the per window customization
+ if (isDashboard(window, user))
+ {
+ // That's how we manufacture dash board keys
+ String dashboardId = userId + "." + window.getId();
+
+ //
+ instance = instance.getCustomization(dashboardId);
+ }
+ else
+ {
+ instance = instance.getCustomization(userId);
+ }
+ }
+ }
+
+ //
+ return instance;
+ }
+
+ /**
+ * Return true if the portal object is in a dashboard context for the current authenticated user.
+ *
+ * @param object
+ * @return
+ */
+ public boolean isDashboard(PortalObject object, User user)
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException("No null object");
+ }
+
+ // Anonymous
+ if (user == null)
+ {
+ return false;
+ }
+
+ // todo
+ // We should test that it is the same than the request user
+ // as for now we can only test permission for the currently
+ // authenticated user
+
+ //
+ try
+ {
+ PortalAuthorizationManager pam = pamf.getManager();
+ PortalObjectPermission perm = new PortalObjectPermission(object.getId(), PortalObjectPermission.DASHBOARD_MASK);
+ return pam.checkPermission(perm);
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot check dashboard for", e);
+ return false;
+ }
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java 2006-11-23 22:49:44 UTC (rev 5719)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * 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.model;
+
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.identity.User;
+
+/**
+ * Encapsulate portlet customization semantics.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CustomizationManager
+{
+ /**
+ * Return a top level named portlet instance.
+ *
+ * @param window the window of the portlet instance
+ * @return the target instance or null if it cannot be found
+ * @throws IllegalArgumentException if the window is null
+ */
+ Instance getInstance(Window window) throws IllegalArgumentException;
+
+ /**
+ * Return a contextualized portlet instance for the specified user id. If the window is in the context
+ * of a dashboard then the portlet instance is further customized for that specific window.
+ *
+ * @param window the window of the portlet instance
+ * @param user the user that can be null
+ * @return the target instance or null if it cannot be found
+ * @throws IllegalArgumentException if the window is null
+ */
+ Instance getInstance(Window window, User user) throws IllegalArgumentException;
+
+ /**
+ * Return true if the portal object is in a dashboard context for the specified user.
+ *
+ * @param object
+ * @return
+ */
+ boolean isDashboard(PortalObject object, User user);
+}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/PortalObjectCommand.java 2006-11-23 22:49:44 UTC (rev 5719)
@@ -31,7 +31,7 @@
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
-import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
+import org.jboss.portal.identity.User;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -104,17 +104,9 @@
{
if (dashboard == null)
{
- try
- {
- PortalAuthorizationManagerFactory pamf = getControllerContext().getController().getPortalAuthorizationManagerFactory();
- PortalAuthorizationManager pam = pamf.getManager();
- PortalObjectPermission perm = new PortalObjectPermission(targetId, PortalObjectPermission.DASHBOARD_MASK);
- dashboard = Boolean.valueOf(pam.checkPermission(perm));
- }
- catch (PortalSecurityException e)
- {
- dashboard = Boolean.FALSE;
- }
+ User user = (User)getControllerContext().getServerInvocation().getRequest().getUser();
+ boolean tmp = context.getController().getCustomizationManager().isDashboard(target, user);
+ dashboard = Boolean.valueOf(tmp);
}
return dashboard.booleanValue();
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/WindowCommand.java 2006-11-23 22:49:44 UTC (rev 5719)
@@ -31,6 +31,7 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.security.PortalSecurityException;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManager;
+import org.jboss.portal.identity.User;
/**
* A superclass for command that target a specific window.
@@ -99,26 +100,17 @@
throw new ResourceNotFoundException(targetId);
}
+ // We need the user id
+ User user = (User)getControllerContext().getServerInvocation().getRequest().getUser();
+
// Get instance
- instance = context.getController().getInstanceContainer().getInstance(window.getInstanceRef());
+ instance = context.getController().getCustomizationManager().getInstance(window, user);
+
+ // No instance means we can't continue
if (instance == null)
{
throw new ResourceNotFoundException(window.getInstanceRef());
}
-
- // Get the user customization id
- String userId = getControllerContext().getServerInvocation().getServerContext().getClientRequest().getRemoteUser();
- if (userId != null)
- {
- instance = instance.getCustomization(userId);
-
- //
- if (isDashboard())
- {
- String dashboardId = userId + targetId;
- instance = instance.getCustomization(dashboardId);
- }
- }
}
/**
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/management/PortalObjectManagerBean.java 2006-11-23 22:49:44 UTC (rev 5719)
@@ -890,6 +890,7 @@
new SelectItem("viewrecursive"),
new SelectItem("personalize"),
new SelectItem("personalizerecursive"),
+ new SelectItem("dashboard"),
};
}
}
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2006-11-23 22:49:44 UTC (rev 5719)
@@ -599,6 +599,27 @@
<attribute name="CacheNaturalId">true</attribute>
</mbean>
+ <!-- Customization maanger -->
+ <mbean
+ code="org.jboss.portal.core.impl.model.CustomizationManagerService"
+ name="portal:service=CustomizationManager"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="PortalAuthorizationManagerFactory"
+ proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
+ <depends
+ optional-attribute-name="InstanceContainer"
+ proxy-type="attribute">portal:container=Instance</depends>
+ <depends
+ optional-attribute-name="UserModule"
+ proxy-type="attribute">portal:service=Module,type=User</depends>
+ <depends
+ optional-attribute-name="RoleModule"
+ proxy-type="attribute">portal:service=Module,type=Role</depends>
+ </mbean>
+
<!-- Command factories -->
<mbean
code="org.jboss.portal.core.controller.command.mapper.DelegatingCommandFactoryService"
@@ -914,6 +935,9 @@
<depends
optional-attribute-name="PortalAuthorizationManagerFactory"
proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
+ <depends
+ optional-attribute-name="CustomizationManager"
+ proxy-type="attribute">portal:service=CustomizationManager</depends>
</mbean>
<!-- The ajax controller -->
@@ -944,6 +968,9 @@
<depends
optional-attribute-name="PortalAuthorizationManagerFactory"
proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
+ <depends
+ optional-attribute-name="CustomizationManager"
+ proxy-type="attribute">portal:service=CustomizationManager</depends>
</mbean>
<!-- -->
Modified: trunk/security/src/main/org/jboss/portal/security/PortalPermissionCollection.java
===================================================================
--- trunk/security/src/main/org/jboss/portal/security/PortalPermissionCollection.java 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/security/src/main/org/jboss/portal/security/PortalPermissionCollection.java 2006-11-23 22:49:44 UTC (rev 5719)
@@ -90,7 +90,7 @@
try
{
PortalPermission portalPermission = (PortalPermission)permission;
- Subject caller = getCaller();
+ Subject caller = getCheckedSubject();
String roleName = getRoleName();
PermissionRepository repository = domain.getPermissionRepository();
boolean implied = owner.implies(repository, caller, roleName, portalPermission);
@@ -114,9 +114,9 @@
public abstract String getRoleName();
/**
- * Return the subject being used or null.
+ * Return the subject being checked or null if there is none.
*
* @return the current subject
*/
- public abstract Subject getCaller();
+ public abstract Subject getCheckedSubject();
}
Modified: trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java
===================================================================
--- trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java 2006-11-23 22:49:44 UTC (rev 5719)
@@ -34,6 +34,7 @@
import javax.security.jacc.PolicyConfiguration;
import javax.security.jacc.PolicyConfigurationFactory;
import javax.security.jacc.PolicyContext;
+import javax.security.jacc.PolicyContextException;
import java.security.Policy;
import java.security.Principal;
import java.security.ProtectionDomain;
@@ -65,6 +66,9 @@
/** . */
private PolicyConfigurationFactory pcf;
+ /** Used to retrieve the subject in hte jacc portal permission collection. */
+ private static final ThreadLocal checkedSubjectLocal = new ThreadLocal();
+
public JACCPortalAuthorizationManager(JACCPortalAuthorizationManagerFactory factory)
{
this.factory = factory;
@@ -133,16 +137,16 @@
/**
*
*/
- public boolean internalCheckPermission(PortalPermission permission) throws Exception
+ private boolean internalCheckPermission(PortalPermission permission) throws Exception
{
// Get the current context id.
String contextID = PolicyContext.getContextID();
// Get the current authenticated subject through the JACC contract
- Subject currentSubject = (Subject)PolicyContext.getContext("javax.security.auth.Subject.container");
+ Subject currentSubject = (Subject)checkedSubjectLocal.get();
//
- Principal[] principals = null;
+ Principal[] principals;
//
if (currentSubject != null)
@@ -184,25 +188,60 @@
return policy.implies(pd, permission);
}
- public boolean checkPermission(PortalPermission permission) throws PortalSecurityException
+
+ public boolean checkPermission(Subject checkedSubject, PortalPermission permission) throws PortalSecurityException
{
try
{
+
+ // Set the subject for later use in that layer
+ checkedSubjectLocal.set(checkedSubject);
if (trace)
{
log.trace("hasPermission:uri=" + permission.getURI() + "::action=" + permission.getType() + "::type=" + permission.getType());
}
+
+ //
boolean result = internalCheckPermission(permission);
if (trace)
{
log.trace("hasPermission:result=" + result);
}
+
+ //
return result;
}
catch (Exception e)
{
log.trace("hasPermission:error", e);
- throw new RuntimeException(e);
+
+ //
+ throw new PortalSecurityException(e);
}
+ finally
+ {
+ checkedSubjectLocal.set(null);
+ }
}
+
+ public boolean checkPermission(PortalPermission permission) throws PortalSecurityException
+ {
+ try
+ {
+ // Get the current authenticated subject through the JACC contract
+ Subject subject = (Subject)PolicyContext.getContext("javax.security.auth.Subject.container");
+
+ //
+ return checkPermission(subject, permission);
+ }
+ catch (PolicyContextException e)
+ {
+ throw new PortalSecurityException(e);
+ }
+ }
+
+ static Subject getCheckedSubject()
+ {
+ return (Subject)checkedSubjectLocal.get();
+ }
}
Modified: trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalPermissionCollection.java
===================================================================
--- trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalPermissionCollection.java 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalPermissionCollection.java 2006-11-23 22:49:44 UTC (rev 5719)
@@ -26,8 +26,6 @@
import org.jboss.portal.security.spi.provider.AuthorizationDomain;
import javax.security.auth.Subject;
-import javax.security.jacc.PolicyContext;
-import javax.security.jacc.PolicyContextException;
import java.util.Enumeration;
import java.util.Vector;
@@ -42,12 +40,11 @@
/** The serialVersionUID */
private static final long serialVersionUID = -4307467280985644450L;
+
/** The role name of the permission container. */
private String roleName;
- public JACCPortalPermissionCollection(
- String roleName,
- AuthorizationDomain repository) throws IllegalArgumentException
+ public JACCPortalPermissionCollection(String roleName, AuthorizationDomain repository) throws IllegalArgumentException
{
super(repository);
if (roleName == null)
@@ -68,16 +65,8 @@
return new Vector().elements();
}
-
- public Subject getCaller()
+ public Subject getCheckedSubject()
{
- try
- {
- return (Subject)PolicyContext.getContext("javax.security.auth.Subject.container");
- }
- catch (PolicyContextException e)
- {
- return null;
- }
+ return JACCPortalAuthorizationManager.getCheckedSubject();
}
}
Modified: trunk/security/src/main/org/jboss/portal/security/spi/auth/PortalAuthorizationManager.java
===================================================================
--- trunk/security/src/main/org/jboss/portal/security/spi/auth/PortalAuthorizationManager.java 2006-11-23 21:53:43 UTC (rev 5718)
+++ trunk/security/src/main/org/jboss/portal/security/spi/auth/PortalAuthorizationManager.java 2006-11-23 22:49:44 UTC (rev 5719)
@@ -25,6 +25,8 @@
import org.jboss.portal.security.PortalPermission;
import org.jboss.portal.security.PortalSecurityException;
+import javax.security.auth.Subject;
+
/**
* Portal Authorization Management Interface
*
@@ -39,4 +41,12 @@
* @throws PortalSecurityException
*/
public boolean checkPermission(PortalPermission permission) throws PortalSecurityException;
+
+ /**
+ * @param checkedSubject
+ * @param permission
+ * @return
+ * @throws PortalSecurityException
+ */
+ public boolean checkPermission(Subject checkedSubject, PortalPermission permission) throws PortalSecurityException;
}
17 years, 5 months
JBoss Portal SVN: r5718 - in trunk: identity identity/src/main/org/jboss/portal/identity2 identity/src/main/org/jboss/portal/identity2/config/metadata identity/src/main/org/jboss/portal/identity2/ldap identity/src/main/org/jboss/portal/identity2/service identity/src/main/org/jboss/portal/test/identity identity/src/main/org/jboss/portal/test/identity/ldap identity/src/resources identity/src/resources/test identity/src/resources/test/config test/src/etc/identityconfig
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2006-11-23 16:53:43 -0500 (Thu, 23 Nov 2006)
New Revision: 5718
Added:
trunk/identity/src/resources/test/
trunk/identity/src/resources/test/config/
trunk/identity/src/resources/test/config/minimal-db-identity-config.xml
trunk/identity/src/resources/test/config/minimal-ldap-identity-config.xml
trunk/identity/src/resources/test/config/standardidentity-config.xml
trunk/test/src/etc/identityconfig/standardidentity-config.xml
Removed:
trunk/identity/src/main/org/jboss/portal/test/identity/ConfigurationTestCase.java
trunk/test/src/etc/identityconfig/test-config.xml
Modified:
trunk/identity/build.xml
trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java
trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/ModulesMetaData.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java
trunk/test/src/etc/identityconfig/opends-config.xml
trunk/test/src/etc/identityconfig/rhds-config.xml
Log:
- IdentityServiceController that loads all identity modules from
- identity testsuite run using new configuration
Modified: trunk/identity/build.xml
===================================================================
--- trunk/identity/build.xml 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/build.xml 2006-11-23 21:53:43 UTC (rev 5718)
@@ -385,7 +385,7 @@
<x-test>
- <!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.ConfigurationTestCase"/>-->
+ <!--<test todir="${test.reports}" name="org.jboss.portal.test.identity.ConfigurationTestCasestCase"/>-->
<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPSimpleUserModuleTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPSimpleRoleModuleTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.identity.ldap.LDAPStaticGroupMembershipModuleTestCase"/>
@@ -397,6 +397,7 @@
<pathelement location="${build.lib}/portal-identity-lib.jar"/>
<pathelement location="${build.lib}/portal-identity-test-lib.jar"/>
<pathelement location="${jboss.portal-test.root}/etc"/>
+ <pathelement location="${jboss.portal-identity.root}/resources/test"/>
<pathelement location="${build.resources}/hibernate"/>
@@ -455,6 +456,7 @@
<pathelement location="${build.lib}/portal-identity-lib.jar"/>
<pathelement location="${build.lib}/portal-identity-test-lib.jar"/>
<pathelement location="${jboss.portal-test.root}/etc"/>
+ <pathelement location="${jboss.portal-identity.root}/resources/test"/>
<pathelement location="${build.resources}/hibernate"/>
Modified: trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -29,19 +29,21 @@
*/
public interface IdentityContext
{
- public static final String TYPE_USER_MODULE = "user_module";
- public static final String TYPE_ROLE_MODULE = "role_module";
+ //TODO: move to safe type enum
+ public static final String TYPE_USER_MODULE = "UserModule";
- public static final String TYPE_MEMBERSHIP_MODULE = "membership_module";
+ public static final String TYPE_ROLE_MODULE = "RoleModule";
- public static final String TYPE_USER_PROFILE_MODULE = "user_profile_module";
+ public static final String TYPE_MEMBERSHIP_MODULE = "MembershipModule";
- public static final String TYPE_CONNECTION_CONTEXT = "connection_context";
+ public static final String TYPE_USER_PROFILE_MODULE = "UserProfileModule";
- public static final String TYPE_IDENTITY_CONFIGURATION = "configuration";
+ public static final String TYPE_CONNECTION_CONTEXT = "ConnectionContext";
+ public static final String TYPE_IDENTITY_CONFIGURATION = "IdentityConfiguration";
+
public void register(Object object, String name) throws IdentityException;
public void unregister(String name);
Modified: trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -71,7 +71,7 @@
}
synchronized(this)
{
- if(!registry.containsKey(name))
+ if(registry.containsKey(name))
{
registry.remove(name);
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -24,12 +24,15 @@
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.common.util.JNDI;
import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.config.SimpleIdentityConfigurationFactory;
import org.jboss.portal.identity2.config.IdentityConfigurationMetaDataFactory;
import org.jboss.portal.identity2.config.metadata.IdentityConfigurationMetaData;
import org.jboss.portal.identity2.config.metadata.ModuleMetaData;
import org.jboss.portal.identity2.config.metadata.ModuleConfigOptionMetaData;
+import org.jboss.portal.identity2.config.metadata.OptionsMetaData;
+import org.jboss.portal.identity2.config.metadata.OptionsGroupMetaData;
+import org.jboss.portal.identity2.config.metadata.OptionsGroupOptionMetaData;
import org.jboss.portal.identity2.service.IdentityModuleService;
+import org.jboss.portal.identity2.service.IdentityConfigurationService;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
import org.jboss.xb.binding.ObjectModelFactory;
@@ -40,6 +43,9 @@
import java.util.Map;
import java.util.Iterator;
import java.util.HashMap;
+import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
@@ -71,6 +77,8 @@
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ //TODO: make a dtd for config files.
+
//parse config files
IdentityConfigurationMetaData meta = parseConfiguration(configFile);
IdentityConfigurationMetaData defaultMeta = parseConfiguration(defaultConfigFile);
@@ -81,17 +89,103 @@
//TODO:update meta options using defaultMeta options
+ //create detault modules set
+
+ //Map[implementation] --> Map[Type] --> ModuleMetaData
+ Map defaultImplementations = new HashMap();
+
+
try
{
- Map modules = meta.getModules().getModules();
+ List defaultModules = defaultMeta.getModules().getModules();
+ for (Iterator iterator = defaultModules.iterator(); iterator.hasNext();)
+ {
+ ModuleMetaData module = (ModuleMetaData)iterator.next();
- for (Iterator iterator = modules.keySet().iterator(); iterator.hasNext();)
+ //check if defaults contains all information
+ if (module.getType() == null ||
+ module.getImplementation() == null ||
+ module.getJndiName() == null ||
+ module.getServiceName() == null ||
+ module.getConfig() == null)
+ {
+ throw new IdentityException("Default module configuration must be complete");
+ }
+
+ //store them as maps for different implementations
+ String implType = module.getImplementation();
+ Map implementation;
+ if (defaultImplementations.containsKey(implType))
+ {
+ implementation = (Map)defaultImplementations.get(implType);
+ }
+ else
+ {
+ implementation = new HashMap();
+ }
+
+ implementation.put(module.getType(), module);
+ defaultImplementations.put(implType, implementation);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Error during processing default configuration file", e);
+ }
+
+
+ //process the list of modules, instantiate them, configure them, tide them
+ try
+ {
+ List modules = meta.getModules().getModules();
+
+ //TODO: update configuration options from defaultMeta
+ //OptionsMetaData options = meta.getOptions();
+
+ //inject configuration service
+ IdentityConfigurationService configuration = new IdentityConfigurationService(meta.getOptions());
+ configuration.setIdentityContext(identityContext);
+
+ //TODO:set proper jndiName and serviceName
+ configuration.start();
+
+ updateOptionsWithDefaults(configuration,defaultMeta.getOptions());
+
+
+ for (Iterator iterator = modules.iterator(); iterator.hasNext();)
{
- String key = (String)iterator.next();
- ModuleMetaData module = (ModuleMetaData)modules.get(key);
+ ModuleMetaData module = (ModuleMetaData)iterator.next();
+ log.debug("Processing module: " + module.getType() + "/" + module.getImplementation());
+ updateModuleWithDefaults(module, defaultImplementations);
+
//instantiate the module
- IdentityModuleService moduleService = (IdentityModuleService)tcl.loadClass(module.getClassName()).newInstance();
+
+ IdentityModuleService moduleService = null;
+
+ if (module.getClassName() == null)
+ {
+ throw new IdentityException("Class name not found for module type: " + module.getType() + " wrong configuration");
+ }
+
+ try
+ {
+ moduleService = (IdentityModuleService)tcl.loadClass(module.getClassName()).newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new IdentityException("Unable to instantiate the class: " + module.getClassName() );
+ }
+ catch (IllegalAccessException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ catch (ClassNotFoundException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ //make a part of identityContext
moduleService.setIdentityContext(identityContext);
//generate initial options
@@ -107,6 +201,8 @@
//set options
moduleService.setInitOptions(optionMap);
+ moduleService.setJndiName(module.getJndiName());
+
//start
moduleService.start();
@@ -116,6 +212,8 @@
getServer().registerMBean(moduleService, new ObjectName(module.getServiceName()));
}
}
+
+
}
catch (Exception e)
{
@@ -138,7 +236,7 @@
private IdentityConfigurationMetaData parseConfiguration(String configFile) throws IdentityException
{
ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- IdentityConfigurationMetaData meta = null;
+ IdentityConfigurationMetaData meta;
try
{
log.info("Processing portal identity configuration");
@@ -164,7 +262,109 @@
return meta;
}
+ /**
+ * updates module with proper defaults
+ * @param module
+ * @param defaultModules
+ */
+ private void updateModuleWithDefaults(ModuleMetaData module, Map defaultModules)
+ {
+ if (module.getImplementation() == null)
+ {
+ return;
+ }
+ if (!defaultModules.containsKey(module.getImplementation()))
+ {
+ return;
+ }
+ Map modules = (Map)defaultModules.get(module.getImplementation());
+ if (!modules.containsKey(module.getType()))
+ {
+ return;
+ }
+ ModuleMetaData def = (ModuleMetaData)modules.get(module.getType());
+ if (module.getClassName() == null)
+ {
+ module.setClassName(def.getClassName());
+ }
+ if (module.getJndiName() == null)
+ {
+ module.setJndiName(def.getJndiName());
+ }
+ if (module.getServiceName() == null)
+ {
+ module.setServiceName(def.getServiceName());
+ }
+
+ //now check if config options are overwritten
+ if (module.getConfig() == null)
+ {
+ module.setConfig(def.getConfig());
+ }
+ else
+ {
+ Map moduleOptions = module.getConfig().getOptions();
+ if (moduleOptions == null)
+ {
+ return;
+ }
+ Map defOptions = def.getConfig().getOptions();
+
+ for (Iterator iterator = defOptions.keySet().iterator(); iterator.hasNext();)
+ {
+ String key = (String)iterator.next();
+ if (!moduleOptions.containsKey(key))
+ {
+ ModuleConfigOptionMetaData o = (ModuleConfigOptionMetaData)defOptions.get(key);
+ module.getConfig().addOption(o);
+ }
+ }
+ }
+ }
+
+ /**
+ * Check current options and update them with defaults if not exists;
+ * @param config
+ * @param defaults
+ */
+ public void updateOptionsWithDefaults(IdentityConfigurationService config, OptionsMetaData defaults)
+ {
+ //Map newGroups = new HashMap();
+ Map groups = defaults.getGroups();
+ for (Iterator iterator = groups.keySet().iterator(); iterator.hasNext();)
+ {
+ String groupKey = (String)iterator.next();
+
+ OptionsGroupMetaData group = (OptionsGroupMetaData)groups.get(groupKey);
+
+ if (config.getOptions(groupKey) == null)
+ {
+ config.setOptions(groupKey, new HashMap());
+ }
+
+ //Map newOptions = new HashMap();
+ Map options = group.getOptions();
+ for (Iterator iterator1 = options.keySet().iterator(); iterator1.hasNext();)
+ {
+ String optionKey = (String)iterator1.next();
+
+ OptionsGroupOptionMetaData option = (OptionsGroupOptionMetaData)options.get(optionKey);
+
+ if (config.getValues(groupKey, optionKey) == null)
+ {
+
+ //config.setValues(groupKey, optionKey, new HashSet());
+ config.setValues(groupKey,optionKey,option.getValues());
+ }
+
+
+ }
+ }
+
+ }
+
+
public IdentityContext getIdentityContext()
{
return identityContext;
Modified: trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/ModulesMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/ModulesMetaData.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/ModulesMetaData.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -23,6 +23,8 @@
import java.util.Map;
import java.util.HashMap;
+import java.util.List;
+import java.util.LinkedList;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
@@ -30,34 +32,34 @@
*/
public class ModulesMetaData
{
- private Map modules;
+ private List modules;
public ModulesMetaData()
{
- modules = new HashMap();
+ modules = new LinkedList();
}
- public Map getModules()
+ public List getModules()
{
return modules;
}
- public void setModules(Map modules)
+ public void setModules(List modules)
{
this.modules = modules;
}
public void addModule(ModuleMetaData module)
{
- modules.put(module.getType(), module);
+ modules.add(module);
}
- public ModuleMetaData getModule(String type)
+ /*public ModuleMetaData getModule(String type)
{
return (ModuleMetaData)modules.get(type);
- }
+ }*/
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -97,12 +97,23 @@
}
catch (NamingException e)
{
- throw new IdentityException("Unable to create InitialLdapContext using: " + this, e);
+ throw new IdentityException("Unable to create ConnectionContext: " + this, e);
//return null;
}
+
}
+ protected void startService() throws Exception
+ {
+ /*if (getInitOptions() == null)
+ {
+ throw new IdentityException("Cannot initialize ConnectionContext - lack of module init options");
+ }*/
+
+ super.startService(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
public String toString()
{
StringBuffer str = new StringBuffer();
@@ -123,6 +134,7 @@
public String getName()
{
return getIdentityConfiguration().getValue(IdentityConfiguration.GROUP_CONNECTION, IdentityConfiguration.CONNECTION_NAME);
+ //return (String)getInitOptions().get(IdentityConfiguration.CONNECTION_NAME);
}
/*public void setName(String name)
@@ -133,6 +145,7 @@
public String getHost()
{
return getIdentityConfiguration().getValue(IdentityConfiguration.GROUP_CONNECTION, IdentityConfiguration.CONNECTION_HOST);
+ //return (String)getInitOptions().get(IdentityConfiguration.CONNECTION_HOST);
}
/*public void setProviderUrl(String providerUrl)
@@ -143,11 +156,13 @@
public String getPort()
{
return getIdentityConfiguration().getValue(IdentityConfiguration.GROUP_CONNECTION, IdentityConfiguration.CONNECTION_PORT);
+ //return (String)getInitOptions().get(IdentityConfiguration.CONNECTION_PORT);
}
public String getContextFactory()
{
return getIdentityConfiguration().getValue(IdentityConfiguration.GROUP_CONNECTION, IdentityConfiguration.CONNECTION_CONTEXT_FACTORY);
+ //return (String)getInitOptions().get(IdentityConfiguration.CONNECTION_CONTEXT_FACTORY);
}
/*public void setContextFactory(String contextFactory)
@@ -158,6 +173,7 @@
public String getAdminDN()
{
return getIdentityConfiguration().getValue(IdentityConfiguration.GROUP_CONNECTION, IdentityConfiguration.CONNECTION_ADMIN_DN);
+ //return (String)getInitOptions().get(IdentityConfiguration.CONNECTION_ADMIN_DN);
}
/*public void setAdminDN(String adminDN)
@@ -168,6 +184,7 @@
public String getAdminPassword()
{
return getIdentityConfiguration().getValue(IdentityConfiguration.GROUP_CONNECTION, IdentityConfiguration.CONNECTION_ADMIN_PASSWORD);
+ //return (String)getInitOptions().get(IdentityConfiguration.CONNECTION_ADMIN_PASSWORD);
}
/*public void setAdminPassword(String adminPassword)
@@ -188,6 +205,7 @@
public String getAuthentication()
{
String auth = getIdentityConfiguration().getValue(IdentityConfiguration.GROUP_CONNECTION, IdentityConfiguration.CONNECTION_AUTHENTICATION);
+ //String auth = (String)getInitOptions().get(IdentityConfiguration.CONNECTION_AUTHENTICATION);
if (auth == null)
{
return "simple";
Modified: trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -62,6 +62,11 @@
public IdentityConfigurationService(OptionsMetaData meta) throws IdentityException
{
this();
+ if (meta == null || meta.getGroups() == null)
+ {
+ data = new HashMap();
+ return;
+ }
try
{
Map newGroups = new HashMap();
Modified: trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -66,6 +66,7 @@
//
if (jndiName != null)
{
+ log.debug("Binding identity module to JNDI with name: " + jndiName);
jndiBinding = new JNDI.Binding(jndiName, this);
jndiBinding.bind();
}
@@ -133,12 +134,12 @@
this.identityContext = identityContext;
}
- protected String getJndiName()
+ public String getJndiName()
{
return jndiName;
}
- protected void setJndiName(String jndiName)
+ public void setJndiName(String jndiName)
{
this.jndiName = jndiName;
}
Deleted: trunk/identity/src/main/org/jboss/portal/test/identity/ConfigurationTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ConfigurationTestCase.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ConfigurationTestCase.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -1,135 +0,0 @@
-/*
-* 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.identity;
-
-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.identity2.IdentityContextImpl;
-import org.jboss.portal.identity2.config.SimpleConfigurationImpl;
-
-
-import java.util.Set;
-import java.util.Iterator;
-
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss dot com">Boleslaw Dawidowicz</a>
- * @version $Revision: 5247 $
- */
-public class ConfigurationTestCase extends junit.framework.TestCase
-{
-
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(ConfigurationTestCase.class);
-
- static
- {
- Appender appender = new ConsoleAppender(new SimpleLayout());
- Logger.getRoot().addAppender(appender);
- Logger.getRoot().setLevel(Level.INFO);
- Logger.getLogger("org.jboss.portal.identity2").setLevel(Level.DEBUG);
- }
-
- /*public static TestSuite createTestSuite(Class clazz) throws Exception
- {
- URL configsURL = Thread.currentThread().getContextClassLoader().getResource("directories.xml");
- Map parameterMap = new HashMap();
- parameterMap.put("DirectoryServerConfig", DSConfig.fromXML2(configsURL));
- POJOJUnitTest abc = new POJOJUnitTest(clazz);
- JUnitAdapter adapter = new JUnitAdapter(abc);
- TestSuite suite = new TestSuite();
- suite.addTest(adapter);
- return suite;
- }*/
-
- public ConfigurationTestCase()
- {
-
- }
-
- /*public ConfigurationTestCase(DSConfig dsConfig)
- {
- this.directoryServerConfigParameter = dsConfig;
- }
-
- private DSConfig directoryServerConfigParameter;
-
- public String getName()
- {
- return super.getName();// + "," + directoryServerConfigParameter.getName() + "," + directoryServerConfigParameter.getDescription();
- }
-
- public DSConfig getDirectoryServerConfigParameter()
- {
- return directoryServerConfigParameter;
- }
-
- public void setDirectoryServerConfigParameter(DSConfig directoryServerConfigParameter)
- {
- this.directoryServerConfigParameter = directoryServerConfigParameter;
- }*/
-
- IdentityContextImpl context;
-
-
- public void setUp() throws Exception
- {
- this.context = new IdentityContextImpl();
- context.start();
-
-
- }
-
- public void testFactory() throws Exception
- {
- SimpleConfigurationImpl configuration = new SimpleConfigurationImpl();
- configuration.setIdentityContext(context);
- configuration.setConfigFile("identityconfig/test-config.xml");
- configuration.start();
- Set keys = configuration.getOptionGroups().keySet();
- log.info("Option Groups:");
- for (Iterator iterator = keys.iterator(); iterator.hasNext();)
- {
- String group = (String)iterator.next();
- log.info("option-group: " + group);
-
- log.info("Options:");
- Set names = configuration.getOptions(group).keySet();
- for (Iterator iterator1 = names.iterator(); iterator1.hasNext();)
- {
- String optionName = (String)iterator1.next();
- log.info("Name: " + optionName);
-
- }
-
- }
-
-
- assertEquals("uid",configuration.getValue("user.uidAttributeId"));
- }
-
-
-
-}
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -28,6 +28,9 @@
import org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl;
import org.jboss.portal.identity2.ldap.LDAPConnectionContext;
import org.jboss.portal.identity2.IdentityContextImpl;
+import org.jboss.portal.identity2.IdentityServiceControllerImpl;
+import org.jboss.portal.identity2.UserModule;
+import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.identity2.config.SimpleConfigurationImpl;
import org.jboss.portal.test.framework.TestRuntimeContext;
import org.jboss.portal.test.identity.ldap.LDAPTestCase;
@@ -58,8 +61,9 @@
{
runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
runtimeContext.addBean("LDAPTestBean", this);
+ runtimeContext.start();
- IdentityContextImpl context = new IdentityContextImpl();
+ /*IdentityContextImpl context = new IdentityContextImpl();
context.start();
identityContext = context;
@@ -77,8 +81,16 @@
//roleModule.setContainerDN("ou=Roles,dc=jboss,dc=org");
//roleModule.setRidAttributeID("cn");
roleModule.start();
- this.roleModule = roleModule;
+ this.roleModule = roleModule;*/
+ IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
+ controller.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
+ controller.setDefaultConfigFile("identityconfig/standardidentity-config.xml");
+ controller.setRegisterMBeans(false);
+ controller.start();
+ identityContext = controller.getIdentityContext();
+ this.roleModule = (RoleModule)identityContext.getObject(IdentityContext.TYPE_ROLE_MODULE);
+
suffix = getDirectoryServerConfigParameter().getCleanUpDN();
super.setUp();
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -28,6 +28,8 @@
import org.jboss.portal.identity2.ldap.LDAPUserModuleImpl;
import org.jboss.portal.identity2.ldap.LDAPConnectionContext;
import org.jboss.portal.identity2.IdentityContextImpl;
+import org.jboss.portal.identity2.IdentityServiceControllerImpl;
+import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.identity2.config.SimpleConfigurationImpl;
import org.jboss.portal.test.framework.TestRuntimeContext;
import org.jboss.portal.test.identity.ldap.LDAPTestCase;
@@ -55,12 +57,13 @@
System.out.println("#########################");
runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
runtimeContext.addBean("LDAPTestBean", this);
+ runtimeContext.start();
- IdentityContextImpl context = new IdentityContextImpl();
- context.start();
- identityContext = context;
+ //IdentityContextImpl context = new IdentityContextImpl();
+ //context.start();
+ //identityContext = context;
- SimpleConfigurationImpl configuration = new SimpleConfigurationImpl();
+ /*SimpleConfigurationImpl configuration = new SimpleConfigurationImpl();
configuration.setIdentityContext(identityContext);
configuration.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
configuration.start();
@@ -76,8 +79,17 @@
//userModule.setUidAttributeID("uid");
userModule.start();
- this.userModule = userModule;
+ this.userModule = userModule;*/
+ IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
+ controller.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
+ controller.setDefaultConfigFile("identityconfig/standardidentity-config.xml");
+ controller.setRegisterMBeans(false);
+ controller.start();
+ identityContext = controller.getIdentityContext();
+ userModule = (UserModule)identityContext.getObject(IdentityContext.TYPE_USER_MODULE);
+
+
suffix = getDirectoryServerConfigParameter().getCleanUpDN();
super.setUp();
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -38,6 +38,8 @@
import org.jboss.portal.identity2.RoleModule;
import org.jboss.portal.identity2.User;
import org.jboss.portal.identity2.Role;
+import org.jboss.portal.identity2.IdentityServiceControllerImpl;
+import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.common.util.Tools;
@@ -73,8 +75,19 @@
{
runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
runtimeContext.addBean("LDAPTestBean", this);
+ runtimeContext.start();
- IdentityContextImpl context = new IdentityContextImpl();
+ IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
+ controller.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
+ controller.setDefaultConfigFile("identityconfig/standardidentity-config.xml");
+ controller.setRegisterMBeans(false);
+ controller.start();
+ identityContext = controller.getIdentityContext();
+ userModule = (UserModule)identityContext.getObject(IdentityContext.TYPE_USER_MODULE);
+ roleModule = (RoleModule)identityContext.getObject(IdentityContext.TYPE_ROLE_MODULE);
+ membershipModule = (MembershipModule)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+
+ /*IdentityContextImpl context = new IdentityContextImpl();
context.start();
identityContext = context;
@@ -108,7 +121,7 @@
//membership.setUidAttributeID("member");
//membership.setUidAttributeIsDN(true);
membership.start();
- this.membershipModule = membership;
+ this.membershipModule = membership;*/
/*mstc = new MembershipStrategyTest();
mstc.setContext(this);
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -27,6 +27,9 @@
import org.jboss.portal.identity2.MembershipModule;
import org.jboss.portal.identity2.IdentityContextImpl;
import org.jboss.portal.identity2.IdentityConfiguration;
+import org.jboss.portal.identity2.IdentityServiceControllerImpl;
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity2.service.MembershipModuleService;
import org.jboss.portal.identity2.ldap.LDAPConnectionContext;
import org.jboss.portal.identity2.ldap.LDAPUserModuleImpl;
import org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl;
@@ -69,12 +72,43 @@
{
runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/ldap-beans.xml");
runtimeContext.addBean("LDAPTestBean", this);
+ runtimeContext.start();
- IdentityContextImpl context = new IdentityContextImpl();
+ IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
+ controller.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
+ controller.setDefaultConfigFile("identityconfig/standardidentity-config.xml");
+ controller.setRegisterMBeans(false);
+ controller.start();
+ identityContext = controller.getIdentityContext();
+
+ //swap the module for the proper one for this test
+ //identityContext.unregister(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+ ((MembershipModuleService)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE)).stop();
+ MembershipModuleService membership = new LDAPStaticRoleMembershipModuleImpl();
+ membership.setIdentityContext(identityContext);
+ membership.start();
+
+ userModule = (UserModule)identityContext.getObject(IdentityContext.TYPE_USER_MODULE);
+ roleModule = (RoleModule)identityContext.getObject(IdentityContext.TYPE_ROLE_MODULE);
+ membershipModule = (MembershipModule)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+
+ IdentityConfiguration configuration = (IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ Set values = new HashSet();
+ values.add("ou=Roles,o=example2,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com");
+ configuration.setValues(IdentityConfiguration.GROUP_COMMON,IdentityConfiguration.ROLE_CONTAINER_DN, values);
+ values = new HashSet();
+ values.add("ou=People,o=example2,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com");
+ configuration.setValues(IdentityConfiguration.GROUP_COMMON,IdentityConfiguration.USER_CONTAINER_DN, values);
+ values = new HashSet();
+ values.add("memberOf");
+ configuration.setValues(IdentityConfiguration.GROUP_COMMON,IdentityConfiguration.MEMBERSHIP_ATTRIBUTE_ID, values);
+
+ /*IdentityContextImpl context = new IdentityContextImpl();
context.start();
- identityContext = context;
+ identityContext = context;*/
- SimpleConfigurationImpl configuration = new SimpleConfigurationImpl();
+
+ /*SimpleConfigurationImpl configuration = new SimpleConfigurationImpl();
configuration.setIdentityContext(identityContext);
configuration.setConfigFile(getDirectoryServerConfigParameter().getConfigFile());
configuration.start();
@@ -115,7 +149,7 @@
//membership.setUidAttributeID("member");
//membership.setUidAttributeIsDN(true);
membership.start();
- this.membershipModule = membership;
+ this.membershipModule = membership;*/
/*mstc = new MembershipStrategyTest();
mstc.setContext(this);
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java 2006-11-23 21:53:43 UTC (rev 5718)
@@ -64,7 +64,7 @@
Appender appender = new ConsoleAppender(new SimpleLayout());
Logger.getRoot().addAppender(appender);
Logger.getRoot().setLevel(Level.INFO);
- Logger.getLogger("org.jboss.portal.identity2.ldap").setLevel(Level.DEBUG);
+ Logger.getLogger("org.jboss.portal.identity2").setLevel(Level.DEBUG);
}
public static TestSuite createTestSuite(Class clazz) throws Exception
@@ -122,7 +122,7 @@
//give a chance to come up...
//Thread.sleep(500);
}*/
- runtimeContext.start();
+ //runtimeContext.start();
populate();
Added: trunk/identity/src/resources/test/config/minimal-db-identity-config.xml
===================================================================
--- trunk/identity/src/resources/test/config/minimal-db-identity-config.xml 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/resources/test/config/minimal-db-identity-config.xml 2006-11-23 21:53:43 UTC (rev 5718)
@@ -0,0 +1,47 @@
+<?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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<identity-configuration>
+ <modules>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserModule</type>
+ <implementation>DB</implementation>
+ </module>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>RoleModule</type>
+ <implementation>DB</implementation>
+ </module>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>MembershipModule</type>
+ <implementation>DB</implementation>
+ </module>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserProfileModule</type>
+ <implementation>DB</implementation>
+ </module>
+ </modules>
+</identity-configuration>
\ No newline at end of file
Added: trunk/identity/src/resources/test/config/minimal-ldap-identity-config.xml
===================================================================
--- trunk/identity/src/resources/test/config/minimal-ldap-identity-config.xml 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/resources/test/config/minimal-ldap-identity-config.xml 2006-11-23 21:53:43 UTC (rev 5718)
@@ -0,0 +1,86 @@
+<?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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<identity-configuration>
+ <modules>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>RoleModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>MembershipModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserProfileModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+
+ <!--For ldap configuration this is needed additionally to use ldap connection...-->
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>ConnectionContext</type>
+ <implementation>LDAP</implementation>
+ <config>
+ <option>
+ <name>host</name>
+ <value>localhost</value>
+ </option>
+ <option>
+ <name>port</name>
+ <value>10389</value>
+ </option>
+ <option>
+ <name>admin-dn</name>
+ <value>cn=Directory Manager</value>
+ </option>
+ <option>
+ <name>admin-password</name>
+ <value>password</value>
+ </option>
+ </config>
+ </module>
+ </modules>
+
+ <options>
+ <option-group>
+ <group-name>common</group-name>
+ <option>
+ <name>userContainerDN</name>
+ <value>ou=People,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
+ </option>
+ <option>
+ <name>roleContainerDN</name>
+ <value>ou=Roles,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
+ </option>
+ </option-group>
+ </options>
+</identity-configuration>
\ No newline at end of file
Added: trunk/identity/src/resources/test/config/standardidentity-config.xml
===================================================================
--- trunk/identity/src/resources/test/config/standardidentity-config.xml 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/identity/src/resources/test/config/standardidentity-config.xml 2006-11-23 21:53:43 UTC (rev 5718)
@@ -0,0 +1,322 @@
+<?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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<identity-configuration>
+ <modules>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserModule</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=User</service-name>
+ <class>org.jboss.portal.identity.db.DBUserModuleImp</class>
+ <jndi-name>java:/portal/UserModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>SessionFactoryJNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>RoleModule</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Role</service-name>
+ <class>org.jboss.portal.identity.db.DBRoleModuleImp</class>
+ <jndi-name>java:/portal/RoleModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>SessionFactoryJNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>MembershipModule</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Membership</service-name>
+ <class>org.jboss.portal.identity.db.DBMembershipModuleImp</class>
+ <jndi-name>java:/portal/MembershipModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>SessionFactoryJNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserProfileModule</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=UserProfile</service-name>
+ <class>org.jboss.portal.identity.db.DBUserProfileModuleImp</class>
+ <jndi-name>java:/portal/UserProfileModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>SessionFactoryJNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>
+ </config>
+ </module>
+
+ <!--for ldap modules...-->
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserModule</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=User</service-name>
+ <class>org.jboss.portal.identity2.ldap.LDAPUserModuleImpl</class>
+ <jndi-name>java:/portal/UserModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config/>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>RoleModule</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Role</service-name>
+ <class>org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl</class>
+ <jndi-name>java:/portal/RoleModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config/>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>MembershipModule</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Membership</service-name>
+ <class>org.jboss.portal.identity2.ldap.LDAPStaticGroupMembershipModuleImpl</class>
+ <jndi-name>java:/portal/MembershipModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config/>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserProfileModule</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=UserProfile</service-name>
+ <class>org.jboss.portal.identity2.ldap.LDAPUserProfileModuleImpl</class>
+ <jndi-name>java:/portal/UserProfileModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <!--<option>
+ <name>LDAPConnectionJNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>-->
+ <!--Hibernate mappings for db level store (dynamic properties not mapped as ldap attributes)-->
+ <option>
+ <name>SessionFactoryJNDIName</name>
+ <value>java:/portal/PropertyStoreSessionFactory</value>
+ </option>
+ <option>
+ <name>profileMappings</name>
+ <value>ldap-profile.xml</value>
+ </option>
+ </config>
+ </module>
+
+ <!--For ldap configuration this is needed additionally to use ldap connection...-->
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>ConnectionContext</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=LDAPConnectionContext</service-name>
+ <class>org.jboss.portal.identity2.ldap.LDAPConnectionContext</class>
+ <jndi-name>java:/portal/LDAPConnectionContext</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>host</name>
+ <value>jboss.com</value>
+ </option>
+ <option>
+ <name>port</name>
+ <value>389</value>
+ </option>
+ <option>
+ <name>context-factory</name>
+ <value>com.sun.jndi.ldap.LdapCtxFactory</value>
+ </option>
+ <option>
+ <name>admin-dn</name>
+ <value>cn=Directory Manager</value>
+ </option>
+ <option>
+ <name>admin-password</name>
+ <value>password</value>
+ </option>
+ <option>
+ <name>authentication</name>
+ <value>simple</value>
+ </option>
+ </config>
+ </module>
+ </modules>
+
+ <options>
+ <!--Common options section-->
+ <!--
+ <option-group>
+ <group-name>connection</group-name>
+ <option>
+ <name>host</name>
+ <value>localhost</value>
+ </option>
+ <option>
+ <name>port</name>
+ <value>10389</value>
+ </option>
+ <option>
+ <name>context-factory</name>
+ <value>com.sun.jndi.ldap.LdapCtxFactory</value>
+ </option>
+ <option>
+ <name>admin-dn</name>
+ <value>cn=Directory Manager</value>
+ </option>
+ <option>
+ <name>admin-password</name>
+ <value>password</value>
+ </option>
+ </option-group> -->
+ <option-group>
+ <group-name>common</group-name>
+ <option>
+ <name>userContainerDN</name>
+ <value>ou=People,dc=example,dc=com</value>
+ </option>
+ <option>
+ <name>uidAttributeId</name>
+ <value>uid</value>
+ </option>
+ <option>
+ <name>passwordAttributeID</name>
+ <value>userPassword</value>
+ </option>
+ <option>
+ <name>hashAlgorithm</name>
+ <value>MD5</value>
+ </option>
+ <option>
+ <name>hashEncoding</name>
+ <value>hex</value>
+ </option>
+ <option>
+ <name>roleContainerDN</name>
+ <value>ou=Roles,dc=example,dc=com</value>
+ </option>
+ <option>
+ <name>ridAttributeId</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>roleDisplayNameAttributeID</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>membershipAttributeID</name>
+ <value>member</value>
+ </option>
+ <option>
+ <name>membershipAttributeIsDN</name>
+ <value>true</value>
+ </option>
+ </option-group>
+ <option-group>
+ <group-name>userCreateAttibutes</group-name>
+ <option>
+ <name>objectClass</name>
+ <value>top</value>
+ <value>uidObject</value>
+ <value>person</value>
+ <value>inetUser</value>
+ </option>
+ <!--Schema requires those to have initial value-->
+ <option>
+ <name>cn</name>
+ <value>none</value>
+ </option>
+ <option>
+ <name>sn</name>
+ <value>none</value>
+ </option>
+ </option-group>
+ <option-group>
+ <group-name>roleCreateAttibutes</group-name>
+ <option>
+ <name>objectClass</name>
+ <value>top</value>
+ <value>groupOfNames</value>
+ </option>
+ <!--Schema requires those to have initial value-->
+ <option>
+ <name>cn</name>
+ <value>none</value>
+ </option>
+ <!--Some directory servers require this attribute to be valid DN-->
+ <!--For safety reasons point to the admin user here-->
+ <option>
+ <name>member</name>
+ <value>uid=dummynonexistinguser,ou=People,dc=jboss,dc=org</value>
+ </option>
+ </option-group>
+ </options>
+</identity-configuration>
\ No newline at end of file
Modified: trunk/test/src/etc/identityconfig/opends-config.xml
===================================================================
--- trunk/test/src/etc/identityconfig/opends-config.xml 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/test/src/etc/identityconfig/opends-config.xml 2006-11-23 21:53:43 UTC (rev 5718)
@@ -22,204 +22,62 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<identity-configuration>
- <option-group>
- <group-name>connection</group-name>
- <option>
- <name>host</name>
- <value>localhost</value>
- </option>
- <option>
- <name>port</name>
- <value>10389</value>
- </option>
- <option>
- <name>context-factory</name>
- <value>com.sun.jndi.ldap.LdapCtxFactory</value>
- </option>
- <option>
- <name>admin-dn</name>
- <value>cn=Directory Manager</value>
- </option>
- <option>
- <name>admin-password</name>
- <value>password</value>
- </option>
- </option-group>
- <option-group>
- <group-name>common</group-name>
- <option>
- <name>userContainerDN</name>
- <value>ou=People,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
- </option>
- <option>
- <name>uidAttributeId</name>
- <value>uid</value>
- </option>
- <option>
- <name>passwordAttributeID</name>
- <value>userPassword</value>
- </option>
- <option>
- <name>hashAlgorithm</name>
- <value>MD5</value>
- </option>
- <option>
- <name>hashEncoding</name>
- <value>hex</value>
- </option>
- <option>
- <name>roleContainerDN</name>
- <value>ou=Roles,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
- </option>
- <option>
- <name>ridAttributeId</name>
- <value>cn</value>
- </option>
- <option>
- <name>roleDisplayNameAttributeID</name>
- <value>cn</value>
- </option>
- <option>
- <name>membershipAttributeID</name>
- <value>member</value>
- </option>
- <option>
- <name>membershipAttributeIsDN</name>
- <value>true</value>
- </option>
- </option-group>
- <option-group>
- <group-name>userCreateAttibutes</group-name>
- <option>
- <name>objectClass</name>
- <value>top</value>
- <value>inetOrgPerson</value>
- <value>person</value>
- </option>
- <!--Schema requires those to have initial value-->
- <option>
- <name>cn</name>
- <value>none</value>
- </option>
- <option>
- <name>sn</name>
- <value>none</value>
- </option>
- </option-group>
- <option-group>
- <group-name>roleCreateAttibutes</group-name>
- <option>
- <name>objectClass</name>
- <value>top</value>
- <value>groupOfNames</value>
- </option>
- <!--Schema requires those to have initial value-->
- <option>
- <name>cn</name>
- <value>none</value>
- </option>
- <!--Some directory servers require this attribute to be valid DN-->
- <!--For safety reasons point to the admin user here-->
- <option>
- <name>member</name>
- <value>uid=dummynonexistinguser,ou=People,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
- </option>
- </option-group>
- <option-group>
- <group-name>userProfileMappings</group-name>
- <option>
- <name>portal.user.name.given</name>
- <!--inetOrgPerson-->
- <value>givenName</value>
- </option>
- <!--<option>
- <name>portal.user.name.family</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.location</name>
- <value></value>
- </option>-->
- <option>
- <name>portal.user.occupation</name>
- <!--inetOrgPerson-->
- <value>title</value>
- </option>
- <!--<option>
- <name>portal.user.extra</name>
- <value></value>
- </option>-->
- <option>
- <name>portal.user.signature</name>
- <!--newPilotPerson-->
- <value>personalSignature</value>
- </option>
- <!--<option>
- <name>portal.user.interests</name>
- <value></value>
- </option>-->
- <option>
- <name>portal.user.locale</name>
- <!--inetOrgPerson-->
- <value>localityName</value><!--or prefferedLanguage-->
- </option>
- <!--<option>
- <name>portal.user.im.icq</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.im.aim</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.im.msnm</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.im.yim</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.im.skype</name>
- <value></value>
- </option>-->
- <option>
- <name>portal.user.homepage</name>
- <!--inetOrgPerson-->
- <value>seeAlso</value>
- </option>
- <!--<option>
- <name>portal.user.time-zone-offset</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.theme</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.security.question</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.security.answer</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.email.fake</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.email.view-real</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.last-login-date</name>
- <value></value>
- </option>
- <option>
- <name>portal.user.registration-date</name>
- <value></value>
- </option>-->
- </option-group>
+ <modules>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+ <module>
+ <type>RoleModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+ <module>
+ <type>MembershipModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+ <module>
+ <type>UserProfileModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+ <!--For ldap configuration this is needed additionally to use ldap connection...-->
+ <module>
+ <type>ConnectionContext</type>
+ <implementation>LDAP</implementation>
+ </module>
+ </modules>
+
+ <options>
+ <option-group>
+ <group-name>connection</group-name>
+ <option>
+ <name>host</name>
+ <value>localhost</value>
+ </option>
+ <option>
+ <name>port</name>
+ <value>10389</value>
+ </option>
+ <option>
+ <name>admin-dn</name>
+ <value>cn=Directory Manager</value>
+ </option>
+ <option>
+ <name>admin-password</name>
+ <value>password</value>
+ </option>
+ </option-group>
+ <option-group>
+ <group-name>common</group-name>
+ <option>
+ <name>userContainerDN</name>
+ <value>ou=People,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
+ </option>
+ <option>
+ <name>roleContainerDN</name>
+ <value>ou=Roles,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
+ </option>
+ </option-group>
+ </options>
</identity-configuration>
\ No newline at end of file
Modified: trunk/test/src/etc/identityconfig/rhds-config.xml
===================================================================
--- trunk/test/src/etc/identityconfig/rhds-config.xml 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/test/src/etc/identityconfig/rhds-config.xml 2006-11-23 21:53:43 UTC (rev 5718)
@@ -22,107 +22,62 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<identity-configuration>
- <option-group>
- <group-name>connection</group-name>
- <option>
- <name>host</name>
- <value>dev39.qa.atl.jboss.com</value>
- </option>
- <option>
- <name>port</name>
- <value>10389</value>
- </option>
- <option>
- <name>context-factory</name>
- <value>com.sun.jndi.ldap.LdapCtxFactory</value>
- </option>
- <option>
- <name>admin-dn</name>
- <value>cn=Directory Manager</value>
- </option>
- <option>
- <name>admin-password</name>
- <value>qpq123qpq</value>
- </option>
- </option-group>
- <option-group>
- <group-name>common</group-name>
- <option>
- <name>userContainerDN</name>
- <value>ou=People,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
- </option>
- <option>
- <name>uidAttributeId</name>
- <value>uid</value>
- </option>
- <option>
- <name>passwordAttributeID</name>
- <value>userPassword</value>
- </option>
- <option>
- <name>hashAlgorithm</name>
- <value>MD5</value>
- </option>
- <option>
- <name>hashEncoding</name>
- <value>hex</value>
- </option>
- <option>
- <name>roleContainerDN</name>
- <value>ou=Roles,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
- </option>
- <option>
- <name>ridAttributeId</name>
- <value>cn</value>
- </option>
- <option>
- <name>roleDisplayNameAttributeID</name>
- <value>cn</value>
- </option>
- <option>
- <name>membershipAttributeID</name>
- <value>member</value>
- </option>
- <option>
- <name>membershipAttributeIsDN</name>
- <value>true</value>
- </option>
- </option-group>
- <option-group>
- <group-name>userCreateAttibutes</group-name>
- <option>
- <name>objectClass</name>
- <value>top</value>
- <value>inetOrgPerson</value>
- <value>person</value>
- </option>
- <!--Schema requires those to have initial value-->
- <option>
- <name>cn</name>
- <value>none</value>
- </option>
- <option>
- <name>sn</name>
- <value>none</value>
- </option>
- </option-group>
- <option-group>
- <group-name>roleCreateAttibutes</group-name>
- <option>
- <name>objectClass</name>
- <value>top</value>
- <value>groupOfNames</value>
- </option>
- <!--Schema requires those to have initial value-->
- <option>
- <name>cn</name>
- <value>none</value>
- </option>
- <!--Some directory servers require this attribute to be valid DN-->
- <!--For safety reasons point to the admin user here-->
- <option>
- <name>member</name>
- <value>uid=dummynonexistinguser,ou=People,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
- </option>
- </option-group>
+ <modules>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+ <module>
+ <type>RoleModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+ <module>
+ <type>MembershipModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+ <module>
+ <type>UserProfileModule</type>
+ <implementation>LDAP</implementation>
+ </module>
+
+ <!--For ldap configuration this is needed additionally to use ldap connection...-->
+ <module>
+ <type>ConnectionContext</type>
+ <implementation>LDAP</implementation>
+ </module>
+ </modules>
+
+ <options>
+ <option-group>
+ <group-name>connection</group-name>
+ <option>
+ <name>host</name>
+ <value>dev39.qa.atl.jboss.com</value>
+ </option>
+ <option>
+ <name>port</name>
+ <value>10389</value>
+ </option>
+ <option>
+ <name>admin-dn</name>
+ <value>cn=Directory Manager</value>
+ </option>
+ <option>
+ <name>admin-password</name>
+ <value>qpq123qpq</value>
+ </option>
+ </option-group>
+ <option-group>
+ <group-name>common</group-name>
+ <option>
+ <name>userContainerDN</name>
+ <value>ou=People,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
+ </option>
+ <option>
+ <name>roleContainerDN</name>
+ <value>ou=Roles,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
+ </option>
+ </option-group>
+ </options>
</identity-configuration>
\ No newline at end of file
Added: trunk/test/src/etc/identityconfig/standardidentity-config.xml
===================================================================
--- trunk/test/src/etc/identityconfig/standardidentity-config.xml 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/test/src/etc/identityconfig/standardidentity-config.xml 2006-11-23 21:53:43 UTC (rev 5718)
@@ -0,0 +1,297 @@
+<?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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<identity-configuration>
+ <modules>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserModule</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=User</service-name>
+ <class>org.jboss.portal.identity.db.DBUserModuleImp</class>
+ <jndi-name>java:/portal/UserModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>SessionFactoryJNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>RoleModule</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Role</service-name>
+ <class>org.jboss.portal.identity.db.DBRoleModuleImp</class>
+ <jndi-name>java:/portal/RoleModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>SessionFactoryJNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>MembershipModule</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Membership</service-name>
+ <class>org.jboss.portal.identity.db.DBMembershipModuleImp</class>
+ <jndi-name>java:/portal/MembershipModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>SessionFactoryJNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserProfileModule</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=UserProfile</service-name>
+ <class>org.jboss.portal.identity.db.DBUserProfileModuleImp</class>
+ <jndi-name>java:/portal/UserProfileModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>SessionFactoryJNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>
+ </config>
+ </module>
+
+ <!--for ldap modules...-->
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserModule</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=User</service-name>
+ <class>org.jboss.portal.identity2.ldap.LDAPUserModuleImpl</class>
+ <jndi-name>java:/portal/UserModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config/>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>RoleModule</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Role</service-name>
+ <class>org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl</class>
+ <jndi-name>java:/portal/RoleModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config/>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>MembershipModule</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Membership</service-name>
+ <class>org.jboss.portal.identity2.ldap.LDAPStaticGroupMembershipModuleImpl</class>
+ <jndi-name>java:/portal/MembershipModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config/>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserProfileModule</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=UserProfile</service-name>
+ <class>org.jboss.portal.identity2.ldap.LDAPUserProfileModuleImpl</class>
+ <jndi-name>java:/portal/UserProfileModule</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <!--<option>
+ <name>LDAPConnectionJNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>-->
+ <!--Hibernate mappings for db level store (dynamic properties not mapped as ldap attributes)-->
+ <option>
+ <name>SessionFactoryJNDIName</name>
+ <value>java:/portal/PropertyStoreSessionFactory</value>
+ </option>
+ <option>
+ <name>profileMappings</name>
+ <value>ldap-profile.xml</value>
+ </option>
+ </config>
+ </module>
+
+ <!--For ldap configuration this is needed additionally to use ldap connection...-->
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>ConnectionContext</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=LDAPConnectionContext</service-name>
+ <class>org.jboss.portal.identity2.ldap.LDAPConnectionContext</class>
+ <jndi-name>java:/portal/LDAPConnectionContext</jndi-name>
+
+ <!--set of options that are passed to a class constructor-->
+ <config/>
+ </module>
+ </modules>
+
+ <options>
+ <option-group>
+ <group-name>connection</group-name>
+ <option>
+ <name>host</name>
+ <value>jboss.com</value>
+ </option>
+ <option>
+ <name>port</name>
+ <value>389</value>
+ </option>
+ <option>
+ <name>context-factory</name>
+ <value>com.sun.jndi.ldap.LdapCtxFactory</value>
+ </option>
+ <option>
+ <name>admin-dn</name>
+ <value>cn=Directory Manager</value>
+ </option>
+ <option>
+ <name>admin-password</name>
+ <value>password</value>
+ </option>
+ </option-group>
+
+ <!--Common options section-->
+ <option-group>
+ <group-name>common</group-name>
+ <option>
+ <name>userContainerDN</name>
+ <value>ou=People,dc=example,dc=com</value>
+ </option>
+ <option>
+ <name>uidAttributeId</name>
+ <value>uid</value>
+ </option>
+ <option>
+ <name>passwordAttributeID</name>
+ <value>userPassword</value>
+ </option>
+ <option>
+ <name>hashAlgorithm</name>
+ <value>MD5</value>
+ </option>
+ <option>
+ <name>hashEncoding</name>
+ <value>hex</value>
+ </option>
+ <option>
+ <name>roleContainerDN</name>
+ <value>ou=Roles,dc=example,dc=com</value>
+ </option>
+ <option>
+ <name>ridAttributeId</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>roleDisplayNameAttributeID</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>membershipAttributeID</name>
+ <value>member</value>
+ </option>
+ <option>
+ <name>membershipAttributeIsDN</name>
+ <value>true</value>
+ </option>
+ </option-group>
+ <option-group>
+ <group-name>userCreateAttibutes</group-name>
+ <option>
+ <name>objectClass</name>
+ <value>top</value>
+ <value>uidObject</value>
+ <value>person</value>
+ <value>inetUser</value>
+ </option>
+ <!--Schema requires those to have initial value-->
+ <option>
+ <name>cn</name>
+ <value>none</value>
+ </option>
+ <option>
+ <name>sn</name>
+ <value>none</value>
+ </option>
+ </option-group>
+ <option-group>
+ <group-name>roleCreateAttibutes</group-name>
+ <option>
+ <name>objectClass</name>
+ <value>top</value>
+ <value>groupOfNames</value>
+ </option>
+ <!--Schema requires those to have initial value-->
+ <option>
+ <name>cn</name>
+ <value>none</value>
+ </option>
+ <!--Some directory servers require this attribute to be valid DN-->
+ <!--For safety reasons point to the admin user here-->
+ <option>
+ <name>member</name>
+ <value>uid=dummynonexistinguser,ou=People,dc=jboss,dc=org</value>
+ </option>
+ </option-group>
+ </options>
+</identity-configuration>
\ No newline at end of file
Deleted: trunk/test/src/etc/identityconfig/test-config.xml
===================================================================
--- trunk/test/src/etc/identityconfig/test-config.xml 2006-11-22 23:48:17 UTC (rev 5717)
+++ trunk/test/src/etc/identityconfig/test-config.xml 2006-11-23 21:53:43 UTC (rev 5718)
@@ -1,84 +0,0 @@
-<?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. ~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-<identity-configuration>
- <option-group>
- <group-name>connection</group-name>
- <option>
- <name>host</name>
- <value>localhost</value>
- </option>
- <option>
- <name>port</name>
- <value>10389</value>
- </option>
- <option>
- <name>context-factory</name>
- <value>com.sun.jndi.ldap.LdapCtxFactory</value>
- </option>
- <option>
- <name>admin-dn</name>
- <value>cn=Directory Manager</value>
- </option>
- <option>
- <name>admin-password</name>
- <value>password</value>
- </option>
- </option-group>
- <option-group>
- <group-name>common</group-name>
- <option>
- <name>user.containerDN</name>
- <value>ou=People,dc=jboss,dc=com</value>
- </option>
- <option>
- <name>user.uidAttributeId</name>
- <value>uid</value>
- </option>
- <option>
- <name>role.containerDN</name>
- <value>ou=Role,dc=jboss,dc=com</value>
- </option>
- <option>
- <name>role.ridAttributeId</name>
- <value>cn</value>
- </option>
- <option>
- <name>role.displayNameAttributeID</name>
- <value>xxx</value>
- </option>
- </option-group>
- <option-group>
- <group-name>user.createAttibutes</group-name>
- <option>
- <name>objectClass</name>
- <value>top</value>
- <value>uidObject</value>
- <value>person</value>
- </option>
- <option>
- <name>extraSchemaAtrribute</name>
- <value>extraValue</value>
- </option>
- </option-group>
-</identity-configuration>
\ No newline at end of file
17 years, 5 months
JBoss Portal SVN: r5717 - in trunk/identity/src: main/org/jboss/portal/identity2 main/org/jboss/portal/identity2/config main/org/jboss/portal/identity2/info main/org/jboss/portal/identity2/ldap main/org/jboss/portal/identity2/service resources/draft
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2006-11-22 18:48:17 -0500 (Wed, 22 Nov 2006)
New Revision: 5717
Added:
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java
Modified:
trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java
trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleConfigurationImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/info/PropertyInfo.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java
trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java
trunk/identity/src/main/org/jboss/portal/identity2/service/MembershipModuleService.java
trunk/identity/src/main/org/jboss/portal/identity2/service/RoleModuleService.java
trunk/identity/src/main/org/jboss/portal/identity2/service/UserModuleService.java
trunk/identity/src/main/org/jboss/portal/identity2/service/UserProfileModuleService.java
trunk/identity/src/resources/draft/identity-config.xml
Log:
- added IdentityModuleServices to instantiate modules in more flexible way
Modified: trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -29,17 +29,17 @@
*/
public interface IdentityContext
{
- public static final String USER_MODULE = "user_module";
+ public static final String TYPE_USER_MODULE = "user_module";
- public static final String ROLE_MODULE = "role_module";
+ public static final String TYPE_ROLE_MODULE = "role_module";
- public static final String MEMBERSHIP_MODULE = "membership_module";
+ public static final String TYPE_MEMBERSHIP_MODULE = "membership_module";
- public static final String USER_PROFILE_MODULE = "user_profile_module";
+ public static final String TYPE_USER_PROFILE_MODULE = "user_profile_module";
- public static final String CONNECTION_CONTEXT = "connection_context";
+ public static final String TYPE_CONNECTION_CONTEXT = "connection_context";
- public static final String IDENTITY_CONFIGURATION = "configuration";
+ public static final String TYPE_IDENTITY_CONFIGURATION = "configuration";
public void register(Object object, String name) throws IdentityException;
Modified: trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -27,13 +27,19 @@
import org.jboss.portal.identity2.config.SimpleIdentityConfigurationFactory;
import org.jboss.portal.identity2.config.IdentityConfigurationMetaDataFactory;
import org.jboss.portal.identity2.config.metadata.IdentityConfigurationMetaData;
+import org.jboss.portal.identity2.config.metadata.ModuleMetaData;
+import org.jboss.portal.identity2.config.metadata.ModuleConfigOptionMetaData;
+import org.jboss.portal.identity2.service.IdentityModuleService;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
import org.jboss.xb.binding.ObjectModelFactory;
+import javax.management.ObjectName;
import java.net.URL;
import java.io.InputStream;
import java.util.Map;
+import java.util.Iterator;
+import java.util.HashMap;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
@@ -49,8 +55,12 @@
private IdentityContext identityContext;
+ private boolean registerMBeans = true;
+
private String configFile;
+ private String defaultConfigFile;
+
protected void startService() throws Exception
{
if (jndiName != null)
@@ -59,30 +69,58 @@
jndiBinding.bind();
}
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+
+ //parse config files
+ IdentityConfigurationMetaData meta = parseConfiguration(configFile);
+ IdentityConfigurationMetaData defaultMeta = parseConfiguration(defaultConfigFile);
+
+ IdentityContextImpl context = new IdentityContextImpl();
+ identityContext = context;
+ context.start();
+
+ //TODO:update meta options using defaultMeta options
+
try
- {
- log.info("Processing portal identity configuration");
- log.debug("config file: " + configFile);
- URL config = Thread.currentThread().getContextClassLoader().getResource(configFile);
- InputStream in = config.openStream();
- // create unmarshaller
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ {
+ Map modules = meta.getModules().getModules();
- // create an instance of ObjectModelFactory
- ObjectModelFactory factory = new IdentityConfigurationMetaDataFactory();
+ for (Iterator iterator = modules.keySet().iterator(); iterator.hasNext();)
+ {
+ String key = (String)iterator.next();
+ ModuleMetaData module = (ModuleMetaData)modules.get(key);
- // let the object model factory to create an instance of Map and populate it with data from XML
- IdentityConfigurationMetaData meta = (IdentityConfigurationMetaData)unmarshaller.unmarshal(in, factory, null);
+ //instantiate the module
+ IdentityModuleService moduleService = (IdentityModuleService)tcl.loadClass(module.getClassName()).newInstance();
+ moduleService.setIdentityContext(identityContext);
- // close the XML stream
- in.close();
- }
- catch (Exception e)
+ //generate initial options
+ Map configOptions = module.getConfig().getOptions();
+ Map optionMap = new HashMap();
+ for (Iterator iterator1 = configOptions.keySet().iterator(); iterator1.hasNext();)
{
- throw new IdentityException("Cannot parse configuration file", e);
+ String optionName = (String)iterator1.next();
+ ModuleConfigOptionMetaData option = (ModuleConfigOptionMetaData)configOptions.get(optionName);
+ optionMap.put(optionName,option.getValue());
}
+ //set options
+ moduleService.setInitOptions(optionMap);
+ //start
+ moduleService.start();
+
+ //register as an mbean
+ if (isRegisterMBeans())
+ {
+ getServer().registerMBean(moduleService, new ObjectName(module.getServiceName()));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot initiate identity modules: ", e);
+ }
}
@@ -97,6 +135,36 @@
}
+ private IdentityConfigurationMetaData parseConfiguration(String configFile) throws IdentityException
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ IdentityConfigurationMetaData meta = null;
+ try
+ {
+ log.info("Processing portal identity configuration");
+ log.debug("config file: " + configFile);
+ URL config = tcl.getResource(configFile);
+ InputStream in = config.openStream();
+ // create unmarshaller
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+ // create an instance of ObjectModelFactory
+ ObjectModelFactory factory = new IdentityConfigurationMetaDataFactory();
+
+ // let the object model factory to create an instance of Map and populate it with data from XML
+ meta = (IdentityConfigurationMetaData)unmarshaller.unmarshal(in, factory, null);
+
+ // close the XML stream
+ in.close();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot parse configuration file", e);
+ }
+ return meta;
+ }
+
+
public IdentityContext getIdentityContext()
{
return identityContext;
@@ -113,7 +181,16 @@
this.configFile = configFile;
}
+ public String getDefaultConfigFile()
+ {
+ return defaultConfigFile;
+ }
+ public void setDefaultConfigFile(String defaultConfigFile)
+ {
+ this.defaultConfigFile = defaultConfigFile;
+ }
+
public String getJndiName()
{
return jndiName;
@@ -133,4 +210,14 @@
{
this.jndiBinding = jndiBinding;
}
+
+ public boolean isRegisterMBeans()
+ {
+ return registerMBeans;
+ }
+
+ public void setRegisterMBeans(boolean registerMBeans)
+ {
+ this.registerMBeans = registerMBeans;
+ }
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleConfigurationImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleConfigurationImpl.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleConfigurationImpl.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -94,7 +94,7 @@
}
else
{
- identityContext.register(this, IdentityContext.IDENTITY_CONFIGURATION);
+ identityContext.register(this, IdentityContext.TYPE_IDENTITY_CONFIGURATION);
}
@@ -115,7 +115,7 @@
}
else
{
- identityContext.unregister(IdentityContext.IDENTITY_CONFIGURATION);
+ identityContext.unregister(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
}
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/info/PropertyInfo.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/info/PropertyInfo.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/info/PropertyInfo.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -31,6 +31,7 @@
public interface PropertyInfo
{
+ //TODO: make it int or safe type enum
public static final String ACCESS_MODE_READ_ONLY = "read-only";
public static final String ACCESS_MODE_READ_WRITE = "read-write";
public static final String USAGE_MANDATORY = "mandatory";
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -25,7 +25,7 @@
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.identity2.service.IdentityModuleService;
import org.jboss.portal.identity.IdentityException;
import javax.naming.Context;
@@ -39,38 +39,13 @@
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public class LDAPConnectionContext extends AbstractJBossService
+public class LDAPConnectionContext extends IdentityModuleService
{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityModuleService.class);
- private IdentityContext identityContext;
- private IdentityConfiguration identityConfiguration;
- protected void startService() throws Exception
- {
- if (identityContext == null)
- {
- log.error("Cannot register module in context - missing reference");
- }
- identityContext.register(this, IdentityContext.CONNECTION_CONTEXT);
-
-
- }
-
-
- protected void stopService() throws Exception
- {
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
-
- identityContext.unregister(IdentityContext.CONNECTION_CONTEXT);
-
- }
-
/*private String name;
private String providerUrl;
@@ -104,7 +79,7 @@
public LDAPConnectionContext()
{
-
+ super(IdentityContext.TYPE_CONNECTION_CONTEXT);
}
@@ -225,31 +200,9 @@
this.authentication = authentication;
}*/
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
+
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
- public IdentityConfiguration getIdentityConfiguration()
- {
- try
- {
- if (identityConfiguration == null)
- {
- this.identityConfiguration = (IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;
- }
- catch (IdentityException e)
- {
- throw new RuntimeException("Can't obtain IdentityConfiguration", e);
- }
- }
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -53,7 +53,7 @@
{
try
{
- this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.CONNECTION_CONTEXT);
+ this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
}
catch (ClassCastException e)
{
@@ -72,7 +72,7 @@
{
try
{
- this.userModule = (LDAPUserModule)getIdentityContext().getObject(IdentityContext.USER_MODULE);
+ this.userModule = (LDAPUserModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_MODULE);
}
catch (ClassCastException e)
{
@@ -89,7 +89,7 @@
{
try
{
- this.roleModule = (LDAPRoleModule)getIdentityContext().getObject(IdentityContext.ROLE_MODULE);
+ this.roleModule = (LDAPRoleModule)getIdentityContext().getObject(IdentityContext.TYPE_ROLE_MODULE);
}
catch (ClassCastException e)
{
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -100,7 +100,7 @@
{
try
{
- MembershipModule mm = (MembershipModule)identityContext.getObject(IdentityContext.MEMBERSHIP_MODULE);
+ MembershipModule mm = (MembershipModule)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
return mm.getUsers(this);
}
catch (IdentityException e)
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -143,7 +143,7 @@
{
if (connectionContext == null)
{
- this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.CONNECTION_CONTEXT);
+ this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
}
return connectionContext;
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -25,13 +25,10 @@
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity2.RoleModule;
import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.identity2.MembershipModule;
import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -319,7 +316,7 @@
{
try
{
- MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.MEMBERSHIP_MODULE);
+ MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
return mm.findRoleMembers(roleName, offset, limit, userNameFilter);
}
catch (IdentityException e)
@@ -334,7 +331,7 @@
{
try
{
- MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.MEMBERSHIP_MODULE);
+ MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
mm.assignRoles(user,roles);
}
catch (IdentityException e)
@@ -349,7 +346,7 @@
{
try
{
- MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.MEMBERSHIP_MODULE);
+ MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
return mm.getRoles(user);
}
catch (IdentityException e)
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -30,8 +30,6 @@
import org.jboss.portal.identity2.IdentityConfiguration;
import org.jboss.portal.common.util.Tools;
-import java.util.Date;
-import java.util.Locale;
import java.security.NoSuchAlgorithmException;
/**
@@ -191,7 +189,7 @@
private IdentityConfiguration getIdentityConfiguration() throws IdentityException
{
- return (IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
+ return (IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
}
private String getHashAlgorightm()
Modified: trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -143,7 +143,7 @@
{
if (userProfileModule == null)
{
- this.userProfileModule = (UserProfileModule)getIdentityContext().getObject(IdentityContext.USER_PROFILE_MODULE);
+ this.userProfileModule = (UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
}
return userProfileModule;
}
@@ -184,7 +184,7 @@
{
if (connectionContext == null)
{
- this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.CONNECTION_CONTEXT);
+ this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
}
return connectionContext;
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -24,110 +24,73 @@
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.identity2.IdentityConfiguration;
import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.config.SimpleIdentityConfigurationFactory;
+import org.jboss.portal.identity2.config.metadata.OptionsMetaData;
+import org.jboss.portal.identity2.config.metadata.OptionsGroupMetaData;
+import org.jboss.portal.identity2.config.metadata.OptionsGroupOptionMetaData;
import org.jboss.portal.common.util.JNDI;
import org.jboss.portal.identity.IdentityException;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.ObjectModelFactory;
import java.util.Map;
import java.util.Set;
-import java.net.URL;
-import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public class IdentityConfigurationService extends AbstractJBossService implements IdentityConfiguration
+public class IdentityConfigurationService extends IdentityModuleService implements IdentityConfiguration
{
+ //TODO: improve access to data to not blow up by NullPointerEx
+
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityConfigurationService.class);
private Map data;
- private String jndiName;
+ public IdentityConfigurationService()
+ {
+ super(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
- //private String configFile;
-
- protected JNDI.Binding jndiBinding;
-
- private IdentityContext identityContext;
-
public IdentityConfigurationService(Map optionGroups)
{
+ this();
this.data = optionGroups;
}
- protected void startService() throws Exception
+ public IdentityConfigurationService(OptionsMetaData meta) throws IdentityException
{
-
-
- /*try
+ this();
+ try
{
- log.info("Processing portal identity configuration");
- log.debug("config file: " + configFile);
- URL config = Thread.currentThread().getContextClassLoader().getResource(configFile);
- InputStream in = config.openStream();
- // create unmarshaller
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Map newGroups = new HashMap();
+ Map groups = meta.getGroups();
+ for (Iterator iterator = groups.keySet().iterator(); iterator.hasNext();)
+ {
+ String groupKey = (String)iterator.next();
+ OptionsGroupMetaData group = (OptionsGroupMetaData)groups.get(groupKey);
- // create an instance of ObjectModelFactory
- ObjectModelFactory factory = new SimpleIdentityConfigurationFactory();
+ Map newOptions = new HashMap();
+ Map options = group.getOptions();
+ for (Iterator iterator1 = options.keySet().iterator(); iterator1.hasNext();)
+ {
+ String optionKey = (String)iterator1.next();
+ OptionsGroupOptionMetaData option = (OptionsGroupOptionMetaData)options.get(optionKey);
- // let the object model factory to create an instance of Map and populate it with data from XML
- data = (Map)unmarshaller.unmarshal(in, factory, null);
+ newOptions.put(option.getName(),option.getValues());
+ }
- // close the XML stream
- in.close();
+ newGroups.put(group.getName(), newOptions);
+ }
+ setData(newGroups);
}
catch (Exception e)
{
- throw new IdentityException("Cannot parse configuration file", e);
- }*/
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
+ throw new IdentityException("Cannot create identity configuration options data:", e);
}
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing reference");
- }
- else
- {
- identityContext.register(this, IdentityContext.IDENTITY_CONFIGURATION);
- }
-
-
}
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- identityContext.unregister(IdentityContext.IDENTITY_CONFIGURATION);
- }
-
- }
-
-
-
public Set getValues(String optionGroup, String option)
{
if (optionGroup == null)
@@ -292,16 +255,6 @@
return data;
}
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
// public String getConfigFile()
// {
// return configFile;
@@ -312,14 +265,5 @@
// this.configFile = configFile;
// }
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-
}
Added: trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -0,0 +1,162 @@
+/*
+* 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.identity2.service;
+
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity2.IdentityConfiguration;
+import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentityModuleService extends AbstractJBossService
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityModuleService.class);
+
+ private String jndiName;
+
+ private IdentityContext identityContext;
+
+ private IdentityConfiguration identityConfiguration;
+
+ private JNDI.Binding jndiBinding;
+
+ private Map initOptions;
+
+ private String moduleType;
+
+ //restrict instance creation
+ private IdentityModuleService()
+ {
+
+ }
+
+ protected IdentityModuleService(String type)
+ {
+ moduleType = type;
+ }
+
+ protected void startService() throws Exception
+ {
+
+ //
+ if (jndiName != null)
+ {
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
+
+ if (identityContext == null)
+ {
+ throw new IdentityException("Cannot register module in context - missing reference");
+ }
+ else
+ {
+ //identityContext.register(this, IdentityContext.TYPE_ROLE_MODULE);
+ identityContext.register(this, this.moduleType);
+ }
+ }
+
+
+ protected void stopService() throws Exception
+ {
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+
+ if (identityContext == null)
+ {
+ log.error("Cannot unregister module in context - missing reference");
+ }
+ else
+ {
+ //identityContext.unregister(IdentityContext.TYPE_ROLE_MODULE);
+ identityContext.unregister(this.moduleType);
+ }
+
+ }
+
+ protected IdentityConfiguration getIdentityConfiguration() //throws IdentityException
+ {
+ /*if (identityConfiguration == null)
+ {
+ this.identityConfiguration = (IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
+ return identityConfiguration;*/
+ try
+ {
+ if (identityConfiguration == null)
+ {
+ this.identityConfiguration = (IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
+ return identityConfiguration;
+ }
+ catch (IdentityException e)
+ {
+ throw new RuntimeException("Can't obtain IdentityConfiguration", e);
+ }
+ }
+
+ public IdentityContext getIdentityContext()
+ {
+ return identityContext;
+ }
+
+ public void setIdentityContext(IdentityContext identityContext)
+ {
+ this.identityContext = identityContext;
+ }
+
+ protected String getJndiName()
+ {
+ return jndiName;
+ }
+
+ protected void setJndiName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public Map getInitOptions()
+ {
+ return initOptions;
+ }
+
+
+ public void setInitOptions(Map initOptions)
+ {
+ this.initOptions = initOptions;
+ }
+
+
+ public String getModuleType()
+ {
+ return moduleType;
+ }
+}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/service/MembershipModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/MembershipModuleService.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/service/MembershipModuleService.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -27,98 +27,32 @@
import org.jboss.portal.identity2.MembershipModule;
import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.identity2.IdentityConfiguration;
+import org.jboss.portal.identity2.info.ProfileInfo;
+import java.util.Map;
+
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public abstract class MembershipModuleService extends AbstractJBossService implements MembershipModule
+public abstract class MembershipModuleService extends IdentityModuleService implements MembershipModule
{
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(MembershipModuleService.class);
- private IdentityContext identityContext;
+ private ProfileInfo profileInfo;
- private IdentityConfiguration identityConfiguration;
-
- private String jndiName;
-
- protected JNDI.Binding jndiBinding;
-
-
- protected void startService() throws Exception
+ protected MembershipModuleService()
{
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing reference");
- }
- else
- {
- identityContext.register(this, IdentityContext.MEMBERSHIP_MODULE);
- }
-
-
-
-
+ super(IdentityContext.TYPE_MEMBERSHIP_MODULE);
}
-
- protected void stopService() throws Exception
+ public ProfileInfo getProfileInfo()
{
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- identityContext.unregister(IdentityContext.MEMBERSHIP_MODULE);
- }
-
+ return profileInfo;
}
- //************************************
- //******* Getters and Setters ********
- //************************************
-
- protected IdentityConfiguration getIdentityConfiguration() throws IdentityException
+ public void setProfileInfo(ProfileInfo profileInfo)
{
- if (identityConfiguration == null)
- {
- this.identityConfiguration = (IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;
+ this.profileInfo = profileInfo;
}
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/service/RoleModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/RoleModuleService.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/service/RoleModuleService.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -28,91 +28,18 @@
import org.jboss.portal.identity2.IdentityContext;
import org.jboss.portal.identity2.IdentityConfiguration;
+import java.util.Map;
+
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public abstract class RoleModuleService extends AbstractJBossService implements RoleModule
+public abstract class RoleModuleService extends IdentityModuleService implements RoleModule
{
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(RoleModuleService.class);
- private String jndiName;
-
- private IdentityContext identityContext;
-
- private IdentityConfiguration identityConfiguration;
-
- private JNDI.Binding jndiBinding;
-
-
- protected void startService() throws Exception
+ protected RoleModuleService()
{
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing reference");
- }
- else
- {
- identityContext.register(this, IdentityContext.ROLE_MODULE);
- }
-
-
+ super(IdentityContext.TYPE_ROLE_MODULE);
}
-
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- identityContext.unregister(IdentityContext.ROLE_MODULE);
- }
-
- }
-
- protected IdentityConfiguration getIdentityConfiguration() throws IdentityException
- {
- if (identityConfiguration == null)
- {
- this.identityConfiguration = (IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;
- }
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-
- protected String getJndiName()
- {
- return jndiName;
- }
-
- protected void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/service/UserModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/UserModuleService.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/service/UserModuleService.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -28,89 +28,18 @@
import org.jboss.portal.identity2.IdentityConfiguration;
import org.jboss.portal.identity2.IdentityContext;
+import java.util.Map;
+
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public abstract class UserModuleService extends AbstractJBossService implements UserModule
+public abstract class UserModuleService extends IdentityModuleService implements UserModule
{
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(UserModuleService.class);
- private IdentityConfiguration identityConfiguration;
-
- private String jndiName;
-
- private IdentityContext identityContext;
-
- private JNDI.Binding jndiBinding;
-
- protected void startService() throws Exception
+ protected UserModuleService()
{
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing reference");
- }
- else
- {
- identityContext.register(this, IdentityContext.USER_MODULE);
- }
-
-
+ super(IdentityContext.TYPE_USER_MODULE);
}
-
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- identityContext.unregister(IdentityContext.USER_MODULE);
- }
- }
-
- protected IdentityConfiguration getIdentityConfiguration() throws IdentityException
- {
- if (identityConfiguration == null)
- {
- this.identityConfiguration = (IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;
- }
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
}
Modified: trunk/identity/src/main/org/jboss/portal/identity2/service/UserProfileModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/UserProfileModuleService.java 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/main/org/jboss/portal/identity2/service/UserProfileModuleService.java 2006-11-22 23:48:17 UTC (rev 5717)
@@ -28,89 +28,20 @@
import org.jboss.portal.identity2.IdentityConfiguration;
import org.jboss.portal.identity2.IdentityContext;
+import java.util.Map;
+
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
*/
-public abstract class UserProfileModuleService extends AbstractJBossService implements UserProfileModule
+public abstract class UserProfileModuleService extends IdentityModuleService implements UserProfileModule
{
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(UserProfileModuleService.class);
- private IdentityConfiguration identityConfiguration;
-
- private String jndiName;
-
- private IdentityContext identityContext;
-
- private JNDI.Binding jndiBinding;
-
- protected void startService() throws Exception
+ protected UserProfileModuleService()
{
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing reference");
- }
- else
- {
- identityContext.register(this, IdentityContext.USER_PROFILE_MODULE);
- }
-
-
+ super(IdentityContext.TYPE_USER_PROFILE_MODULE);
}
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- identityContext.unregister(IdentityContext.USER_PROFILE_MODULE);
- }
- }
-
- protected IdentityConfiguration getIdentityConfiguration() throws IdentityException
- {
- if (identityConfiguration == null)
- {
- this.identityConfiguration = (IdentityConfiguration)identityContext.getObject(IdentityContext.IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;
- }
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
}
Modified: trunk/identity/src/resources/draft/identity-config.xml
===================================================================
--- trunk/identity/src/resources/draft/identity-config.xml 2006-11-22 23:14:30 UTC (rev 5716)
+++ trunk/identity/src/resources/draft/identity-config.xml 2006-11-22 23:48:17 UTC (rev 5717)
@@ -118,7 +118,7 @@
<!--For ldap configuration this is needed additionally to use ldap connection...-->
<module>
<!--type used to correctly map in IdentityContext registry-->
- <type>LDAPConnectionContext</type>
+ <type>ConnectionContext</type>
<implementation>CUSTOM</implementation>
<!--name of service and class for creating mbean-->
17 years, 5 months