[jboss-cvs] jboss-seam/examples/security/src/org/jboss/seam/example/security ...
Shane Bryzak
Shane_Bryzak at symantec.com
Mon Jul 31 02:46:57 EDT 2006
User: sbryzak2
Date: 06/07/31 02:46:57
Modified: examples/security/src/org/jboss/seam/example/security
LoginAction.java ProtectedAction.java
Added: examples/security/src/org/jboss/seam/example/security
AuthenticatorAction.java
Log:
Updated security test app
Revision Changes Path
1.3 +10 -8 jboss-seam/examples/security/src/org/jboss/seam/example/security/LoginAction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LoginAction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/security/src/org/jboss/seam/example/security/LoginAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- LoginAction.java 26 Jul 2006 06:03:14 -0000 1.2
+++ LoginAction.java 31 Jul 2006 06:46:57 -0000 1.3
@@ -1,13 +1,15 @@
package org.jboss.seam.example.security;
-import java.security.Principal;
import javax.ejb.Stateless;
+import static org.jboss.seam.ScopeType.SESSION;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
-import org.jboss.seam.core.FacesMessages;
-import org.jboss.seam.security.realm.Realm;
+import org.jboss.seam.security.Authentication;
+import org.jboss.seam.security.AuthenticationException;
+import org.jboss.seam.security.UsernamePasswordToken;
+import org.jboss.seam.security.authenticator.Authenticator;
/**
* Authenticates the user against the Realm.
@@ -18,7 +20,8 @@
@Name("login")
public class LoginAction implements LoginLocal
{
- @In("org.jboss.seam.security.realm.Realm") Realm realm;
+ @In(value = "org.jboss.seam.security.Authenticator") Authenticator authenticator;
+ @Out(scope = SESSION) Authentication authentication;
@In @Out User user;
@@ -26,15 +29,14 @@
{
System.out.println("login() called");
+ authentication = new UsernamePasswordToken(user.getUsername(), user.getPassword());
try
{
- Principal principal = realm.authenticate(user.getUsername(), user.getPassword());
- System.out.println("Got principal: " + principal);
+ authenticator.authenticate(authentication);
return "success";
}
- catch (Exception ex)
+ catch (AuthenticationException ex)
{
- FacesMessages.instance().add("Invalid login, please check your username and password are correct");
return "login";
}
}
1.2 +1 -1 jboss-seam/examples/security/src/org/jboss/seam/example/security/ProtectedAction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ProtectedAction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/security/src/org/jboss/seam/example/security/ProtectedAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ProtectedAction.java 25 Jul 2006 06:56:16 -0000 1.1
+++ ProtectedAction.java 31 Jul 2006 06:46:57 -0000 1.2
@@ -15,7 +15,7 @@
*/
@Stateless
@Name("protectedAction")
- at SecurityDomain("securityexample")
+ at SecurityDomain("seam")
public class ProtectedAction implements ProtectedLocal
{
@RolesAllowed("admin")
1.1 date: 2006/07/31 06:46:57; author: sbryzak2; state: Exp;jboss-seam/examples/security/src/org/jboss/seam/example/security/AuthenticatorAction.java
Index: AuthenticatorAction.java
===================================================================
package org.jboss.seam.example.security;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.security.Authentication;
import org.jboss.seam.security.AuthenticationException;
import org.jboss.seam.security.provider.AuthenticationProvider;
/**
*
* @author Shane Bryzak
* @version 1.0
*/
@Name("authenticatorAction")
public class AuthenticatorAction implements AuthenticationProvider
{
@PersistenceContext EntityManager manager;
public Authentication authenticate(Authentication authentication)
throws AuthenticationException
{
return null;
}
}
More information about the jboss-cvs-commits
mailing list