[jboss-cvs] jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace ...
Shane Bryzak
Shane_Bryzak at symantec.com
Thu Jan 25 08:24:07 EST 2007
User: sbryzak2
Date: 07/01/25 08:24:07
Modified: examples/seamspace/src/org/jboss/seam/example/seamspace
BlogAction.java ContentAction.java
ProfileAction.java Register.java
RegisterAction.java
Added: examples/seamspace/src/org/jboss/seam/example/seamspace
Authenticator.java
Removed: examples/seamspace/src/org/jboss/seam/example/seamspace
AclObjectIdentity.java AclPermission.java
LoginAction.java LoginLocal.java
Log:
updated with security changes
Revision Changes Path
1.9 +1 -3 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/BlogAction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BlogAction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/BlogAction.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- BlogAction.java 18 Jan 2007 12:48:05 -0000 1.8
+++ BlogAction.java 25 Jan 2007 13:24:07 -0000 1.9
@@ -18,7 +18,6 @@
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.RequestParameter;
import org.jboss.seam.annotations.security.Restrict;
-import org.jboss.seam.security.Identity;
@Stateful
@Name("blog")
@@ -117,8 +116,7 @@
public void createEntry()
{
- Identity.instance().checkRestriction("#{s:hasPermission('blog', 'createEntry', selectedMember, authenticatedMember)}");
-// MemberBlog selectedBlog = new MemberBlog();
+ MemberBlog selectedBlog = new MemberBlog();
}
@Remove @Destroy
1.5 +7 -7 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/ContentAction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ContentAction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/ContentAction.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- ContentAction.java 23 Jan 2007 14:54:26 -0000 1.4
+++ ContentAction.java 25 Jan 2007 13:24:07 -0000 1.5
@@ -5,22 +5,22 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
-import org.jboss.seam.security.Security;
+import org.jboss.seam.security.Identity;
@Stateless
@Name("contentAction")
public class ContentAction implements ContentLocal
{
@In(create = true) EntityManager entityManager;
- @In Security security;
+ @In(create = true) Identity identity;
public MemberImage getImage(int imageId)
{
MemberImage img = entityManager.find(MemberImage.class, imageId);
- if (img != null && security.hasPermission("memberImage", "view", img))
- return img;
- else
+ if (img == null || !identity.hasPermission("memberImage", "view", img))
return null;
+ else
+ return img;
}
}
1.12 +2 -2 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/ProfileAction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ProfileAction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/ProfileAction.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- ProfileAction.java 23 Jan 2007 02:48:16 -0000 1.11
+++ ProfileAction.java 25 Jan 2007 13:24:07 -0000 1.12
@@ -41,8 +41,8 @@
{
if (name == null && authenticatedMember != null)
{
- selectedMember = authenticatedMember;
- entityManager.refresh(selectedMember);
+ selectedMember = (Member) entityManager.find(Member.class,
+ authenticatedMember.getMemberId());
}
else if (name != null)
{
1.5 +2 -1 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/Register.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Register.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/Register.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- Register.java 23 Jan 2007 14:54:26 -0000 1.4
+++ Register.java 25 Jan 2007 13:24:07 -0000 1.5
@@ -1,13 +1,14 @@
package org.jboss.seam.example.seamspace;
import javax.ejb.Local;
+import javax.security.auth.login.LoginException;
@Local
public interface Register
{
void start();
void next();
- void uploadPicture();
+ void uploadPicture() throws LoginException;
String getConfirm();
void setConfirm(String confirm);
String getGender();
1.5 +7 -7 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RegisterAction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- RegisterAction.java 23 Jan 2007 05:25:07 -0000 1.4
+++ RegisterAction.java 25 Jan 2007 13:24:07 -0000 1.5
@@ -6,6 +6,7 @@
import javax.ejb.Remove;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
+import javax.security.auth.login.LoginException;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.Destroy;
@@ -15,6 +16,7 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.core.FacesMessages;
+import org.jboss.seam.security.Identity;
@Stateful
@Name("register")
@@ -27,10 +29,7 @@
private EntityManager entityManager;
@In(create = true)
- private LoginLocal login;
-
- @In(required = false)
- Member member;
+ private Identity identity;
/**
* Password confirmation
@@ -58,6 +57,7 @@
@End
public void uploadPicture()
+ throws LoginException
{
newMember.setMemberSince(new Date());
newMember.setRoles(new HashSet<MemberRole>());
@@ -83,9 +83,9 @@
}
// Login the user
- member.setUsername(newMember.getUsername());
- member.setPassword(newMember.getPassword());
- login.login();
+ identity.setUsername(newMember.getUsername());
+ identity.setPassword(newMember.getPassword());
+ identity.login();
}
public String getConfirm()
1.1 date: 2007/01/25 13:24:07; author: sbryzak2; state: Exp;jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/Authenticator.java
Index: Authenticator.java
===================================================================
package org.jboss.seam.example.seamspace;
import static org.jboss.seam.ScopeType.SESSION;
import java.util.Set;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Synchronized;
import org.jboss.seam.core.FacesMessages;
import org.jboss.seam.security.Identity;
/**
* Authenticator bean - authenticates the user against the database
*
* @author Shane Bryzak
*/
@Synchronized
@Name("authenticator")
public class Authenticator
{
@In(create=true)
private EntityManager entityManager;
@In Identity identity;
@Out(required = false, scope = SESSION)
private Member authenticatedMember;
public boolean authenticate(String username, String password, Set<String> roles)
{
try
{
authenticatedMember = (Member) entityManager.createQuery(
"from Member where username = :username and password = :password")
.setParameter("username", username)
.setParameter("password", password)
.getSingleResult();
if (authenticatedMember.getRoles() != null)
{
for (MemberRole mr : authenticatedMember.getRoles())
roles.add(mr.getName());
}
return true;
}
catch (NoResultException ex)
{
FacesMessages.instance().add("Invalid username/password");
return false;
}
}
}
More information about the jboss-cvs-commits
mailing list