You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ryan Esch <ry...@yahoo.com.INVALID> on 2024/02/08 14:37:35 UTC

Getting provider/properties from jaspic-providers.xml to my ServerAuthModule

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 in the xml. If I hardcode the properties before passing them into registerConfigProvider, the ServerAuthModule functions correctly.
Thanks!

Re: Getting provider/properties from jaspic-providers.xml to my ServerAuthModule

Posted by Mark Thomas <ma...@apache.org>.
On 08/02/2024 14:37, Ryan Esch wrote:
> I'm using Tomcat 9. I have a provider in jaspic-providers.xml:

<snip/>

> 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 in the xml. If I hardcode the properties before passing them
> into registerConfigProvider, the ServerAuthModule functions correctly.
> Thanks!

You shouldn't need to call factory.registerConfigProvider() at all. That 
should happen automatically.

Are you sure the appContext is correct. The context path for the ROOT 
web application is "" (the empty string), not "/".

That would make the appContext "Catalina/localhost ".

Note that means it will only be applied to the ROOT web application.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org