Author: shane.bryzak(a)jboss.com
Date: 2010-01-11 20:12:46 -0500 (Mon, 11 Jan 2010)
New Revision: 11945
Modified:
modules/security/trunk/src/main/java/org/jboss/seam/security/Identity.java
modules/security/trunk/src/main/java/org/jboss/seam/security/JpaTokenStore.java
modules/security/trunk/src/main/java/org/jboss/seam/security/RememberMe.java
modules/security/trunk/src/main/java/org/jboss/seam/security/SecurityInterceptor.java
modules/security/trunk/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java
modules/security/trunk/src/main/java/org/jboss/seam/security/management/IdentityManager.java
modules/security/trunk/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
modules/security/trunk/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java
modules/security/trunk/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java
modules/security/trunk/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java
Log:
start fixing compiler errors
Modified: modules/security/trunk/src/main/java/org/jboss/seam/security/Identity.java
===================================================================
--- modules/security/trunk/src/main/java/org/jboss/seam/security/Identity.java 2010-01-11
09:17:43 UTC (rev 11944)
+++ modules/security/trunk/src/main/java/org/jboss/seam/security/Identity.java 2010-01-12
01:12:46 UTC (rev 11945)
@@ -14,6 +14,7 @@
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.security.auth.Subject;
@@ -26,7 +27,6 @@
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
-import org.jboss.seam.beans.BeanManagerHelper;
import org.jboss.seam.el.Expressions;
import org.jboss.seam.security.callbacks.AuthenticatorCallback;
import org.jboss.seam.security.callbacks.IdentityCallback;
@@ -42,9 +42,10 @@
import org.jboss.seam.security.events.QuietLoginEvent;
import org.jboss.seam.security.management.IdentityManager;
import org.jboss.seam.security.permission.PermissionMapper;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* API for authorization and authentication via Seam security.
*
@@ -60,13 +61,17 @@
public static final String ROLES_GROUP = "Roles";
- @Logger Log log;
+ Logger log = LoggerFactory.getLogger(Identity.class);
@Inject private BeanManager manager;
@Inject private Credentials credentials;
@Inject private PermissionMapper permissionMapper;
@Inject private Expressions expressions;
+ @Inject private IdentityManager identityManager;
+
+ @Inject Instance<RequestSecurityState> requestSecurityState;
+
private Principal principal;
private Subject subject;
private String jaasConfigName = null;
@@ -114,12 +119,11 @@
* @return true if the user is logged in, false otherwise
*/
public boolean tryLogin()
- {
- RequestSecurityState state = BeanManagerHelper.getInstanceByType(manager,
RequestSecurityState.class);
-
- if (!authenticating && getPrincipal() == null &&
credentials.isSet() && !state.isLoginTried())
+ {
+ if (!authenticating && getPrincipal() == null &&
credentials.isSet() &&
+ !requestSecurityState.get().isLoginTried())
{
- state.setLoginTried(true);
+ requestSecurityState.get().setLoginTried(true);
quietLogin();
}
@@ -212,8 +216,7 @@
// If authentication has already occurred during this request via a silent
login,
// and login() is explicitly called then we still want to raise the
LOGIN_SUCCESSFUL event,
// and then return.
- RequestSecurityState state = BeanManagerHelper.getInstanceByType(manager,
RequestSecurityState.class);
- if (state.isSilentLogin())
+ if (requestSecurityState.get().isSilentLogin())
{
manager.fireEvent(new LoggedInEvent(principal));
return "loggedIn";
@@ -271,10 +274,9 @@
{
authenticate();
- RequestSecurityState state = BeanManagerHelper.getInstanceByType(manager,
RequestSecurityState.class);
if (isLoggedIn())
{
- state.setSilentLogin(true);
+ requestSecurityState.get().setSilentLogin(true);
}
}
}
@@ -401,7 +403,6 @@
{
final Identity identity = this;
final Authenticator authenticator;
- final IdentityManager identityManager =
BeanManagerHelper.getInstanceByType(manager, IdentityManager.class);
Set<Bean<?>> authenticators = manager.getBeans(Authenticator.class);
if (authenticators.size() == 1)
Modified: modules/security/trunk/src/main/java/org/jboss/seam/security/JpaTokenStore.java
===================================================================
---
modules/security/trunk/src/main/java/org/jboss/seam/security/JpaTokenStore.java 2010-01-11
09:17:43 UTC (rev 11944)
+++
modules/security/trunk/src/main/java/org/jboss/seam/security/JpaTokenStore.java 2010-01-12
01:12:46 UTC (rev 11945)
@@ -4,12 +4,12 @@
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.Query;
-import org.jboss.seam.beans.BeanManagerHelper;
import org.jboss.seam.security.annotations.TokenUsername;
import org.jboss.seam.security.annotations.TokenValue;
import org.jboss.seam.security.management.IdentityManagementException;
@@ -32,6 +32,8 @@
@Inject BeanManager manager;
+ @Inject Instance<EntityManager> entityManagerInstance;
+
@Inject
public void create()
{
@@ -138,6 +140,6 @@
private EntityManager lookupEntityManager()
{
- return BeanManagerHelper.getInstanceByType(manager, EntityManager.class);
+ return entityManagerInstance.get();
}
}
Modified: modules/security/trunk/src/main/java/org/jboss/seam/security/RememberMe.java
===================================================================
---
modules/security/trunk/src/main/java/org/jboss/seam/security/RememberMe.java 2010-01-11
09:17:43 UTC (rev 11944)
+++
modules/security/trunk/src/main/java/org/jboss/seam/security/RememberMe.java 2010-01-12
01:12:46 UTC (rev 11945)
@@ -12,7 +12,6 @@
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Named;
-import org.jboss.seam.beans.BeanManagerHelper;
import org.jboss.seam.security.events.CredentialsInitializedEvent;
import org.jboss.seam.security.events.LoggedOutEvent;
import org.jboss.seam.security.events.PostAuthenticateEvent;
@@ -31,7 +30,7 @@
*
* @author Shane Bryzak
*/
-(a)Named//("org.jboss.seam.security.rememberMe")
+@Named
@SessionScoped
public class RememberMe implements Serializable
{
Modified:
modules/security/trunk/src/main/java/org/jboss/seam/security/SecurityInterceptor.java
===================================================================
---
modules/security/trunk/src/main/java/org/jboss/seam/security/SecurityInterceptor.java 2010-01-11
09:17:43 UTC (rev 11944)
+++
modules/security/trunk/src/main/java/org/jboss/seam/security/SecurityInterceptor.java 2010-01-12
01:12:46 UTC (rev 11945)
@@ -15,7 +15,6 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
-import org.jboss.seam.beans.BeanManagerHelper;
import org.jboss.seam.security.annotations.PermissionCheck;
import org.jboss.seam.security.annotations.Restrict;
import org.jboss.seam.security.annotations.RoleCheck;
@@ -38,6 +37,7 @@
private transient volatile Map<Method,Restriction> restrictions = new
HashMap<Method,Restriction>();
@Inject BeanManager manager;
+ @Inject Identity identity;
private class Restriction
{
@@ -162,7 +162,7 @@
Restriction restriction = getRestriction(interfaceMethod);
if ( restriction != null )
{
- Identity identity = BeanManagerHelper.getInstanceByType(manager,
Identity.class);
+
restriction.check(identity, invocation.getParameters());
}
}
Modified:
modules/security/trunk/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java
===================================================================
---
modules/security/trunk/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java 2010-01-11
09:17:43 UTC (rev 11944)
+++
modules/security/trunk/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java 2010-01-12
01:12:46 UTC (rev 11945)
@@ -21,9 +21,10 @@
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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Performs authentication using a Seam component or Identity Management
*
@@ -31,7 +32,7 @@
*/
public class SeamLoginModule implements LoginModule
{
- private static final LogProvider log = Logging.getLogProvider(SeamLoginModule.class);
+ private Logger log = LoggerFactory.getLogger(SeamLoginModule.class);
protected Set<String> roles = new HashSet<String>();
Modified:
modules/security/trunk/src/main/java/org/jboss/seam/security/management/IdentityManager.java
===================================================================
---
modules/security/trunk/src/main/java/org/jboss/seam/security/management/IdentityManager.java 2010-01-11
09:17:43 UTC (rev 11944)
+++
modules/security/trunk/src/main/java/org/jboss/seam/security/management/IdentityManager.java 2010-01-12
01:12:46 UTC (rev 11945)
@@ -7,16 +7,14 @@
import java.util.List;
import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import javax.inject.Named;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import org.jboss.seam.beans.BeanManagerHelper;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.util.Strings;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Identity Management API, deals with user name/password-based identity management.
@@ -37,28 +35,17 @@
public static final String PERMISSION_UPDATE = "update";
public static final String PERMISSION_DELETE = "delete";
- @Logger Log log;
+ private Logger log = LoggerFactory.getLogger(IdentityManager.class);
@Inject BeanManager manager;
@Inject Identity identity;
- private IdentityStore identityStore;
+ @Inject private IdentityStore identityStore;
private IdentityStore roleIdentityStore;
@Inject
public void create()
{
- initIdentityStore();
- }
-
- protected void initIdentityStore()
- {
- // Default to JpaIdentityStore
- if (identityStore == null)
- {
- identityStore =
BeanManagerHelper.getInstanceByType(manager,JpaIdentityStore.class);
- }
-
if (roleIdentityStore == null && identityStore != null)
{
roleIdentityStore = identityStore;
Modified:
modules/security/trunk/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
---
modules/security/trunk/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-01-11
09:17:43 UTC (rev 11944)
+++
modules/security/trunk/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-01-12
01:12:46 UTC (rev 11945)
@@ -13,12 +13,12 @@
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
-import org.jboss.seam.beans.BeanManagerHelper;
import org.jboss.seam.security.Role;
import org.jboss.seam.security.SimplePrincipal;
import org.jboss.seam.security.crypto.BinTools;
@@ -26,9 +26,10 @@
import org.jboss.seam.security.events.PrePersistUserRoleEvent;
import org.jboss.seam.security.events.UserAuthenticatedEvent;
import org.jboss.seam.security.events.UserCreatedEvent;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* The default identity store implementation, uses JPA as its persistence mechanism.
*
@@ -41,9 +42,11 @@
protected FeatureSet featureSet;
- @Logger Log log;
+ private Logger log = LoggerFactory.getLogger(JpaIdentityStore.class);
@PersistenceContext EntityManager entityManager;
+
+ @Inject Instance<PasswordHash> passwordHashInstance;
private JpaIdentityStoreConfig config;
private BeanManager manager;
@@ -904,6 +907,6 @@
protected PasswordHash getPasswordHash()
{
- return BeanManagerHelper.getInstanceByType(manager, PasswordHash.class);
+ return passwordHashInstance.get();
}
}
Modified:
modules/security/trunk/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java
===================================================================
---
modules/security/trunk/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java 2010-01-11
09:17:43 UTC (rev 11944)
+++
modules/security/trunk/src/main/java/org/jboss/seam/security/management/LdapIdentityStore.java 2010-01-12
01:12:46 UTC (rev 11945)
@@ -22,8 +22,8 @@
import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* An IdentityStore implementation that integrates with a directory service.
@@ -39,7 +39,7 @@
private static final String LDAP_BOOLEAN_TRUE = "TRUE";
private static final String LDAP_BOOLEAN_FALSE = "FALSE";
- @Logger Log log;
+ private Logger log = LoggerFactory.getLogger(LdapIdentityStore.class);
protected FeatureSet featureSet = new FeatureSet();
Modified:
modules/security/trunk/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java
===================================================================
---
modules/security/trunk/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java 2010-01-11
09:17:43 UTC (rev 11944)
+++
modules/security/trunk/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java 2010-01-12
01:12:46 UTC (rev 11945)
@@ -4,11 +4,11 @@
import java.util.concurrent.ConcurrentHashMap;
import javax.inject.Inject;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
-import org.jboss.seam.beans.BeanManagerHelper;
import org.jboss.seam.el.Expressions;
import org.jboss.seam.security.annotations.permission.Identifier;
import org.jboss.seam.security.util.Strings;
@@ -23,8 +23,10 @@
private Map<Class,String> identifierNames = new
ConcurrentHashMap<Class,String>();
//@Inject PersistenceProvider persistenceProvider;
- @Inject Expressions expressions;
+ //@Inject Expressions expressions;
+
@Inject BeanManager manager;
+ @Inject Instance<EntityManager> entityManagerInstance;
public boolean canIdentify(Class targetClass)
{
@@ -71,6 +73,7 @@
private EntityManager lookupEntityManager()
{
//return entityManager.getValue();
- return BeanManagerHelper.getInstanceByType(manager, EntityManager.class);
+ //return BeanManagerHelper.getInstanceByType(manager, EntityManager.class);
+ return entityManagerInstance.get();
}
}
Modified:
modules/security/trunk/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java
===================================================================
---
modules/security/trunk/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2010-01-11
09:17:43 UTC (rev 11944)
+++
modules/security/trunk/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2010-01-12
01:12:46 UTC (rev 11945)
@@ -15,7 +15,6 @@
import javax.persistence.EntityManager;
import javax.persistence.Query;
-import org.jboss.seam.beans.BeanManagerHelper;
import org.jboss.seam.security.Role;
import org.jboss.seam.security.SimplePrincipal;
import org.jboss.seam.security.annotations.permission.PermissionAction;
@@ -26,10 +25,11 @@
import org.jboss.seam.security.management.IdentityManager;
import org.jboss.seam.security.management.JpaIdentityStore;
import org.jboss.seam.security.management.JpaIdentityStoreConfig;
+import org.jboss.seam.security.management.LdapIdentityStore;
import org.jboss.seam.security.permission.PermissionMetadata.ActionSet;
import org.jboss.seam.security.util.AnnotatedBeanProperty;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A permission store implementation that uses JPA as its persistence mechanism.
@@ -41,7 +41,7 @@
{
private static final long serialVersionUID = 4764590939669047915L;
- @Logger Log log;
+ private Logger log = LoggerFactory.getLogger(LdapIdentityStore.class);
private enum Discrimination { user, role, either }