はセッターがかかるResource
...
/**
* Allows you to set a {@link Resource}, which represents the location of the
* private key used for authenticating against the remote host. If the privateKey
* is not provided, then the {@link DefaultSftpSessionFactory#setPassword(String) password}
* property is mandatory (or {@link #setUserInfo(UserInfo) userInfo} that returns a
* password.
* @param privateKey The private key.
* @see JSch#addIdentity(String)
* @see JSch#addIdentity(String, String)
*/
public void setPrivateKey(Resource privateKey) {
this.privateKey = privateKey;
}
あなたが使用できるByteArrayResource
、を含むResource
の多くの種類がありますが、
setPrivateKey(new ByteArrayResource(myKeyString.getBytes());