javapac4j

INSTANCE singleton missing


I would like to add SSO functionalty to an existing Webapp and I am trying to use pac4j for that. I downloaded the jee-jac4j-demo and I am running in errors all over the place which all point to missing static fields called "INSTANCE"

For example:

src/main/webapp/loginForm.jsp line 5:

  FormClient formClient = (FormClient) Config.INSTANCE.getClients().findClient("FormClient").get();

gives me the error:

Unable to compile class for JSP: 

An error occurred at line: [5] in the jsp file: [/loginForm.jsp]
INSTANCE cannot be resolved or is not a field
5:  FormClient formClient = (FormClient) Config.INSTANCE.getClients().findClient("FormClient").get();

According the javadocs this field went away around version 6.0.0-RC2.

So here my questions:

action = client.getRedirectionAction(new CallContext(context, JEESessionStore.INSTANCE)).get();

CallContext only seems to exist in pac4j 6.0, but JEESessionStore.INSTANCE is gone there?!


Solution

  • You are fully right. There was an issue.

    Using singletons is not generally the best practice so I removed it.

    In plain JEE, it is still necessary though so the singleton is back in the ConfigFactory this time. It's fixed by this commit: https://github.com/pac4j/jee-pac4j-demo/commit/810da2c224f18f4a7bc44e1f34993cf992ddaf9b