[seam-commits] Seam SVN: r13327 - in modules/security/trunk: examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/action and 5 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Sun Jul 4 20:36:48 EDT 2010
Author: shane.bryzak at jboss.com
Date: 2010-07-04 20:36:47 -0400 (Sun, 04 Jul 2010)
New Revision: 13327
Added:
modules/security/trunk/examples/idmconsole/src/main/webapp/userdetail.xhtml
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserDTO.java
Modified:
modules/security/trunk/examples/idmconsole/pom.xml
modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/action/EntityManagerProducer.java
modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/faces-config.xml
modules/security/trunk/examples/idmconsole/src/main/webapp/manageusers.xhtml
modules/security/trunk/impl/pom.xml
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserSearch.java
Log:
example improvements, minor security module stuff
Modified: modules/security/trunk/examples/idmconsole/pom.xml
===================================================================
--- modules/security/trunk/examples/idmconsole/pom.xml 2010-07-02 12:58:29 UTC (rev 13326)
+++ modules/security/trunk/examples/idmconsole/pom.xml 2010-07-05 00:36:47 UTC (rev 13327)
@@ -60,6 +60,22 @@
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-persistence</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
<!-- CDI (JSR-299) -->
<dependency>
<groupId>javax.enterprise</groupId>
Modified: modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/action/EntityManagerProducer.java
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/action/EntityManagerProducer.java 2010-07-02 12:58:29 UTC (rev 13326)
+++ modules/security/trunk/examples/idmconsole/src/main/java/org/jboss/seam/security/examples/idmconsole/action/EntityManagerProducer.java 2010-07-05 00:36:47 UTC (rev 13327)
@@ -7,7 +7,7 @@
public class EntityManagerProducer
{
- @PersistenceContext EntityManager entityManager;
+ @PersistenceContext(unitName = "idmconsoleDatabase") EntityManager entityManager;
public @Produces @RequestScoped EntityManager produceEntityManager()
{
Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/faces-config.xml 2010-07-02 12:58:29 UTC (rev 13326)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/WEB-INF/faces-config.xml 2010-07-05 00:36:47 UTC (rev 13327)
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- This file is not required if you don't need any extra configuration. -->
<faces-config version="2.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -7,6 +6,33 @@
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
- <!-- Write your navigation rules here. You are encouraged to use CDI for creating @Named managed beans. -->
+ <name>idmconsole</name>
+
+ <navigation-rule>
+ <from-view-id>/manageusers.xhtml</from-view-id>
+ <navigation-case>
+ <from-action>#{userAction.createUser}</from-action>
+ <if>#{true}</if>
+ <to-view-id>/userdetail.xhtml</to-view-id>
+ <redirect />
+ </navigation-case>
+
+ <navigation-case>
+ <from-action>#{userAction.editUser(user.username)}</from-action>
+ <if>#{true}</if>
+ <to-view-id>/userdetail.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/userdetail.xhtml</from-view-id>
+ <navigation-case>
+ <from-action>#{userAction.save}</from-action>
+ <if>#{true}</if>
+ <to-view-id>/manageusers.xhtml</to-view-id>
+ <redirect />
+ </navigation-case>
+ </navigation-rule>
</faces-config>
Modified: modules/security/trunk/examples/idmconsole/src/main/webapp/manageusers.xhtml
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/manageusers.xhtml 2010-07-02 12:58:29 UTC (rev 13326)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/manageusers.xhtml 2010-07-05 00:36:47 UTC (rev 13327)
@@ -12,42 +12,47 @@
<ui:define name="content">
<h3>Manage Users</h3>
- <h:button id="newUser" action="#{userAction.createUser}" styleClass="newuser" rendered="#{identity.hasPermission('seam.account', 'create')}"/>
-
- <h:dataTable
- id="threads"
- value="#{userSearch.users}"
- var="user"
- styleClass="security"
- cellspacing="0"
- headerClass="header"
- rowClasses="odd,even"
- columnClasses=",,enabled,action">
- <h:column width="auto">
- <f:facet name="header">
- User name
- </f:facet>
- #{user}
- </h:column>
- <h:column id="enabled" width="auto">
- <f:facet name="header">
- Enabled
- </f:facet>
- <div class="#{identityManager.isUserEnabled(user) ? 'checkmark' : 'cross'}"/>
- </h:column>
- <h:column id="action" width="auto">
- <f:facet name="header">
- Action
- </f:facet>
-
- <ui:fragment rendered="#{identity.hasPermission('seam.user', 'update')}">
- <h:link id="edit" value="Edit" action="#{userAction.editUser(userSearch.selectedUser)}"/><span> | </span>
- </ui:fragment>
- <h:link id="delete" value="Delete" action="#{identityManager.deleteUser(userSearch.selectedUser)}"
- rendered="#{identity.hasPermission('seam.user', 'delete')}"
- onclick="return confirmDelete()"/>
- </h:column>
- </h:dataTable>
+ <h:form>
+ <h:commandButton action="#{userAction.createUser}" styleClass="newuser" rendered="#{identity.hasPermission('seam.account', 'create')}"/>
+ </h:form>
+
+ <h:form>
+ <h:dataTable
+ id="threads"
+ value="#{userSearch.users}"
+ var="user"
+ styleClass="security"
+ cellspacing="0"
+ headerClass="header"
+ rowClasses="odd,even"
+ columnClasses=",,enabled,action">
+ <h:column width="auto">
+ <f:facet name="header">
+ User name
+ </f:facet>
+ #{user.username}
+ </h:column>
+ <h:column id="enabled" width="auto">
+ <f:facet name="header">
+ Enabled
+ </f:facet>
+ <div class="#{user.enabled ? 'checkmark' : 'cross'}"/>
+ </h:column>
+ <h:column id="action" width="auto">
+ <f:facet name="header">
+ Action
+ </f:facet>
+
+ <ui:fragment rendered="#{identity.hasPermission('seam.user', 'update')}">
+ <h:commandLink id="edit" value="Edit" action="#{userAction.editUser(user.username)}"/>
+ <span> | </span>
+ </ui:fragment>
+ <h:link id="delete" value="Delete" action="#{identityManager.deleteUser(userSearch.selectedUser)}"
+ rendered="#{identity.hasPermission('seam.user', 'delete')}"
+ onclick="return confirmDelete()"/>
+ </h:column>
+ </h:dataTable>
+ </h:form>
<br style="clear:both"/>
Added: modules/security/trunk/examples/idmconsole/src/main/webapp/userdetail.xhtml
===================================================================
--- modules/security/trunk/examples/idmconsole/src/main/webapp/userdetail.xhtml (rev 0)
+++ modules/security/trunk/examples/idmconsole/src/main/webapp/userdetail.xhtml 2010-07-05 00:36:47 UTC (rev 13327)
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ template="/WEB-INF/templates/default.xhtml">
+
+ <ui:define name="sidebar">
+ <ui:include src="menu.xhtml"/>
+ </ui:define>
+
+ <ui:define name="content">
+
+ <div id="contentMain">
+
+ <h2>User Details</h2>
+
+ <h:messages globalOnly="true"/>
+
+ <h:form id="user">
+
+ <div class="formRow">
+ <h:outputLabel for="firstname" value="First name" styleClass="formLabel"/>
+ <h:inputText id="firstname" value="#{userAction.firstname}"/>
+ <div class="validationError"><h:message for="firstname"/></div>
+ </div>
+
+ <div class="formRow">
+ <h:outputLabel for="lastname" value="Last name" styleClass="formLabel"/>
+ <h:inputText id="lastname" value="#{userAction.lastname}"/>
+ <div class="validationError"><h:message for="lastname"/></div>
+ </div>
+
+ <div class="formRow">
+ <h:outputLabel for="username" value="Username" styleClass="formLabel"/>
+ <h:inputText id="username" value="#{userAction.username}"/>
+ <div class="validationError"><h:message for="username"/></div>
+ </div>
+
+ <div class="formRow">
+ <h:outputLabel for="password" value="Password" styleClass="formLabel"/>
+ <h:inputSecret id="password" value="#{userAction.password}"/>
+ <div class="validationError"><h:message for="password"/></div>
+ </div>
+
+ <div class="formRow">
+ <h:outputLabel for="confirm" value="Confirm password" styleClass="formLabel"/>
+ <h:inputSecret id="confirm" value="#{userAction.confirm}"/>
+ </div>
+
+ <div class="formRow">
+ <h:outputLabel for="roles" value="Member of" styleClass="formLabel"/>
+ <div class="selectMany">
+ <h:selectManyCheckbox id="roles" value="#{userAction.roles}" layout="pageDirection" styleClass="roles">
+ <!--s:selectItems value="#{identityManager.listGrantableRoles}" var="role" label="#{role}"/-->
+ </h:selectManyCheckbox>
+ </div>
+ <div class="validationError"><h:message for="roles"/></div>
+ </div>
+
+ <div class="formRow">
+ <h:outputLabel for="enabled" value="Account enabled" styleClass="formLabel"/>
+ <h:selectBooleanCheckbox id="enabled" value="#{userAction.enabled}"/>
+ </div>
+
+ <div class="formButtons">
+ <h:commandButton id="save" value="Save" action="#{userAction.save}" styleClass="formButton"/>
+ <h:commandButton id="cancel" view="/usermanager.xhtml" value="Cancel" styleClass="formButton"/>
+ </div>
+
+ <br class="clear"/>
+
+ </h:form>
+
+ </div>
+
+ </ui:define>
+
+</ui:composition>
+
Modified: modules/security/trunk/impl/pom.xml
===================================================================
--- modules/security/trunk/impl/pom.xml 2010-07-02 12:58:29 UTC (rev 13326)
+++ modules/security/trunk/impl/pom.xml 2010-07-05 00:36:47 UTC (rev 13327)
@@ -81,6 +81,13 @@
</dependency>
<dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-persistence</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
<groupId>org.picketlink.idm</groupId>
<artifactId>picketlink-idm-core</artifactId>
<exclusions>
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java 2010-07-02 12:58:29 UTC (rev 13326)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java 2010-07-05 00:36:47 UTC (rev 13327)
@@ -5,10 +5,11 @@
import java.util.Collection;
import java.util.List;
-import javax.enterprise.inject.Model;
+import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
+import org.jboss.seam.transaction.Transactional;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.util.Strings;
import org.picketlink.idm.api.Credential;
@@ -29,7 +30,7 @@
*
* @author Shane Bryzak
*/
- at Model
+ at RequestScoped @Transactional
public class IdentityManagerImpl implements IdentityManager, Serializable
{
private static final long serialVersionUID = 6864253169970552893L;
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-07-02 12:58:29 UTC (rev 13326)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-07-05 00:36:47 UTC (rev 13327)
@@ -14,7 +14,6 @@
import javax.persistence.EntityManager;
import javax.persistence.Id;
import javax.persistence.NoResultException;
-import javax.persistence.Query;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
@@ -917,7 +916,7 @@
}
public IdentityObject createIdentityObject(
- IdentityStoreInvocationContext invocationCtx, String name,
+ IdentityStoreInvocationContext ctx, String name,
IdentityObjectType identityObjectType, Map<String, String[]> attributes)
throws IdentityException
{
@@ -935,19 +934,20 @@
else
{
typeProp.setValue(identityInstance, lookupIdentityType(identityObjectType.getName(),
- getEntityManager(invocationCtx)));
+ getEntityManager(ctx)));
}
//beanManager.fireEvent(new PrePersistUserEvent(identityInstance));
- //entityManagerInstance.get().persist(identityInstance);
+ getEntityManager(ctx).persist(identityInstance);
//beanManager.fireEvent(new UserCreatedEvent(identityInstance));
// TODO persist attributes
+ Object id = modelProperties.get(PROPERTY_IDENTITY_ID).getValue(identityInstance);
IdentityObject obj = new IdentityObjectImpl(
- modelProperties.get(PROPERTY_IDENTITY_ID).getValue(identityInstance).toString(),
+ (id != null ? id.toString() : null),
name, identityObjectType);
return obj;
Added: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserDTO.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserDTO.java (rev 0)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserDTO.java 2010-07-05 00:36:47 UTC (rev 13327)
@@ -0,0 +1,32 @@
+package org.jboss.seam.security.management.action;
+
+/**
+ * Used to transfer user information to a view layer
+ *
+ * @author Shane Bryzak
+ */
+public class UserDTO
+{
+ private String username;
+ private boolean enabled;
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserSearch.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserSearch.java 2010-07-02 12:58:29 UTC (rev 13326)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserSearch.java 2010-07-05 00:36:47 UTC (rev 13327)
@@ -1,6 +1,7 @@
package org.jboss.seam.security.management.action;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.SessionScoped;
@@ -15,16 +16,22 @@
{
private static final long serialVersionUID = 8592034786339372510L;
- List<String> users;
-
- //@DataModelSelection
- //String selectedUser;
-
+ List<UserDTO> users;
+
@Inject IdentityManager identityManager;
@Inject public void loadUsers()
- {
- users = identityManager.findUsers(null);
+ {
+ users = new ArrayList<UserDTO>();
+
+ List<String> usernames = identityManager.findUsers(null);
+ for (String username : usernames)
+ {
+ UserDTO dto = new UserDTO();
+ dto.setUsername(username);
+ dto.setEnabled(identityManager.isUserEnabled(username));
+ users.add(dto);
+ }
}
public String getUserRoles(String username)
@@ -49,7 +56,7 @@
//return selectedUser;
//}
- public List<String> getUsers()
+ public List<UserDTO> getUsers()
{
return users;
}
More information about the seam-commits
mailing list