[seam-commits] Seam SVN: r13090 - modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed Jun 9 04:44:06 EDT 2010
Author: shane.bryzak at jboss.com
Date: 2010-06-09 04:44:06 -0400 (Wed, 09 Jun 2010)
New Revision: 13090
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java
Log:
start implementing methods
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-06-09 08:43:31 UTC (rev 13089)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java 2010-06-09 08:44:06 UTC (rev 13090)
@@ -3,17 +3,19 @@
import java.io.Serializable;
import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Model;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
-import javax.inject.Named;
import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.UserImpl;
import org.jboss.seam.security.util.Strings;
import org.picketlink.idm.api.Credential;
+import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.IdentityType;
import org.picketlink.idm.api.Role;
+import org.picketlink.idm.api.User;
+import org.picketlink.idm.common.exception.IdentityException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -22,7 +24,7 @@
*
* @author Shane Bryzak
*/
- at Named @ApplicationScoped
+ at Model
public class IdentityManagerImpl implements IdentityManager, Serializable
{
private static final long serialVersionUID = 6864253169970552893L;
@@ -41,24 +43,36 @@
@Inject BeanManager manager;
@Inject Identity identity;
- @PostConstruct
- public void create()
- {
-
- }
+ @Inject IdentitySession identitySession;
public boolean createUser(String name, Credential credential)
{
identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_CREATE);
- //return identityStore.createUser(name, credential, null);
- return false;
+ try
+ {
+ User user = identitySession.getPersistenceManager().createUser(name);
+ identitySession.getAttributesManager().updateCredential(user, credential);
+ return true;
+ }
+ catch (IdentityException ex)
+ {
+ throw new RuntimeException("Error creating user", ex);
+ }
}
public boolean deleteUser(String name)
{
identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_DELETE);
- //return identityStore.deleteUser(name);
- return false;
+
+ try
+ {
+ identitySession.getPersistenceManager().removeUser(name, true);
+ return true;
+ }
+ catch (IdentityException ex)
+ {
+ throw new RuntimeException("Failed to delete user", ex);
+ }
}
public boolean enableUser(String name)
@@ -78,8 +92,16 @@
public boolean updateCredential(String name, Credential credential)
{
identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
- //return identityStore.updateCredential(name, credential);
- return false;
+
+ try
+ {
+ identitySession.getAttributesManager().updateCredential(new UserImpl(name), credential);
+ return true;
+ }
+ catch (IdentityException ex)
+ {
+ throw new RuntimeException("Exception updating credential", ex);
+ }
}
public boolean isUserEnabled(String name)
More information about the seam-commits
mailing list