• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

jsf and jstl

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can youu paste some code?
 
Predrag Ristic
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
components.xml :


login.xhml:


pages.xml:

 
Cristian Boariu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic