You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by kait <ka...@tverra.net> on 2010/11/03 11:18:45 UTC

Shiro and JSF problems

Hi. 

I have a question I hope someone here can help me solve:

I have a JSF application running on glassfish 2.2.1, using java 1.5. My
ShiroRealm is a JDBC connection to a Postgres server. 

One jsp-page I made contains the following code:

   <f:verbatim>
       <shiro:hasRole name="superadmin">superadmin<br/></shiro:hasRole>
   </f:verbatim>

   <f:verbatim>
      <shiro:hasPermission
name="cpadmin:list">cpadmin:list</shiro:hasPermission>
   </f:verbatim>   

My problem is: The first part shows, whereas the second one doesn't. 

Extract from database (using the standard schema):

select * from roles_permission;
 id | permission |   role_name    
----+------------+----------------
  1 | superadmin | admin:*
  2 | superadmin | cpadmin:list


select * from user_roles;

 id | role_name  | username 
----+------------+----------
  1 | superadmin | kait
  2 | superadmin | superduper

Hope someone can help me.

- Kai
-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro-and-JSF-problems-tp5700715p5700715.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Shiro and JSF problems

Posted by kait <ka...@tverra.net>.
Doh. 

My mistake. A good old-fashioned type. Oh well. The mistake is in the
following:

CREATE TABLE roles_permission( 
   id SERIAL PRIMARY KEY, 
   permission varchar(64) NOT NULL, 
   role_name varchar(64)   
); 

Should be 

CREATE TABLE roles_permissions{ ...

- Cheers 

-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro-and-JSF-problems-tp5700715p5732303.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Shiro and JSF problems

Posted by kait <ka...@tverra.net>.
Hi. 

I have now tested it using iniRealm, and the everything works just fine...
So I guess I have muddled the creation of the database. 

CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    username varchar(32) NOT NULL UNIQUE,
    password varchar(32) NOT NULL
);

CREATE TABLE user_roles (
   id SERIAL PRIMARY KEY,
   role_name varchar(32) NOT NULL,
   username varchar(32)   
);

CREATE TABLE roles_permission(
   id SERIAL PRIMARY KEY,
   permission varchar(64) NOT NULL,
   role_name varchar(64)  
);

Can anyone spot a mistake that would lead to none of my users having any
permissions?
-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro-and-JSF-problems-tp5700715p5720903.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Shiro and JSF problems

Posted by Deluan Quintão <de...@deluan.com>.
Hi Kai,

Are you using JSP or Facelets as view handler? My tags only work with
Facelets. Also, for now, it only works with JSF 1.X, If you can, use
Facelets, as it's a better solution for JSF's view handler (it was created
just for that) and has been incorporated as the default view handler
technology in
JSF 2.

As for the permissions in the database, I didn't use the JDBC Realm yet, so
I can't help you with that. Try using the IniRealm first (
http://shiro.apache.org/configuration.html#Configuration-%255Cusers%255C) so
you can check if the problem is with your database or with the tags (most
probably is with the tags)

Regards,
Deluan.

On Thu, Nov 4, 2010 at 4:53 AM, kait <ka...@tverra.net> wrote:

>
> Hi Les, and thanks for answering.
>
> No, I haven't tried Deluan's Shiro JSF tags yet. I'll try that as well.
> What
> I find confounding though, is that all tags /except/ hasPermission works,
> indicating
>
> a) I am doing it the wrong way
> b) There is something wrong in the way I've added permission to the
> database
>
> Being quite new to JSF and newer still to Shiro, I am somewhat lost to what
> causes this.
>
> - Kai
> --
> View this message in context:
> http://shiro-user.582556.n2.nabble.com/Shiro-and-JSF-problems-tp5700715p5704312.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>

Re: Shiro and JSF problems

Posted by kait <ka...@tverra.net>.
Hi Les, and thanks for answering. 

No, I haven't tried Deluan's Shiro JSF tags yet. I'll try that as well. What
I find confounding though, is that all tags /except/ hasPermission works,
indicating 

a) I am doing it the wrong way
b) There is something wrong in the way I've added permission to the database

Being quite new to JSF and newer still to Shiro, I am somewhat lost to what
causes this.

- Kai
-- 
View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro-and-JSF-problems-tp5700715p5704312.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Shiro and JSF problems

Posted by Les Hazlewood <lh...@apache.org>.
Hi Kai,

Are you using Deluan's Shiro JSF tags?  Shiro's JSP tags won't work in
a JSF application.

-- 
Les Hazlewood
Founder, Katasoft, Inc.
Application Security Products & Professional Apache Shiro Support and Training:
http://www.katasoft.com