Table of Contents
Just a second...

Developing a local authentication handler

Implement the AuthenticationHandler interface to create a local authentication handler.

Local authentication handlers can be implemented only in Java™.
Note: Where c.p.d is used in package names, it indicates com.pushtechnology.diffusion.
  1. Create a Java class that implements AuthenticationHandler.
    package com.example;
                        
    import com.pushtechnology.diffusion.client.details.SessionDetails;
    import com.pushtechnology.diffusion.client.security.authentication.AuthenticationHandler;
    import com.pushtechnology.diffusion.client.types.Credentials;
                    
    public class ExampleAuthenticationHandler implements AuthenticationHandler{
    
        public void authenticate(String principal, Credentials credentials,
                SessionDetails sessionDetails, Callback callback) {
                
            // Logic to make the authentication decision.
            
            // Authentication decision
            callback.abstain();
           
            // callback.deny();
            // callback.allow();
         
        }
    
    }
    1. Ensure that you import Credentials from the c.p.d.client.types package, not the c.p.d.api package.
    2. Implement the authenticate method.
    3. Use the allow, deny, or abstain method on the Callback object to respond with the authentication decision.
  2. Package your compiled Java class in a JAR file and put the JAR file in the ext directory of your Diffusion™ installation.
    This includes the authentication handler on the server classpath.
  3. Edit the etc/Server.xml configuration file to point to your authentication handler.
    Include the authentication-handler element in the list of authentication handlers. The order of the list defines the order in which the authentication handlers are called. The value of the class attribute is the fully qualified name of your authentication handler class. For example:
    <security>
        <authentication-handlers>
                
            <authentication-handler class="com.example.ExampleAuthenticationHandler" />
            
        </authentication-handlers>
    </security>
  4. Start or restart the Diffusion server.
    • On UNIX®-based systems, run the diffusion.sh command in the diffusion_installation_dir/bin directory.
    • On Windows™ systems, run the diffusion.bat command in the diffusion_installation_dir\bin directory.