Seam SVN: r7411 - trunk.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-02-11 14:04:13 -0500 (Mon, 11 Feb 2008)
New Revision: 7411
Modified:
trunk/changelog.txt
trunk/readme.txt
Log:
versions
Modified: trunk/changelog.txt
===================================================================
--- trunk/changelog.txt 2008-02-10 08:40:45 UTC (rev 7410)
+++ trunk/changelog.txt 2008-02-11 19:04:13 UTC (rev 7411)
@@ -1,6 +1,56 @@
JBoss Seam Changelog
====================
+Release Notes - JBoss Seam - Version 2.1.0.A1
+
+** Bug
+ * [JBSEAM-1021] - Don't log exceptions if they are handled in pages.xml
+ * [JBSEAM-1034] - Usage of jBPM core:process-definitions needs clarification
+ * [JBSEAM-1753] - Problems mixing a4j:support, @In and component binding
+ * [JBSEAM-2194] - Terrible error message for DTD not found when reading *.xml config file
+ * [JBSEAM-2195] - Converters should be created in stateless scope
+ * [JBSEAM-2243] - org.jboss.seam.persistence.HibernateSessionProxy does not implement org.hibernate.event.EventSource
+ * [JBSEAM-2271] - Remove deprecated events from Identity
+ * [JBSEAM-2302] - Query Parser adding Where clause conditions to Non Where clauses
+ * [JBSEAM-2373] - Seam-gen makes /Applications/jboss-4.2.2.GA the even when JBoss home is specified as C:/jboss-4.2.1.GA
+ * [JBSEAM-2393] - Query order by regexp fails when using lower/upper on a column
+ * [JBSEAM-2492] - Fix the injection-vulnerable order parameter in seam-gen applications
+ * [JBSEAM-2505] - ServletContexts instance returns null request during JSF request
+ * [JBSEAM-2526] - org.jboss.seam.core.SeamResourceBundle::getKeys()
+ * [JBSEAM-2527] - <s:convertEntity /> doesn't detect custom object added through external hibernate.cfg.xml
+ * [JBSEAM-2543] - Typos in Seam documentation
+ * [JBSEAM-2554] - pdf docType needs to be serializable
+ * [JBSEAM-2556] - NPE in AuthenticationFilter during Basic authentication
+
+** Feature Request
+ * [JBSEAM-619] - Make the booking work on WAS EJB3 Preview
+ * [JBSEAM-730] - Identity management API
+ * [JBSEAM-737] - run as
+ * [JBSEAM-895] - Support re-setting the principal in identity without relogin
+ * [JBSEAM-1342] - Generic Scanner usability
+ * [JBSEAM-1679] - passing callId to callback after async call
+ * [JBSEAM-2046] - Seam allows out of date pages.xml schema
+ * [JBSEAM-2071] - Introduce log attribute to exception handlers
+ * [JBSEAM-2227] - Write some docs on how to use SeamTest without TestNG
+ * [JBSEAM-2424] - Rearchitect BaseSeamTest to have one configuration per suite instead of class
+ * [JBSEAM-2497] - s:fileUpload should only store uploaded file name, not the full path
+ * [JBSEAM-2531] - Merge improved Wiki DBUnitSeamTest upstream
+ * [JBSEAM-2548] - Nicer URLs for wiki user info page
+ * [JBSEAM-2552] - Restructure UIFileUpload.processUpdates code
+ * [JBSEAM-2569] - Delete/Edit buttons on directory browser
+
+** Task
+ * [JBSEAM-1532] - include jar-versions.xml file
+ * [JBSEAM-1835] - Improve logging
+ * [JBSEAM-2151] - Document and use com.ibm.ws.webcontainer.invokefilterscompatibility with ajax4jsf in hibernate2/jpa examples
+ * [JBSEAM-2374] - Update to latest Trinidad version in seamdiscs example.
+ * [JBSEAM-2392] - document p:html
+ * [JBSEAM-2468] - Remove deprecated methods from SeamTest and BaseSeamTest
+ * [JBSEAM-2483] - Deploy Seam applications to Websphere 6.1.X and create Reference guide chapter
+ * [JBSEAM-2536] - Complete Annotations for use with Seam JavaBean components in a J2EE environment section
+ * [JBSEAM-2542] - Document semantics of s:link with view and action
+ * [JBSEAM-2555] - Upgrade to Richfaces 3.1.4
+
Release Notes - JBoss Seam - Version 2.0.1.CR2
** Bug
Modified: trunk/readme.txt
===================================================================
--- trunk/readme.txt 2008-02-10 08:40:45 UTC (rev 7410)
+++ trunk/readme.txt 2008-02-11 19:04:13 UTC (rev 7411)
@@ -1,6 +1,6 @@
JBoss Seam - Contextual Component framework for Java EE 5
=========================================================
-version 2.1.0.ALPHA, February 2008
+version 2.1.0.A1, February 2008
This software is distributed under the terms of the FSF Lesser Gnu
Public License (see lgpl.txt).
16 years, 3 months
Seam SVN: r7410 - trunk/examples/seamspace/src/org/jboss/seam/example/seamspace.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-02-10 03:40:45 -0500 (Sun, 10 Feb 2008)
New Revision: 7410
Modified:
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ContentServlet.java
Log:
better image type handling
Modified: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ContentServlet.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ContentServlet.java 2008-02-10 04:01:13 UTC (rev 7409)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ContentServlet.java 2008-02-10 08:40:45 UTC (rev 7410)
@@ -117,9 +117,10 @@
g2d.dispose();
String formatName = "";
- if ("image/png".equals(contentType))
+ if (contentType != null && contentType.indexOf("png") != -1)
formatName = "png";
- else if ("image/jpeg".equals(contentType))
+ else if (contentType != null && (contentType.indexOf("jpg") != -1) ||
+ contentType.indexOf("jpeg") != -1)
formatName = "jpeg";
ImageIO.write(bImg, formatName, response.getOutputStream());
16 years, 3 months
Seam SVN: r7409 - branches/Seam_2_0/src/main/org/jboss/seam/core.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-02-09 23:01:13 -0500 (Sat, 09 Feb 2008)
New Revision: 7409
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/core/Init.java
Log:
JBSEAM-2571
Modified: branches/Seam_2_0/src/main/org/jboss/seam/core/Init.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/core/Init.java 2008-02-10 03:54:45 UTC (rev 7408)
+++ branches/Seam_2_0/src/main/org/jboss/seam/core/Init.java 2008-02-10 04:01:13 UTC (rev 7409)
@@ -7,6 +7,7 @@
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -279,6 +280,17 @@
{
return "ObserverMethod(" + method + ')';
}
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof ObserverMethod)) return false;
+
+ ObserverMethod other = (ObserverMethod) obj;
+ return this.component.equals(other.component) &&
+ Arrays.equals(this.method.getParameterTypes(), other.method.getParameterTypes()) &&
+ this.method.getName().equals(other.getMethod().getName());
+ }
}
public static class ObserverMethodExpression
@@ -320,7 +332,12 @@
observerList = new ArrayList<ObserverMethod>();
observerMethods.put(eventType, observerList);
}
- observerList.add( new ObserverMethod(method, component, create) );
+
+ ObserverMethod observerMethod = new ObserverMethod(method, component, create);
+ if (!observerList.contains(observerMethod))
+ {
+ observerList.add( observerMethod );
+ }
}
public void addObserverMethodExpression(String eventType, MethodExpression methodBinding)
16 years, 3 months
Seam SVN: r7408 - trunk/src/main/org/jboss/seam/core.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-02-09 22:54:45 -0500 (Sat, 09 Feb 2008)
New Revision: 7408
Modified:
trunk/src/main/org/jboss/seam/core/Init.java
Log:
JBSEAM-2571
Modified: trunk/src/main/org/jboss/seam/core/Init.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/Init.java 2008-02-10 02:41:59 UTC (rev 7407)
+++ trunk/src/main/org/jboss/seam/core/Init.java 2008-02-10 03:54:45 UTC (rev 7408)
@@ -7,6 +7,7 @@
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -279,6 +280,17 @@
{
return "ObserverMethod(" + method + ')';
}
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof ObserverMethod)) return false;
+
+ ObserverMethod other = (ObserverMethod) obj;
+ return this.component.equals(other.component) &&
+ Arrays.equals(this.method.getParameterTypes(), other.method.getParameterTypes()) &&
+ this.method.getName().equals(other.getMethod().getName());
+ }
}
public static class ObserverMethodExpression
@@ -320,7 +332,12 @@
observerList = new ArrayList<ObserverMethod>();
observerMethods.put(eventType, observerList);
}
- observerList.add( new ObserverMethod(method, component, create) );
+
+ ObserverMethod observerMethod = new ObserverMethod(method, component, create);
+ if (!observerList.contains(observerMethod))
+ {
+ observerList.add( observerMethod );
+ }
}
public void addObserverMethodExpression(String eventType, MethodExpression methodBinding)
16 years, 3 months
Seam SVN: r7406 - trunk/seam-gen.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-02-09 21:16:46 -0500 (Sat, 09 Feb 2008)
New Revision: 7406
Modified:
trunk/seam-gen/build.xml
Log:
remove extra space
Modified: trunk/seam-gen/build.xml
===================================================================
--- trunk/seam-gen/build.xml 2008-02-09 05:59:44 UTC (rev 7405)
+++ trunk/seam-gen/build.xml 2008-02-10 02:16:46 UTC (rev 7406)
@@ -195,7 +195,7 @@
<property name="old.icefaces.home" value="" />
<input addproperty="icefaces.home.new"
- message="By default, seam-gen will download the recommended ICEFaces. If you want to use a specific version of ICEFaces, enter the path to icefaces here [${old.icefaces.home}]"
+ message="By default, seam-gen will download the recommended ICEFaces. If you want to use a specific version of ICEFaces, enter the path to icefaces here [${old.icefaces.home}]"
defaultvalue="${old.icefaces.home}" />
<condition property="richfaces.skin.new" value="">
16 years, 3 months
Seam SVN: r7405 - trunk/src/main/org/jboss/seam/security/management.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-02-09 00:59:44 -0500 (Sat, 09 Feb 2008)
New Revision: 7405
Modified:
trunk/src/main/org/jboss/seam/security/management/IdentityManager.java
Log:
no need for permission on roleExists()
Modified: trunk/src/main/org/jboss/seam/security/management/IdentityManager.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/IdentityManager.java 2008-02-09 05:59:07 UTC (rev 7404)
+++ trunk/src/main/org/jboss/seam/security/management/IdentityManager.java 2008-02-09 05:59:44 UTC (rev 7405)
@@ -146,7 +146,6 @@
public boolean roleExists(String name)
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_READ);
return identityStore.roleExists(name);
}
16 years, 3 months
Seam SVN: r7404 - trunk/doc/reference/en/modules.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-02-09 00:59:07 -0500 (Sat, 09 Feb 2008)
New Revision: 7404
Modified:
trunk/doc/reference/en/modules/security.xml
Log:
updated api docs
Modified: trunk/doc/reference/en/modules/security.xml
===================================================================
--- trunk/doc/reference/en/modules/security.xml 2008-02-09 05:21:59 UTC (rev 7403)
+++ trunk/doc/reference/en/modules/security.xml 2008-02-09 05:59:07 UTC (rev 7404)
@@ -1847,7 +1847,7 @@
<row>
<entry>
<para>
- <literal>createAccount(String name, String password)</literal>
+ <literal>createUser(String name, String password)</literal>
</para>
</entry>
<entry>
@@ -1861,12 +1861,12 @@
if successful, or <literal>false</literal> if not.
</para>
</entry>
- </row>
+ </row>
<row>
<entry>
<para>
- <literal>deleteAccount(String name)</literal>
+ <literal>deleteUser(String name)</literal>
</para>
</entry>
<entry>
@@ -1881,11 +1881,49 @@
</para>
</entry>
</row>
+
+ <row>
+ <entry>
+ <para>
+ <literal>createRole(String role)</literal>
+ </para>
+ </entry>
+ <entry>
+ <para>
+ <literal>boolean</literal>
+ </para>
+ </entry>
+ <entry>
+ <para>
+ Creates a new role, with the specified name. Returns <literal>true</literal>
+ if successful, or <literal>false</literal> if not.
+ </para>
+ </entry>
+ </row>
+
+ <row>
+ <entry>
+ <para>
+ <literal>deleteRole(String name)</literal>
+ </para>
+ </entry>
+ <entry>
+ <para>
+ <literal>boolean</literal>
+ </para>
+ </entry>
+ <entry>
+ <para>
+ Deletes the role with the specified name. Returns <literal>true</literal>
+ if successful, or <literal>false</literal> if not.
+ </para>
+ </entry>
+ </row>
<row>
<entry>
<para>
- <literal>enableAccount(String name)</literal>
+ <literal>enableUser(String name)</literal>
</para>
</entry>
<entry>
@@ -1905,7 +1943,7 @@
<row>
<entry>
<para>
- <literal>disableAccount(String name)</literal>
+ <literal>disableUser(String name)</literal>
</para>
</entry>
<entry>
@@ -1943,7 +1981,7 @@
<row>
<entry>
<para>
- <literal>isEnabled(String name)</literal>
+ <literal>isUserEnabled(String name)</literal>
</para>
</entry>
<entry>
@@ -1972,7 +2010,7 @@
</entry>
<entry>
<para>
- Grants the specified role to the specified user account. The role must already exist for it to
+ Grants the specified role to the specified user or role. The role must already exist for it to
be granted. Returns <literal>true</literal> if the role is successfully granted, or
<literal>false</literal> if it is already granted to the user.
</para>
@@ -1992,7 +2030,7 @@
</entry>
<entry>
<para>
- Revokes the specified role from the specified user account. Returns <literal>true</literal>
+ Revokes the specified role from the specified user or role. Returns <literal>true</literal>
if the specified user is a member of the role and it is successfully revoked, or
<literal>false</literal> if the user is not a member of the role.
</para>
@@ -2002,7 +2040,7 @@
<row>
<entry>
<para>
- <literal>accountExists(String name)</literal>
+ <literal>userExists(String name)</literal>
</para>
</entry>
<entry>
@@ -2170,7 +2208,7 @@
<row>
<entry>
<para>
- <literal>createAccount()</literal>
+ <literal>createUser()</literal>
</para>
</entry>
<entry>
@@ -2188,7 +2226,7 @@
<row>
<entry>
<para>
- <literal>deleteAccount()</literal>
+ <literal>deleteUser()</literal>
</para>
</entry>
<entry>
@@ -2202,11 +2240,47 @@
</para>
</entry>
</row>
+
+ <row>
+ <entry>
+ <para>
+ <literal>createRole()</literal>
+ </para>
+ </entry>
+ <entry>
+ <para>
+ <literal>seam.account</literal>
+ </para>
+ </entry>
+ <entry>
+ <para>
+ <literal>create</literal>
+ </para>
+ </entry>
+ </row>
+
+ <row>
+ <entry>
+ <para>
+ <literal>deleteRole()</literal>
+ </para>
+ </entry>
+ <entry>
+ <para>
+ <literal>seam.account</literal>
+ </para>
+ </entry>
+ <entry>
+ <para>
+ <literal>delete</literal>
+ </para>
+ </entry>
+ </row>
<row>
<entry>
<para>
- <literal>enableAccount()</literal>
+ <literal>enableUser()</literal>
</para>
</entry>
<entry>
@@ -2224,7 +2298,7 @@
<row>
<entry>
<para>
- <literal>disableAccount()</literal>
+ <literal>disableUser()</literal>
</para>
</entry>
<entry>
@@ -2260,7 +2334,7 @@
<row>
<entry>
<para>
- <literal>isEnabled()</literal>
+ <literal>isUserEnabled()</literal>
</para>
</entry>
<entry>
@@ -2314,7 +2388,7 @@
<row>
<entry>
<para>
- <literal>accountExists()</literal>
+ <literal>userExists()</literal>
</para>
</entry>
<entry>
@@ -2327,7 +2401,7 @@
<literal>read</literal>
</para>
</entry>
- </row>
+ </row>
<row>
<entry>
16 years, 3 months
Seam SVN: r7403 - in trunk/examples/seamspace: src/org/jboss/seam/example/seamspace and 3 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-02-09 00:21:59 -0500 (Sat, 09 Feb 2008)
New Revision: 7403
Added:
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RoleAction.java
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RoleSearch.java
trunk/examples/seamspace/view/images/btn_newrole.png
trunk/examples/seamspace/view/roledetail.xhtml
trunk/examples/seamspace/view/rolemanager.xhtml
Modified:
trunk/examples/seamspace/resources/WEB-INF/pages.xml
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/UserAction.java
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/UserSearch.java
trunk/examples/seamspace/view/register2.xhtml
trunk/examples/seamspace/view/style/seamspace.css
trunk/examples/seamspace/view/userdetail.xhtml
trunk/examples/seamspace/view/usermanager.xhtml
Log:
role management, updated to work with api changes
Modified: trunk/examples/seamspace/resources/WEB-INF/pages.xml
===================================================================
--- trunk/examples/seamspace/resources/WEB-INF/pages.xml 2008-02-09 05:21:07 UTC (rev 7402)
+++ trunk/examples/seamspace/resources/WEB-INF/pages.xml 2008-02-09 05:21:59 UTC (rev 7403)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd"
login-view-id="/home.xhtml">
- <page view-id="/home.xhtml">
+ <page view-id="/home.xhtml" action="#{identity.logout}">
<navigation from-action="#{identity.login}">
<rule if-outcome="loggedIn">
<redirect view-id="/profile.xhtml"/>
@@ -73,14 +73,34 @@
</navigation>
</page>
+ <page view-id="/rolemanager.xhtml" action="#{roleSearch.loadRoles}">
+ <restrict>#{s:hasPermission('seam.account', 'read', null)}</restrict>
+
+ <navigation from-action="#{roleAction.createRole}">
+ <redirect view-id="/roledetail.xhtml"/>
+ </navigation>
+
+ <navigation from-action="#{roleAction.editRole(roleSearch.selectedRole)}">
+ <redirect view-id="/roledetail.xhtml"/>
+ </navigation>
+ </page>
+
<page view-id="/userdetail.xhtml">
<navigation from-action="#{userAction.save}">
<rule if-outcome="success">
- <redirect view-id="/usermanager.xhtml"/>
+ <redirect view-id="/usermanager.xhtml"/>
</rule>
</navigation>
</page>
+ <page view-id="/roledetail.xhtml">
+ <navigation from-action="#{roleAction.save}">
+ <rule if-outcome="success">
+ <redirect view-id="/rolemanager.xhtml"/>
+ </rule>
+ </navigation>
+ </page>
+
<page view-id="/profile.xhtml">
<param name="name" value="#{selectedMember.memberName}"/>
@@ -111,9 +131,9 @@
</page>
<page view-id="*">
- <navigation from-action="#{identity.logout}">
+ <!--navigation from-action="#{identity.logout}">
<redirect view-id="/home.xhtml"/>
- </navigation>
+ </navigation-->
<navigation from-action="#{blog.createComment}">
<redirect view-id="/comment.xhtml"/>
@@ -124,11 +144,11 @@
</navigation>
</page>
- <exception class="org.jboss.seam.security.NotLoggedInException" log="false">
+ <!--exception class="org.jboss.seam.security.NotLoggedInException" log="false">
<redirect view-id="/register.xhtml">
<message severity="warn">You must be a member to use this feature</message>
</redirect>
- </exception>
+ </exception-->
<!--exception class="org.jboss.seam.security.AuthorizationException">
<end-conversation/>
Modified: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java 2008-02-09 05:21:07 UTC (rev 7402)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java 2008-02-09 05:21:59 UTC (rev 7403)
@@ -52,6 +52,7 @@
private byte[] picture;
private String pictureContentType;
+ private String pictureFileName;
private boolean verified;
@@ -109,7 +110,7 @@
}
public void execute() {
- identityManager.createAccount(username, password);
+ identityManager.createUser(username, password);
identityManager.grantRole(username, "user");
}
}.run();
@@ -195,6 +196,16 @@
this.pictureContentType = contentType;
}
+ public String getPictureFileName()
+ {
+ return pictureFileName;
+ }
+
+ public void setPictureFileName(String filename)
+ {
+ this.pictureFileName = filename;
+ }
+
public boolean isVerified()
{
return verified;
Added: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RoleAction.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RoleAction.java (rev 0)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RoleAction.java 2008-02-09 05:21:59 UTC (rev 7403)
@@ -0,0 +1,106 @@
+package org.jboss.seam.example.seamspace;
+
+import static org.jboss.seam.ScopeType.CONVERSATION;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.core.Conversation;
+import org.jboss.seam.security.management.IdentityManager;
+
+@Name("roleAction")
+@Scope(CONVERSATION)
+public class RoleAction
+{
+ private String role;
+ private List<String> memberships;
+
+ @In IdentityManager identityManager;
+
+ @Begin
+ public void createRole()
+ {
+ memberships = new ArrayList<String>();
+ }
+
+ @Begin
+ public void editRole(String role)
+ {
+ this.role = role;
+ memberships = identityManager.getGrantedRoles(role);
+ }
+
+ public String save()
+ {
+ if (identityManager.roleExists(role))
+ {
+ return saveExistingRole();
+ }
+ else
+ {
+ return saveNewRole();
+ }
+ }
+
+ private String saveNewRole()
+ {
+ boolean success = identityManager.createRole(role);
+
+ if (success)
+ {
+ for (String r : memberships)
+ {
+ identityManager.grantRole(role, r);
+ }
+
+ Conversation.instance().end();
+ }
+
+ return "success";
+ }
+
+ private String saveExistingRole()
+ {
+ List<String> grantedRoles = identityManager.getGrantedRoles(role);
+
+ if (grantedRoles != null)
+ {
+ for (String r : grantedRoles)
+ {
+ if (!memberships.contains(r)) identityManager.revokeRole(role, r);
+ }
+ }
+
+ for (String r : memberships)
+ {
+ if (grantedRoles == null || !grantedRoles.contains(r)) identityManager.grantRole(role, r);
+ }
+
+ Conversation.instance().end();
+ return "success";
+ }
+
+ public String getRole()
+ {
+ return role;
+ }
+
+ public void setRole(String role)
+ {
+ this.role = role;
+ }
+
+ public List<String> getMemberships()
+ {
+ return memberships;
+ }
+
+ public void setMemberships(List<String> memberships)
+ {
+ this.memberships = memberships;
+ }
+}
\ No newline at end of file
Added: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RoleSearch.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RoleSearch.java (rev 0)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RoleSearch.java 2008-02-09 05:21:59 UTC (rev 7403)
@@ -0,0 +1,52 @@
+package org.jboss.seam.example.seamspace;
+
+import static org.jboss.seam.ScopeType.SESSION;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.datamodel.DataModel;
+import org.jboss.seam.annotations.datamodel.DataModelSelection;
+import org.jboss.seam.security.management.IdentityManager;
+
+@Name("roleSearch")
+@Scope(SESSION)
+public class RoleSearch implements Serializable
+{
+ @DataModel
+ List<String> roles;
+
+ @DataModelSelection
+ String selectedRole;
+
+ @In IdentityManager identityManager;
+
+ public void loadRoles()
+ {
+ roles = identityManager.listRoles();
+ }
+
+ public String getRoleMemberships(String role)
+ {
+ List<String> roles = identityManager.getGrantedRoles(role);
+
+ if (roles == null) return "";
+
+ StringBuilder sb = new StringBuilder();
+
+ for (String r : roles)
+ {
+ sb.append((sb.length() > 0 ? ", " : "") + r);
+ }
+
+ return sb.toString();
+ }
+
+ public String getSelectedRole()
+ {
+ return selectedRole;
+ }
+}
\ No newline at end of file
Modified: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/UserAction.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/UserAction.java 2008-02-09 05:21:07 UTC (rev 7402)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/UserAction.java 2008-02-09 05:21:59 UTC (rev 7403)
@@ -36,12 +36,12 @@
{
this.username = username;
roles = identityManager.getGrantedRoles(username);
- enabled = identityManager.isEnabled(username);
+ enabled = identityManager.isUserEnabled(username);
}
public String save()
{
- if (identityManager.accountExists(username))
+ if (identityManager.userExists(username))
{
return saveExistingUser();
}
@@ -59,7 +59,7 @@
return "failure";
}
- boolean success = identityManager.createAccount(username, password);
+ boolean success = identityManager.createUser(username, password);
if (success)
{
@@ -70,7 +70,7 @@
if (!enabled)
{
- identityManager.disableAccount(username);
+ identityManager.disableUser(username);
}
Conversation.instance().end();
@@ -97,23 +97,29 @@
List<String> grantedRoles = identityManager.getGrantedRoles(username);
- for (String role : grantedRoles)
+ if (grantedRoles != null)
{
- if (!roles.contains(role)) identityManager.revokeRole(username, role);
+ for (String role : grantedRoles)
+ {
+ if (!roles.contains(role)) identityManager.revokeRole(username, role);
+ }
}
for (String role : roles)
{
- if (!grantedRoles.contains(role)) identityManager.grantRole(username, role);
+ if (grantedRoles == null || !grantedRoles.contains(role))
+ {
+ identityManager.grantRole(username, role);
+ }
}
if (enabled)
{
- identityManager.enableAccount(username);
+ identityManager.enableUser(username);
}
else
{
- identityManager.disableAccount(username);
+ identityManager.disableUser(username);
}
Conversation.instance().end();
Modified: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/UserSearch.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/UserSearch.java 2008-02-09 05:21:07 UTC (rev 7402)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/UserSearch.java 2008-02-09 05:21:59 UTC (rev 7403)
@@ -34,6 +34,9 @@
public String getUserRoles(String username)
{
List<String> roles = identityManager.getGrantedRoles(username);
+
+ if (roles == null) return "";
+
StringBuilder sb = new StringBuilder();
for (String role : roles)
Added: trunk/examples/seamspace/view/images/btn_newrole.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/seamspace/view/images/btn_newrole.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/examples/seamspace/view/register2.xhtml
===================================================================
--- trunk/examples/seamspace/view/register2.xhtml 2008-02-09 05:21:07 UTC (rev 7402)
+++ trunk/examples/seamspace/view/register2.xhtml 2008-02-09 05:21:59 UTC (rev 7403)
@@ -20,6 +20,7 @@
<div class="formRow">
<h:outputLabel for="picture">Member photo</h:outputLabel>
<s:fileUpload id="picture" data="#{register.picture}" accept="image/png"
+ fileName="#{register.pictureFileName}"
contentType="#{register.pictureContentType}" />
<div class="validationError"><h:message for="picture"/></div>
</div>
Added: trunk/examples/seamspace/view/roledetail.xhtml
===================================================================
--- trunk/examples/seamspace/view/roledetail.xhtml (rev 0)
+++ trunk/examples/seamspace/view/roledetail.xhtml 2008-02-09 05:21:59 UTC (rev 7403)
@@ -0,0 +1,51 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:s="http://jboss.com/products/seam/taglib">
+
+ <ui:composition template="template.xhtml">
+
+ <ui:define name="content">
+
+ <div id="contentMain">
+
+ <h2>Role Details</h2>
+
+ <h:messages globalOnly="true"/>
+
+ <h:form>
+
+ <div class="formRow">
+ <h:outputLabel for="role" value="Role" styleClass="formLabel"/>
+ <h:inputText id="role" value="#{roleAction.role}" readonly="#{identityManager.userExists(roleAction.role)}"/>
+ <div class="validationError"><h:message for="role"/></div>
+ </div>
+
+ <div class="formRow">
+ <h:outputLabel for="roles" value="Member of" styleClass="formLabel"/>
+ <div class="selectMany">
+ <h:selectManyCheckbox id="roles" value="#{roleAction.memberships}" layout="pageDirection" styleClass="roles">
+ <s:selectItems value="#{identityManager.listRoles()}" var="role" label="#{role}"/>
+ </h:selectManyCheckbox>
+ </div>
+ <div class="validationError"><h:message for="roles"/></div>
+ </div>
+
+ <div class="formButtons">
+ <h:commandButton value="Save" action="#{roleAction.save}" styleClass="formButton"/>
+ <s:button view="/rolemanager.xhtml" value="Cancel" propagation="end" styleClass="formButton"/>
+ </div>
+
+ <br class="clear"/>
+
+ </h:form>
+
+ </div>
+
+ </ui:define>
+
+ </ui:composition>
+</html>
Added: trunk/examples/seamspace/view/rolemanager.xhtml
===================================================================
--- trunk/examples/seamspace/view/rolemanager.xhtml (rev 0)
+++ trunk/examples/seamspace/view/rolemanager.xhtml 2008-02-09 05:21:59 UTC (rev 7403)
@@ -0,0 +1,66 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:s="http://jboss.com/products/seam/taglib">
+
+ <ui:composition template="template.xhtml">
+
+ <ui:define name="content">
+
+ <script type="text/javascript">
+ function confirmDelete()
+ {
+ return confirm("Are you sure you wish to delete this role? This action cannot be undone.");
+ }
+ </script>
+
+ <div id="contentMain">
+
+ <h2>Role Manager</h2>
+
+ <s:button action="#{roleAction.createRole}" styleClass="newrole" rendered="#{s:hasPermission('seam.account', 'create', null)}"/>
+ <s:link view="/usermanager.xhtml" value="--> Manage Users" propagation="none"/>
+
+ <rich:dataTable
+ id="threads"
+ value="#{roles}"
+ var="role"
+ styleClass="default"
+ columnClasses=",,enabled,action">
+ <f:facet name="header">
+ <rich:columnGroup>
+ <rich:column width="auto">
+ User name
+ </rich:column>
+ <rich:column width="auto">
+ Member Of
+ </rich:column>
+ <rich:column width="auto">
+ Action
+ </rich:column>
+ </rich:columnGroup>
+ </f:facet>
+ <rich:column width="auto">
+ #{role}
+ </rich:column>
+ <rich:column width="auto">
+ #{roleSearch.getRoleMemberships(role)}
+ </rich:column>
+ <rich:column width="auto">
+ <s:fragment rendered="#{s:hasPermission('seam.account', 'update', null)}">
+ <s:link value="Edit" action="#{roleAction.editRole(roleSearch.selectedRole)}"/><span> | </span>
+ </s:fragment>
+ <s:link value="Delete" action="#{identityManager.deleteAccount(roleSearch.selectedRole)}"
+ rendered="#{s:hasPermission('seam.account', 'delete', null)}"
+ onclick="return confirmDelete()"/>
+ </rich:column>
+ </rich:dataTable>
+ </div>
+
+ </ui:define>
+
+ </ui:composition>
+</html>
Modified: trunk/examples/seamspace/view/style/seamspace.css
===================================================================
--- trunk/examples/seamspace/view/style/seamspace.css 2008-02-09 05:21:07 UTC (rev 7402)
+++ trunk/examples/seamspace/view/style/seamspace.css 2008-02-09 05:21:59 UTC (rev 7403)
@@ -509,6 +509,15 @@
cursor: pointer;
}
+input.newrole {
+ background: url(../images/btn_newrole.png) top left no-repeat;
+ height: 24px;
+ width: 80px;
+ margin: 4px 4px 4px 4px;
+ border: 0px;
+ cursor: pointer;
+}
+
/* General form styles */
div.formRow {
Modified: trunk/examples/seamspace/view/userdetail.xhtml
===================================================================
--- trunk/examples/seamspace/view/userdetail.xhtml 2008-02-09 05:21:07 UTC (rev 7402)
+++ trunk/examples/seamspace/view/userdetail.xhtml 2008-02-09 05:21:59 UTC (rev 7403)
@@ -20,7 +20,7 @@
<div class="formRow">
<h:outputLabel for="username" value="Username" styleClass="formLabel"/>
- <h:inputText id="username" value="#{userAction.username}" readonly="#{identityManager.accountExists(userAction.username)}"/>
+ <h:inputText id="username" value="#{userAction.username}" readonly="#{identityManager.userExists(userAction.username)}"/>
<div class="validationError"><h:message for="username"/></div>
</div>
Modified: trunk/examples/seamspace/view/usermanager.xhtml
===================================================================
--- trunk/examples/seamspace/view/usermanager.xhtml 2008-02-09 05:21:07 UTC (rev 7402)
+++ trunk/examples/seamspace/view/usermanager.xhtml 2008-02-09 05:21:59 UTC (rev 7403)
@@ -22,6 +22,7 @@
<h2>User Manager</h2>
<s:button action="#{userAction.createUser}" styleClass="newuser" rendered="#{s:hasPermission('seam.account', 'create', null)}"/>
+ <s:link view="/rolemanager.xhtml" value="--> Manage Roles" propagation="none"/>
<rich:dataTable
id="threads"
@@ -52,7 +53,7 @@
#{userSearch.getUserRoles(user)}
</rich:column>
<rich:column width="auto">
- <div class="#{identityManager.isEnabled(user) ? 'checkmark' : 'cross'}"/>
+ <div class="#{identityManager.isUserEnabled(user) ? 'checkmark' : 'cross'}"/>
</rich:column>
<rich:column width="auto">
<s:fragment rendered="#{s:hasPermission('seam.account', 'update', null)}">
16 years, 3 months
Seam SVN: r7402 - trunk/src/main/org/jboss/seam/security/management.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-02-09 00:21:07 -0500 (Sat, 09 Feb 2008)
New Revision: 7402
Added:
trunk/src/main/org/jboss/seam/security/management/NoSuchRoleException.java
Modified:
trunk/src/main/org/jboss/seam/security/management/IdentityManager.java
trunk/src/main/org/jboss/seam/security/management/IdentityStore.java
trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
trunk/src/main/org/jboss/seam/security/management/NoSuchUserException.java
Log:
Refactored, improved exception handling, more sensible API, support for role management
Modified: trunk/src/main/org/jboss/seam/security/management/IdentityManager.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/IdentityManager.java 2008-02-09 05:02:33 UTC (rev 7401)
+++ trunk/src/main/org/jboss/seam/security/management/IdentityManager.java 2008-02-09 05:21:07 UTC (rev 7402)
@@ -31,6 +31,11 @@
public static final String IDENTITY_STORE_COMPONENT_NAME = "identityStore";
public static final String ACCOUNT_PERMISSION_NAME = "seam.account";
+ public static final String PERMISSION_CREATE = "create";
+ public static final String PERMISSION_READ = "read";
+ public static final String PERMISSION_UPDATE = "update";
+ public static final String PERMISSION_DELETE = "delete";
+
private static final LogProvider log = Logging.getLogProvider(IdentityManager.class);
private IdentityStore identityStore;
@@ -73,63 +78,81 @@
return instance;
}
- public boolean createAccount(String name, String password)
+ public boolean createUser(String name, String password)
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, "create");
- return identityStore.createAccount(name, password);
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_CREATE);
+ return identityStore.createUser(name, password);
}
- public boolean deleteAccount(String name)
+ public boolean deleteUser(String name)
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, "delete");
- return identityStore.deleteAccount(name);
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_DELETE);
+ return identityStore.deleteUser(name);
}
- public boolean enableAccount(String name)
+ public boolean enableUser(String name)
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, "update");
- return identityStore.enableAccount(name);
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_UPDATE);
+ return identityStore.enableUser(name);
}
- public boolean disableAccount(String name)
+ public boolean disableUser(String name)
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, "update");
- return identityStore.disableAccount(name);
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_UPDATE);
+ return identityStore.disableUser(name);
}
public boolean changePassword(String name, String password)
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, "update");
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_UPDATE);
return identityStore.changePassword(name, password);
}
- public boolean isEnabled(String name)
+ public boolean isUserEnabled(String name)
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, "read");
- return identityStore.isEnabled(name);
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_READ);
+ return identityStore.isUserEnabled(name);
}
public boolean grantRole(String name, String role)
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, "update");
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_UPDATE);
return identityStore.grantRole(name, role);
}
public boolean revokeRole(String name, String role)
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, "update");
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_UPDATE);
return identityStore.revokeRole(name, role);
}
- public boolean accountExists(String name)
+ public boolean createRole(String role)
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, "read");
- return identityStore.accountExists(name);
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_CREATE);
+ return identityStore.createRole(role);
}
+ public boolean deleteRole(String role)
+ {
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_DELETE);
+ return identityStore.deleteRole(role);
+ }
+
+ public boolean userExists(String name)
+ {
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_READ);
+ return identityStore.userExists(name);
+ }
+
+ public boolean roleExists(String name)
+ {
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_READ);
+ return identityStore.roleExists(name);
+ }
+
public List<String> listUsers()
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, "read");
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_READ);
List<String> users = identityStore.listUsers();
Collections.sort(users, new Comparator<String>() {
@@ -143,7 +166,7 @@
public List<String> listUsers(String filter)
{
- Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, "read");
+ Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_READ);
List<String> users = identityStore.listUsers(filter);
Collections.sort(users, new Comparator<String>() {
Modified: trunk/src/main/org/jboss/seam/security/management/IdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/IdentityStore.java 2008-02-09 05:02:33 UTC (rev 7401)
+++ trunk/src/main/org/jboss/seam/security/management/IdentityStore.java 2008-02-09 05:21:07 UTC (rev 7402)
@@ -10,18 +10,20 @@
*/
public interface IdentityStore
{
- boolean createAccount(String username, String password);
- boolean deleteAccount(String name);
+ boolean createUser(String username, String password);
+ boolean deleteUser(String name);
+ boolean enableUser(String name);
+ boolean disableUser(String name);
+ boolean isUserEnabled(String name);
+ boolean changePassword(String name, String password);
+ boolean userExists(String name);
+ boolean createRole(String role);
boolean grantRole(String name, String role);
boolean revokeRole(String name, String role);
-
- boolean enableAccount(String name);
- boolean disableAccount(String name);
- boolean isEnabled(String name);
- boolean changePassword(String name, String password);
-
- boolean accountExists(String name);
+ boolean deleteRole(String role);
+ boolean roleExists(String name);
+
List<String> listUsers();
List<String> listUsers(String filter);
List<String> listRoles();
Modified: trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java 2008-02-09 05:02:33 UTC (rev 7401)
+++ trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java 2008-02-09 05:21:07 UTC (rev 7402)
@@ -68,7 +68,7 @@
}
}
- public boolean createAccount(String username, String password)
+ public boolean createUser(String username, String password)
{
try
{
@@ -77,7 +77,7 @@
throw new IdentityManagementException("Could not create account, accountClass not set");
}
- if (accountExists(username))
+ if (userExists(username))
{
throw new IdentityManagementException("Could not create account, already exists");
}
@@ -115,35 +115,31 @@
}
}
- public boolean deleteAccount(String name)
+ public boolean deleteUser(String name)
{
- UserAccount account;
- try
+ UserAccount account = validateAccount(name);
+ if (account == null || !account.getAccountType().equals(AccountType.user))
{
- account = validateUser(name);
- }
- catch (NoSuchUserException e)
- {
- return false;
+ throw new NoSuchUserException("Could not delete account, no such user '" + name + "'");
}
+
getEntityManager().remove(account);
return true;
}
public boolean grantRole(String name, String role)
{
- UserAccount account;
-
- try
+ UserAccount account = validateAccount(name);
+ if (account == null)
{
- account = validateUser(name);
+ throw new NoSuchUserException("Could not grant role, no such user or role '" + name + "'");
}
- catch (NoSuchUserException ex)
+
+ UserAccount roleToGrant = validateAccount(role);
+ if (roleToGrant == null)
{
- return false;
+ throw new NoSuchRoleException("Could not grant role, role '" + role + "' does not exist");
}
-
- UserAccount roleToGrant = validateRole(role);
if (account.getMemberships() == null)
{
@@ -162,34 +158,78 @@
public boolean revokeRole(String name, String role)
{
- UserAccount account;
- try
+ UserAccount account = validateAccount(name);
+ if (account == null)
{
- account = validateUser(name);
- }
- catch (NoSuchUserException e)
- {
- return false;
+ throw new NoSuchUserException("Could not revoke role, no such user or role '" + name + "'");
}
- UserAccount roleToRevoke = validateRole(role);
+ UserAccount roleToRevoke = validateAccount(role);
+ if (roleToRevoke == null)
+ {
+ throw new NoSuchRoleException("Could not revoke role, role '" + role + "' does not exist");
+ }
+
boolean success = account.getMemberships().remove(roleToRevoke);
mergeAccount(account);
return success;
}
- public boolean enableAccount(String name)
+ public boolean createRole(String role)
{
- UserAccount account;
try
{
- account = validateUser(name);
- }
- catch (NoSuchUserException e)
+ if (accountClass == null)
+ {
+ throw new IdentityManagementException("Could not create role, accountClass not set");
+ }
+
+ if (roleExists(role))
+ {
+ throw new IdentityManagementException("Could not create role, already exists");
+ }
+
+ UserAccount account = accountClass.newInstance();
+ account.setAccountType(UserAccount.AccountType.role);
+ account.setUsername(role);
+
+ persistAccount(account);
+
+ return true;
+ }
+ catch (Exception ex)
{
- return false;
+ if (ex instanceof IdentityManagementException)
+ {
+ throw (IdentityManagementException) ex;
+ }
+ else
+ {
+ throw new IdentityManagementException("Could not create role", ex);
+ }
+ }
+ }
+
+ public boolean deleteRole(String role)
+ {
+ UserAccount roleToDelete = validateAccount(role);
+ if (roleToDelete == null)
+ {
+ throw new NoSuchRoleException("Could not delete role, role '" + role + "' does not exist");
}
+ getEntityManager().remove(roleToDelete);
+ return true;
+ }
+
+ public boolean enableUser(String name)
+ {
+ UserAccount account = validateAccount(name);
+ if (account == null || !account.getAccountType().equals(AccountType.user))
+ {
+ throw new NoSuchUserException("Could not enable account, user '" + name + "' does not exist");
+ }
+
// If it's already enabled return false
if (account.isEnabled())
{
@@ -202,17 +242,13 @@
return true;
}
- public boolean disableAccount(String name)
+ public boolean disableUser(String name)
{
- UserAccount account;
- try
+ UserAccount account = validateAccount(name);
+ if (account == null || !account.getAccountType().equals(AccountType.user))
{
- account = validateUser(name);
- }
- catch (NoSuchUserException e)
- {
- return false;
- }
+ throw new NoSuchUserException("Could not disable account, user '" + name + "' does not exist");
+ }
// If it's already enabled return false
if (!account.isEnabled())
@@ -228,63 +264,42 @@
public boolean changePassword(String name, String password)
{
- UserAccount account;
- try
+ UserAccount account = validateAccount(name);
+ if (account == null || !account.getAccountType().equals(AccountType.user))
{
- account = validateUser(name);
- account.setPasswordHash(hashPassword(password, name));
- mergeAccount(account);
- return true;
- }
- catch (NoSuchUserException e)
- {
- return false;
- }
+ throw new NoSuchUserException("Could not change password, user '" + name + "' does not exist");
+ }
+
+ account.setPasswordHash(hashPassword(password, name));
+ mergeAccount(account);
+ return true;
}
- public boolean accountExists(String name)
+ public boolean userExists(String name)
{
- UserAccount account;
- try
- {
- account = validateUser(name);
- return account != null;
- }
- catch (NoSuchUserException e)
- {
- return false;
- }
+ UserAccount account = validateAccount(name);
+ return account != null && account.getAccountType().equals(AccountType.user);
}
- public boolean isEnabled(String name)
+ public boolean roleExists(String name)
{
- UserAccount account;
- try
- {
- account = validateUser(name);
- }
- catch (NoSuchUserException e)
- {
- return false;
- }
-
- return account.isEnabled();
+ UserAccount role = validateAccount(name);
+ return role != null && role.getAccountType().equals(AccountType.role);
}
+ public boolean isUserEnabled(String name)
+ {
+ UserAccount account = validateAccount(name);
+ return account != null && account.getAccountType().equals(AccountType.user)
+ && account.isEnabled();
+ }
+
public List<String> getGrantedRoles(String name)
{
- UserAccount account;
- try
- {
- account = validateUser(name);
- }
- catch (NoSuchUserException e)
- {
- return null;
- }
+ UserAccount account = validateAccount(name);
+ if (account == null) throw new NoSuchUserException("No such user '" + name + "'");
- List<String> roles = new ArrayList<String>();
-
+ List<String> roles = new ArrayList<String>();
if (account.getMemberships() != null)
{
for (UserAccount membership : account.getMemberships())
@@ -301,15 +316,8 @@
public List<String> getImpliedRoles(String name)
{
- UserAccount account;
- try
- {
- account = validateUser(name);
- }
- catch (NoSuchUserException e)
- {
- return null;
- }
+ UserAccount account = validateAccount(name);
+ if (account == null) throw new NoSuchUserException("No such user '" + name + "'");
Set<String> roles = new HashSet<String>();
@@ -339,17 +347,7 @@
public boolean authenticate(String username, String password)
{
- UserAccount account = null;
-
- try
- {
- account = validateUser(username);
- }
- catch (NoSuchUserException ex)
- {
- return false;
- }
-
+ UserAccount account = validateAccount(username);
if (account == null || !account.getAccountType().equals(AccountType.user)
|| !account.isEnabled())
{
@@ -366,66 +364,32 @@
return success;
}
- /**
- * Retrieves a user UserAccount from persistent storage. If the UserAccount does
- * not exist, an IdentityManagementException is thrown.
- *
- * @param name The user's username
- * @return The UserAccount for the specified user
- */
- protected UserAccount validateUser(String name) throws NoSuchUserException
- {
+ protected UserAccount validateAccount(String name)
+ {
try
{
- return (UserAccount) getEntityManager().createQuery(
- "from " + accountClass.getName() + " where username = :username and " +
- "accountType = :accountType")
+ UserAccount account = (UserAccount) getEntityManager().createQuery(
+ "from " + accountClass.getName() + " where username = :username")
.setParameter("username", name)
- .setParameter("accountType", AccountType.user)
.getSingleResult();
- }
- catch (NoResultException ex)
- {
- throw new NoSuchUserException("No such user: " + name);
- }
- }
-
- /**
- * Retrieves a role UserAccount from persistent storage. If the UserAccount
- * does not exist, an IdentityManagementException is thrown.
- *
- * @param name The role name
- * @return The UserAccount for the specific role
- */
- protected UserAccount validateRole(String name)
- {
- try
- {
- // As a last ditch effort, check the db
- UserAccount role = (UserAccount) getEntityManager().createQuery(
- "from " + accountClass.getName() + " where username = :username and " +
- "accountType = :accountType")
- .setParameter("username", name)
- .setParameter("accountType", AccountType.role)
- .getSingleResult();
-
- if (!roleCache.containsKey(role.getUsername()))
+
+ if (account.getAccountType().equals(AccountType.role) &&
+ !roleCache.containsKey(account.getUsername()))
{
Set<String> memberships = new HashSet<String>();
- for (UserAccount m : role.getMemberships())
+ for (UserAccount m : account.getMemberships())
{
memberships.add(m.getUsername());
}
- roleCache.put(role.getUsername(), memberships);
+ roleCache.put(account.getUsername(), memberships);
}
- return role;
+ return account;
}
catch (NoResultException ex)
{
- roleCache.remove(name);
- throw new IdentityManagementException("No such role: " + name);
+ return null;
}
}
Added: trunk/src/main/org/jboss/seam/security/management/NoSuchRoleException.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/NoSuchRoleException.java (rev 0)
+++ trunk/src/main/org/jboss/seam/security/management/NoSuchRoleException.java 2008-02-09 05:21:07 UTC (rev 7402)
@@ -0,0 +1,19 @@
+package org.jboss.seam.security.management;
+
+/**
+ * Thrown when an operation is performed on a non-existent role.
+ *
+ * @author Shane Bryzak
+ */
+public class NoSuchRoleException extends RuntimeException
+{
+ public NoSuchRoleException(String message)
+ {
+ super(message);
+ }
+
+ public NoSuchRoleException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
Modified: trunk/src/main/org/jboss/seam/security/management/NoSuchUserException.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/NoSuchUserException.java 2008-02-09 05:02:33 UTC (rev 7401)
+++ trunk/src/main/org/jboss/seam/security/management/NoSuchUserException.java 2008-02-09 05:21:07 UTC (rev 7402)
@@ -1,11 +1,11 @@
package org.jboss.seam.security.management;
/**
- * Thrown when an operation is attempted on a non-existant user.
+ * Thrown when an operation is attempted on a non-existent user.
*
* @author Shane Bryzak
*/
-public class NoSuchUserException extends Exception
+public class NoSuchUserException extends RuntimeException
{
public NoSuchUserException(String message)
{
16 years, 3 months
Seam SVN: r7401 - trunk/doc/reference/en/modules.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-02-09 00:02:33 -0500 (Sat, 09 Feb 2008)
New Revision: 7401
Modified:
trunk/doc/reference/en/modules/remoting.xml
Log:
commented out documentation on evaluating el expressions
Modified: trunk/doc/reference/en/modules/remoting.xml
===================================================================
--- trunk/doc/reference/en/modules/remoting.xml 2008-02-09 04:59:13 UTC (rev 7400)
+++ trunk/doc/reference/en/modules/remoting.xml 2008-02-09 05:02:33 UTC (rev 7401)
@@ -258,7 +258,7 @@
</sect2>
</sect1>
- <sect1>
+ <!--sect1>
<title>Evaluating EL Expressions</title>
<para>
@@ -287,7 +287,7 @@
</para>
<programlisting><![CDATA[<s:remote include="customer"/>]]></programlisting>
- </sect1>
+ </sect1-->
<sect1>
<title>Client Interfaces</title>
16 years, 3 months