[jboss-user] [JBoss jBPM] - Re: custom-authentication, how to do it
aleem
do-not-reply at jboss.com
Mon Mar 12 09:34:48 EDT 2007
i m also a newbee. I have done a simple authentication for users. There is a verify method implementation in IdentitySession class. This is my IdentitySession
public Object verify(String userName, String pwd) {
Object userId = null;
System.out.println("#@#@##@userName="+userName+"Password="+pwd);
Query query = session.createQuery(
"select user.id " +
"from org.jbpm.identity.User as user " +
"where user.name = :userName " +
" and user.password = :password");
query.setString("userName", userName);
query.setString("password", pwd);
userId = (Long) query.uniqueResult();
return userId;
}
Called this verify from the Userbean as
public String login() {
String reVal = null ;
Session session = JbpmContext.getCurrentJbpmContext().getSession();
IdentitySession identitySession = new IdentitySession(session);
if ( identitySession.verify(userName, password) != null ) {
reVal = "home";
JbpmContext.getCurrentJbpmContext().setActorId(userName);
}
else
{
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Authentication Failed."));
reVal = logout();
}
return reVal ;
}
make appropriate changes in faces-config.xml
call userBean.login on the commandbutton event in login.jsp.
Hope that might help you ;)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4027154#4027154
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4027154
More information about the jboss-user
mailing list