Hi Surendra,

I don't have a working example, but in a standalone desktop
application, there will be almost always a single SecurityManager
instance for the entire client-side JVM.  In this case, it is usually
safe to set the SecurityManager instance as a static singleton:

SecurityUtils.setSecurityManager(myApplicationsShiroSecurityManagerInstance);

from that point on you can call SecurityUtils.getSubject() anywhere in
your UI code and control buttons and such as necessary.

For example:

Button button = new Button("Delete User") {
    @Override
    public boolean isEnabled() {
        Subject currentUser = SecurityUtils.getSubject();
        return currentUser.isPermitted("user:delete") &&
                 super.isEnabled();
    }
}

This may or may not be the best example (it tightly couples your code
to Shiro's API) and you could clean it up using interfaces and
factories and such, but it should give you some ideas.

HTH!

Les


On Mon, Jan 31, 2011 at 1:21 PM, ksurendra <[email protected]> wrote:
>
> I'm new to Shiro and was looking for any working example implementing shiro
> on a desktop application.
> I would appreciate if anyone can share or point me.
>
> I'm specifically looking at enabling/disabling  button for a particular
> user, allow/disallow a particular operation like not being able to
> delete/add a new record.
>
> Thanks
> Surendra
> --
> View this message in context: 
> http://shiro-user.582556.n2.nabble.com/Looking-for-a-sample-example-desktop-tp5978765p5978765.html
> Sent from the Shiro User mailing list archive at Nabble.com.

Reply via email to