|
28 | 28 |
|
29 | 29 | import net.jsign.jca.Azure;
|
30 | 30 | import net.jsign.jca.DigiCertONE;
|
| 31 | +import net.jsign.jca.GoogleCloud; |
31 | 32 | import net.jsign.pe.PEFile;
|
32 | 33 |
|
33 | 34 | import static org.junit.Assert.*;
|
@@ -100,6 +101,36 @@ public void testAzureKeyVault() throws Exception {
|
100 | 101 | assertEquals("Digest algorithm", NISTObjectIdentifiers.id_sha256, si.getDigestAlgorithmID().getAlgorithm());
|
101 | 102 | }
|
102 | 103 |
|
| 104 | + @Test |
| 105 | + public void testGoogleCloud() throws Exception { |
| 106 | + File sourceFile = new File("target/test-classes/wineyes.exe"); |
| 107 | + File targetFile = new File("target/test-classes/wineyes-signed-with-signing-service.exe"); |
| 108 | + |
| 109 | + FileUtils.copyFile(sourceFile, targetFile); |
| 110 | + |
| 111 | + SignerHelper helper = new SignerHelper(new StdOutConsole(1), "option") |
| 112 | + .storetype("GOOGLECLOUD") |
| 113 | + .keystore("projects/fifth-glider-316809/locations/global/keyRings/jsignkeyring") |
| 114 | + .storepass(GoogleCloud.getAccessToken()) |
| 115 | + .alias("test") |
| 116 | + .certfile("src/test/resources/keystores/jsign-test-certificate-full-chain-reversed.pem") |
| 117 | + .alg("SHA-256"); |
| 118 | + |
| 119 | + helper.sign(targetFile); |
| 120 | + |
| 121 | + PEFile peFile = new PEFile(targetFile); |
| 122 | + List<CMSSignedData> signatures = peFile.getSignatures(); |
| 123 | + assertNotNull(signatures); |
| 124 | + assertEquals(1, signatures.size()); |
| 125 | + |
| 126 | + CMSSignedData signedData = signatures.get(0); |
| 127 | + assertNotNull(signedData); |
| 128 | + |
| 129 | + // Check the signature algorithm |
| 130 | + SignerInformation si = signedData.getSignerInfos().getSigners().iterator().next(); |
| 131 | + assertEquals("Digest algorithm", NISTObjectIdentifiers.id_sha256, si.getDigestAlgorithmID().getAlgorithm()); |
| 132 | + } |
| 133 | + |
103 | 134 | @Test
|
104 | 135 | public void testDigiCertONE() throws Exception {
|
105 | 136 | String apikey = DigiCertONE.getApiKey();
|
|
0 commit comments