How can my JASPIC ServerAuthModule get properties from jaspic-providers.xml in tomcat?

31 Views Asked by At

I'm using Tomcat 9. I have a provider in jaspic-providers.xml

  <provider name="test-oauth"
            className="org.apache.catalina.authenticator.jaspic.SimpleAuthConfigProvider"
            layer="HttpServlet"
            appContext="Catalina/localhost /"
            description="OAuth test">
    <property name="org.apache.catalina.authenticator.jaspic.ServerAuthModule.1"
              value="com.oauth.OAuthServerAuthModule" />
    <property name="clientid"
              value="abc123" />
    <property name="clientsecret"
              value="xyz321" />
  </provider>

I am not sure how to get these properties to my ServerAuthModule. I have a ServletContextListener and can see that the jaspic-providers.xml file is being processed if I call:

AuthConfigFactory factory = AuthConfigFactory.getFactory();

It looks like I need to get the properties from the factory before calling:

factory.registerConfigProvider(
        new SimpleAuthConfigProvider(props, factory),
        "HttpServlet", null,
        "test"
);

I can't figure out how to get the properties from the provider. If I hardcode the properties before passing them into registerConfigProvider, the ServerAuthModule functions correctly.

0

There are 0 best solutions below