当前位置: 首页>>代码示例>>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;未经允许,请勿转载。