问题
I'm creating a small application(for now) that needs to generate a Token with Kerberos library. The two methods equivalent I'm searching for are the gss_import_name and gss_init_sec_context methods. I have found several examples in other languages: C,C++ and C#, but none in Java. I'm not even sure of which library to import in my application. If someone has an answer to my question it would be very helpful to me.
Cordially, Ephismen.
回答1:
The package you want to use is sun.security.jgss. In that package you will find you can do the following:
byte[] kerberosTicket;
GSSContext context = GSSManager.getInstance().createContext((GSSCredential);
context.initSecContext(kerberosTicket, 0, kerberosTicket.length);
String user = context.getSrcName().toString();
context.dispose();
return user;
The only implementation of GSSContext
is GSSContextImpl
which is also in the same package.
Grant
回答2:
If you look at this document:
Generic Security Service API Version 2 : Java Bindings
This document explains a lot about GSS and gives a couple examples. One section of the document explains which interfaces implement functionality of the GSS-API routines you mentioned above.
gss_import_name : implemented by the GSSManager class.
gss_init_sec_context: implemented by the GSSContext interface.
来源:https://stackoverflow.com/questions/4085460/equivalent-of-gss-import-name-and-gss-init-sec-context-methods-in-java