0

I find out the official demo about the pac4j for JEE: jee-pac4j-demo in github (https://github.com/pac4j/jee-pac4j-demo)

The configuration for each Authentication mechanisms have defined in the org.pac4j.demo.jee.DemoConfigFactory, refer to the picture below: org.pac4j.demo.jee.DemoConfigFactory

However, many configs are hardcode in the ConfigFactory which is not flexible, is it any ways to define those configs in a property file such as oidc.properties / samls.properties, then we can load these properties and set to the ConfigFactory in order to adapt to diff environment (dev/sit/uat/prod).

Expect to define configs in external property file(s) such as oidc.properties / samls.properties, then we can load these properties and set to the ConfigFactory instead of hardcode configs in the implementation of ConfigFactory

Carson
  • 21
  • 2

1 Answers1

0

You can of course implement your own loading of properties in the DemoConfigFactory via the loading of a java.util.Properties component.

But you also have many other options:

jleleu
  • 2,309
  • 1
  • 13
  • 9
  • how can I use pac4j-config in the jee-pac4j-demo, I don't want to introduce the spring framework into the old application. I cannot find any sample for that. – Carson Apr 20 '23 at 09:32
  • You need to import the dependency and use the `PropertiesConfigFactory` component. It must be built from a map of String/String and then you call `build`. So you must first load the properties before turning it into a map and passing it to the `PropertiesConfigFactory`. Doc is missing here, see: https://github.com/pac4j/pac4j/blob/5.7.x/pac4j-config/src/test/java/org/pac4j/config/client/PropertiesConfigFactoryTests.java – jleleu Apr 24 '23 at 05:26