Programmatic configuration

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Programmatic configuration

mgargano
Hi,

     Shiro looks like a it supports exactly what I need for a project I'm working on.  All the examples I see, however, use the web.xml or an ini file for configuration of the realms that are supported.  I need to dynamically change realms and the locations of authentication servers at runtime. (ie, the user configures, through a web app, that they have 2 ldap servers and one day they decide to remove one and add 2 AD servers and have this change instantly take affect on authc and authz of users logging into that app)  Is there a way this can be done programmatically?

Thanks.
-Mike

Reply | Threaded
Open this post in threaded view
|

Re: Programmatic configuration

Brian Demers
Setting the realms at runtime is pretty easy, just get the security
manager (assuming it is a RealmSecurityManager) and call setRealms()

After that you have full control over your Realm objects. Our realms
do not use the web.xml / ini config, as they use custom persistance.
(although we have ideas how to clean this up, but that is a different
topic)

Basically when my application starts, we programmatically set the
Realms with objects created by our container (not the Shiro object
factory).




On Fri, Dec 3, 2010 at 10:39 AM, mgargano <[hidden email]> wrote:

>
> Hi,
>
>     Shiro looks like a it supports exactly what I need for a project I'm
> working on.  All the examples I see, however, use the web.xml or an ini file
> for configuration of the realms that are supported.  I need to dynamically
> change realms and the locations of authentication servers at runtime. (ie,
> the user configures, through a web app, that they have 2 ldap servers and
> one day they decide to remove one and add 2 AD servers and have this change
> instantly take affect on authc and authz of users logging into that app)  Is
> there a way this can be done programmatically?
>
> Thanks.
> -Mike
>
>
> --
> View this message in context: http://shiro-user.582556.n2.nabble.com/Programmatic-configuration-tp5800258p5800258.html
> Sent from the Shiro User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Programmatic configuration

AndrewGr
Hi Brian!

Concerning "(although we have ideas how to clean this up, but that is a
different topic)". Could you please mention a little bit how to disable
realms? As this is exactly what I am working on now!

Honestly I was also thinking to do this via
RealmSecurityManager.setRealms(), as it looks pretty straight forward for
adding the realm, but I am a little bit concerned about reducing the list of
realms in the same way...

Thank you!



--
Sent from: http://shiro-user.582556.n2.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Programmatic configuration

Brian Demers
Yup, you can just call 'setRealms()', if you are swapping implementations at runtime you my also want to clean up the old ones too (depending on your realm implementation)  For example some realms are 'Destroyable' so you could just call 'destroy()' and that would cleanup any lingering resources.


On Tue, Oct 3, 2017 at 4:24 AM, AndrewGr <[hidden email]> wrote:
Hi Brian!

Concerning "(although we have ideas how to clean this up, but that is a
different topic)". Could you please mention a little bit how to disable
realms? As this is exactly what I am working on now!

Honestly I was also thinking to do this via
RealmSecurityManager.setRealms(), as it looks pretty straight forward for
adding the realm, but I am a little bit concerned about reducing the list of
realms in the same way...

Thank you!



--
Sent from: http://shiro-user.582556.n2.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Programmatic configuration

AndrewGr
That sounds good! Thank you for sharing your experience with that! )



--
Sent from: http://shiro-user.582556.n2.nabble.com/