本文整理汇总了Java中sun.security.krb5.internal.ccache.CredentialsCache.save方法的典型用法代码示例。如果您正苦于以下问题:Java CredentialsCache.save方法的具体用法?Java CredentialsCache.save怎么用?Java CredentialsCache.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.security.krb5.internal.ccache.CredentialsCache
的用法示例。
在下文中一共展示了CredentialsCache.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putInCache
import sun.security.krb5.internal.ccache.CredentialsCache; //导入方法依赖的package包/类
/**
* Put TGS credentials ticket in cache file to persist credentials.
*
* @param tgsCredentials TGS credentials
* @throws KrbException
* @throws IOException
*/
public static void putInCache(sun.security.krb5.Credentials tgsCredentials)
throws KrbException, IOException {
CredentialsCache cache = CredentialsCache.getInstance();
Credentials ccreds = new sun.security.krb5.internal.ccache.Credentials(
tgsCredentials.getClient(),
tgsCredentials.getServer(),
tgsCredentials.getSessionKey(),
new KerberosTime(tgsCredentials.getAuthTime()),
/*new KerberosTime(tgsCredentials.getStartTime())*/ null,
new KerberosTime(tgsCredentials.getEndTime()),
/*new KerberosTime(receivedCredentials.getRenewTill())*/ null,
false,
tgsCredentials.getTicketFlags(),
/*new HostAddresses(receivedCredentials.getClientAddresses())*/ null,
null,
tgsCredentials.getTicket(),
null);
cache.update(ccreds);
cache.save();
}
示例2: main
import sun.security.krb5.internal.ccache.CredentialsCache; //导入方法依赖的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);
}
}
示例3: main
import sun.security.krb5.internal.ccache.CredentialsCache; //导入方法依赖的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);
}
}