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