Configuring a Java Authentication SPI for Containers (JASPIC) User Feature

You can develop a JASPIC provider to authenticate inbound web requests by using the interface that is provided in the Liberty server.

About this task

The Java™ Authentication SPI for Containers specification, JSR 196, defines an interface for authentication providers. In the Liberty server, you must package your JASPIC provider as a user feature. Your feature must implement the interface.


  1. Create an OSGi component that provides a service that implements the interface.

    The ProviderService interface defines method, getAuthConfigProvider, which the Liberty run time invokes to retrieve an instance of your JASPIC provider class that implements the interface.

    The following example uses OSGi declarative services annotations:
    @package com.mycompany.jaspi;
    import java.util.Map;
    import org.osgi.service.component.ComponentContext;
    import com.mycompany.jaspi.SampleAuthConfigProvider;
    @Component(service = { ProviderService.class },
               configurationPolicy = ConfigurationPolicy.IGNORE,
               immediate = true,
               property = { "myPoviderPoperty1=value1",
    public class SampleJaspiProviderService implements ProviderService {
        Map<String, String> configProps = null;
        // This method called by the Liberty runtime
        // to get an instance of AuthConfigProvider
        public AuthConfigProvider getAuthConfigProvider(Map<String, String>,
                                                   AuthConfigFactory factory)
            return new SampleAuthConfigProvider(configProps, factory);
        protected void activate(ComponentContext cc) {
            // Read provider config properties here if needed,
            // then pass them to the AuthConfigProvider factory.
            // This example reads the properties from the OSGi
            // component definition.
            configProps = (Map<String, String>) cc.getProperties();
        protected void deactivate(ComponentContext cc) {}
  2. Package the component into an OSGi bundle that is part of your user feature, along with your JASPIC authentication provider.
  3. Ensure that your feature includes the OSGi subsystem content:; type="osgi.subsystem.feature".
  4. After the feature is installed into the user product extension location, configure the server.xml file with the feature name. For example: