标签:decode mpi erro 匹配 row UI val creat error
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<FileKeyProvider> {
// public Factory() {
// }
//
// public FileKeyProvider create() {
// return new SSH2KeyProvider();
// }
//
// public String getName() {
// return "SSH2";
// }
// }
标签:decode mpi erro 匹配 row UI val creat error
原文地址:http://www.cnblogs.com/breakyang/p/7955012.html