本文整理汇总了Java中org.globus.gsi.OpenSSLKey.writeTo方法的典型用法代码示例。如果您正苦于以下问题:Java OpenSSLKey.writeTo方法的具体用法?Java OpenSSLKey.writeTo怎么用?Java OpenSSLKey.writeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.globus.gsi.OpenSSLKey
的用法示例。
在下文中一共展示了OpenSSLKey.writeTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeKey
import org.globus.gsi.OpenSSLKey; //导入方法依赖的package包/类
private void writeKey(OpenSSLKey key, File f) throws GeneralSecurityException {
try {
OutputStream keyStream = openStream(f);
if (!SHARED_PROXIES) {
f.deleteOnExit();
}
try {
key.writeTo(keyStream);
}
finally {
keyStream.close();
}
}
catch (Exception e) {
throw new GeneralSecurityException("Failed to save CA private key", e);
}
}
示例2: writePrivateKey
import org.globus.gsi.OpenSSLKey; //导入方法依赖的package包/类
public static String writePrivateKey(PrivateKey key, String password)
throws Exception {
OpenSSLKey ssl = new BouncyCastleOpenSSLKey(key);
if (password != null) {
ssl.encrypt(password);
}
StringWriter sw = new StringWriter();
ssl.writeTo(sw);
sw.close();
StringBuffer buf = sw.getBuffer();
// strip out any windows-specific carriage return chars
int winNlChar = -1;
while ((winNlChar = buf.indexOf("\r")) != -1) {
buf.deleteCharAt(winNlChar);
}
String s = buf.toString();
return s;
}
示例3: toString
import org.globus.gsi.OpenSSLKey; //导入方法依赖的package包/类
private String toString(OpenSSLKey key) throws Exception {
StringWriter writer = new StringWriter();
key.writeTo(writer);
writer.close();
String s = writer.toString();
System.out.println(s);
return s;
}
示例4: testEncryptAES
import org.globus.gsi.OpenSSLKey; //导入方法依赖的package包/类
public void testEncryptAES() throws Exception {
KeyPair keyPair = getKeyPair();
OpenSSLKey key = new BouncyCastleOpenSSLKey(keyPair.getPrivate());
assertTrue(!key.isEncrypted());
key.setEncryptionAlgorithm("AES-128-CBC");
key.encrypt(pwd);
assertTrue(key.isEncrypted());
key.writeTo(System.out);
}