You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Waypoint D <wa...@gmail.com> on 2014/10/20 06:22:45 UTC

Request help integrating Shiro, Guice, and LDAP

Greetings,

       I am trying to build a webapp which uses apache shiro and google
guice.   I have been following a [1] tutorial, but cannot seem to get code
to compile with the realm I need to use.  In particular, I am not sure what
to supply for the following sections of code (which has been edited for
readability)...

*file:BigBankShiroWebModule.java*
    public class BigBankShiroWebModule extends ShiroWebModule {
        protected void configureShiroWeb() {
            bindRealm().toConstructor( IniRealm.class.getConstructor(
Ini.class ) );
        }
        Ini loadShiroIni() {
            return Ini.fromResourcePath( "classpath:shiro.ini" );
        }

I have tried to replace *IniRealm *with *IsisLdapRealm *or
*JndiLdapRealm *which
seems to work to a degree, but they wont load my *shiro.ini* file since
those realms don't implement the *Ini *class.  Since the realm I need to
use does not support ini files, how can I configure the realm?

Help is appreciated more than you know!
- John


*Web link appendix*   [1] Add an example for using Guice integration.
   https://issues.apache.org/jira/browse/SHIRO-320

Re: Request help integrating Shiro, Guice, and LDAP

Posted by Waypoint D <wa...@gmail.com>.
On Mon, Oct 20, 2014 at 9:19 AM, Jeroen van der Wal <je...@stromboli.it> wrote:
> Hi John,
>
> Since this is not really an Isis question: did you try asking on the Shiro
> mailing list [1]?

Actually, I just realized that (i've been looking at this too long, up
to late, desperate, lol, etc..).  Yes, I am subscribing to the Shiro
group now.

Thanks,
John

> Kind regards,
>
> Jeroen
>
> [1] http://shiro.apache.org/mailing-lists.html
>
> On Mon, Oct 20, 2014 at 2:55 PM, Waypoint D <wa...@gmail.com>
> wrote:
>
>> On Mon, Oct 20, 2014 at 2:22 AM, Dan Haywood
>> <da...@haywood-associates.co.uk> wrote:
>> >
>> > On 20 October 2014 05:22, Waypoint D <waypoint.delta@gmail.com
>> > <javascript:_e(%7B%7D,'cvml','waypoint.delta@gmail.com');>> wrote:
>> >
>> > > Greetings,
>> > >
>> > >
>> > Hi John,
>> > welcome to the Isis mailing list.
>>
>> Thank you.
>>
>> >
>> > >        I am trying to build a webapp which uses apache shiro and google
>> > > guice.   I have been following a [1] tutorial, but cannot seem to get
>> code
>> > > to compile with the realm I need to use.  In particular, I am not sure
>> what
>> > > to supply for the following sections of code (which has been edited for
>> > > readability)...
>> > >
>> > >
>> > I presume you're building an Isis webapp, in which case the bootstrapping
>> > is taken care of for you.  Isis already integrates with Shiro, and the
>> > WEB-INF/shiro.ini file is the one that is read from.  There should be no
>> > need to build your own Guice module.
>>
>> I am building a general webapp which only uses the ldap classes from
>> the shiro-security module within apache isis. So I am literally only
>> compiling against 3 java files within the entire apache isis project.
>>
>> I use IsisLdapRealm for its functionality to map ldap groups to shiro
>> roles (which JndiLdapRealm does not do).
>>
>> However, I must use Guice within my project for dependency reasons;
>> otherwise yes, you are correct, when I follow the example webapp which
>> does not use guice, the shiro.ini file is loaded with all of my
>> configuration settings.
>>
>> I went from a web.xml file containing
>>
>> <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
>>     <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
>> to one that looked like this
>>     <listener-class>bigbank.guice.BootstrapListener</listener-class>
>>    <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
>> and now i have lost whatever EnvironmentLoaderListener was doing to
>> automagically load shiro.ini.  I am left to either load the shiro.ini
>> file inside of configureShiroWeb() or set the configuration options at
>> runtime, but i am not sure how to accomplish either.
>>
>> John
>>
>> > You might want to check out the new isis-module-security [1] add-on [2],
>> > which provides an out-of-the-box realm for pluggable authentication and
>> > also authorization.
>>
>> Thank you, although these modules appear to only support isis webapps,
>> which my project does not leverage.
>>
>> > If the above doesn't fit, let us know a bit more what you're wanting to
>> > do...
>> >
>> > Cheers
>> > Dan
>> >
>> > [1] https://github.com/isisaddons/isis-module-security
>> > [2] http://www.isisaddons.org/
>> >
>> >
>> >
>> > > *file:BigBankShiroWebModule.java*
>> > >     public class BigBankShiroWebModule extends ShiroWebModule {
>> > >         protected void configureShiroWeb() {
>> > >             bindRealm().toConstructor( IniRealm.class.getConstructor(
>> > > Ini.class ) );
>> > >         }
>> > >         Ini loadShiroIni() {
>> > >             return Ini.fromResourcePath( "classpath:shiro.ini" );
>> > >         }
>> > >
>> > > I have tried to replace *IniRealm *with *IsisLdapRealm *or
>> > > *JndiLdapRealm *which
>> > > seems to work to a degree, but they wont load my *shiro.ini* file since
>> > > those realms don't implement the *Ini *class.  Since the realm I need
>> to
>> > > use does not support ini files, how can I configure the realm?
>> > >
>> > > Help is appreciated more than you know!
>> > > - John
>> > >
>> > >
>> > > *Web link appendix*   [1] Add an example for using Guice integration.
>> > >    https://issues.apache.org/jira/browse/SHIRO-320
>> > >
>>

Re: Request help integrating Shiro, Guice, and LDAP

Posted by Jeroen van der Wal <je...@stromboli.it>.
Hi John,

Since this is not really an Isis question: did you try asking on the Shiro
mailing list [1]?

Kind regards,

Jeroen

[1] http://shiro.apache.org/mailing-lists.html

On Mon, Oct 20, 2014 at 2:55 PM, Waypoint D <wa...@gmail.com>
wrote:

> On Mon, Oct 20, 2014 at 2:22 AM, Dan Haywood
> <da...@haywood-associates.co.uk> wrote:
> >
> > On 20 October 2014 05:22, Waypoint D <waypoint.delta@gmail.com
> > <javascript:_e(%7B%7D,'cvml','waypoint.delta@gmail.com');>> wrote:
> >
> > > Greetings,
> > >
> > >
> > Hi John,
> > welcome to the Isis mailing list.
>
> Thank you.
>
> >
> > >        I am trying to build a webapp which uses apache shiro and google
> > > guice.   I have been following a [1] tutorial, but cannot seem to get
> code
> > > to compile with the realm I need to use.  In particular, I am not sure
> what
> > > to supply for the following sections of code (which has been edited for
> > > readability)...
> > >
> > >
> > I presume you're building an Isis webapp, in which case the bootstrapping
> > is taken care of for you.  Isis already integrates with Shiro, and the
> > WEB-INF/shiro.ini file is the one that is read from.  There should be no
> > need to build your own Guice module.
>
> I am building a general webapp which only uses the ldap classes from
> the shiro-security module within apache isis. So I am literally only
> compiling against 3 java files within the entire apache isis project.
>
> I use IsisLdapRealm for its functionality to map ldap groups to shiro
> roles (which JndiLdapRealm does not do).
>
> However, I must use Guice within my project for dependency reasons;
> otherwise yes, you are correct, when I follow the example webapp which
> does not use guice, the shiro.ini file is loaded with all of my
> configuration settings.
>
> I went from a web.xml file containing
>
> <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
>     <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
> to one that looked like this
>     <listener-class>bigbank.guice.BootstrapListener</listener-class>
>    <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
> and now i have lost whatever EnvironmentLoaderListener was doing to
> automagically load shiro.ini.  I am left to either load the shiro.ini
> file inside of configureShiroWeb() or set the configuration options at
> runtime, but i am not sure how to accomplish either.
>
> John
>
> > You might want to check out the new isis-module-security [1] add-on [2],
> > which provides an out-of-the-box realm for pluggable authentication and
> > also authorization.
>
> Thank you, although these modules appear to only support isis webapps,
> which my project does not leverage.
>
> > If the above doesn't fit, let us know a bit more what you're wanting to
> > do...
> >
> > Cheers
> > Dan
> >
> > [1] https://github.com/isisaddons/isis-module-security
> > [2] http://www.isisaddons.org/
> >
> >
> >
> > > *file:BigBankShiroWebModule.java*
> > >     public class BigBankShiroWebModule extends ShiroWebModule {
> > >         protected void configureShiroWeb() {
> > >             bindRealm().toConstructor( IniRealm.class.getConstructor(
> > > Ini.class ) );
> > >         }
> > >         Ini loadShiroIni() {
> > >             return Ini.fromResourcePath( "classpath:shiro.ini" );
> > >         }
> > >
> > > I have tried to replace *IniRealm *with *IsisLdapRealm *or
> > > *JndiLdapRealm *which
> > > seems to work to a degree, but they wont load my *shiro.ini* file since
> > > those realms don't implement the *Ini *class.  Since the realm I need
> to
> > > use does not support ini files, how can I configure the realm?
> > >
> > > Help is appreciated more than you know!
> > > - John
> > >
> > >
> > > *Web link appendix*   [1] Add an example for using Guice integration.
> > >    https://issues.apache.org/jira/browse/SHIRO-320
> > >
>

Re: Request help integrating Shiro, Guice, and LDAP

Posted by Waypoint D <wa...@gmail.com>.
On Mon, Oct 20, 2014 at 2:22 AM, Dan Haywood
<da...@haywood-associates.co.uk> wrote:
>
> On 20 October 2014 05:22, Waypoint D <waypoint.delta@gmail.com
> <javascript:_e(%7B%7D,'cvml','waypoint.delta@gmail.com');>> wrote:
>
> > Greetings,
> >
> >
> Hi John,
> welcome to the Isis mailing list.

Thank you.

>
> >        I am trying to build a webapp which uses apache shiro and google
> > guice.   I have been following a [1] tutorial, but cannot seem to get code
> > to compile with the realm I need to use.  In particular, I am not sure what
> > to supply for the following sections of code (which has been edited for
> > readability)...
> >
> >
> I presume you're building an Isis webapp, in which case the bootstrapping
> is taken care of for you.  Isis already integrates with Shiro, and the
> WEB-INF/shiro.ini file is the one that is read from.  There should be no
> need to build your own Guice module.

I am building a general webapp which only uses the ldap classes from
the shiro-security module within apache isis. So I am literally only
compiling against 3 java files within the entire apache isis project.

I use IsisLdapRealm for its functionality to map ldap groups to shiro
roles (which JndiLdapRealm does not do).

However, I must use Guice within my project for dependency reasons;
otherwise yes, you are correct, when I follow the example webapp which
does not use guice, the shiro.ini file is loaded with all of my
configuration settings.

I went from a web.xml file containing
    <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
    <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
to one that looked like this
    <listener-class>bigbank.guice.BootstrapListener</listener-class>
   <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
and now i have lost whatever EnvironmentLoaderListener was doing to
automagically load shiro.ini.  I am left to either load the shiro.ini
file inside of configureShiroWeb() or set the configuration options at
runtime, but i am not sure how to accomplish either.

John

> You might want to check out the new isis-module-security [1] add-on [2],
> which provides an out-of-the-box realm for pluggable authentication and
> also authorization.

Thank you, although these modules appear to only support isis webapps,
which my project does not leverage.

> If the above doesn't fit, let us know a bit more what you're wanting to
> do...
>
> Cheers
> Dan
>
> [1] https://github.com/isisaddons/isis-module-security
> [2] http://www.isisaddons.org/
>
>
>
> > *file:BigBankShiroWebModule.java*
> >     public class BigBankShiroWebModule extends ShiroWebModule {
> >         protected void configureShiroWeb() {
> >             bindRealm().toConstructor( IniRealm.class.getConstructor(
> > Ini.class ) );
> >         }
> >         Ini loadShiroIni() {
> >             return Ini.fromResourcePath( "classpath:shiro.ini" );
> >         }
> >
> > I have tried to replace *IniRealm *with *IsisLdapRealm *or
> > *JndiLdapRealm *which
> > seems to work to a degree, but they wont load my *shiro.ini* file since
> > those realms don't implement the *Ini *class.  Since the realm I need to
> > use does not support ini files, how can I configure the realm?
> >
> > Help is appreciated more than you know!
> > - John
> >
> >
> > *Web link appendix*   [1] Add an example for using Guice integration.
> >    https://issues.apache.org/jira/browse/SHIRO-320
> >

Request help integrating Shiro, Guice, and LDAP

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 20 October 2014 05:22, Waypoint D <waypoint.delta@gmail.com
<javascript:_e(%7B%7D,'cvml','waypoint.delta@gmail.com');>> wrote:

> Greetings,
>
>
Hi John,
welcome to the Isis mailing list.




>        I am trying to build a webapp which uses apache shiro and google
> guice.   I have been following a [1] tutorial, but cannot seem to get code
> to compile with the realm I need to use.  In particular, I am not sure what
> to supply for the following sections of code (which has been edited for
> readability)...
>
>
I presume you're building an Isis webapp, in which case the bootstrapping
is taken care of for you.  Isis already integrates with Shiro, and the
WEB-INF/shiro.ini file is the one that is read from.  There should be no
need to build your own Guice module.

You might want to check out the new isis-module-security [1] add-on [2],
which provides an out-of-the-box realm for pluggable authentication and
also authorization.

If the above doesn't fit, let us know a bit more what you're wanting to
do...

Cheers
Dan

[1] https://github.com/isisaddons/isis-module-security
[2] http://www.isisaddons.org/



> *file:BigBankShiroWebModule.java*
>     public class BigBankShiroWebModule extends ShiroWebModule {
>         protected void configureShiroWeb() {
>             bindRealm().toConstructor( IniRealm.class.getConstructor(
> Ini.class ) );
>         }
>         Ini loadShiroIni() {
>             return Ini.fromResourcePath( "classpath:shiro.ini" );
>         }
>
> I have tried to replace *IniRealm *with *IsisLdapRealm *or
> *JndiLdapRealm *which
> seems to work to a degree, but they wont load my *shiro.ini* file since
> those realms don't implement the *Ini *class.  Since the realm I need to
> use does not support ini files, how can I configure the realm?
>
> Help is appreciated more than you know!
> - John
>
>
> *Web link appendix*   [1] Add an example for using Guice integration.
>    https://issues.apache.org/jira/browse/SHIRO-320
>

Re: Request help integrating Shiro, Guice, and LDAP

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 20 October 2014 05:22, Waypoint D <wa...@gmail.com> wrote:

> Greetings,
>
>
Hi John,
welcome to the Isis mailing list.




>        I am trying to build a webapp which uses apache shiro and google
> guice.   I have been following a [1] tutorial, but cannot seem to get code
> to compile with the realm I need to use.  In particular, I am not sure what
> to supply for the following sections of code (which has been edited for
> readability)...
>
>
I presume you're building an Isis webapp, in which case the bootstrapping
is taken care of for you.  Isis already integrates with Shiro, and the
WEB-INF/shiro.ini file is the one that is read from.  There should be no
need to build your own Guice module.

You might want to check out the new isis-module-security [1] add-on [2],
which provides an out-of-the-box realm for pluggable authentication and
also authorization.

If the above doesn't fit, let us know a bit more what you're wanting to
do...

Cheers
Dan

[1] https://github.com/isisaddons/isis-module-security
[2] http://www.isisaddons.org/



> *file:BigBankShiroWebModule.java*
>     public class BigBankShiroWebModule extends ShiroWebModule {
>         protected void configureShiroWeb() {
>             bindRealm().toConstructor( IniRealm.class.getConstructor(
> Ini.class ) );
>         }
>         Ini loadShiroIni() {
>             return Ini.fromResourcePath( "classpath:shiro.ini" );
>         }
>
> I have tried to replace *IniRealm *with *IsisLdapRealm *or
> *JndiLdapRealm *which
> seems to work to a degree, but they wont load my *shiro.ini* file since
> those realms don't implement the *Ini *class.  Since the realm I need to
> use does not support ini files, how can I configure the realm?
>
> Help is appreciated more than you know!
> - John
>
>
> *Web link appendix*   [1] Add an example for using Guice integration.
>    https://issues.apache.org/jira/browse/SHIRO-320
>