Nothing looks obviously wrong to me - I'm fairly certain that the SecurityManager should not be overwritten by any other systems. Have you checked your server logs for exceptions or error messages? It may also be helpful to attach a debugger to see if the initialization is actually occurring as you'd expect.
On Sun, Jun 3, 2012 at 11:55 AM, melvyndekort - [email protected] wrote: > I've created an extended EnvironmentLoaderListener. > But I see now when I try to login that my securityManger has no realms > available. > Do you know if my securityManager could be overwritten somewhere? > > public class CdiEnvironmentLoaderListener extends EnvironmentLoaderListener > { > @Inject > JpaRealm jpaRealm; > > @Override > protected WebEnvironment createEnvironment(ServletContext sc) { > WebEnvironment environment = super.createEnvironment(sc); > > RealmSecurityManager rsm = (RealmSecurityManager) > environment.getSecurityManager(); > > HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(); > matcher.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME); > > jpaRealm.setCredentialsMatcher(matcher); > > rsm.setRealm(jpaRealm); > > ((DefaultWebEnvironment) environment).setSecurityManager(rsm); > > return environment; > } > } > > > atomicknight wrote > > > > You can't use the built-in EnvironmentLoaderListener because it doesn't > > use > > injection to build the Environment. However, you should be able to extend > > it and override #createEnvironment(ServletContext) to use an injected > > CdiWebEnvironment instance: > > > > public class CdiEnvironmentLoaderListener extends > > EnvironmentLoaderListener > > { > > @Inject > > private CdiWebEnvironment environment; > > > > protected WebEnvironment createEnvironment(ServletContext sc) { > > // Do your initialization here > > return environment; > > } > > } > > > > I haven't actually tried this because I ended up writing my own > > version of EnvironmentLoaderListener, > > but this should work. > > > > -- > View this message in context: > http://shiro-user.582556.n2.nabble.com/Shiro-in-CDI-JPA2-JSF2-project-tp7577437p7577461.html > Sent from the Shiro User mailing list archive at Nabble.com. > >
