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