shiro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Dold <>
Subject Setting up Enviroment
Date Thu, 01 Jun 2017 21:30:37 GMT

I am trying to work on SHIRO-625 ticket and I am finding it hard to
understand the new implementation.

I understand the deprecated code;

> Factory<SecurityManager> factory = new IniSecurityManagerFactory("
> classpath:shiro.ini")

SecurityManager securityManager = factory.getInstance()

This is a simple implementation but looking up how to implement the
Environment class in a similar fashion is proving very difficult.
So far I have got as far as;

> Ini config = Ini.fromResourcePath("classpath;shiro:ini")

Environment environment = new DefaultEnvironment(config)

SecurityManager securityManager = environment.getSecurityManager()

But running this produces the following error;

> Exception in thread "main" java.lang.IllegalStateException: No
>> SecurityManager found in Environment.  This is an invalid environment state.
> at
>> org.apache.shiro.env.DefaultEnvironment.getSecurityManager(
> at Quickstart.main(
I have tried setting the SecurityManager doing the following;

>  environment.setSecurityManager(new DefaultSecurityManager());

But that gave the following error;


Exception in thread "main" java.lang.ClassCastException:
> org.apache.shiro.mgt.DefaultSecurityManager cannot be cast to
> org.apache.shiro.config.Ini$Section

at org.apache.shiro.config.Ini.put(

> org.apache.shiro.env.DefaultEnvironment.setObject(

> org.apache.shiro.env.DefaultEnvironment.setSecurityManager(

at Quickstart.main(

I'm completely stuck on where to turn now.
Is there any documentation on how to setup Shiro using the Enviroment (or
is that what I am trying to setup), even a quick explanation on where I am
going right/wrong.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message