Equivalent of 'gss_import_name' and 'gss_init_sec_context' methods in java?

孤街醉人 提交于 2020-01-06 11:36:28

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!