Changeset 30829 in osm for applications
- Timestamp:
- 2014-11-29T20:52:09+01:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/trustosm
- Files:
-
- 6 added
- 6 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/trustosm/.classpath
r30750 r30829 2 2 <classpath> 3 3 <classpathentry kind="src" path="src"/> 4 <classpathentry kind="lib" path="lib/bcpg-jdk15on-1.50.jar" sourcepath="bcpg-jdk15on-1.50-sources.jar"> 4 <classpathentry kind="lib" path="lib/jcalendar-1.4.jar"/> 5 <classpathentry kind="lib" path="lib/swingx-core-1.6.5-1.jar"/> 6 <classpathentry kind="lib" path="lib/bcpg-jdk15on-151.jar" sourcepath="lib/bcpg-jdk15on-1.51-sources.jar"> 5 7 <attributes> 6 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-trustosm/ bcpg-jdk15on-1.50-javadoc.jar!/"/>8 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-trustosm/lib/bcpg-jdk15on-1.51-javadoc.jar!/"/> 7 9 </attributes> 8 10 </classpathentry> 9 <classpathentry kind="lib" path="lib/bcprov-jdk15on-1 .50.jar" sourcepath="bcprov-jdk15on-1.50-sources.jar">11 <classpathentry kind="lib" path="lib/bcprov-jdk15on-151.jar" sourcepath="lib/bcprov-jdk15on-1.51-sources.jar"> 10 12 <attributes> 11 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-trustosm/ bcprov-jdk15on-1.50-javadoc.jar!/"/>13 <attribute name="javadoc_location" value="jar:platform:/resource/JOSM-trustosm/lib/bcprov-jdk15on-1.51-javadoc.jar!/"/> 12 14 </attributes> 13 15 </classpathentry> 14 <classpathentry kind="lib" path="lib/jcalendar-1.4.jar"/>15 <classpathentry kind="lib" path="lib/swingx-core-1.6.5-1.jar"/>16 16 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> 17 17 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> -
applications/editors/josm/plugins/trustosm/build.xml
r30750 r30829 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 7 <property name="plugin.main.version" value="7001" /> 8 9 <!-- Configure these properties (replace "..." accordingly).10 See http://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins11 -->12 8 <property name="plugin.author" value="Christoph Wagner" /> 13 9 <property name="plugin.class" value="org.openstreetmap.josm.plugins.trustosm.TrustOSMplugin" /> … … 40 36 <fileset dir="${plugin.lib.dir}"> 41 37 <include name="**/*.jar"/> 38 <exclude name="**/*-sources.jar"/> 39 <exclude name="**/*-javadoc.jar"/> 42 40 </fileset> 43 41 </path> -
applications/editors/josm/plugins/trustosm/src/org/openstreetmap/josm/plugins/trustosm/util/TrustGPG.java
r30744 r30829 19 19 import java.security.NoSuchAlgorithmException; 20 20 import java.security.NoSuchProviderException; 21 import java.security.Provider; 21 22 import java.security.SecureRandom; 22 23 import java.security.Security; … … 47 48 import javax.swing.SpringLayout; 48 49 50 import org.bouncycastle.bcpg.HashAlgorithmTags; 49 51 import org.bouncycastle.bcpg.sig.NotationData; 50 52 import org.bouncycastle.jce.provider.BouncyCastleProvider; … … 65 67 import org.bouncycastle.openpgp.PGPSignatureSubpacketVector; 66 68 import org.bouncycastle.openpgp.PGPUtil; 69 import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; 70 import org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor; 71 import org.bouncycastle.openpgp.operator.PGPContentSignerBuilder; 72 import org.bouncycastle.openpgp.operator.PGPContentVerifierBuilderProvider; 73 import org.bouncycastle.openpgp.operator.PGPDigestCalculator; 74 import org.bouncycastle.openpgp.operator.PGPDigestCalculatorProvider; 75 import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder; 76 import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider; 77 import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder; 78 import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyPair; 79 import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; 80 import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder; 67 81 import org.bouncycastle.util.encoders.Hex; 68 82 import org.openstreetmap.josm.Main; … … 534 548 } 535 549 536 PGPPrivateKey pgpPrivKey = pgpSecKey.extractPrivateKey(password, "BC"); 537 PGPSignatureGenerator sGen = new PGPSignatureGenerator(pgpSecKey.getPublicKey().getAlgorithm(), digest, "BC"); 538 sGen.initSign(PGPSignature.CANONICAL_TEXT_DOCUMENT, pgpPrivKey); 550 Provider provider = Security.getProvider("BC"); 551 PGPDigestCalculatorProvider digestCalculatorProvider = new JcaPGPDigestCalculatorProviderBuilder().setProvider(provider).build(); 552 PBESecretKeyDecryptor secretKeyDecryptor = new JcePBESecretKeyDecryptorBuilder(digestCalculatorProvider).setProvider(provider).build(password); 553 PGPPrivateKey pgpPrivKey = pgpSecKey.extractPrivateKey(secretKeyDecryptor); 554 int keyAlgorithm = pgpSecKey.getPublicKey().getAlgorithm(); 555 PGPContentSignerBuilder contentSignerBuilder = new JcaPGPContentSignerBuilder(keyAlgorithm, digest).setProvider(provider).setDigestProvider(provider); 556 PGPSignatureGenerator sGen = new PGPSignatureGenerator(contentSignerBuilder); 557 sGen.init(PGPSignature.CANONICAL_TEXT_DOCUMENT, pgpPrivKey); 539 558 540 559 Iterator<?> it = pgpSecKey.getPublicKey().getUserIDs(); … … 575 594 }*/ 576 595 try { 577 sig.initVerify(pgpPub.getPublicKey(sig.getKeyID()), "BC"); 596 Provider provider = Security.getProvider("BC"); 597 PGPContentVerifierBuilderProvider contentVerifierBuilderProvider = new JcaPGPContentVerifierBuilderProvider().setProvider(provider); 598 sig.init(contentVerifierBuilderProvider, pgpPub.getPublicKey(sig.getKeyID())); 578 599 sig.update(sigtext.getBytes(Charset.forName("UTF-8"))); 579 600 return sig.verify(); … … 812 833 813 834 Date now = new Date(); 814 PGPKeyPair pgpKp = new PGPKeyPair(al, kp, now);835 PGPKeyPair pgpKp = new JcaPGPKeyPair(al, kp, now); 815 836 816 837 getPasswordfromUser(); … … 825 846 } 826 847 827 PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, pgpKp, 828 userId.getText(), protAl[protectBox.getSelectedIndex()], password, true, subPck, null, new SecureRandom(), "BC"); 848 Provider provider = Security.getProvider("BC"); 849 int encAlgorithm = protAl[protectBox.getSelectedIndex()]; 850 PGPDigestCalculator checksumCalculator = new JcaPGPDigestCalculatorProviderBuilder().build().get(HashAlgorithmTags.SHA1); 851 PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(pgpKp.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA1); 852 PBESecretKeyEncryptor encryptor = new JcePBESecretKeyEncryptorBuilder(encAlgorithm).setProvider(provider). 853 setSecureRandom(new SecureRandom()).build(password); 854 855 PGPKeyRingGenerator keyRingGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, pgpKp, userId.getText(), 856 checksumCalculator, subPck, null, signerBuilder, encryptor); 829 857 830 858 if (pgpPub == null) {
Note:
See TracChangeset
for help on using the changeset viewer.