[seam-commits] Seam SVN: r10599 - in modules/trunk/security/src/main/java/org/jboss/seam/security: callbacks and 3 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed Apr 22 20:37:41 EDT 2009
Author: shane.bryzak at jboss.com
Date: 2009-04-22 20:37:40 -0400 (Wed, 22 Apr 2009)
New Revision: 10599
Added:
modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/
modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/AuthenticatorCallback.java
modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/IdentityCallback.java
modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/IdentityManagerCallback.java
modules/trunk/security/src/main/java/org/jboss/seam/security/util/
modules/trunk/security/src/main/java/org/jboss/seam/security/util/Strings.java
Modified:
modules/trunk/security/src/main/java/org/jboss/seam/security/Authenticator.java
modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java
modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java
modules/trunk/security/src/main/java/org/jboss/seam/security/JaasConfiguration.java
modules/trunk/security/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java
Log:
fix SeamLoginModule
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/Authenticator.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/Authenticator.java 2009-04-22 22:55:46 UTC (rev 10598)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/Authenticator.java 2009-04-23 00:37:40 UTC (rev 10599)
@@ -7,5 +7,5 @@
*/
public interface Authenticator
{
- void authenticate();
+ boolean authenticate();
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java 2009-04-22 22:55:46 UTC (rev 10598)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/Credentials.java 2009-04-23 00:37:40 UTC (rev 10599)
@@ -109,37 +109,5 @@
public String toString()
{
return "Credentials[" + username + "]";
- }
-
-
- /**
- * Creates a callback handler that can handle a standard username/password
- * callback, using the username and password properties.
- */
- public CallbackHandler createCallbackHandler()
- {
- return new CallbackHandler()
- {
- public void handle(Callback[] callbacks)
- throws IOException, UnsupportedCallbackException
- {
- for (int i=0; i < callbacks.length; i++)
- {
- if (callbacks[i] instanceof NameCallback)
- {
- ( (NameCallback) callbacks[i] ).setName(getUsername());
- }
- else if (callbacks[i] instanceof PasswordCallback)
- {
- ( (PasswordCallback) callbacks[i] ).setPassword( getPassword() != null ?
- getPassword().toCharArray() : null );
- }
- else
- {
- log.warn("Unsupported callback " + callbacks[i]);
- }
- }
- }
- };
- }
+ }
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java 2009-04-22 22:55:46 UTC (rev 10598)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/Identity.java 2009-04-23 00:37:40 UTC (rev 10599)
@@ -1,5 +1,6 @@
package org.jboss.seam.security;
+import java.io.IOException;
import java.io.Serializable;
import java.security.Principal;
import java.security.acl.Group;
@@ -7,18 +8,29 @@
import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
+import java.util.Set;
import javax.annotation.Named;
import javax.context.SessionScoped;
import javax.inject.Current;
import javax.inject.Initializer;
+import javax.inject.manager.Bean;
import javax.inject.manager.Manager;
import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.Configuration;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.seam.security.callbacks.AuthenticatorCallback;
+import org.jboss.seam.security.callbacks.IdentityCallback;
+import org.jboss.seam.security.callbacks.IdentityManagerCallback;
import org.jboss.seam.security.events.AlreadyLoggedInEvent;
import org.jboss.seam.security.events.LoggedInEvent;
import org.jboss.seam.security.events.LoggedOutEvent;
@@ -28,6 +40,7 @@
import org.jboss.seam.security.events.PostAuthenticateEvent;
import org.jboss.seam.security.events.PreAuthenticateEvent;
import org.jboss.seam.security.events.QuietLoginEvent;
+import org.jboss.seam.security.management.IdentityManager;
import org.jboss.seam.security.permission.PermissionMapper;
/**
@@ -78,12 +91,6 @@
{
securityEnabled = enabled;
}
-
- public static Identity instance()
- {
- // TODO - implement
- return null;
- }
/**
* Simple check that returns true if the user is logged in, without attempting to authenticate
@@ -348,13 +355,75 @@
if (getJaasConfigName() != null)
{
return new LoginContext(getJaasConfigName(), getSubject(),
- credentials.createCallbackHandler());
+ createCallbackHandler());
}
+ Bean<Configuration> configBean = manager.resolveByType(Configuration.class).iterator().next();
+ Configuration config = manager.getInstance(configBean);
+
return new LoginContext(JaasConfiguration.DEFAULT_JAAS_CONFIG_NAME, getSubject(),
- credentials.createCallbackHandler(), JaasConfiguration.instance());
+ createCallbackHandler(), config);
}
+
+ /**
+ * Creates a callback handler that can handle a standard username/password
+ * callback, using the credentials username and password properties
+ */
+ public CallbackHandler createCallbackHandler()
+ {
+ final Identity identity = this;
+ final Authenticator authenticator;
+ final IdentityManager identityManager = manager.getInstanceByType(IdentityManager.class);
+
+ Set<Bean<Authenticator>> authenticators = manager.resolveByType(Authenticator.class);
+ if (authenticators.size() > 0)
+ {
+ Bean<Authenticator> authenticatorBean = authenticators.iterator().next();
+ authenticator = manager.getInstance(authenticatorBean);
+ }
+ else
+ {
+ authenticator = null;
+ }
+
+ return new CallbackHandler()
+ {
+ public void handle(Callback[] callbacks)
+ throws IOException, UnsupportedCallbackException
+ {
+ for (int i=0; i < callbacks.length; i++)
+ {
+ if (callbacks[i] instanceof NameCallback)
+ {
+ ( (NameCallback) callbacks[i] ).setName(credentials.getUsername());
+ }
+ else if (callbacks[i] instanceof PasswordCallback)
+ {
+ ( (PasswordCallback) callbacks[i] ).setPassword( credentials.getPassword() != null ?
+ credentials.getPassword().toCharArray() : null );
+ }
+ else if (callbacks[i] instanceof IdentityCallback)
+ {
+ ((IdentityCallback ) callbacks[i]).setIdentity(identity);
+ }
+ else if (callbacks[i] instanceof AuthenticatorCallback)
+ {
+ ((AuthenticatorCallback) callbacks[i]).setAuthenticator(authenticator);
+ }
+ else if (callbacks[i] instanceof IdentityManagerCallback)
+ {
+ ((IdentityManagerCallback) callbacks[i]).setIdentityManager(identityManager);
+ }
+ else
+ {
+ log.warn("Unsupported callback " + callbacks[i]);
+ }
+ }
+ }
+ };
+ }
+
public void logout()
{
if (isLoggedIn())
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/JaasConfiguration.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/JaasConfiguration.java 2009-04-22 22:55:46 UTC (rev 10598)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/JaasConfiguration.java 2009-04-23 00:37:40 UTC (rev 10599)
@@ -5,12 +5,13 @@
import javax.context.ApplicationScoped;
import javax.inject.Produces;
import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
import org.jboss.seam.security.jaas.SeamLoginModule;
/**
- * Factory for the JAAS Configuration used by Seam Security.
+ * Producer for the JAAS Configuration used by Seam Security.
*
* @author Shane Bryzak
*
@@ -19,9 +20,9 @@
{
static final String DEFAULT_JAAS_CONFIG_NAME = "default";
- protected javax.security.auth.login.Configuration createConfiguration()
+ protected Configuration createConfiguration()
{
- return new javax.security.auth.login.Configuration()
+ return new Configuration()
{
private AppConfigurationEntry[] aces = { createAppConfigurationEntry() };
@@ -45,7 +46,7 @@
);
}
- @Produces @ApplicationScoped javax.security.auth.login.Configuration getConfiguration()
+ @Produces @ApplicationScoped Configuration getConfiguration()
{
return createConfiguration();
}
Added: modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/AuthenticatorCallback.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/AuthenticatorCallback.java (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/AuthenticatorCallback.java 2009-04-23 00:37:40 UTC (rev 10599)
@@ -0,0 +1,29 @@
+package org.jboss.seam.security.callbacks;
+
+import java.io.Serializable;
+
+import javax.security.auth.callback.Callback;
+
+import org.jboss.seam.security.Authenticator;
+
+/**
+ * This callback implementation is used to provide an instance of the Authenticator bean to the LoginModule
+ *
+ * @author Shane Bryzak
+ */
+public class AuthenticatorCallback implements Serializable, Callback
+{
+ private static final long serialVersionUID = -6186364148255506167L;
+
+ private Authenticator authenticator;
+
+ public Authenticator getAuthenticator()
+ {
+ return authenticator;
+ }
+
+ public void setAuthenticator(Authenticator authenticator)
+ {
+ this.authenticator = authenticator;
+ }
+}
Added: modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/IdentityCallback.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/IdentityCallback.java (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/IdentityCallback.java 2009-04-23 00:37:40 UTC (rev 10599)
@@ -0,0 +1,29 @@
+package org.jboss.seam.security.callbacks;
+
+import java.io.Serializable;
+
+import javax.security.auth.callback.Callback;
+
+import org.jboss.seam.security.Identity;
+
+/**
+ * This callback implementation is used to provide an instance of the Identity bean to the LoginModule
+ *
+ * @author Shane Bryzak
+ */
+public class IdentityCallback implements Serializable, Callback
+{
+ private static final long serialVersionUID = 5720975438991518059L;
+
+ private Identity identity;
+
+ public void setIdentity(Identity identity)
+ {
+ this.identity = identity;
+ }
+
+ public Identity getIdentity()
+ {
+ return identity;
+ }
+}
Added: modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/IdentityManagerCallback.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/IdentityManagerCallback.java (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/callbacks/IdentityManagerCallback.java 2009-04-23 00:37:40 UTC (rev 10599)
@@ -0,0 +1,29 @@
+package org.jboss.seam.security.callbacks;
+
+import java.io.Serializable;
+
+import javax.security.auth.callback.Callback;
+
+import org.jboss.seam.security.management.IdentityManager;
+
+/**
+ * This callback implementation is used to provide an instance of the IdentityManager bean to the LoginModule
+ *
+ * @author Shane Bryzak
+ */
+public class IdentityManagerCallback implements Serializable, Callback
+{
+ private static final long serialVersionUID = 8430300053672194472L;
+
+ private IdentityManager identityManager;
+
+ public IdentityManager getIdentityManager()
+ {
+ return identityManager;
+ }
+
+ public void setIdentityManager(IdentityManager identityManager)
+ {
+ this.identityManager = identityManager;
+ }
+}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java 2009-04-22 22:55:46 UTC (rev 10598)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java 2009-04-23 00:37:40 UTC (rev 10599)
@@ -7,7 +7,6 @@
import java.util.Map;
import java.util.Set;
-import javax.inject.manager.Manager;
import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
@@ -16,15 +15,17 @@
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-import org.jboss.seam.security.Identity;
import org.jboss.seam.security.SimpleGroup;
import org.jboss.seam.security.SimplePrincipal;
+import org.jboss.seam.security.callbacks.AuthenticatorCallback;
+import org.jboss.seam.security.callbacks.IdentityCallback;
+import org.jboss.seam.security.callbacks.IdentityManagerCallback;
import org.jboss.seam.security.management.IdentityManager;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
/**
- * Performs authentication using a Seam component
+ * Performs authentication using a Seam component or Identity Management
*
* @author Shane Bryzak
*/
@@ -82,74 +83,63 @@
public boolean login()
throws LoginException
- {
+ {
+ PasswordCallback cbPassword = null;
try
{
NameCallback cbName = new NameCallback("Enter username");
- PasswordCallback cbPassword = new PasswordCallback("Enter password", false);
-
- // Get the username and password from the callback handler
- callbackHandler.handle(new Callback[] { cbName, cbPassword });
- username = cbName.getName();
- }
- catch (Exception ex)
- {
- log.error("Error logging in", ex);
- LoginException le = new LoginException(ex.getMessage());
- le.initCause(ex);
- throw le;
- }
+ cbPassword = new PasswordCallback("Enter password", false);
+
+ IdentityCallback idCallback = new IdentityCallback();
+ AuthenticatorCallback authCallback = new AuthenticatorCallback();
+ IdentityManagerCallback idmCallback = new IdentityManagerCallback();
- // If an authentication method has been specified, use that to authenticate
- MethodExpression mb = Identity.instance().getAuthenticateMethod();
- if (mb != null)
- {
- try
- {
- return (Boolean) mb.invoke();
- }
- catch (Exception ex)
- {
- log.error("Error invoking login method", ex);
- throw new LoginException(ex.getMessage());
- }
- }
-
- // Otherwise if identity management is enabled, use it.
- IdentityManager identityManager = IdentityManager.instance();
- if (identityManager != null && identityManager.isEnabled())
- {
- Identity identity = Identity.instance();
+ // Get the username, password and identity from the callback handler
+ callbackHandler.handle(new Callback[] { cbName, cbPassword, idCallback, authCallback, idmCallback });
- try
+ username = cbName.getName();
+
+ // If an authenticator method has been specified, use that to authenticate
+ if (authCallback.getAuthenticator() != null)
{
- boolean success = identityManager.authenticate(username, identity.getCredentials().getPassword());
+ return authCallback.getAuthenticator().authenticate();
+ }
+
+ // Otherwise if identity management is enabled, use it.
+ IdentityManager identityManager = idmCallback.getIdentityManager();
+ if (identityManager != null && identityManager.isEnabled())
+ {
+ boolean success = identityManager.authenticate(username,
+ new String(cbPassword.getPassword()));
if (success)
{
for (String role : identityManager.getImpliedRoles(username))
{
- identity.addRole(role);
+ idCallback.getIdentity().addRole(role);
}
}
return success;
}
- catch (Exception ex)
+ else
{
- log.error("Error invoking login method", ex);
- LoginException le = new LoginException(ex.getMessage());
- le.initCause(ex);
- throw le;
+ log.error("No authentication method defined - " +
+ "please define authenticate-method for <security:identity/> in components.xml");
+ throw new LoginException("No authentication method defined");
}
}
- else
+ catch (Exception ex)
{
- log.error("No authentication method defined - " +
- "please define authenticate-method for <security:identity/> in components.xml");
- throw new LoginException("No authentication method defined");
+ log.error("Error logging in", ex);
+ LoginException le = new LoginException(ex.getMessage());
+ le.initCause(ex);
+ throw le;
+ }
+ finally
+ {
+ cbPassword.clearPassword();
}
-
}
public boolean logout() throws LoginException
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java 2009-04-22 22:55:46 UTC (rev 10598)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/IdentityManager.java 2009-04-23 00:37:40 UTC (rev 10599)
@@ -1,37 +1,33 @@
package org.jboss.seam.security.management;
-import static org.jboss.seam.ScopeType.EVENT;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
import java.io.Serializable;
import java.security.Principal;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import org.jboss.seam.Component;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.log.LogProvider;
-import org.jboss.seam.log.Logging;
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.inject.Current;
+import javax.inject.Initializer;
+import javax.inject.manager.Manager;
+
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
import org.jboss.seam.security.Identity;
-import org.jboss.seam.util.Strings;
+import org.jboss.seam.security.util.Strings;
/**
* Identity Management API, deals with user name/password-based identity management.
*
* @author Shane Bryzak
*/
- at Scope(EVENT)
- at Name("org.jboss.seam.security.identityManager")
- at Install(precedence = BUILT_IN)
- at BypassInterceptors
+ at Named
+ at RequestScoped
public class IdentityManager implements Serializable
{
+ private static final long serialVersionUID = 6864253169970552893L;
+
public static final String USER_PERMISSION_NAME = "seam.user";
public static final String ROLE_PERMISSION_NAME = "seam.role";
@@ -45,7 +41,10 @@
private IdentityStore identityStore;
private IdentityStore roleIdentityStore;
- @Create
+ @Current Manager manager;
+ @Current Identity identity;
+
+ @Initializer
public void create()
{
initIdentityStore();
@@ -55,7 +54,7 @@
{
// Default to JpaIdentityStore
if (identityStore == null)
- {
+ {
identityStore = (IdentityStore) Component.getInstance(JpaIdentityStore.class, true);
}
@@ -71,24 +70,6 @@
}
}
- public static IdentityManager instance()
- {
- if ( !Contexts.isEventContextActive() )
- {
- throw new IllegalStateException("No active event context");
- }
-
- IdentityManager instance = (IdentityManager) Component.getInstance(
- IdentityManager.class, EVENT);
-
- if (instance == null)
- {
- throw new IllegalStateException("No IdentityManager could be created");
- }
-
- return instance;
- }
-
public boolean createUser(String name, String password)
{
return createUser(name, password, null, null);
@@ -96,79 +77,79 @@
public boolean createUser(String name, String password, String firstname, String lastname)
{
- Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_CREATE);
+ identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_CREATE);
return identityStore.createUser(name, password, firstname, lastname);
}
public boolean deleteUser(String name)
{
- Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_DELETE);
+ identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_DELETE);
return identityStore.deleteUser(name);
}
public boolean enableUser(String name)
{
- Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
return identityStore.enableUser(name);
}
public boolean disableUser(String name)
{
- Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
return identityStore.disableUser(name);
}
public boolean changePassword(String name, String password)
{
- Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
return identityStore.changePassword(name, password);
}
public boolean isUserEnabled(String name)
{
- Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
+ identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
return identityStore.isUserEnabled(name);
}
public boolean grantRole(String name, String role)
{
- Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
return roleIdentityStore.grantRole(name, role);
}
public boolean revokeRole(String name, String role)
{
- Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
return roleIdentityStore.revokeRole(name, role);
}
public boolean createRole(String role)
{
- Identity.instance().checkPermission(ROLE_PERMISSION_NAME, PERMISSION_CREATE);
+ identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_CREATE);
return roleIdentityStore.createRole(role);
}
public boolean deleteRole(String role)
{
- Identity.instance().checkPermission(ROLE_PERMISSION_NAME, PERMISSION_DELETE);
+ identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_DELETE);
return roleIdentityStore.deleteRole(role);
}
public boolean addRoleToGroup(String role, String group)
{
- Identity.instance().checkPermission(ROLE_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_UPDATE);
return roleIdentityStore.addRoleToGroup(role, group);
}
public boolean removeRoleFromGroup(String role, String group)
{
- Identity.instance().checkPermission(ROLE_PERMISSION_NAME, PERMISSION_UPDATE);
+ identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_UPDATE);
return roleIdentityStore.removeRoleFromGroup(role, group);
}
public boolean userExists(String name)
{
- Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
+ identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
return identityStore.userExists(name);
}
@@ -179,7 +160,7 @@
public List<String> listUsers()
{
- Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
+ identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
List<String> users = identityStore.listUsers();
Collections.sort(users, new Comparator<String>() {
@@ -193,7 +174,7 @@
public List<String> listUsers(String filter)
{
- Identity.instance().checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
+ identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
List<String> users = identityStore.listUsers(filter);
Collections.sort(users, new Comparator<String>() {
@@ -207,7 +188,7 @@
public List<String> listRoles()
{
- Identity.instance().checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
+ identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
List<String> roles = roleIdentityStore.listRoles();
Collections.sort(roles, new Comparator<String>() {
@@ -256,7 +237,7 @@
public List<Principal> listMembers(String role)
{
- Identity.instance().checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
+ identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
return roleIdentityStore.listMembers(role);
}
Added: modules/trunk/security/src/main/java/org/jboss/seam/security/util/Strings.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/util/Strings.java (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/util/Strings.java 2009-04-23 00:37:40 UTC (rev 10599)
@@ -0,0 +1,22 @@
+package org.jboss.seam.security.util;
+
+public class Strings
+{
+ public static boolean isEmpty(String string)
+ {
+ int len;
+ if (string == null || (len = string.length()) == 0)
+ {
+ return true;
+ }
+
+ for (int i = 0; i < len; i++)
+ {
+ if ((Character.isWhitespace(string.charAt(i)) == false))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+}
More information about the seam-commits
mailing list