use of org.apache.felix.deploymentadmin.itest.util.CertificateUtil.SignerInfo 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());
}
}
use of org.apache.felix.deploymentadmin.itest.util.CertificateUtil.SignerInfo in project felix by apache.
the class InstallDeploymentPackageTest method testInstallDeploymentPackageWithLocalizationAndSignatureFilesOk.
/**
* FELIX-518 - Test that DP with localization and signature files are properly deployed.
*/
@Test
public void testInstallDeploymentPackageWithLocalizationAndSignatureFilesOk() throws Exception {
URL dpProps = getClass().getResource("/dp.properties");
assertNotNull(dpProps);
SignerInfo signer = createSelfSignedCert("CN=dpTest", KeyType.EC);
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.signOutput(signer.getPrivate(), signer.getCert()).add(dpBuilder.createLocalizationResource().setUrl(dpProps).setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setFilename("dp.properties")).add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
// should succeed.
installDeploymentPackage(dpBuilder);
assertBundleExists("testbundles.bundle1", "1.0.0");
assertBundleExists("testbundles.bundle2", "1.0.0");
assertBundleExists("testbundles.rp1", "1.0.0");
}
Aggregations