当前位置: 首页>>代码示例>>Java>>正文


Java Credentials.acquireTGTFromCache方法代码示例

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


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

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

示例2: 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();

        // java -cp $test.classes EmptyCC readcc
        ProcessBuilder pb = new ProcessBuilder(
                new File(new File(System.getProperty("java.home"), "bin"),
                    "java").getPath(),
                "-cp",
                System.getProperty("test.classes"),
                "EmptyCC",
                ccache,
                "readcc"
                );

        pb.environment().put("KRB5CCNAME", ccache);
        pb.redirectErrorStream(true);

        Process p = pb.start();
        try (InputStream ins = p.getInputStream()) {
            byte[] buf = new byte[8192];
            int n;
            while ((n = ins.read(buf)) > 0) {
                System.out.write(buf, 0, n);
            }
        }
        if (p.waitFor() != 0) {
            throw new Exception("Test failed");
        }
    } 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:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:52,代码来源:EmptyCC.java


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