本文整理汇总了Java中com.trilead.ssh2.crypto.PEMDecoder类的典型用法代码示例。如果您正苦于以下问题:Java PEMDecoder类的具体用法?Java PEMDecoder怎么用?Java PEMDecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PEMDecoder类属于com.trilead.ssh2.crypto包,在下文中一共展示了PEMDecoder类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkKeyFile
import com.trilead.ssh2.crypto.PEMDecoder; //导入依赖的package包/类
private void checkKeyFile() {
myKeyFileEmptyOrCorrect = true;
setErrorText(null);
if (! myKeyButton.isSelected()) return;
final String text = myKeyFileText.getText();
if (StringUtil.isEmptyOrSpaces(text)) return;
final File file = new File(text);
if (! file.exists()) {
setErrorText("Private key file does not exist");
myKeyFileEmptyOrCorrect = false;
return;
}
final char[] password = myPassphraseText.getPassword();
try {
PEMDecoder.decode(SVNSSHPrivateKeyUtil.readPrivateKey(file), String.valueOf(password));
}
catch (IOException e) {
setErrorText("Private key file is not valid. " + e.getMessage());
myKeyFileEmptyOrCorrect = false;
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:SSHCredentialsDialog.java
示例2: authenticatePublicKey
import com.trilead.ssh2.crypto.PEMDecoder; //导入依赖的package包/类
public boolean authenticatePublicKey(String user, char[] PEMPrivateKey, String password, SecureRandom rnd)
throws IOException
{
KeyPair pair = PEMDecoder.decode(PEMPrivateKey, password);
return authenticatePublicKey(user, pair, rnd);
}
开发者ID:dragonlinux,项目名称:connectbot,代码行数:8,代码来源:AuthenticationManager.java
示例3: authenticatePublicKey
import com.trilead.ssh2.crypto.PEMDecoder; //导入依赖的package包/类
public boolean authenticatePublicKey(String user, char[] PEMPrivateKey, String password, SecureRandom rnd)
throws IOException
{
Object key = PEMDecoder.decode(PEMPrivateKey, password);
return authenticatePublicKey(user, key, rnd);
}
开发者ID:runsoftdev,项目名称:bVnc,代码行数:8,代码来源:AuthenticationManager.java
示例4: tryPublicKey
import com.trilead.ssh2.crypto.PEMDecoder; //导入依赖的package包/类
/**
* Attempt connection with database row pointed to by cursor.
* @param cursor
* @return true for successful authentication
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
* @throws IOException
*/
private boolean tryPublicKey(PubkeyBean pubkey) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException {
KeyPair pair = null;
if(manager.isKeyLoaded(pubkey.getNickname())) {
// load this key from memory if its already there
Log.d(TAG, String.format("Found unlocked key '%s' already in-memory", pubkey.getNickname()));
if (pubkey.isConfirmUse()) {
if (!promptForPubkeyUse(pubkey.getNickname()))
return false;
}
pair = manager.getKey(pubkey.getNickname());
} else {
// otherwise load key from database and prompt for password as needed
String password = null;
if (pubkey.isEncrypted()) {
password = bridge.getPromptHelper().requestStringPrompt(null,
manager.res.getString(R.string.prompt_pubkey_password, pubkey.getNickname()));
// Something must have interrupted the prompt.
if (password == null)
return false;
}
if(PubkeyDatabase.KEY_TYPE_IMPORTED.equals(pubkey.getType())) {
// load specific key using pem format
pair = PEMDecoder.decode(new String(pubkey.getPrivateKey()).toCharArray(), password);
} else {
// load using internal generated format
PrivateKey privKey;
try {
privKey = PubkeyUtils.decodePrivate(pubkey.getPrivateKey(),
pubkey.getType(), password);
} catch (Exception e) {
String message = String.format("Bad password for key '%s'. Authentication failed.", pubkey.getNickname());
Log.e(TAG, message, e);
bridge.outputLine(message);
return false;
}
PublicKey pubKey = PubkeyUtils.decodePublic(pubkey.getPublicKey(), pubkey.getType());
// convert key to trilead format
pair = new KeyPair(pubKey, privKey);
Log.d(TAG, "Unlocked key " + PubkeyUtils.formatKey(pubKey));
}
Log.d(TAG, String.format("Unlocked key '%s'", pubkey.getNickname()));
// save this key in memory
manager.addKey(pubkey, pair);
}
return tryPublicKey(host.getUsername(), pubkey.getNickname(), pair);
}
开发者ID:dragonlinux,项目名称:connectbot,代码行数:65,代码来源:SSH.java
示例5: authenticatePublicKey
import com.trilead.ssh2.crypto.PEMDecoder; //导入依赖的package包/类
public boolean authenticatePublicKey(String user, char[] PEMPrivateKey,
String password, SecureRandom rnd) throws IOException {
Object key = PEMDecoder.decode(PEMPrivateKey, password);
return authenticatePublicKey(user, key, rnd);
}
开发者ID:jianlinwei,项目名称:sshtunnel,代码行数:7,代码来源:AuthenticationManager.java
注:本文中的com.trilead.ssh2.crypto.PEMDecoder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论