How do I use custom authentication with spark?

When using an authentication strategy that's been developed for your site, you can use the same authenticator that you use for your Java client.

If the AMPS default authenticator works with your custom authentication strategy, you simply need to provide a username and password to the server parameter, as described in the AMPS User Guide

> spark sow -topic demo -server user:pass@localhost:9007 -topic myTopic

If you have developed a custom authenticator, then you can implement the AuthenticatorFactory interface.

Source code for spark, including the interface definition for the AuthenticatorFactory, is provided with the AMPS java client. The AuthenticatorFactory has the following interface:

public interface AuthenticatorFactory
{

   public Authenticator createAuthenticator(String connectionURI)


            throws AuthenticationException; 
}

Once you have implemented the interface to return your custom authenticator, you can then direct spark to use your AuthenticatorFactory. For example, if your authenticator factory is com.example.MyAuth, the command line would be:

> spark sow -topic demo -server localhost:9007 -topic myTopic \

   –authenticator com.example.MyAuth

Last updated