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


Java OpenSSLKey.decrypt方法代码示例

本文整理汇总了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;
}
 
开发者ID:NLeSC,项目名称:vbrowser,代码行数:34,代码来源:GlobusUtil.java

示例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);
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:35,代码来源:DefaultGridProxyModel.java

示例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();
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:9,代码来源:KeyUtil.java


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