本文整理汇总了Java中org.globus.gsi.OpenSSLKey.decrypt方法的典型用法代码示例。如果您正苦于以下问题:Java OpenSSLKey.decrypt方法的具体用法?Java OpenSSLKey.decrypt怎么用?Java OpenSSLKey.decrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.globus.gsi.OpenSSLKey
的用法示例。
在下文中一共展示了OpenSSLKey.decrypt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrivateKey
import org.globus.gsi.OpenSSLKey; //导入方法依赖的package包/类
/**
* Decode userkey.pem and return it.
*
* <pre>
* *** WARNING *** this return the DECRYPTED key. do not store or keep it around in memory.
* </pre>
*
* @throws Exception
*/
public static PrivateKey getPrivateKey(String filename, Secret passprhase) throws Exception
{
// X509Certificate userCert =
// CertUtil.loadCertificate(this.getDefaultUserCertLocation());
OpenSSLKey key = new BouncyCastleOpenSSLKey(filename);
// String charSet="UTF-8";
if (key.isEncrypted())
{
try
{
// byte[] bytes=passprhase.toByteBuffer("UTF-8").array();
// key.decrypt(bytes);
key.decrypt(new String(passprhase.getChars()));
}
catch (GeneralSecurityException e)
{
throw new Exception("Wrong password or other security error");
}
}
java.security.PrivateKey userKey = key.getPrivateKey();
return userKey;
}
示例2: createProxy
import org.globus.gsi.OpenSSLKey; //导入方法依赖的package包/类
public GlobusCredential createProxy(String pwd)
throws Exception {
getProperties();
userCert = CertUtil.loadCertificate(props.getUserCertFile());
OpenSSLKey key =
new BouncyCastleOpenSSLKey(props.getUserKeyFile());
if (key.isEncrypted()) {
try {
key.decrypt(pwd);
} catch(GeneralSecurityException e) {
throw new Exception("Wrong password or other security error");
}
}
PrivateKey userKey = key.getPrivateKey();
BouncyCastleCertProcessingFactory factory =
BouncyCastleCertProcessingFactory.getDefault();
int proxyType = (getLimited()) ?
GSIConstants.DELEGATION_LIMITED :
GSIConstants.DELEGATION_FULL;
return factory.createCredential(new X509Certificate[] {userCert},
userKey,
props.getProxyStrength(),
props.getProxyLifeTime() * 3600,
proxyType,
(X509ExtensionSet)null);
}
示例3: loadPrivateKey
import org.globus.gsi.OpenSSLKey; //导入方法依赖的package包/类
public static PrivateKey loadPrivateKey(File location, String password)
throws IOException, GeneralSecurityException {
OpenSSLKey key = new BouncyCastleOpenSSLKey(location.getAbsolutePath());
if (key.isEncrypted()) {
key.decrypt(password);
}
return key.getPrivateKey();
}