2017-11-22 2 views
0

バーンシーキャッスルpgpでキーペアを生成しようとしています。 私は、この例の使用:http://grepcode.com/file/repo1.maven.org/maven2/org.bouncycastle/bcpg-jdk15/1.45/org/bouncycastle/openpgp/examples/RSAKeyPairGenerator.javaバウンシーキャッスルキージェネレータの例エラー

をしかし、私はライン上/決意を理解できないエラーがありました

PGPSecretKey secretKey = new PGPSecretKey(PGPSignature.DEFAULT_CERTIFICATION, PGPPublicKey.RSA_GENERAL, publicKey, privateKey, new Date(), identity, PGPEncryptedData.CAST5, passPhrase, null, null, new SecureRandom(), "BC"); 

コンストラクタ... を解決することはできませんが、私は、javaを見ればそれは私には大丈夫と思われるドキュメント...

コンパイラエラー

Error:(43, 37) java: no suitable constructor found for PGPSecretKey(int,int,java.security.PublicKey,java.security.PrivateKey,java.util.Date,java.lang.String,int,char[],<nulltype>,<nulltype>,java.security.SecureRandom,java.lang.String) 
    constructor org.bouncycastle.openpgp.PGPSecretKey.PGPSecretKey(org.bouncycastle.bcpg.SecretKeyPacket,org.bouncycastle.openpgp.PGPPublicKey) is not applicable 
     (actual and formal argument lists differ in length) 
    constructor org.bouncycastle.openpgp.PGPSecretKey.PGPSecretKey(org.bouncycastle.openpgp.PGPPrivateKey,org.bouncycastle.openpgp.PGPPublicKey,org.bouncycastle.openpgp.operator.PGPDigestCalculator,org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor) is not applicable 
     (actual and formal argument lists differ in length) 
    constructor org.bouncycastle.openpgp.PGPSecretKey.PGPSecretKey(org.bouncycastle.openpgp.PGPPrivateKey,org.bouncycastle.openpgp.PGPPublicKey,org.bouncycastle.openpgp.operator.PGPDigestCalculator,boolean,org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor) is not applicable 
     (actual and formal argument lists differ in length) 
    constructor org.bouncycastle.openpgp.PGPSecretKey.PGPSecretKey(int,org.bouncycastle.openpgp.PGPKeyPair,java.lang.String,org.bouncycastle.openpgp.PGPSignatureSubpacketVector,org.bouncycastle.openpgp.PGPSignatureSubpacketVector,org.bouncycastle.openpgp.operator.PGPContentSignerBuilder,org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor) is not applicable 
     (actual and formal argument lists differ in length) 
    constructor org.bouncycastle.openpgp.PGPSecretKey.PGPSecretKey(int,org.bouncycastle.openpgp.PGPKeyPair,java.lang.String,org.bouncycastle.openpgp.operator.PGPDigestCalculator,org.bouncycastle.openpgp.PGPSignatureSubpacketVector,org.bouncycastle.openpgp.PGPSignatureSubpacketVector,org.bouncycastle.openpgp.operator.PGPContentSignerBuilder,org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor) is not applicable 
     (actual and formal argument lists differ in length) 

おかげ

+1

これは、インポートしたクラスに12パラメータコンストラクタがないようです。参照として使用しているJavaDocが、実際に使用しているバージョンと一致していない可能性があります。 – Hulk

答えて

3

バージョン1.45を使用しています。これはかなり古く、現在のバージョンは1.58です。

@Hulkは正しく推測されているので、Javadocは12引数のコンストラクタを持つ非常に新しいバージョンを参照しているようです。このコンストラクタは1.45には存在しません。

POMを参照バージョン1.58に更新してください。