use of won.cryptography.service.keystore.FileBasedKeyStoreService in project webofneeds by researchstudio-sat.
the class TestSigningUtils method printCerts.
public void printCerts() throws IOException, CertificateException {
// load public keys:
File keysFile = new File(this.getClass().getResource(TestSigningUtils.KEYS_FILE).getFile());
KeyStoreService storeService = new FileBasedKeyStoreService(keysFile, "temp");
printCerificate(storeService, atomCertUri, atomCertUri);
printCerificate(storeService, ownerCertUri, ownerCertUri);
printCerificate(storeService, ownerCertUri, nodeCertUri);
}
use of won.cryptography.service.keystore.FileBasedKeyStoreService in project webofneeds by researchstudio-sat.
the class TestSigningUtils method generateKeystoreForNodeAndOwner.
/**
* Not a test - but sometimes can be useful for generating test keys.
*
* @throws Exception
*/
// @Test
public void generateKeystoreForNodeAndOwner() throws Exception {
Security.addProvider(new BouncyCastleProvider());
// KeyStoreService storeServiceOnNode = new KeyStoreService(new
// File("node-keys.jks"));
FileBasedKeyStoreService storeServiceOnOwner = new FileBasedKeyStoreService(new File("owner-keys.jks"), "temp");
storeServiceOnOwner.init();
// KeyStoreService storeServiceOnMatcher = new KeyStoreService(new
// File("matcher-keys.jks"));
KeyPairService keyPairService = new KeyPairService();
CertificateService certificateService = new CertificateService();
// addKeyByUris(new String[]{
// "http://rsa021.researchstudio.at:8080/won/resource",
// "http://sat016.researchstudio.at:8080/won/resource",
// "http://localhost:8080/won/resource"},
// keyPairService, certificateService, storeServiceOnNode);
addKeyByUris(new String[] { "http://rsa021.researchstudio.at:8080/owner/rest/keys", "http://sat016.researchstudio.at:8080/owner/rest/keys", "http://localhost:8080/owner/rest/keys" }, keyPairService, certificateService, storeServiceOnOwner);
// addKeyByUris(new String[]{
// "http://sat001.researchstudio.at:8080/matcher/resource",
// "http://localhost:8080/matcher/resource"},
// keyPairService, certificateService, storeServiceOnMatcher);
}
use of won.cryptography.service.keystore.FileBasedKeyStoreService in project webofneeds by researchstudio-sat.
the class WonMessageSignerVerifierTest method init.
@Before
public void init() throws Exception {
// load public keys:
Security.addProvider(new BouncyCastleProvider());
File keysFile = new File(this.getClass().getResource(TestSigningUtils.KEYS_FILE).getFile());
FileBasedKeyStoreService storeService = new FileBasedKeyStoreService(keysFile, "temp");
storeService.init();
pubKeysMap.put(TestSigningUtils.atomCertUri, storeService.getCertificate(TestSigningUtils.atomCertUri).getPublicKey());
pubKeysMap.put(TestSigningUtils.ownerCertUri, storeService.getCertificate(TestSigningUtils.ownerCertUri).getPublicKey());
pubKeysMap.put(TestSigningUtils.nodeCertUri, storeService.getCertificate(TestSigningUtils.nodeCertUri).getPublicKey());
this.atomKey = (ECPrivateKey) storeService.getPrivateKey(TestSigningUtils.atomCertUri);
// do we need owner key for some messages? e.g. when we send an error occurred
// message not generated by owner client but by owner server?
this.ownerKey = (ECPrivateKey) storeService.getPrivateKey(TestSigningUtils.ownerCertUri);
this.nodeKey = (ECPrivateKey) storeService.getPrivateKey(TestSigningUtils.nodeCertUri);
}
use of won.cryptography.service.keystore.FileBasedKeyStoreService in project webofneeds by researchstudio-sat.
the class VerifyAndSignExamples method init.
@Before
public void init() throws Exception {
// initialize signature adding and signature checking processors:
Security.addProvider(new BouncyCastleProvider());
File keysFile = new File(this.getClass().getResource(TestSigningUtils.KEYS_FILE).getFile());
FileBasedKeyStoreService storeService = new FileBasedKeyStoreService(keysFile, "temp");
storeService.init();
nodeAddingProcessor = new SignatureAddingWonMessageProcessor();
CryptographyService cryptographyService = new CryptographyService(storeService, TestSigningUtils.ownerCertUri);
nodeAddingProcessor.setCryptographyService(cryptographyService);
ownerAddingProcessor = new SignatureAddingWonMessageProcessor();
ownerAddingProcessor.setCryptographyService(cryptographyService);
checkingProcessor = new SignatureCheckingWonMessageProcessor();
DefaultWebIdKeyLoader keyLoader = new DefaultWebIdKeyLoader();
keyLoader.setLinkedDataSource(new TestingDataSource());
checkingProcessor.setWebIdKeyLoader(keyLoader);
}
use of won.cryptography.service.keystore.FileBasedKeyStoreService in project webofneeds by researchstudio-sat.
the class TestSigningUtils method generateTestKeystore.
/**
* Not a test - but sometimes can be useful for generating test keys.
*
* @throws Exception
*/
// @Test
public void generateTestKeystore() throws Exception {
Security.addProvider(new BouncyCastleProvider());
File keysFile = new File("test-keys2.jks");
FileBasedKeyStoreService storeService = new FileBasedKeyStoreService(keysFile, "temp");
storeService.init();
KeyPairService keyPairService = new KeyPairService();
CertificateService certificateService = new CertificateService();
addKeyByUri(atomCertUri, keyPairService, certificateService, storeService);
addKeyByUri(ownerCertUri, keyPairService, certificateService, storeService);
addKeyByUri(nodeCertUri, keyPairService, certificateService, storeService);
}
Aggregations