我想要做的是創建一個可以用來實現連接類的接口。我應該能夠使用這個不同的認證,如LDAP,OpenId等;所以我想通過用戶名,密碼和可變數量的參數。我該怎麼做..我試過這個。我正朝着正確的方向前進嗎?如果是這樣,我如何初始化該對象來保存可變參數。新手到java。將非常感謝幫助。謝謝!如何在java中傳遞可變參數/持有可變參數的對象?
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();
}
您是否正在使用java 5或以上版本?你會得到什麼確切的錯誤?如果沒有錯誤,請繼續。儘快啓動並測試。 – Snicolas
我正在使用Java 6 ...因爲我是新的,我只是想確保..看看是否有替代或更好的方式來做到這一點 – user3438489
該機器是你的[奧卡姆剃刀](http:// en.wikipedia.org/wiki/Occam's_razor),而不是SOF。 – Snicolas