當前位置: 首頁>>代碼示例>>Java>>正文


Java KerberosTicket.destroy方法代碼示例

本文整理匯總了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");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:KerberosTixDateTest.java

示例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");
    }
}
 
開發者ID:kkllwww007,項目名稱:jstrom,代碼行數:27,代碼來源:AutoTGT.java

示例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");
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:27,代碼來源:UserGroupInformation.java

示例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;
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:16,代碼來源:KerberosUtils.java

示例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);
    
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:44,代碼來源:KerberosTicketTest.java


注:本文中的javax.security.auth.kerberos.KerberosTicket.destroy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。