本文整理汇总了Java中javax.security.auth.kerberos.KerberosTicket.destroy方法的典型用法代码示例。如果您正苦于以下问题:Java KerberosTicket.destroy方法的具体用法?Java KerberosTicket.destroy怎么用?Java KerberosTicket.destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.security.auth.kerberos.KerberosTicket
的用法示例。
在下文中一共展示了KerberosTicket.destroy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDestroy
import javax.security.auth.kerberos.KerberosTicket; //导入方法依赖的package包/类
private static void testDestroy(KerberosTicket t) throws Exception {
t.destroy();
if (!t.isDestroyed()) {
throw new RuntimeException("ticket should have been destroyed");
}
// Although these methods are meaningless, they can be called
for (Method m: KerberosTicket.class.getDeclaredMethods()) {
if (Modifier.isPublic(m.getModifiers())
&& m.getParameterCount() == 0) {
System.out.println("Testing " + m.getName() + "...");
try {
m.invoke(t);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof RefreshFailedException ||
cause instanceof IllegalStateException) {
// this is OK
} else {
throw e;
}
}
}
}
System.out.println("Destroy Test Passed");
}
示例2: populateSubjectWithTGT
import javax.security.auth.kerberos.KerberosTicket; //导入方法依赖的package包/类
private void populateSubjectWithTGT(Subject subject, Map<String, String> credentials) {
KerberosTicket tgt = getTGT(credentials);
if (tgt != null) {
Set<Object> creds = subject.getPrivateCredentials();
synchronized (creds) {
Iterator<Object> iterator = creds.iterator();
while (iterator.hasNext()) {
Object o = iterator.next();
if (o instanceof KerberosTicket) {
KerberosTicket t = (KerberosTicket) o;
iterator.remove();
try {
t.destroy();
} catch (DestroyFailedException e) {
LOG.warn("Failed to destory ticket ", e);
}
}
}
creds.add(tgt);
}
subject.getPrincipals().add(tgt.getClient());
kerbTicket.set(tgt);
} else {
LOG.info("No TGT found in credentials");
}
}
示例3: fixKerberosTicketOrder
import javax.security.auth.kerberos.KerberosTicket; //导入方法依赖的package包/类
private void fixKerberosTicketOrder() {
Set<Object> creds = getSubject().getPrivateCredentials();
synchronized (creds) {
for (Iterator<Object> iter = creds.iterator(); iter.hasNext();) {
Object cred = iter.next();
if (cred instanceof KerberosTicket) {
KerberosTicket ticket = (KerberosTicket) cred;
if (!ticket.getServer().getName().startsWith("krbtgt")) {
LOG.warn("The first kerberos ticket is not TGT"
+ "(the server principal is {}), remove and destroy it.",
ticket.getServer());
iter.remove();
try {
ticket.destroy();
} catch (DestroyFailedException e) {
LOG.warn("destroy ticket failed", e);
}
} else {
return;
}
}
}
}
LOG.warn("Warning, no kerberos ticket found while attempting to renew" +
" ticket");
}
示例4: isCurrent
import javax.security.auth.kerberos.KerberosTicket; //导入方法依赖的package包/类
private static boolean isCurrent(KerberosTicket ticket) {
if (!ticket.isCurrent()) {
try {
ticket.refresh();
} catch (RefreshFailedException e) {
try {
ticket.destroy();
} catch (DestroyFailedException e1) {
e1.printStackTrace();
}
return false;
}
}
return true;
}
示例5: test_equals
import javax.security.auth.kerberos.KerberosTicket; //导入方法依赖的package包/类
/**
* @tests javax.security.auth.kerberos.KerberosTicket#equals(java.lang.Object)
*/
public void test_equals() throws Exception {
KerberosTicket krbTicket1 = new KerberosTicket(ticket, pClient,
pServer, sessionKey, KEY_TYPE, flags, authTime, startTime,
endTime, renewTill, addesses);
KerberosTicket krbTicket2 = new KerberosTicket(ticket, pClient,
pServer, sessionKey, KEY_TYPE, flags, authTime, startTime,
endTime, renewTill, addesses);
KerberosTicket krbTicket3 = new KerberosTicket(ticket, pClient,
pServer, sessionKey, KEY_TYPE, new boolean[] { true, false },
authTime, startTime, endTime, renewTill, addesses);
assertEquals("krbTicket1 and krbTicket2 should be equivalent ",
krbTicket1, krbTicket2);
assertFalse("krbTicket1 and krbTicket3 sholudn't be equivalent ",
krbTicket1.equals(krbTicket3));
try {
krbTicket2.destroy();
} catch (DestroyFailedException e) {
fail("krbTicket2 destroy failed");
}
assertFalse("Destroyed krbTicket sholudn't be equivalent ", krbTicket1
.equals(krbTicket2));
//Regression test for KerberosTicket.equals().
final KerberosPrincipal clientPrincipal = new KerberosPrincipal(
"[email protected]");
final KerberosPrincipal serverPrincipal = new KerberosPrincipal(
"krbtgt/[email protected]");
KerberosTicket tgt = new KerberosTicket(new byte[0], clientPrincipal,
serverPrincipal, new byte[0], 1, new boolean[0],
new Date(1000), null, new Date(new Date().getTime() + 1000),
null, null);
assertEquals(tgt, tgt);
KerberosTicket tgt1 = new KerberosTicket(new byte[0], clientPrincipal,
serverPrincipal, new byte[0], 1, new boolean[0],
new Date(1000), null, new Date(new Date().getTime() + 1000),
null, null);
assertEquals(tgt, tgt1);
assertEquals(tgt1, tgt);
}