You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by akhan <ah...@gmail.com> on 2013/07/28 09:38:15 UTC

Setting up Annotations and Shiro faces tags

Hi,
I have couple of of questions related to configuration of Shiro Annotations
and Shiro faces Tags. I know they are different subjects but it seems to me
to that most likely they are configuration issues and both related to Shiro
- hence posting them together.

I downloaded and built Shiro web, core, faces and JAspect from Shiro version
1.3.0 and added all the JAR files to my list of libraries. That's all I have
done. In both cases there are no exceptions messages.

*Shiro Tags not working:*

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:shiro="http://shiro.apache.org/tags">
    <h:head></h:head>
    <h:body>
        <shiro:hasRole  name="ADMIN">
            Hey Admin from Shiro
        </shiro:hasRole>
    </h:body>
</html>

Not sure if there are additional configuration steps that I have missed.


*Shiro Annotations issue*

On different but related problem is that the Shiro Annotations are not
working but calling the API methods are working fine. 

    @RequiresPermissions("admin:create") //Does not work
    public String createAccount()
    {
        //Return false
        System.out.println("admin:delete" +
SecurityUtils.getSubject().isPermitted("admin:delete")); 
        return "Account created";
    }





--
View this message in context: http://shiro-user.582556.n2.nabble.com/Setting-up-Annotations-and-Shiro-faces-tags-tp7578964.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Setting up Annotations and Shiro faces tags

Posted by akhan <ah...@gmail.com>.
Thanks Harald,

I was able to solve the Shiro faces tag issue after debugging. It was a SQL
query issue and not a tags issue. 

I don't know much about Aspect and Maven - so am going to skip the
annotation part for time being.

Thanks again.




--
View this message in context: http://shiro-user.582556.n2.nabble.com/Setting-up-Annotations-and-Shiro-faces-tags-tp7578964p7578972.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Setting up Annotations and Shiro faces tags

Posted by Harald Wellmann <hw...@gmail.com>.
Just to make sure we're talking about the same thing: do you mean
AspectJ when you say JAspect?

Did you take a look at the Shiro AspectJ sample? In the POM [1], you
can see how to use the AspectJ Maven plugin to weave your code. Just
adding the libs is not enough.

In case you're not familiar with AspectJ or not quite sure what
weaving means, maybe you'll find it easier to use Shiro with Spring or
Guice to make the annotations work. In any case, the samples should
help you getting started.

Regarding the tags, it's hard to say anything without a self-contained
sample. Can you try using the debugger to find out what's going on in
your case? Set a breakpoint on HasRoleTag.hasRole() and check if the
subject is null or the expected role is missing. Enable Shiro TRACE
logging to see if your request is properly authenticated. Something
like that...

[1] https://github.com/apache/shiro/blob/1.2.x/samples/aspectj/pom.xml


Best regards,
Harald

2013/7/28 akhan <ah...@gmail.com>:
> Hi Harald,
>
> Thanks for your response.
>
> The content within the Shiro faces tag doesn't get rendered. Though a
> request.isUserInRole("ADMIN") works fine. I am not sure what is missing.
>
> Regarding the Annotations, I just added JAspect to my libraries - Is there
> more configuration required? And can you please provide some pointers on how
> to go about the configuration.
>
> Thanks
>
>
>
>
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Setting-up-Annotations-and-Shiro-faces-tags-tp7578964p7578966.html
> Sent from the Shiro User mailing list archive at Nabble.com.

Re: Setting up Annotations and Shiro faces tags

Posted by akhan <ah...@gmail.com>.
Hi Harald,

Thanks for your response.

The content within the Shiro faces tag doesn't get rendered. Though a
request.isUserInRole("ADMIN") works fine. I am not sure what is missing. 

Regarding the Annotations, I just added JAspect to my libraries - Is there
more configuration required? And can you please provide some pointers on how
to go about the configuration.

Thanks





--
View this message in context: http://shiro-user.582556.n2.nabble.com/Setting-up-Annotations-and-Shiro-faces-tags-tp7578964p7578966.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Setting up Annotations and Shiro faces tags

Posted by Harald Wellmann <hw...@gmail.com>.
Regarding the Faces tags, all I can say is that a private
1.3.0-SNAPSHOT build works fine for me. What exactly is not working
for you - do you see the tag content when the user does not have the
role, or do you see it even though the user does not have the role...?

Shiro annotations only work in combination with a suitable interceptor
framework. You mentioned AspectJ, so did you weave your code or use a
runtime agent?

Best regards,
Harald


2013/7/28 akhan <ah...@gmail.com>:
> Hi,
> I have couple of of questions related to configuration of Shiro Annotations
> and Shiro faces Tags. I know they are different subjects but it seems to me
> to that most likely they are configuration issues and both related to Shiro
> - hence posting them together.
>
> I downloaded and built Shiro web, core, faces and JAspect from Shiro version
> 1.3.0 and added all the JAR files to my list of libraries. That's all I have
> done. In both cases there are no exceptions messages.
>
> *Shiro Tags not working:*
>
> <?xml version='1.0' encoding='UTF-8' ?>
> <!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
> &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>
> <html xmlns="http://www.w3.org/1999/xhtml"
>       xmlns:h="http://xmlns.jcp.org/jsf/html"
>       xmlns:shiro="http://shiro.apache.org/tags">
>     <h:head></h:head>
>     <h:body>
>         <shiro:hasRole  name="ADMIN">
>             Hey Admin from Shiro
>         </shiro:hasRole>
>     </h:body>
> </html>
>
> Not sure if there are additional configuration steps that I have missed.
>
>
> *Shiro Annotations issue*
>
> On different but related problem is that the Shiro Annotations are not
> working but calling the API methods are working fine.
>
>     @RequiresPermissions("admin:create") //Does not work
>     public String createAccount()
>     {
>         //Return false
>         System.out.println("admin:delete" +
> SecurityUtils.getSubject().isPermitted("admin:delete"));
>         return "Account created";
>     }
>
>
>
>
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Setting-up-Annotations-and-Shiro-faces-tags-tp7578964.html
> Sent from the Shiro User mailing list archive at Nabble.com.