Seam SVN: r10741 - modules/trunk.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 15:00:17 -0400 (Fri, 01 May 2009)
New Revision: 10741
Modified:
modules/trunk/readme.txt
Log:
add running feature list (so we can sort out what we are providing in Seam)
formatting
Modified: modules/trunk/readme.txt
===================================================================
--- modules/trunk/readme.txt 2009-05-01 18:41:56 UTC (rev 10740)
+++ modules/trunk/readme.txt 2009-05-01 19:00:17 UTC (rev 10741)
@@ -3,10 +3,9 @@
==========================================================================
Seam is distributed under the terms of the GNU Lesser General Public License.
- => license avaialble at dist/lgpl.txt
+ -> license available at dist/lgpl.txt
-Building Seam (for developers)
-------------------------------
+= Building Seam (for developers)
These instructions assume that you are working with a local checkout of the
Seam repository (Seam 3 and above).
@@ -50,7 +49,19 @@
mvn install
cd ..
-Furthur reading
----------------
+= Feature list
-* Read the documentation and FAQ online at http://seamframework.org
+- [module] feature (description)
+
+- [el, faces] Integration with the JBoss EL (parameterized method expressions in JSF, etc)
+- [el] Resolve EL expressions from Java (easy API for executing the EL resolver)
+- [faces] Preserve JSF messages over a redirect (marks them to be saved in JSF 2 flash scope)
+- [i18n] Interpolate strings (resolve inline value expressions, such as in a message string)
+- [i18n] Status messages (register message to be displayed to user in the UI)
+- [faces] Status message to JSF message bridge (convert the status messages into JSF messages)
+- [i18n] Access to current Locale (provides @Current Locale)
+- [i18n] Access to current TimeZone (provides @Current TimeZone)
+
+= Furthur reading
+
+- Read the documentation and FAQ online at http://seamframework.org
15 years, 6 months
Seam SVN: r10740 - in examples/trunk/booking: ejb-jar/src/main/java/org/jboss/seam/examples/booking/security and 3 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 14:41:56 -0400 (Fri, 01 May 2009)
New Revision: 10740
Added:
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
Modified:
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java
examples/trunk/booking/ejb-jar/src/main/resources/import.sql
examples/trunk/booking/readme.txt
examples/trunk/booking/war/src/main/webapp/home.xhtml
examples/trunk/booking/war/src/main/webapp/register.xhtml
Log:
use real authenticator to login
further emulate Seam Security API so it is quick to integrate
note about Bean Validation
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Authenticator.java 2009-05-01 18:41:56 UTC (rev 10740)
@@ -0,0 +1,15 @@
+package org.jboss.seam.examples.booking.security;
+
+import javax.ejb.Local;
+
+/**
+ * <strong>Authenticator</strong> is responsible for authenticating
+ * the current user.
+ *
+ * @author Dan Allen
+ */
+public
+@Local
+interface Authenticator {
+ boolean authenticate();
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/AuthenticatorBean.java 2009-05-01 18:41:56 UTC (rev 10740)
@@ -0,0 +1,38 @@
+package org.jboss.seam.examples.booking.security;
+
+import javax.ejb.Stateless;
+import javax.inject.Current;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.jboss.seam.examples.booking.model.User;
+
+/**
+ * This implementation of <strong>Authenticator</strong>
+ * cross references the values of the user's credentials
+ * against the database.
+ *
+ * @author Dan Allen
+ */
+public
+@Stateless
+class AuthenticatorBean implements Authenticator
+{
+ @PersistenceContext EntityManager em;
+
+ @Current Credentials credentials;
+
+ public boolean authenticate()
+ {
+ if (credentials.getUsername() != null && credentials.getUsername().length() > 0)
+ {
+ User user = em.find(User.class, credentials.getUsername());
+ if (user != null && user.getPassword().equals(credentials.getPassword()))
+ {
+ credentials.setPassword(null);
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
Added: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java (rev 0)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Credentials.java 2009-05-01 18:41:56 UTC (rev 10740)
@@ -0,0 +1,47 @@
+package org.jboss.seam.examples.booking.security;
+
+import java.io.Serializable;
+import javax.annotation.Named;
+import javax.context.SessionScoped;
+
+/**
+ * Holds the user's credentials.
+ *
+ * @author Dan Allen
+ */
+public
+@Named
+@SessionScoped
+class Credentials implements Serializable
+{
+ private String username;
+
+ private String password;
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ public void clear()
+ {
+ this.username = null;
+ this.password = null;
+ }
+
+}
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java 2009-05-01 08:28:37 UTC (rev 10739)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/security/Identity.java 2009-05-01 18:41:56 UTC (rev 10740)
@@ -4,7 +4,8 @@
import javax.annotation.Named;
import javax.context.SessionScoped;
import javax.faces.context.FacesContext;
-import javax.inject.manager.Manager;
+import javax.inject.Current;
+import javax.inject.Initializer;
/**
* @author Dan Allen
@@ -14,59 +15,50 @@
@SessionScoped
class Identity implements Serializable
{
- private String username;
+ @Current Authenticator authenticator;
- private String password;
+ private Credentials credentials;
private boolean loggedIn;
- public boolean isLoggedIn()
+ public Identity() {}
+
+ public @Initializer Identity(Credentials credentials)
{
- return loggedIn;
+ this.credentials = credentials;
}
- public void setLoggedIn(boolean loggedIn)
- {
- this.loggedIn = loggedIn;
- }
- public String getPassword()
+ public boolean isLoggedIn()
{
- return password;
+ return loggedIn;
}
- public void setPassword(String password)
- {
- this.password = password;
- }
-
public String getUsername()
{
- return username;
+ return credentials.getUsername();
}
- public void setUsername(String username)
+ public void autoLogin()
{
- this.username = username;
+ loggedIn = true;
}
- public boolean login()
+ public void login()
{
- if (username != null && username.length() > 0)
+ if (authenticator.authenticate())
{
- password = null;
loggedIn = true;
- return true;
+ // authenticationEvent.fire(new AuthenticationEvent(credentials), new AnnotationLiteral<Success>() {});
+ return;
}
- return false;
+ // authenticationEvent.fire(new AuthenticationEvent(credentials), new AnnotationLiteral<Failed>() {});
}
- Manager manager;
-
public void logout()
{
- username = null;
+ credentials.clear();
loggedIn = false;
// FIXME this is a dirty hack to reset a producer
FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
Modified: examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java 2009-05-01 08:28:37 UTC (rev 10739)
+++ examples/trunk/booking/ejb-jar/src/main/java/org/jboss/seam/examples/booking/session/RegistrarBean.java 2009-05-01 18:41:56 UTC (rev 10740)
@@ -9,6 +9,7 @@
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.jboss.seam.examples.booking.model.User;
+import org.jboss.seam.examples.booking.security.Credentials;
import org.jboss.seam.examples.booking.security.Identity;
import org.jboss.seam.international.StatusMessage;
import org.jboss.seam.international.StatusMessages;
@@ -29,6 +30,8 @@
@Current RegistrationFormControls formControls;
+ @Current Credentials credentials;
+
@Current Identity identity;
private User newUser;
@@ -44,8 +47,8 @@
if (verifyPasswordsMatch() && verifyUsernameIsAvailable())
{
em.persist(newUser);
- identity.setUsername(newUser.getUsername());
- identity.login();
+ credentials.setUsername(newUser.getUsername());
+ identity.autoLogin();
registered = true;
statusMessages.add("You have been successfully registered as the user {0}!", newUser.getUsername());
}
Modified: examples/trunk/booking/ejb-jar/src/main/resources/import.sql
===================================================================
--- examples/trunk/booking/ejb-jar/src/main/resources/import.sql 2009-05-01 08:28:37 UTC (rev 10739)
+++ examples/trunk/booking/ejb-jar/src/main/resources/import.sql 2009-05-01 18:41:56 UTC (rev 10740)
@@ -1,7 +1,7 @@
insert into Customer (username, password, name) values ('gavin', 'mexico', 'Gavin King')
insert into Customer (username, password, name) values ('pete', 'edinburgh', 'Pete Muir')
insert into Customer (username, password, name) values ('shane', 'brisbane', 'Shane Bryzak')
-insert into Customer (username, password, name) values ('dan', 'maryland', 'Dan Allen')
+insert into Customer (username, password, name) values ('dan', 'laurel', 'Dan Allen')
insert into Hotel (id, price, name, address, city, state, zip, country) values (1, 120, 'Marriott Courtyard', 'Tower Place, Buckhead', 'Atlanta', 'GA', '30305', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (2, 180, 'Doubletree', 'Tower Place, Buckhead', 'Atlanta', 'GA', '30305', 'USA')
insert into Hotel (id, price, name, address, city, state, zip, country) values (3, 450, 'W Hotel', 'Union Square, Manhattan', 'NY', 'NY', '10011', 'USA')
Modified: examples/trunk/booking/readme.txt
===================================================================
--- examples/trunk/booking/readme.txt 2009-05-01 08:28:37 UTC (rev 10739)
+++ examples/trunk/booking/readme.txt 2009-05-01 18:41:56 UTC (rev 10740)
@@ -5,12 +5,15 @@
Java EE 5 environment enhanced with JSR-299 [Web Beans] and JSF 2.0).
Contextual state management and dependency injection are handled by JSR-299.
Transaction and persistence context management is handled by the EJB 3
-container.
+container. Validation of input fields is handled by Bean Validation.
Please consult the Web Beans reference documentation for instructions on how to
deploy the Web Bean implementation to JBoss AS 5. To upgrade the JSF libraries
to JSF 2.0, go to the Seam jsf-updater-tool module and follow the instructions
-there.
+there. You will also need to have Bean Validation installed in the container
+(or added to the classpath) in order for UI validation to work. Installing Bean
+Validation is as simple as putting the JARs in the library directory of the
+application server.
This example uses a Maven 2 build. To build the EJB and WAR and package them
inside an EAR, execute the following command:
Modified: examples/trunk/booking/war/src/main/webapp/home.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/home.xhtml 2009-05-01 08:28:37 UTC (rev 10739)
+++ examples/trunk/booking/war/src/main/webapp/home.xhtml 2009-05-01 18:41:56 UTC (rev 10740)
@@ -43,12 +43,12 @@
<fieldset>
<div>
<h:outputLabel for="username" value="Login name"/>
- <h:inputText id="username" value="#{identity.username}" style="width: 175px;"/>
+ <h:inputText id="username" value="#{credentials.username}" style="width: 175px;"/>
<div class="errors"><h:message for="username"/></div>
</div>
<div>
<h:outputLabel for="password" value="Password"/>
- <h:inputSecret id="password" value="#{identity.password}" style="width: 175px;"/>
+ <h:inputSecret id="password" value="#{credentials.password}" style="width: 175px;"/>
</div>
<div class="errors"><h:messages id="messages" globalOnly="true"/></div>
<div class="buttonBox"><h:commandButton id="login" action="#{identity.login}" value="Account Login"/></div>
@@ -59,7 +59,7 @@
<li>gavin/mexico</li>
<li>pete/edinburgh</li>
<li>shane/brisbane</li>
- <li>dan/maryland</li>
+ <li>dan/laurel</li>
</ul>
</div>
</fieldset>
Modified: examples/trunk/booking/war/src/main/webapp/register.xhtml
===================================================================
--- examples/trunk/booking/war/src/main/webapp/register.xhtml 2009-05-01 08:28:37 UTC (rev 10739)
+++ examples/trunk/booking/war/src/main/webapp/register.xhtml 2009-05-01 18:41:56 UTC (rev 10740)
@@ -25,7 +25,7 @@
<h:messages id="messages" globalOnly="true"/>
</div>
- <h:form id="registrationForm">
+ <h:form id="registrationForm" prependId="false">
<fieldset>
15 years, 6 months
Seam SVN: r10739 - examples/trunk/servlet-booking.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 04:28:37 -0400 (Fri, 01 May 2009)
New Revision: 10739
Modified:
examples/trunk/servlet-booking/pom.xml
Log:
make src/main/webapp a property
Modified: examples/trunk/servlet-booking/pom.xml
===================================================================
--- examples/trunk/servlet-booking/pom.xml 2009-05-01 06:32:03 UTC (rev 10738)
+++ examples/trunk/servlet-booking/pom.xml 2009-05-01 08:28:37 UTC (rev 10739)
@@ -27,7 +27,7 @@
<filesets>
<fileset>
<!-- clean up files from war:inplace -->
- <directory>src/main/webapp</directory>
+ <directory>${webapp.directory}</directory>
<includes>
<include>WEB-INF/classes/**</include>
<include>WEB-INF/lib/**</include>
@@ -92,6 +92,7 @@
<tomcat.http.port>8080</tomcat.http.port>
<embedded-tomcat.http.port>9090</embedded-tomcat.http.port>
<embedded-tomcat.debug.port>9190</embedded-tomcat.debug.port>
+ <webapp.directory>src/main/webapp</webapp.directory>
</properties>
<dependencies>
15 years, 7 months
Seam SVN: r10738 - in modules/trunk/faces/src/main/java/org/jboss/seam/faces: lifecycle and 1 other directory.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-05-01 02:32:03 -0400 (Fri, 01 May 2009)
New Revision: 10738
Added:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/JcdiManager.java
Modified:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamViewHandler.java
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java
Log:
lookup Manager via JNDI rather than EL
Added: modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/JcdiManager.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/JcdiManager.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/JcdiManager.java 2009-05-01 06:32:03 UTC (rev 10738)
@@ -0,0 +1,60 @@
+package org.jboss.seam.faces.application;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.inject.manager.Manager;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * <strong>JcdiManager</strong> retrieves the JCDI Manager from JNDI and caches the
+ * result in an application-scoped attribute.
+ *
+ * @author Dan Allen
+ */
+public class JcdiManager
+{
+ public static final String JCDI_MANAGER_JNDI_NAME = "java:app/Manager";
+
+ public static final String JCDI_MANAGER_ALT_JNDI_NAME = "java:comp/env/app/Manager";
+
+ private static final String JCDI_MANAGER_CACHE_KEY = JcdiManager.class.getName() + ".CACHE_KEY";
+
+ public static Manager getCurrentManager()
+ {
+ Manager currentManager = null;
+ ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
+ if (externalContext != null)
+ {
+ currentManager = (Manager) externalContext.getApplicationMap().get(JCDI_MANAGER_CACHE_KEY);
+ }
+
+ if (currentManager != null)
+ {
+ return currentManager;
+ }
+
+ try
+ {
+ InitialContext initialContext = new InitialContext();
+ try
+ {
+ currentManager = (Manager) initialContext.lookup(JCDI_MANAGER_JNDI_NAME);
+ }
+ catch (NamingException e)
+ {
+ currentManager = (Manager) initialContext.lookup(JCDI_MANAGER_ALT_JNDI_NAME);
+ }
+ }
+ catch (NamingException e)
+ {
+ }
+
+ if (currentManager != null && externalContext != null)
+ {
+ externalContext.getApplicationMap().put(JCDI_MANAGER_CACHE_KEY, currentManager);
+ }
+
+ return currentManager;
+ }
+}
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamViewHandler.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamViewHandler.java 2009-05-01 01:17:13 UTC (rev 10737)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/application/SeamViewHandler.java 2009-05-01 06:32:03 UTC (rev 10738)
@@ -6,7 +6,6 @@
import javax.faces.application.ViewHandlerWrapper;
import javax.faces.context.FacesContext;
import org.jboss.seam.faces.lifecycle.TransferStatusMessagesListener;
-import org.jboss.seam.international.StatusMessages;
/**
* Wrap the standard JSF view handler to capture the
@@ -42,6 +41,7 @@
{
// QUESTION hmmm, we have to convert to faces messages now to leverage JSF's flash feature...I suppose that is okay
new TransferStatusMessagesListener().execute();
+ // should I move this next step into TransferStatusMessagesListener?
if (context.getMessages().hasNext())
{
context.getExternalContext().getFlash().setKeepMessages(true);
Modified: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java 2009-05-01 01:17:13 UTC (rev 10737)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java 2009-05-01 06:32:03 UTC (rev 10738)
@@ -1,10 +1,8 @@
package org.jboss.seam.faces.lifecycle;
-import java.beans.Introspector;
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
-import org.jboss.seam.el.Expressions;
-import org.jboss.seam.faces.FacesExpressions;
+import org.jboss.seam.faces.application.JcdiManager;
import org.jboss.seam.international.StatusMessages;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -33,9 +31,8 @@
public void execute()
{
- Expressions expressions = new FacesExpressions();
- // FIXME this is kind of ugly...reminds me of the bad old days of JSF managed beans
- StatusMessages statusMessages = (StatusMessages) expressions.createValueExpression(getBeanExpression(StatusMessages.class)).getValue();
+ StatusMessages statusMessages = JcdiManager.getCurrentManager().getInstanceByType(StatusMessages.class);
+
if (statusMessages != null)
{
statusMessages.onBeforeRender();
@@ -45,14 +42,4 @@
log.warn("Could not locate StatusMessages bean. Status messages will not be transfered to FacesContext.");
}
}
-
- private String getBeanName(Class beanClass)
- {
- return beanClass.getPackage().getName() + "." + Introspector.decapitalize(beanClass.getSimpleName());
- }
-
- private String getBeanExpression(Class beanClass)
- {
- return "#{" + getBeanName(beanClass) + "}";
- }
}
15 years, 7 months
Seam SVN: r10737 - in modules/trunk/security: src/main/java/org/jboss/seam/security and 3 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)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
*/
-@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
*/
-@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);
}
+
+ */
}
15 years, 7 months
Seam SVN: r10736 - in modules/trunk/drools: src/main/java/org/jboss/seam/drools and 1 other directories.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-04-30 20:58:23 -0400 (Thu, 30 Apr 2009)
New Revision: 10736
Modified:
modules/trunk/drools/pom.xml
modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsHandler.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java
modules/trunk/drools/src/main/java/org/jboss/seam/drools/util/Resources.java
Log:
get drools module to compilable state
Modified: modules/trunk/drools/pom.xml
===================================================================
--- modules/trunk/drools/pom.xml 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/pom.xml 2009-05-01 00:58:23 UTC (rev 10736)
@@ -16,22 +16,26 @@
<dependencies>
<dependency>
- <groupId>org.jboss.webbeans</groupId>
+ <groupId>${webbeans.groupId}</groupId>
<artifactId>jsr299-api</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.webbeans</groupId>
+ <groupId>${webbeans.groupId}</groupId>
<artifactId>webbeans-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.seam</groupId>
+ </dependency>
+ <!--dependency>
+ <groupId>${seam.groupId}</groupId>
<artifactId>seam-bpm</artifactId>
- </dependency>
+ </dependency-->
<dependency>
- <groupId>org.jboss.seam</groupId>
+ <groupId>${seam.groupId}</groupId>
<artifactId>seam-el</artifactId>
</dependency>
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsActionHandler.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -19,10 +19,12 @@
public List<String> assertObjects;
public String workingMemoryName;
-
+
public void execute(ExecutionContext executionContext) throws Exception
{
- getWorkingMemory(workingMemoryName, assertObjects, executionContext).fireAllRules();
+ // Disabled BPM support for now
+
+ //getWorkingMemory(workingMemoryName, assertObjects, executionContext).fireAllRules();
}
}
\ No newline at end of file
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsAssignmentHandler.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -24,9 +24,12 @@
public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception
{
+ // Disabled BPM support for now
+ /*
WorkingMemory workingMemory = getWorkingMemory(workingMemoryName, assertObjects, executionContext);
workingMemory.setGlobal( "assignable", assignable );
workingMemory.fireAllRules();
+ */
}
}
\ No newline at end of file
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsDecisionHandler.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -23,10 +23,15 @@
public String decide(ExecutionContext executionContext) throws Exception
{
+ // Disabled BPM support for now
+ /*
WorkingMemory workingMemory = getWorkingMemory(workingMemoryName, assertObjects, executionContext);
workingMemory.setGlobal( "decision", new Decision() );
workingMemory.fireAllRules();
return ( (Decision) workingMemory.getGlobal("decision") ).getOutcome();
+ */
+
+ return null;
}
}
\ No newline at end of file
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsHandler.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsHandler.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/DroolsHandler.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -4,9 +4,6 @@
import org.drools.FactHandle;
import org.drools.WorkingMemory;
-import org.jboss.seam.Component;
-import org.jboss.seam.bpm.Actor;
-import org.jboss.seam.core.Expressions;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.jpdl.el.ELException;
@@ -19,6 +16,9 @@
*/
public class DroolsHandler
{
+ // Disabled BPM support for now
+
+ /*
protected WorkingMemory getWorkingMemory(String workingMemoryName, List<String> expressions, ExecutionContext executionContext)
throws ELException
{
@@ -45,7 +45,7 @@
workingMemory.insert(Actor.instance());
return workingMemory;
- }
+ }*/
private void assertObject(WorkingMemory workingMemory, Object element)
{
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/ManagedWorkingMemory.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -11,7 +11,7 @@
import org.drools.RuleBase;
import org.drools.StatefulSession;
import org.drools.spi.GlobalResolver;
-import org.jboss.seam.core.Mutable;
+//import org.jboss.seam.core.Mutable;
import org.jboss.seam.el.Expressions.ValueExpression;
/**
@@ -21,7 +21,8 @@
*
*/
@ConversationScoped
-public class ManagedWorkingMemory implements Mutable, Serializable
+//TODO implement mutable
+public class ManagedWorkingMemory implements /*Mutable, */Serializable
{
private static final long serialVersionUID = -1746942080571374743L;
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/RuleBase.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -5,15 +5,17 @@
import java.io.Reader;
import javax.context.ApplicationScoped;
+import javax.inject.Current;
import javax.inject.Initializer;
import javax.inject.Produces;
+import javax.servlet.ServletContext;
import org.drools.RuleBaseFactory;
import org.drools.compiler.DroolsError;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.compiler.RuleError;
-import org.jboss.seam.core.ResourceLoader;
+import org.jboss.seam.drools.util.Resources;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -32,6 +34,8 @@
private String dslFile;
private org.drools.RuleBase ruleBase;
+ @Current ServletContext servletContext;
+
@Initializer
public void compileRuleBase() throws Exception
{
@@ -43,7 +47,7 @@
for (String ruleFile: ruleFiles)
{
log.info("parsing rules: " + ruleFile);
- InputStream stream = ResourceLoader.instance().getResourceAsStream(ruleFile);
+ InputStream stream = getResourceAsStream(ruleFile);
if (stream==null)
{
throw new IllegalStateException("could not locate rule file: " + ruleFile);
@@ -57,7 +61,7 @@
}
else
{
- Reader dslReader = new InputStreamReader( ResourceLoader.instance().getResourceAsStream(dslFile) );
+ Reader dslReader = new InputStreamReader( getResourceAsStream(dslFile) );
builder.addPackageFromDrl(drlReader, dslReader);
}
@@ -111,4 +115,8 @@
this.dslFile = dslFile;
}
+ public InputStream getResourceAsStream(String resource)
+ {
+ return Resources.getResourceAsStream( resource, servletContext );
+ }
}
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/SeamGlobalResolver.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -1,9 +1,6 @@
package org.jboss.seam.drools;
import org.drools.spi.GlobalResolver;
-import org.jboss.seam.Component;
-import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.core.Init;
/**
* Resolves Seam context variables as Drools globals
@@ -13,6 +10,8 @@
*/
public class SeamGlobalResolver implements GlobalResolver
{
+ private static final long serialVersionUID = -2274336299784922069L;
+
private GlobalResolver delegate;
public SeamGlobalResolver(GlobalResolver delegate)
@@ -29,6 +28,10 @@
public Object resolveGlobal(String name)
{
+ return delegate.resolveGlobal(name);
+
+ // TODO enable contextual variable resolution
+ /*
if ( !Contexts.isApplicationContextActive() )
{
return delegate.resolveGlobal(name);
@@ -48,5 +51,6 @@
return instance;
}
}
+ */
}
}
\ No newline at end of file
Modified: modules/trunk/drools/src/main/java/org/jboss/seam/drools/util/Resources.java
===================================================================
--- modules/trunk/drools/src/main/java/org/jboss/seam/drools/util/Resources.java 2009-04-30 20:56:30 UTC (rev 10735)
+++ modules/trunk/drools/src/main/java/org/jboss/seam/drools/util/Resources.java 2009-05-01 00:58:23 UTC (rev 10736)
@@ -4,13 +4,40 @@
import java.io.InputStream;
import java.net.URL;
+import javax.servlet.ServletContext;
+
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
public class Resources
{
private static final LogProvider log = Logging.getLogProvider(Resources.class);
+
+ public static InputStream getResourceAsStream(String resource, ServletContext servletContext)
+ {
+ String stripped = resource.startsWith("/") ?
+ resource.substring(1) : resource;
+
+ InputStream stream = null;
+ if (servletContext!=null) {
+ try {
+ stream = servletContext.getResourceAsStream(resource);
+ if (stream!=null) {
+ log.debug("Loaded resource from servlet context: " + resource);
+ }
+ } catch (Exception e) {
+ //
+ }
+ }
+
+ if (stream==null) {
+ stream = getResourceAsStream(resource, stripped);
+ }
+
+ return stream;
+ }
+
public static InputStream getResourceAsStream(String resource)
{
String stripped = resource.startsWith("/") ? resource.substring(1) : resource;
15 years, 7 months