Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsf and jstl

 
Predrag Ristic
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple seam project created in Eclipse.All my web pages have extension xhtml and I access each of them by typing page_name.seam.I would like to restrict access to every other page other than login page if the user is not logged in.I tried to use <c:if> tag but it didn't work.Other c: tags won't work either.Can anyone tell me how to implement this login check?Thanks
 
Cristian Boariu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ristic,
You must make a pages.xml where you will have like:




check this out for more info:

http://docs.jboss.com/seam/1.1.5.GA/reference/en/html/security.html

Also note that you can add that role after login, like:
identity.addRole("ACCES_ALL_PAGES_ROLE");

Have fun.
 
Predrag Ristic
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've added identity attribute in my LoginBean class and in method that is invoked when user clicks on the submit button there is line
identity.addRole("logged").This method is registered in components.xml.Your tip about restriction is used in pages.xml but but I always get rejected no matter what username I use.
 
Cristian Boariu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can youu paste some code?
 
Predrag Ristic
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
components.xml :


login.xhml:


pages.xml:

 
Cristian Boariu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After you have injected the identity component, have you checked with debug that after the login click, it has the new role?
 
Predrag Ristic
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could not find any property of identity in the Variables tab in the debug mode that could show if the role is set or not.This is the managed bean.I hope it can help you so you can help me
 
Cristian Boariu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please notice that in jsf you have: register_bean and in the @Name of the seam component there is a missing "_"
 
Predrag Ristic
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that I have written register_bean everywhere.Can you show more precisely what do you mean?
 
Cristian Boariu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my fault...i did not noticed it because of the the background.......however i recommend to use cammel case like registerBean...of course this is not the problem here but it's good for better practices
 
Cristian Boariu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also try to use the instance of Identity..I think that is: Identity.instance().addRole
 
Predrag Ristic
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really don't understand why it doesn't work when I add the role with
this.identity.addRole("logged");
I thought that is all what is necessary
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic