如何在win7上通过Java Gss-api获取Kerberos凭据

时间:2013-04-23 10:26:51

标签: kerberos jgss

我想编写一个简单的程序,通过调用gss-api来实现客户端和服务器之间的安全通信。我试着这样:

        mgr = GSSManager.getInstance();

        krb5Mechanism = new Oid("1.2.840.113554.1.2.2");
        krb5PrincipalNameType = new Oid("1.2.840.113554.1.2.2.1");

        serviceName = mgr.createName(serviceNameStr, krb5PrincipalNameType);
        cred = mgr.createCredential(serviceName, GSSCredential.INDEFINITE_LIFETIME, krb5Mechanism, GSSCredential.ACCEPT_ONLY);

但是在创建GSSCredential时我得到了GSSException。

GSSException: No valid credentials provided (Mechanism level: Failed to find any Kerberos credentails)
at sun.security.jgss.krb5.Krb5AcceptCredential.getInstance(Unknown Source)
at sun.security.jgss.krb5.Krb5MechFactory.getCredentialElement(Unknown Source)
at sun.security.jgss.GSSManagerImpl.getCredentialElement(Unknown Source)
at sun.security.jgss.GSSCredentialImpl.add(Unknown Source)
at sun.security.jgss.GSSCredentialImpl.<init>(Unknown Source)
at sun.security.jgss.GSSManagerImpl.createCredential(Unknown Source)
at com.juan.gssapi.SimpleGSSAPIServer.loop(SimpleGSSAPIServer.java:55)
at com.juan.gssapi.SimpleGSSAPIServer.main(SimpleGSSAPIServer.java:36)

有人知道原因吗?

0 个答案:

没有答案