Developing a local authentication handler
Implement the AuthenticationHandler interface to create a local authentication handler.
Note: Where
c.p.d is used in package names, it
indicates com.pushtechnology.diffusion.
-
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(); } }
- Ensure that you import Credentials from the c.p.d.client.types package, not the c.p.d.api package.
- Implement the authenticate method.
- Use the allow, deny, or abstain method on the Callback object to respond with the authentication decision.
-
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.
-
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>
-
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.