Difficulty with LoginContext
firepoet Jan 6, 2004 12:09 PM
"firepoet" wrote:
Greetings all,
I'm attempting to implement a custom filter that authenticates different users in different ways depending on the state of the application. The filter loads a LoginContext and attempts to perform the login using a generic HtmlCallbackHandler we've written with Apache's ECS. However, the custom login module we've written isn't even getting loaded. It seems to be using the default login module (evidenced when we change prompts and they don't change on-screen).
We have configured an "auth.conf" file, and archived it in the same .JAR file as our module's .class file:Custom { auth.CustomLoginModule required datasource=java:/ds/customDS debug="true"; };
We let our applications choose which module to use in a properties file, also bundled in the same .JAR file:auth.loginModuleName=Custom
We attempt to tell Java to use the "Custom" module in our code:public LoginContext getLoginContext(CallbackHandler handler) throws ConfigurationException { try { if (loginModuleName == null) { String url = getClass().getClassLoader().getResource(AUTH_CONFIG).toString(); System.setProperty("java.security.auth.login.config", url); loginModuleName = getConfig().getProperty(AUTH_MODULE, ""); if (loginModuleName.length() == 0) { return null; } } System.out.println("New context returned with module: " + loginModuleName + " and handler: " + handler.getClass().getName()); return new LoginContext(loginModuleName, handler); } catch (Exception e) { throw new ConfigurationException(e); } }
Finally, in our filter:try { LoginContext context = Config.getInstance().getLoginContext(loginHandler); if (context != null) { context.login(); } filterChain.doFilter(servletRequest, servletResponse); return; } //etc...
We have code that emits HTML depending on what callbacks appeared from the module, and all that is working. However, the callbacks that show up aren't the callbacks from our module. Is there something I'm missing, something that JBoss does that overrides the System.setProperty(...) call that tells my filter's LoginContext which module to use to authenticate?
Thanks for any help in advance,
Stephen Starkey.
P.S. Why in the world doesn't this board preserve white space in code blocks? :-)