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


Java KerberosTicket.refresh方法代碼示例

本文整理匯總了Java中javax.security.auth.kerberos.KerberosTicket.refresh方法的典型用法代碼示例。如果您正苦於以下問題:Java KerberosTicket.refresh方法的具體用法?Java KerberosTicket.refresh怎麽用?Java KerberosTicket.refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.security.auth.kerberos.KerberosTicket的用法示例。


在下文中一共展示了KerberosTicket.refresh方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import javax.security.auth.kerberos.KerberosTicket; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {

        OneKDC kdc = new OneKDC(null);

        KDC.saveConfig(OneKDC.KRB5_CONF, kdc,
                "ticket_lifetime = 10s",
                "renew_lifetime = 11s");
        Config.refresh();

        KerberosTicket ticket = Context
                .fromUserPass(OneKDC.USER, OneKDC.PASS, false).s()
                .getPrivateCredentials(KerberosTicket.class).iterator().next();

        System.out.println(ticket);
        Asserts.assertTrue(ticket.getRenewTill() != null, ticket.toString());

        Thread.sleep(2000);

        ticket.refresh();
        System.out.println(ticket);
        Asserts.assertTrue(ticket.getRenewTill() == null, ticket.toString());

        Thread.sleep(2000);
        ticket.refresh();
        System.out.println(ticket);
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:NullRenewUntil.java

示例2: renew

import javax.security.auth.kerberos.KerberosTicket; //導入方法依賴的package包/類
@Override
public void renew(Map<String, String> credentials, Map topologyConf) {
    KerberosTicket tgt = getTGT(credentials);
    if (tgt != null) {
        long refreshTime = getRefreshTime(tgt);
        long now = System.currentTimeMillis();
        if (now >= refreshTime) {
            try {
                LOG.info("Renewing TGT for " + tgt.getClient());
                tgt.refresh();
                saveTGT(tgt, credentials);
            } catch (RefreshFailedException e) {
                LOG.warn("Failed to refresh TGT", e);
            }
        }
    }
}
 
開發者ID:kkllwww007,項目名稱:jstrom,代碼行數:18,代碼來源:AutoTGT.java

示例3: 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


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