Login and logout... using jboss seam
freedom2k6 Jul 19, 2008 3:07 PMHai friends...
How to do authentication in jboss seam...
This is my java class where i am authentication ....
----------------------------------------------------
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.Query;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;
import org.jboss.seam.security.Identity;
import com.camsoft.camera.administration.user.entity.Users;
@Name("authenticator")
public class Authenticator{
@Logger
Log log;
@In
Identity identity;
@Out(value="users",required=true,scope=ScopeType.SESSION)
private Users users;
@In(create=true)
private EntityManager entityManager;
private List menuList = new ArrayList();
public Users getUsers() {
return users;
}
public void setUsers(Users user) {
this.users = user;
}
public boolean authenticate() {
boolean result = false;
if (getUsers() == null) {
try {
Identity identity = Identity.instance();
Query query = entityManager.createQuery("from Users where userName = :userName " +
"and encryptedUserPassword = :password").setParameter("userName", identity.getUsername())
.setParameter("password", identity.getPassword());
setUsers((Users) query.getSingleResult());
}catch (NoResultException nre) {
FacesMessages.instance().add("Username/password do not match");
}
}
result = (getUsers() == null ? false : true);
return result;
}
}
-----------------------------------------------------------
I have two login and logout(screen) in same web application...
How can i use the same identity class to authentication ....
I have admin java object... from which i can get the username and password .... to login into administration screen...
I have user java object from which i can get the username and password .... to login into user screen...
After login into administration screen... i can able to login to user .... screen....
First login to administration.... and then login to user screen...
After logout of user screen then i can able to logout of administration screen....
Please help me....
shashi
How to do authentication in jboss seam...
This is my java class where i am authentication ....
----------------------------------------------------
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.Query;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;
import org.jboss.seam.security.Identity;
import com.camsoft.camera.administration.user.entity.Users;
@Name("authenticator")
public class Authenticator{
@Logger
Log log;
@In
Identity identity;
@Out(value="users",required=true,scope=ScopeType.SESSION)
private Users users;
@In(create=true)
private EntityManager entityManager;
private List menuList = new ArrayList();
public Users getUsers() {
return users;
}
public void setUsers(Users user) {
this.users = user;
}
public boolean authenticate() {
boolean result = false;
if (getUsers() == null) {
try {
Identity identity = Identity.instance();
Query query = entityManager.createQuery("from Users where userName = :userName " +
"and encryptedUserPassword = :password").setParameter("userName", identity.getUsername())
.setParameter("password", identity.getPassword());
setUsers((Users) query.getSingleResult());
}catch (NoResultException nre) {
FacesMessages.instance().add("Username/password do not match");
}
}
result = (getUsers() == null ? false : true);
return result;
}
}
-----------------------------------------------------------
I have two login and logout(screen) in same web application...
How can i use the same identity class to authentication ....
I have admin java object... from which i can get the username and password .... to login into administration screen...
I have user java object from which i can get the username and password .... to login into user screen...
After login into administration screen... i can able to login to user .... screen....
First login to administration.... and then login to user screen...
After logout of user screen then i can able to logout of administration screen....
Please help me....
shashi