【发布时间】:2014-04-10 21:02:08
【问题描述】:
我有一个界面
import javax.naming.AuthenticationException;
import com.unboundid.ldap.sdk.LDAPException;
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, LDAPException;
/**
* Disconnects the connection.
*/
void disconnect();
}
实现该接口的类
package com.cerner.jira.plugins.esig.servicemanagerimpl;
import javax.naming.AuthenticationException;
import com.cerner.jira.plugins.esig.servicemanager.AuthenticationServiceManager;
import com.unboundid.ldap.sdk.LDAPException;
public class AuthenticationManagerImpl implements AuthenticationServiceManager {
@Override
public boolean authenticate(String username, String password)
throws AuthenticationException, LDAPException {
return false;
}
@Override
public boolean authenticate(String username, String password, String url)
{
return false;
}
@Override
public void disconnect() {
// TODO Auto-generated method stub
}
}
我正在尝试创建一个可用于实现连接类的接口。我应该能够将它用于不同的身份验证,如 LDAP、OpenId 等;所以我想传递用户名、密码(如果是 LDAP)和可变数量的参数(如果是 OpenId)。我怎么做?我试过这个。它正在抛出错误。如何初始化对象以保存可变参数?
错误:AuthenticationManagerImpl 类型的方法 authenticate(String, String) 必须重写或实现超类型方法
【问题讨论】:
-
“抛出错误。” 什么错误?总是,总是,总是包含这样的基本信息。为什么你会认为它是可选的?
-
我认为您在这里有点重新发明轮子。你检查过这个吗? docs.spring.io/spring-security/site/docs/3.1.x/reference/…
-
对此我很抱歉..这是错误“AuthenticationManagerImpl 类型的方法 authenticate(String, String) 必须覆盖或实现超类型方法”
标签: java parameter-passing argument-passing