本文整理汇总了Java中sun.security.jgss.spnego.NegTokenTarg类的典型用法代码示例。如果您正苦于以下问题:Java NegTokenTarg类的具体用法?Java NegTokenTarg怎么用?Java NegTokenTarg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NegTokenTarg类属于sun.security.jgss.spnego包,在下文中一共展示了NegTokenTarg类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import sun.security.jgss.spnego.NegTokenTarg; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
byte[] buf = (byte[])NegTokenTargFields.class.getField(args[0]).get(null);
new NegTokenTarg(buf);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:5,代码来源:NegTokenTargFields.java
示例2: main
import sun.security.jgss.spnego.NegTokenTarg; //导入依赖的package包/类
public static void main(String[] argv) throws Exception {
// Generates a NegTokenInit mechTypes field, with an
// unsupported mech as the preferred.
DerOutputStream mech = new DerOutputStream();
mech.write(new Oid("1.2.3.4").getDER());
mech.write(GSSUtil.GSS_KRB5_MECH_OID.getDER());
DerOutputStream mechTypeList = new DerOutputStream();
mechTypeList.write(DerValue.tag_Sequence, mech);
// Generates a NegTokenInit mechToken field for 1.2.3.4 mech
GSSHeader h1 = new GSSHeader(new ObjectIdentifier("1.2.3.4"), 1);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
h1.encode(bout);
bout.write(new byte[1]);
// Generates the NegTokenInit token
Constructor<NegTokenInit> ctor = NegTokenInit.class.getDeclaredConstructor(
byte[].class, BitArray.class, byte[].class, byte[].class);
ctor.setAccessible(true);
NegTokenInit initToken = ctor.newInstance(
mechTypeList.toByteArray(),
new BitArray(0),
bout.toByteArray(),
null);
Method m = Class.forName("sun.security.jgss.spnego.SpNegoToken")
.getDeclaredMethod("getEncoded");
m.setAccessible(true);
byte[] spnegoToken = (byte[])m.invoke(initToken);
// and wraps it into a GSSToken
GSSHeader h = new GSSHeader(
new ObjectIdentifier(GSSUtil.GSS_SPNEGO_MECH_OID.toString()),
spnegoToken.length);
bout = new ByteArrayOutputStream();
h.encode(bout);
bout.write(spnegoToken);
byte[] token = bout.toByteArray();
// and feeds it to a GSS acceptor
GSSManager man = GSSManager.getInstance();
GSSContext ctxt = man.createContext((GSSCredential) null);
token = ctxt.acceptSecContext(token, 0, token.length);
NegTokenTarg targ = new NegTokenTarg(token);
// Make sure it's a GO-ON message
Method m2 = NegTokenTarg.class.getDeclaredMethod("getNegotiatedResult");
m2.setAccessible(true);
int negResult = (int)m2.invoke(targ);
if (negResult != 1 /* ACCEPT_INCOMPLETE */) {
throw new Exception("Not a continue");
}
}
开发者ID:campolake,项目名称:openjdk9,代码行数:55,代码来源:NotPreferredMech.java
注:本文中的sun.security.jgss.spnego.NegTokenTarg类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论