我如何通过ning http客户端支持基于Kerberos的身份验证?
我正在扩展现有代码,该代码支持NTLMAuth,并且希望能够包括对Kerberos的支持,该协议在我需要测试的某些网站中使用。
我希望能够以编程方式输入用户名和密码,我不想在运行它的系统上使用keyTab或设置krb5配置。
我有以下代码块;
import com.ning.http.client.RequestBuilder;
import com.ning.http.client.Realm.RealmBuilder;
....
RealmBuilder myRealmBuilder = new RealmBuilder()
.setScheme(AuthScheme.KERBEROS)
.setUsePreemptiveAuth(true)
.setNtlmDomain(getDomain())
.setNtlmHost(getHost())
.setPrincipal(getUsername())
.setPassword(getUserPassword()));
RequestBuilder rb = new RequestBuilder()
.setMethod(site.getMethod())
.setUrl(site.getUrl())
.setFollowRedirects(site.isFollowRedirects())
.setRealm(myRealmBuilder),
site)
´´´
Currently I get the error response:
FAILED: Invalid name provided (Mechanism level: KrbException: Cannot locate default realm)
Does anyone have an good example of how to do this correctly?