Equivalent of 'gss_import_name' and 'gss_init_sec_context' methods in java?
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开发者_Go百科 to import in my application. If someone has an answer to my question it would be very helpful to me.
Cordially, Ephismen.
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
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.
精彩评论