本文整理汇总了Java中net.handle.hdllib.Util.decrypt方法的典型用法代码示例。如果您正苦于以下问题:Java Util.decrypt方法的具体用法?Java Util.decrypt怎么用?Java Util.decrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.handle.hdllib.Util
的用法示例。
在下文中一共展示了Util.decrypt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readPrivKey
import net.handle.hdllib.Util; //导入方法依赖的package包/类
private PrivateKey readPrivKey(byte[] key, final String file) {
PrivateKey privkey=null;
String secret = System.getProperty("dataverse.handlenet.admprivphrase");
byte secKey[] = null;
try {
if(Util.requiresSecretKey(key)){
secKey = secret.getBytes();
}
key = Util.decrypt(key, secKey);
privkey = Util.getPrivateKeyFromBytes(key, 0);
} catch (Throwable t){
logger.severe("Can't load private key in " + file +": " + t);
}
return privkey;
}
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:17,代码来源:HandlenetServiceBean.java
示例2: init
import net.handle.hdllib.Util; //导入方法依赖的package包/类
/**
*
*
* @exception ServletException
*/
public void init() throws ServletException
{
HandleConfig handleConfig = HandleConfig.getHandleConfig();
try
{
HashMap<String,Object> hm = new HashMap<String,Object>();
String na = getInitParameter("naming-authority");
if (na == null)
{
throw new ServletException("naming-authority not set, unable to initialise");
}
hm.put("naming-authority", na);
String configDir = getInitParameter("config-dir");
if (configDir == null)
{
throw new ServletException("config-dir not set, unable to initialise");
}
hm.put("config-dir", configDir);
File privateKeyFile = new File(configDir + File.separator + "admpriv.bin");
FileInputStream in = new FileInputStream(privateKeyFile);
byte encKeyBytes[] = new byte[(int)privateKeyFile.length()];
int n = 0; int r= 0;
while(n < encKeyBytes.length && (r = in.read(encKeyBytes, n, encKeyBytes.length-n)) > 0)
{
n +=r;
}
in.close();
// only support unencrypted keys for now
byte[] keyBytes = Util.decrypt(encKeyBytes, null);
hm.put("key", Util.getPrivateKeyFromBytes(keyBytes, 0));
handleConfig.init(hm);
}
catch (Exception e)
{
log.error("Exception occurred", e);
throw new ServletException(e);
}
}