use of org.apache.felix.deploymentadmin.itest.util.DPSigner in project felix by apache.
the class DPSignerTest method testSignArtifactsOk.
@Test
public void testSignArtifactsOk() throws Exception {
URL dpProps = getClass().getResource("/dp.properties");
assertNotNull(dpProps);
DeploymentPackageBuilder builder = DeploymentPackageBuilder.create("dpSignerTest1", "1.0.0");
builder.add(builder.createLocalizationResource().setUrl(dpProps).setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setFilename("dp.properties"));
SignerInfo signerInfo = CertificateUtil.createSelfSignedCert("CN=testCert", KeyType.RSA);
DPSigner signer = new DPSigner();
byte[] rawData;
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
signer.sign(builder, signerInfo.getPrivate(), signerInfo.getCert(), baos);
rawData = baos.toByteArray();
}
try (ByteArrayInputStream bais = new ByteArrayInputStream(rawData);
JarInputStream jis = new JarInputStream(bais, true)) {
JarEntry entry;
while ((entry = jis.getNextJarEntry()) != null) {
assertNotNull(entry);
jis.closeEntry();
}
assertNotNull(jis.getManifest());
}
}
Aggregations