webspherejaspic

Custom JASPIC on WebSphere error message


Though similar, the specific problem I have is not addressed in Use JASPIC auth module on WebSphere 8.5

I am getting the following error message:

SECJ8027E: The path and name of file where JASPI persistent registrations are stored must be specified using property com.ibm.websphere.jaspi.configuration.

I can set the custom property in the administration to some existing folder but I wanted to make sure that is the right approach or if there is some step I was missing.

Note I am specifically using the "embedded in application" approach rather than a server installed JASPIC module so I have something like this

@WebListener
public class JaspicInitializer implements
    ServletContextListener {

    @Override
    public void contextInitialized(final ServletContextEvent sce) {

        final Map<String, String> options = new HashMap<>();
        AuthConfigFactory.getFactory()
            .registerConfigProvider(AuthModuleConfigProvider.class.getName(), options, "HttpServlet", null, null);
    }
}

I had the error on both WebSphere 8.5.5.11 and 9.0.0.3


Solution

  • From @Uux comment, I changed the way I do the registration so it no longer give the error.

    @WebListener
    public class JaspicInitializer implements
        ServletContextListener {
    
        private String registrationID;
    
        @Override
        public void contextDestroyed(final ServletContextEvent sce) {
    
            AuthConfigFactory.getFactory().removeRegistration(registrationID);
        }
    
        @Override
        public void contextInitialized(final ServletContextEvent sce) {
    
            final ServletContext context = sce.getServletContext();
            registrationID = AuthConfigFactory.getFactory()
                .registerConfigProvider(new AuthModuleConfigProvider(), "HttpServlet", 
                  context.getVirtualServerName() + " " + context.getContextPath(), "JEE Sample");
        }
    }
    

    Also WebSphere Global Security needs to be configured with

    enter image description here