• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Credentials类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中sun.security.krb5.Credentials的典型用法代码示例。如果您正苦于以下问题:Java Credentials类的具体用法?Java Credentials怎么用?Java Credentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Credentials类属于sun.security.krb5包,在下文中一共展示了Credentials类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: credsToTicket

import sun.security.krb5.Credentials; //导入依赖的package包/类
public static KerberosTicket credsToTicket(Credentials serviceCreds) {
    EncryptionKey sessionKey =  serviceCreds.getSessionKey();
    return new KerberosTicket(
        serviceCreds.getEncoded(),
        new KerberosPrincipal(serviceCreds.getClient().getName()),
        new KerberosPrincipal(serviceCreds.getServer().getName(),
                            KerberosPrincipal.KRB_NT_SRV_INST),
        sessionKey.getBytes(),
        sessionKey.getEType(),
        serviceCreds.getFlags(),
        serviceCreds.getAuthTime(),
        serviceCreds.getStartTime(),
        serviceCreds.getEndTime(),
        serviceCreds.getRenewTill(),
        serviceCreds.getClientAddresses());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:Krb5Util.java


示例2: renewCredentials

import sun.security.krb5.Credentials; //导入依赖的package包/类
private Credentials renewCredentials(Credentials creds)
{
    Credentials lcreds;
    try {
        if (!creds.isRenewable())
            throw new RefreshFailedException("This ticket" +
                            " is not renewable");
        if (System.currentTimeMillis() > cred.getRenewTill().getTime())
            throw new RefreshFailedException("This ticket is past "
                                         + "its last renewal time.");
        lcreds = creds.renew();
        if (debug)
            System.out.println("Renewed Kerberos Ticket");
    } catch (Exception e) {
        lcreds = null;
        if (debug)
            System.out.println("Ticket could not be renewed : "
                            + e.getMessage());
    }
    return lcreds;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:Krb5LoginModule.java


示例3: main

import sun.security.krb5.Credentials; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    final PrincipalName pn = new PrincipalName("[email protected]");
    final String ccache = args[0];

    if (args.length == 1) {
        // Main process, write the ccache and launch sub process
        CredentialsCache cache = CredentialsCache.create(pn, ccache);
        cache.save();
        Proc p = Proc.create("EmptyCC").args(ccache, "readcc")
                .env("KRB5CCNAME", ccache).start();
        p.waitFor();
    } else {
        // Sub process, read the ccache
        String cc = System.getenv("KRB5CCNAME");
        if (!cc.equals(ccache)) {
            throw new Exception("env not set correctly");
        }
        // 8001208: Fix for KRB5CCNAME not complete
        // Make sure the ccache is created with bare file name
        if (CredentialsCache.getInstance() == null) {
            throw new Exception("Cache not instantiated");
        }
        if (!new File("tmpcc").exists()) {
            throw new Exception("File not found");
        }
        Credentials.acquireTGTFromCache(pn, null);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:EmptyCC.java


示例4: isOld

import sun.security.krb5.Credentials; //导入依赖的package包/类
private static boolean isOld(Credentials creds)
{
    Date endTime = creds.getEndTime();
    if (endTime != null) {
        Date authTime = creds.getAuthTime();
        long now = System.currentTimeMillis();
        if (authTime != null) {
            // pass the mid between auth and end
            return now - authTime.getTime() > endTime.getTime() - now;
        } else {
            // will expire in less than 2 hours
            return now <= endTime.getTime() - 1000*3600*2L;
        }
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Krb5LoginModule.java


示例5: renewCredentials

import sun.security.krb5.Credentials; //导入依赖的package包/类
private Credentials renewCredentials(Credentials creds)
{
    Credentials lcreds;
    try {
        if (!creds.isRenewable())
            throw new RefreshFailedException("This ticket" +
                            " is not renewable");
        if (creds.getRenewTill() == null) {
            // Renewable ticket without renew-till. Illegal and ignored.
            return creds;
        }
        if (System.currentTimeMillis() > cred.getRenewTill().getTime())
            throw new RefreshFailedException("This ticket is past "
                                         + "its last renewal time.");
        lcreds = creds.renew();
        if (debug)
            System.out.println("Renewed Kerberos Ticket");
    } catch (Exception e) {
        lcreds = null;
        if (debug)
            System.out.println("Ticket could not be renewed : "
                            + e.getMessage());
    }
    return lcreds;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:Krb5LoginModule.java


示例6: getKerberosTicket

import sun.security.krb5.Credentials; //导入依赖的package包/类
private static KerberosTicket getKerberosTicket ( KerberosPrincipal principal, String password, Long expire ) throws Exception {
    PrincipalName principalName = new PrincipalName(principal.getName(), PrincipalName.KRB_NT_PRINCIPAL, principal.getRealm());
    KrbAsReqBuilder builder = new KrbAsReqBuilder(principalName, password != null ? password.toCharArray() : new char[0]);

    if ( expire != null ) {
        System.out.println("Request expires " + expire);
        KerberosTime till = new KerberosTime(expire);
        Field tillF = builder.getClass().getDeclaredField("till");
        tillF.setAccessible(true);
        tillF.set(builder, till);
    }

    Credentials creds = builder.action().getCreds();
    builder.destroy();

    KerberosTicket ticket = Krb5Util.credsToTicket(creds);
    System.out.println("Ends " + ticket.getEndTime().getTime());
    return ticket;
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:20,代码来源:KerberosTest.java


示例7: ticketToCreds

import sun.security.krb5.Credentials; //导入依赖的package包/类
public static Credentials ticketToCreds(KerberosTicket kerbTicket)
        throws KrbException, IOException {
    return new Credentials(
        kerbTicket.getEncoded(),
        kerbTicket.getClient().getName(),
        kerbTicket.getServer().getName(),
        kerbTicket.getSessionKey().getEncoded(),
        kerbTicket.getSessionKeyType(),
        kerbTicket.getFlags(),
        kerbTicket.getAuthTime(),
        kerbTicket.getStartTime(),
        kerbTicket.getEndTime(),
        kerbTicket.getRenewTill(),
        kerbTicket.getClientAddresses());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:Krb5Util.java


示例8: getInitCred

import sun.security.krb5.Credentials; //导入依赖的package包/类
public Credentials getInitCred() {
    if (destroyed) {
        throw new IllegalStateException("This object is destroyed");
    }
    if (tgt == null) {
        return null;
    }
    try {
        return Krb5Util.ticketToCreds(tgt);
    } catch (KrbException | IOException e) {
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:ServiceCreds.java


示例9: isCurrent

import sun.security.krb5.Credentials; //导入依赖的package包/类
private boolean isCurrent(Credentials creds)
{
    Date endTime = creds.getEndTime();
    if (endTime != null) {
        return (System.currentTimeMillis() <= endTime.getTime());
    }
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:Krb5LoginModule.java



注:本文中的sun.security.krb5.Credentials类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HFileLink类代码示例发布时间:2022-05-21
下一篇:
Java ExceptionHandlingAsyncTaskExecutor类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap