shiro-dev mailing list archives

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

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(DefaultEnvironment.java:81)
>
> at Quickstart.main(Quickstart.java:60)
>
>
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(Ini.java:47)

at
> org.apache.shiro.env.DefaultEnvironment.setObject(DefaultEnvironment.java:162)

at
> org.apache.shiro.env.DefaultEnvironment.setSecurityManager(DefaultEnvironment.java:92)

at Quickstart.main(Quickstart.java:60)


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.

Thanks,
Dan

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