本文整理汇总了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;
}