本文整理匯總了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);
}