Search in sources :

Example 1 with FileBasedKeyStoreService

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);
}
Also used : FileBasedKeyStoreService(won.cryptography.service.keystore.FileBasedKeyStoreService) FileBasedKeyStoreService(won.cryptography.service.keystore.FileBasedKeyStoreService) KeyStoreService(won.cryptography.service.keystore.KeyStoreService) File(java.io.File)

Example 2 with FileBasedKeyStoreService

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);
}
Also used : FileBasedKeyStoreService(won.cryptography.service.keystore.FileBasedKeyStoreService) CertificateService(won.cryptography.service.CertificateService) File(java.io.File) KeyPairService(won.cryptography.service.KeyPairService) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider)

Example 3 with FileBasedKeyStoreService

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);
}
Also used : FileBasedKeyStoreService(won.cryptography.service.keystore.FileBasedKeyStoreService) File(java.io.File) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) Before(org.junit.Before)

Example 4 with FileBasedKeyStoreService

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);
}
Also used : FileBasedKeyStoreService(won.cryptography.service.keystore.FileBasedKeyStoreService) DefaultWebIdKeyLoader(won.cryptography.rdfsign.DefaultWebIdKeyLoader) SignatureAddingWonMessageProcessor(won.protocol.message.processor.impl.SignatureAddingWonMessageProcessor) File(java.io.File) CryptographyService(won.cryptography.service.CryptographyService) SignatureCheckingWonMessageProcessor(won.protocol.message.processor.impl.SignatureCheckingWonMessageProcessor) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) TestingDataSource(won.cryptography.utils.TestingDataSource) Before(org.junit.Before)

Example 5 with FileBasedKeyStoreService

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);
}
Also used : FileBasedKeyStoreService(won.cryptography.service.keystore.FileBasedKeyStoreService) CertificateService(won.cryptography.service.CertificateService) File(java.io.File) KeyPairService(won.cryptography.service.KeyPairService) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider)

Aggregations

File (java.io.File)6 FileBasedKeyStoreService (won.cryptography.service.keystore.FileBasedKeyStoreService)6 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)4 Before (org.junit.Before)2 CertificateService (won.cryptography.service.CertificateService)2 KeyPairService (won.cryptography.service.KeyPairService)2 IOException (java.io.IOException)1 KeyStoreException (java.security.KeyStoreException)1 Certificate (java.security.cert.Certificate)1 X509Certificate (java.security.cert.X509Certificate)1 DefaultWebIdKeyLoader (won.cryptography.rdfsign.DefaultWebIdKeyLoader)1 CryptographyService (won.cryptography.service.CryptographyService)1 KeyStoreService (won.cryptography.service.keystore.KeyStoreService)1 TestingDataSource (won.cryptography.utils.TestingDataSource)1 SignatureAddingWonMessageProcessor (won.protocol.message.processor.impl.SignatureAddingWonMessageProcessor)1 SignatureCheckingWonMessageProcessor (won.protocol.message.processor.impl.SignatureCheckingWonMessageProcessor)1