博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
KeyProvider
阅读量:4450 次
发布时间:2019-06-07

本文共 2236 字,大约阅读时间需要 7 分钟。

private PublicKey pubKey;     public PublicKey getPublic() throws IOException {
return this.pubKey != null ? this.pubKey : super.getPublic(); } public void init(File location) {
File f = new File(location + ".pub"); if (f.exists()) {
try {
this.initPubKey(new FileReader(f)); } catch (IOException var4) {
this.log.warn("Error reading public key file: {}", var4.toString()); } } super.init(location); } public void init(String privateKey, String publicKey) {
if (publicKey != null) {
this.initPubKey(new StringReader(publicKey)); } super.init(privateKey, null); } private void initPubKey(Reader publicKey) {
this.type = KeyType.DSA; try {
StringBuilder publicKeyString = new StringBuilder(); try (BufferedReader br = new BufferedReader(publicKey)) {
String keydata; while ((keydata = br.readLine()) != null) {
if (skipInvalid(keydata)) {
publicKeyString.append(keydata); } } this.pubKey = (new Buffer.PlainBuffer(Base64.decode(publicKeyString.toString()))).readPublicKey(); } } catch (IOException var9) {
this.log.warn("Error reading public key: {}", var9.toString()); } } private boolean skipInvalid(String keydata) {
String regEx = "[-:\"]"; // 编译正则表达式 Pattern pattern = Pattern.compile(regEx); // 忽略大小写的写法 // Pattern pat = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(keydata); // 字符串是否与正则表达式相匹配 return matcher.matches(); } // public static class Factory implements net.schmizz.sshj.common.Factory.Named
{
// public Factory() {
// } // // public FileKeyProvider create() {
// return new SSH2KeyProvider(); // } // // public String getName() {
// return "SSH2"; // } // }

转载于:https://www.cnblogs.com/breakyang/p/7955012.html

你可能感兴趣的文章
NOI Linux下Emacs && gdb调试方法
查看>>
React (2) -- State and Lifecycle
查看>>
【转】在EmEditor上编译并运行JAVA
查看>>
关于SqlDateTime溢出的问题
查看>>
jquery下php与ajax的数据交换方式
查看>>
魅蓝Note有几种颜色 魅蓝Note哪个颜色好看
查看>>
使用PullToRefresh实现下拉刷新和上拉加载
查看>>
透明度百分比与十六进制转换
查看>>
HBase表预分区
查看>>
arcgis desktop 10.1 license manager无法启动问题解决
查看>>
django select_related() 联表查询
查看>>
mysql 常用,使用经验
查看>>
NSBundle,UIImage,UIButton的使用
查看>>
vue-cli3 中console.log报错
查看>>
GridView 中Item项居中显示
查看>>
UML类图五种关系与代码的对应关系
查看>>
如何理解作用域
查看>>
从无到满意offer,你需要知道的那些事
查看>>
P1516 青蛙的约会 洛谷
查看>>
SDOI2011 染色
查看>>