[seam-commits] Seam SVN: r10737 - in modules/trunk/security: src/main/java/org/jboss/seam/security and 3 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Apr 30 21:17:13 EDT 2009
Author: shane.bryzak at jboss.com
Date: 2009-04-30 21:17:13 -0400 (Thu, 30 Apr 2009)
New Revision: 10737
Modified:
modules/trunk/security/pom.xml
modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java
modules/trunk/security/src/main/java/org/jboss/seam/security/EntitySecurityListener.java
modules/trunk/security/src/main/java/org/jboss/seam/security/HibernateSecurityInterceptor.java
modules/trunk/security/src/main/java/org/jboss/seam/security/JpaTokenStore.java
modules/trunk/security/src/main/java/org/jboss/seam/security/NotLoggedInException.java
modules/trunk/security/src/main/java/org/jboss/seam/security/RememberMe.java
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityFunctions.java
modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java
modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
modules/trunk/security/src/main/java/org/jboss/seam/security/permission/action/PermissionSearch.java
Log:
get security to compilable state
Modified: modules/trunk/security/pom.xml
===================================================================
--- modules/trunk/security/pom.xml 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/pom.xml 2009-05-01 01:17:13 UTC (rev 10737)
@@ -53,8 +53,12 @@
</dependency>
<dependency>
<groupId>${seam.groupId}</groupId>
+ <artifactId>seam-faces</artifactId>
+ </dependency>
+ <!--dependency>
+ <groupId>${seam.groupId}</groupId>
<artifactId>seam-persistence</artifactId>
- </dependency>
+ </dependency-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -8,7 +8,7 @@
import javax.persistence.EntityManager;
import org.jboss.seam.security.annotations.Restrict;
-import org.jboss.seam.persistence.PersistenceProvider;
+//import org.jboss.seam.persistence.PersistenceProvider;
import org.jboss.seam.security.util.Strings;
/**
@@ -19,6 +19,7 @@
@ApplicationScoped
public class EntityPermissionChecker
{
+ /*
private String entityManagerName = "entityManager";
@Current Manager manager;
@@ -90,5 +91,6 @@
}
}
}
- }
+ }
+ */
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/EntitySecurityListener.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/EntitySecurityListener.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/EntitySecurityListener.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -18,6 +18,7 @@
*/
public class EntitySecurityListener
{
+ /*
@PostLoad
public void postLoad(Object entity)
{
@@ -41,4 +42,5 @@
{
EntityPermissionChecker.instance().checkEntityPermission(entity, DELETE);
}
+ */
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/HibernateSecurityInterceptor.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/HibernateSecurityInterceptor.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/HibernateSecurityInterceptor.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -10,7 +10,7 @@
import org.hibernate.EmptyInterceptor;
import org.hibernate.Interceptor;
import org.hibernate.type.Type;
-import org.jboss.seam.Entity.NotEntityException;
+//import org.jboss.seam.Entity.NotEntityException;
/**
* Facilitates security checks for Hibernate entities
@@ -20,6 +20,7 @@
*/
public class HibernateSecurityInterceptor extends EmptyInterceptor
{
+ /*
private Interceptor wrappedInterceptor;
public HibernateSecurityInterceptor(Interceptor wrappedInterceptor)
@@ -96,5 +97,6 @@
return wrappedInterceptor != null ?
wrappedInterceptor.onSave(entity, id, state, propertyNames, types) :
false;
- }
+ }
+ */
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/JpaTokenStore.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/JpaTokenStore.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/JpaTokenStore.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -3,7 +3,9 @@
import java.io.Serializable;
import javax.context.ApplicationScoped;
+import javax.inject.Current;
import javax.inject.Initializer;
+import javax.inject.manager.Manager;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.Query;
@@ -23,47 +25,42 @@
{
private static final long serialVersionUID = -1984227349549914828L;
- private Class tokenClass;
+ private Class<?> tokenEntityClass;
- private ValueExpression<EntityManager> entityManager;
-
private AnnotatedBeanProperty<TokenUsername> tokenUsernameProperty;
private AnnotatedBeanProperty<TokenValue> tokenValueProperty;
+ @Current Manager manager;
+
@Initializer
public void create()
- {
- if (entityManager == null)
- {
- entityManager = Expressions.instance().createValueExpression("#{entityManager}", EntityManager.class);
- }
+ {
+ tokenUsernameProperty = new AnnotatedBeanProperty<TokenUsername>(tokenEntityClass, TokenUsername.class);
+ tokenValueProperty = new AnnotatedBeanProperty<TokenValue>(tokenEntityClass, TokenValue.class);
- tokenUsernameProperty = new AnnotatedBeanProperty<TokenUsername>(tokenClass, TokenUsername.class);
- tokenValueProperty = new AnnotatedBeanProperty<TokenValue>(tokenClass, TokenValue.class);
-
if (!tokenUsernameProperty.isSet())
{
- throw new IllegalStateException("Invalid tokenClass " + tokenClass.getName() +
+ throw new IllegalStateException("Invalid tokenClass " + tokenEntityClass.getName() +
" - required annotation @TokenUsername not found on any Field or Method.");
}
if (!tokenValueProperty.isSet())
{
- throw new IllegalStateException("Invalid tokenClass " + tokenClass.getName() +
+ throw new IllegalStateException("Invalid tokenClass " + tokenEntityClass.getName() +
" - required annotation @TokenValue not found on any Field or Method.");
}
}
public void createToken(String username, String value)
{
- if (tokenClass == null)
+ if (tokenEntityClass == null)
{
- throw new IllegalStateException("Could not create token, tokenClass not set");
+ throw new IllegalStateException("Could not create token, tokenEntityClass not set");
}
try
{
- Object token = tokenClass.newInstance();
+ Object token = tokenEntityClass.newInstance();
tokenUsernameProperty.setValue(token, username);
tokenValueProperty.setValue(token, value);
@@ -100,7 +97,7 @@
public void invalidateAll(String username)
{
Query query = lookupEntityManager().createQuery(
- "select t from " + tokenClass.getName() + " t where " + tokenUsernameProperty.getName() +
+ "select t from " + tokenEntityClass.getName() + " t where " + tokenUsernameProperty.getName() +
" = :username")
.setParameter("username", username);
@@ -115,7 +112,7 @@
try
{
Object token = lookupEntityManager().createQuery(
- "select t from " + tokenClass.getName() + " t where " + tokenUsernameProperty.getName() +
+ "select t from " + tokenEntityClass.getName() + " t where " + tokenUsernameProperty.getName() +
" = :username and " + tokenValueProperty.getName() + " = :value")
.setParameter("username", username)
.setParameter("value", value)
@@ -129,28 +126,18 @@
}
}
- public Class getTokenClass()
+ public Class<?> getTokenEntityClass()
{
- return tokenClass;
+ return tokenEntityClass;
}
- public void setTokenClass(Class tokenClass)
+ public void setTokenEntityClass(Class<?> tokenEntityClass)
{
- this.tokenClass = tokenClass;
+ this.tokenEntityClass = tokenEntityClass;
}
private EntityManager lookupEntityManager()
{
- return entityManager.getValue();
+ return manager.getInstanceByType(EntityManager.class);
}
-
- public ValueExpression getEntityManager()
- {
- return entityManager;
- }
-
- public void setEntityManager(ValueExpression expression)
- {
- this.entityManager = expression;
- }
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/NotLoggedInException.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/NotLoggedInException.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/NotLoggedInException.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -1,11 +1,11 @@
package org.jboss.seam.security;
-import javax.ejb.ApplicationException;
+//import javax.ejb.ApplicationException;
/**
* Thrown when an unauthenticated user attempts to execute a restricted action.
*
* @author Shane Bryzak
*/
- at ApplicationException(rollback=true)
+//@ApplicationException(rollback=true)
public class NotLoggedInException extends RuntimeException {}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/RememberMe.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/RememberMe.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/RememberMe.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -9,11 +9,11 @@
import javax.annotation.Named;
import javax.context.SessionScoped;
import javax.event.Observes;
-import javax.faces.context.FacesContext;
+//import javax.faces.context.FacesContext;
import javax.inject.Current;
import javax.inject.Initializer;
-import org.jboss.seam.faces.Selector;
+//import org.jboss.seam.faces.Selector;
import org.jboss.seam.security.events.CredentialsInitializedEvent;
import org.jboss.seam.security.events.CredentialsUpdatedEvent;
import org.jboss.seam.security.events.LoggedOutEvent;
@@ -36,6 +36,7 @@
@SessionScoped
public class RememberMe implements Serializable
{
+ /*
class UsernameSelector extends Selector
{
@Override
@@ -286,6 +287,7 @@
boolean value;
}
+ /*
public void quietLogin(@Observes QuietLoginEvent event)
{
if (mode.equals(Mode.autoLogin) && isEnabled())
@@ -393,13 +395,18 @@
usernameSelector.setDirty();
}
}
+ */
/**
* A flag that an application can use to protect sensitive operations if the user has been
* auto-authenticated.
*/
+ /*
public boolean isAutoLoggedIn()
{
return autoLoggedIn;
}
+
+ */
+
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityEventMessages.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -2,6 +2,7 @@
import javax.context.ApplicationScoped;
import javax.event.Observes;
+import javax.inject.Current;
import javax.security.auth.login.LoginException;
import org.jboss.seam.international.StatusMessages;
@@ -27,9 +28,12 @@
//ServletContexts.instance().getRequest(), identity.getPrincipal().getName());
}
+ @Current StatusMessages statusMessages;
+ @Current Credentials credentials;
+
public void addLoginFailedMessage(@Observes LoginFailedEvent event)
{
- StatusMessages.instance().addFromResourceBundleOrDefault(
+ statusMessages.addFromResourceBundleOrDefault(
getLoginFailedMessageSeverity(),
getLoginFailedMessageKey(),
getLoginFailedMessage(),
@@ -53,17 +57,16 @@
public void addLoginSuccessfulMessage(@Observes LoggedInEvent event)
{
- StatusMessages.instance().addFromResourceBundleOrDefault(
+ statusMessages.addFromResourceBundleOrDefault(
getLoginSuccessfulMessageSeverity(),
getLoginSuccessfulMessageKey(),
getLoginSuccessfulMessage(),
- Identity.instance().getCredentials().getUsername());
+ credentials.getUsername());
}
public void addNotLoggedInMessage(@Observes NotLoggedInEvent event)
{
- StatusMessages.instance().addFromResourceBundleOrDefault(
- Severity.WARN,
+ statusMessages.addFromResourceBundleOrDefault( Severity.WARN,
"org.jboss.seam.NotLoggedIn",
"Please log in first"
);
@@ -86,8 +89,7 @@
public void addAlreadyLoggedInMessage(@Observes AlreadyLoggedInEvent event)
{
- StatusMessages.instance().addFromResourceBundleOrDefault (
- Severity.WARN,
+ statusMessages.addFromResourceBundleOrDefault ( Severity.WARN,
"org.jboss.seam.AlreadyLoggedIn",
"You are already logged in, please log out first if you wish to log in again"
);
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityFunctions.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityFunctions.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityFunctions.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -7,6 +7,8 @@
*/
public class SecurityFunctions
{
+ // TODO enable
+ /*
public static boolean hasRole(String name)
{
return Identity.instance().hasRole(name);
@@ -28,4 +30,6 @@
{
return Identity.instance().hasPermission(target, action);
}
+
+ */
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/SecurityInterceptor.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -148,6 +148,7 @@
}
}
+ /*
@AroundInvoke
public Object aroundInvoke(InvocationContext invocation) throws Exception
{
@@ -165,7 +166,10 @@
return invocation.proceed();
}
+ */
+
+ /*
private Restriction getRestriction(Method interfaceMethod) throws Exception
{
// see field declaration as to why this is done
@@ -284,6 +288,8 @@
return restrictions.get(interfaceMethod);
}
+ */
+
private String getPermissionAction(PermissionCheck check, Annotation annotation)
{
if (!"".equals(check.value()))
@@ -295,9 +301,11 @@
return annotation.annotationType().getSimpleName().toLowerCase();
}
}
-
+
+ /*
public boolean isInterceptorEnabled()
{
return getComponent().isSecure() && !getComponent().beanClassHasAnnotation("javax.jws.WebService");
}
+ */
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/RoleSearch.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -15,6 +15,7 @@
{
private static final long serialVersionUID = -1014495134519417515L;
+ /*
@DataModel
List<String> roles;
@@ -48,4 +49,6 @@
{
return selectedRole;
}
+
+ */
}
\ No newline at end of file
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/management/action/UserSearch.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -7,8 +7,8 @@
import javax.context.SessionScoped;
import javax.inject.Current;
-import org.jboss.seam.annotations.datamodel.DataModel;
-import org.jboss.seam.annotations.datamodel.DataModelSelection;
+//import org.jboss.seam.faces.annotations.DataModel;
+//import org.jboss.seam.faces.annotations.DataModelSelection;
import org.jboss.seam.security.management.IdentityManager;
@Named
@@ -17,6 +17,7 @@
{
private static final long serialVersionUID = 8592034786339372510L;
+ /*
@DataModel
List<String> users;
@@ -50,4 +51,6 @@
{
return selectedUser;
}
+
+ */
}
\ No newline at end of file
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/EntityIdentifierStrategy.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -4,13 +4,15 @@
import java.util.concurrent.ConcurrentHashMap;
import javax.context.Dependent;
+import javax.inject.Current;
+import javax.inject.manager.Manager;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import org.jboss.seam.security.annotations.permission.Identifier;
-import org.jboss.seam.core.Expressions;
-import org.jboss.seam.core.Expressions.ValueExpression;
-import org.jboss.seam.persistence.PersistenceProvider;
+import org.jboss.seam.el.Expressions;
+import org.jboss.seam.el.Expressions.ValueExpression;
+//import org.jboss.seam.persistence.PersistenceProvider;
import org.jboss.seam.security.util.Strings;
/**
@@ -18,24 +20,14 @@
*
* @author Shane Bryzak
*/
- at Dependent
public class EntityIdentifierStrategy implements IdentifierStrategy
-{
- private ValueExpression<EntityManager> entityManager;
-
+{
private Map<Class,String> identifierNames = new ConcurrentHashMap<Class,String>();
- @Current PersistenceProvider persistenceProvider;
-
- public EntityIdentifierStrategy()
- {
- if (entityManager == null)
- {
- entityManager = Expressions.instance().createValueExpression("#{entityManager}",
- EntityManager.class);
- }
- }
-
+ //@Current PersistenceProvider persistenceProvider;
+ @Current Expressions expressions;
+ @Current Manager manager;
+
public boolean canIdentify(Class targetClass)
{
return targetClass.isAnnotationPresent(Entity.class);
@@ -43,8 +35,12 @@
public String getIdentifier(Object target)
{
- return String.format("%s:%s", getIdentifierName(target.getClass()),
+ /**
+ return String.format("%s:%s", getIdentifierName(target.getClass()),
+
persistenceProvider.getId(target, lookupEntityManager()).toString());
+ */
+ return null;
}
private String getIdentifierName(Class cls)
@@ -76,6 +72,7 @@
private EntityManager lookupEntityManager()
{
- return entityManager.getValue();
+ //return entityManager.getValue();
+ return manager.getInstanceByType(EntityManager.class);
}
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -21,14 +21,11 @@
import org.jboss.seam.security.annotations.permission.PermissionRole;
import org.jboss.seam.security.annotations.permission.PermissionTarget;
import org.jboss.seam.security.annotations.permission.PermissionUser;
-import org.jboss.seam.el.Expressions;
-import org.jboss.seam.el.Expressions.ValueExpression;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.seam.security.Role;
import org.jboss.seam.security.SimplePrincipal;
import org.jboss.seam.security.management.IdentityManager;
-import org.jboss.seam.security.management.IdentityStore;
import org.jboss.seam.security.management.JpaIdentityStore;
import org.jboss.seam.security.permission.PermissionMetadata.ActionSet;
import org.jboss.seam.security.util.AnnotatedBeanProperty;
@@ -41,14 +38,14 @@
@ApplicationScoped
public class JpaPermissionStore implements PermissionStore, Serializable
{
+ private static final long serialVersionUID = 4764590939669047915L;
+
private static final LogProvider log = Logging.getLogProvider(JpaPermissionStore.class);
private enum Discrimination { user, role, either }
- private ValueExpression<EntityManager> entityManager;
-
- private Class userPermissionClass;
- private Class rolePermissionClass;
+ private Class<?> userPermissionClass;
+ private Class<?> rolePermissionClass;
private AnnotatedBeanProperty<PermissionUser> userProperty;
private AnnotatedBeanProperty<PermissionRole> roleProperty;
@@ -80,12 +77,6 @@
return;
}
- if (entityManager == null)
- {
- entityManager = Expressions.instance().createValueExpression("#{entityManager}",
- EntityManager.class);
- }
-
initProperties();
}
@@ -539,11 +530,12 @@
if (identityStore != null)
{
- if (recipientIsRole && roleProperty.isSet() && roleProperty.getPropertyType().equals(identityStore.getRoleClass()))
+ if (recipientIsRole && roleProperty.isSet() &&
+ roleProperty.getPropertyType().equals(identityStore.getRoleEntityClass()))
{
return identityStore.lookupRole(recipient.getName());
}
- else if (userProperty.getPropertyType().equals(identityStore.getUserClass()))
+ else if (userProperty.getPropertyType().equals(identityStore.getUserEntityClass()))
{
return identityStore.lookupUser(recipient.getName());
}
@@ -565,12 +557,12 @@
if (identityStore != null)
{
- if (isUser && identityStore.getUserClass().isAssignableFrom(principal.getClass()))
+ if (isUser && identityStore.getUserEntityClass().isAssignableFrom(principal.getClass()))
{
return new SimplePrincipal(identityStore.getUserName(principal));
}
- if (!isUser && identityStore.getRoleClass().isAssignableFrom(principal.getClass()))
+ if (!isUser && identityStore.getRoleEntityClass().isAssignableFrom(principal.getClass()))
{
String name = identityStore.getRoleName(principal);
return new Role(name, identityStore.isRoleConditional(name));
@@ -757,19 +749,9 @@
private EntityManager lookupEntityManager()
{
- return entityManager.getValue();
+ return manager.getInstanceByType(EntityManager.class);
}
- public ValueExpression getEntityManager()
- {
- return entityManager;
- }
-
- public void setEntityManager(ValueExpression expression)
- {
- this.entityManager = expression;
- }
-
public Class getUserPermissionClass()
{
return userPermissionClass;
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PermissionMapper.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -142,7 +142,8 @@
private ResolverChain createDefaultResolverChain()
{
- ResolverChain chain = (ResolverChain) Contexts.getSessionContext().get(DEFAULT_RESOLVER_CHAIN);
+ // TODO fix
+ ResolverChain chain = null; //(ResolverChain) Contexts.getSessionContext().get(DEFAULT_RESOLVER_CHAIN);
if (chain == null)
{
@@ -154,7 +155,8 @@
chain.getResolvers().add((PermissionResolver) manager.getInstance(resolverBean));
}
- Contexts.getSessionContext().set(DEFAULT_RESOLVER_CHAIN, chain);
+ // TODO fix
+ // Contexts.getSessionContext().set(DEFAULT_RESOLVER_CHAIN, chain);
manager.fireEvent(new DefaultResolverChainCreatedEvent(chain));
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/PersistentPermissionResolver.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -31,6 +31,7 @@
@Current Manager manager;
@Current Identity identity;
+ @Current RuleBasedPermissionResolver ruleBasedPermissionResolver;
@Initializer
public void initPermissionStore()
@@ -80,8 +81,7 @@
if (role.isConditional())
{
- RuleBasedPermissionResolver resolver = RuleBasedPermissionResolver.instance();
- if (resolver.checkConditionalRole(role.getName(), target, action)) return true;
+ if (ruleBasedPermissionResolver.checkConditionalRole(role.getName(), target, action)) return true;
}
else if (identity.hasRole(role.getName()))
{
@@ -125,8 +125,7 @@
if (role.isConditional())
{
- RuleBasedPermissionResolver resolver = RuleBasedPermissionResolver.instance();
- if (resolver.checkConditionalRole(role.getName(), target, action))
+ if (ruleBasedPermissionResolver.checkConditionalRole(role.getName(), target, action))
{
iter.remove();
break;
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/RuleBasedPermissionResolver.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -14,12 +14,12 @@
import javax.inject.Current;
import javax.inject.Initializer;
import javax.inject.manager.Initialized;
+import javax.inject.manager.Manager;
import org.drools.FactHandle;
import org.drools.RuleBase;
import org.drools.StatefulSession;
import org.drools.base.ClassObjectFilter;
-import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.drools.SeamGlobalResolver;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -36,15 +36,16 @@
*/
@SessionScoped
public class RuleBasedPermissionResolver implements PermissionResolver, Serializable
-{
- public static final String RULES_COMPONENT_NAME = "securityRules";
-
+{
+ private static final long serialVersionUID = -7572627522601793024L;
+
private static final LogProvider log = Logging.getLogProvider(RuleBasedPermissionResolver.class);
private StatefulSession securityContext;
private RuleBase securityRules;
+ @Current Manager manager;
@Current Identity identity;
@Initializer
@@ -55,23 +56,12 @@
}
protected void initSecurityContext()
- {
- if (getSecurityRules() == null)
- {
- setSecurityRules((RuleBase) Component.getInstance(RULES_COMPONENT_NAME, true));
- }
-
+ {
if (getSecurityRules() != null)
{
setSecurityContext(getSecurityRules().newStatefulSession(false));
getSecurityContext().setGlobalResolver(new SeamGlobalResolver(getSecurityContext().getGlobalResolver()));
}
-
- if (getSecurityContext() == null)
- {
- log.debug("no security rule base available - please install a RuleBase with the name '" +
- RULES_COMPONENT_NAME + "' if permission checks are required.");
- }
}
/**
@@ -99,7 +89,8 @@
}
else if (target instanceof Class)
{
- String componentName = Seam.getComponentName((Class) target);
+ // TODO fix
+ String componentName = null; // manager. Seam.getComponentName((Class) target);
target = componentName != null ? componentName : ((Class) target).getName();
}
@@ -153,7 +144,8 @@
}
else if (target instanceof Class)
{
- String componentName = Seam.getComponentName((Class) target);
+ // TODO fix
+ String componentName = null; //Seam.getComponentName((Class) target);
target = componentName != null ? componentName : ((Class) target).getName();
}
@@ -167,7 +159,8 @@
{
for (String requirement : check.getRequirements())
{
- Object value = Contexts.lookupInStatefulContexts(requirement);
+ // TODO fix
+ Object value = null; // Contexts.lookupInStatefulContexts(requirement);
if (value != null)
{
handles.add (securityContext.insert(value));
@@ -289,12 +282,14 @@
getSecurityContext().insert(identity.getPrincipal());
// If we were authenticated with the JpaIdentityStore, then insert the authenticated
- // UserAccount into the security context.
- if (Contexts.isEventContextActive() && Contexts.isSessionContextActive() &&
+ // UserAccount into the security context.
+
+ // TODO fix
+ /*if (Contexts.isEventContextActive() && Contexts.isSessionContextActive() &&
Contexts.getEventContext().isSet(JpaIdentityStore.AUTHENTICATED_USER))
{
getSecurityContext().insert(Contexts.getEventContext().get(JpaIdentityStore.AUTHENTICATED_USER));
- }
+ }*/
}
}
}
Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/permission/action/PermissionSearch.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/permission/action/PermissionSearch.java 2009-05-01 00:58:23 UTC (rev 10736)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/permission/action/PermissionSearch.java 2009-05-01 01:17:13 UTC (rev 10737)
@@ -12,8 +12,8 @@
import javax.context.ConversationScoped;
import javax.inject.Current;
-import org.jboss.seam.annotations.datamodel.DataModel;
-import org.jboss.seam.annotations.datamodel.DataModelSelection;
+//import org.jboss.seam.faces.annotations.DataModel;
+//import org.jboss.seam.faces.annotations.DataModelSelection;
import org.jboss.seam.security.management.IdentityManager;
import org.jboss.seam.security.permission.Permission;
import org.jboss.seam.security.permission.PermissionManager;
@@ -23,7 +23,8 @@
public class PermissionSearch implements Serializable
{
private Map<Principal,List<Permission>> groupedPermissions = new HashMap<Principal,List<Permission>>();
-
+
+ /*
@DataModel
List<Principal> recipients;
@@ -102,4 +103,6 @@
{
return groupedPermissions.get(selectedRecipient);
}
+
+ */
}
More information about the seam-commits
mailing list