Question

What I'm trying to do is to create an interface that can be used to implement a connection class. I should be able to use this for different authentication like LDAP, OpenId etc; So I want to pass username,password and variable number of arguments. How do I do that.. I tried this. Am I going in the right direction.? If so, how do I initialize the object to hold variable parameters.? Newbie to java. would greatly appreciate the help. Thanks!

package com.cerner.jira.plugins.esig.servicemanager;
import javax.naming.AuthenticationException;

public interface AuthenticationServiceManager {

   /**
    * Creates the Connection for the specific user logging in, and binds the
    * user's credentials to  object.
    * 
    * @param userName
    *            The user name to authenticate .
    * @param password
    *            The user's password to check .
    * @param args
    *            is an object that holds variable arguments which can be used
    *            to authenticate using both LDAP and OpenId
    * @return boolean The connection status showing whether the user has been
    *         successfully authenticated or not.
    * @throws AuthenticationException
    *             If there is an error authenticating with the passed
    *             parameters
    **/

    boolean authenticate(String username, String password, Object... args)
        throws AuthenticationException;

    /**
    * Disconnects the connection.
    */
    void disconnect();
}
Was it helpful?

Solution

Looks like you've got it. You call it like this:

authenticate(username, password, someOtherArgument, yetAnotherArgument, stillAnotherArgument);

And then inside your method, args[0] will contain someOtherArgument, args[1] will contain yetAnotherArgument and args[2] will contain stillAnotherArgument.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top