Using for BalusC tutorial for implementing shiro to a JSF app http://balusc.blogspot.fi/2013/01/apache-shiro-is-it-ready-for-java-ee-6.html
Currently I am trying to add my own custom realm on top of the example, but I am obviously missing something.
I have the shiro.ini as follows (mainly copied from the given tutorial and probably all is not necessary):
[main]
user = com.example.filter.AjaxSessionFilter
mockRealm = com.example.realm.MockRealm
authc.loginUrl = /Login.xhtml
user.loginUrl = /Login.xhtml
[users]
admin = password
[urls]
/Login.xhtml = user
/* = user
securityManager.realms = $mockRealm
My MockRealm in short:
import org.apache.shiro.realm.AuthorizingRealm;
public class MockRealm extends AuthorizingRealm { /* Implement stuff */ }
I am running this on GlassFish v4.1. Everything worked so far correctly until I tried to add this custom realm. This results in the following error:
Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: There is no filter with name '$mockRealm' to apply to chain [securityManager.realms] in the pool of available Filters. Ensure a filter with that name/path has first been registered with the addFilter method(s).
I fail to find any information about this error, neither can I find any example how to implement the custom realm correctly.
Could any one point me to right direction? Thanks.
Well, this happens (annoyingly) often.
After a sleep I realized that the
securityManager.realms = $mockRealm
could be at wrong part of the shiro.ini.
Moved this under the [main]
and it worked.
Sometimes you just have to forget things for a while to get a fresh look at them.