Search in sources :

Example 1 with KeyPairService

use of won.cryptography.service.KeyPairService 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 2 with KeyPairService

use of won.cryptography.service.KeyPairService in project webofneeds by researchstudio-sat.

the class CryptographyServiceTest method testInfoExractorOfKeyPairBrainpoolp384r1.

@Test
public void testInfoExractorOfKeyPairBrainpoolp384r1() {
    KeyPairService keyPairService = context.getBean("keyPairService", KeyPairService.class);
    KeyPair keypair = keyPairService.generateNewKeyPairInBrainpoolp384r1();
    KeyInformationExtractorBouncyCastle extractor = new KeyInformationExtractorBouncyCastle();
    try {
        Assert.assertEquals("ECDSA", extractor.getAlgorithm(keypair.getPublic()));
        logger.debug("algorithm: " + extractor.getAlgorithm(keypair.getPublic()));
        Assert.assertEquals("brainpoolp384r1", extractor.getCurveID(keypair.getPublic()));
        logger.debug("curveID: " + extractor.getCurveID(keypair.getPublic()));
        Assert.assertNotNull(extractor.getQX(keypair.getPublic()));
        logger.debug("qx: " + extractor.getQX(keypair.getPublic()));
        Assert.assertNotNull(extractor.getQY(keypair.getPublic()));
        logger.debug("qy: " + extractor.getQY(keypair.getPublic()));
    } catch (KeyNotSupportedException ex) {
        Assert.fail(ex.getMessage());
    }
}
Also used : KeyPair(java.security.KeyPair) KeyNotSupportedException(won.cryptography.exception.KeyNotSupportedException) KeyInformationExtractorBouncyCastle(won.cryptography.key.KeyInformationExtractorBouncyCastle) KeyPairService(won.cryptography.service.KeyPairService) Test(org.junit.Test)

Example 3 with KeyPairService

use of won.cryptography.service.KeyPairService in project webofneeds by researchstudio-sat.

the class CryptographyServiceTest method testInfoExtractorOfKeyPairSecp384r1.

@Test
public void testInfoExtractorOfKeyPairSecp384r1() {
    KeyPairService keyPairService = context.getBean("keyPairService", KeyPairService.class);
    KeyPair keypair = keyPairService.generateNewKeyPairInSecp384r1();
    KeyInformationExtractorBouncyCastle extractor = new KeyInformationExtractorBouncyCastle();
    try {
        Assert.assertEquals("ECDSA", extractor.getAlgorithm(keypair.getPublic()));
        logger.debug("algorithm: " + extractor.getAlgorithm(keypair.getPublic()));
        Assert.assertEquals("secp384r1", extractor.getCurveID(keypair.getPublic()));
        logger.debug("curveID: " + extractor.getCurveID(keypair.getPublic()));
        Assert.assertNotNull(extractor.getQX(keypair.getPublic()));
        logger.debug("qx: " + extractor.getQX(keypair.getPublic()));
        Assert.assertNotNull(extractor.getQY(keypair.getPublic()));
        logger.debug("qy: " + extractor.getQY(keypair.getPublic()));
    } catch (KeyNotSupportedException ex) {
        Assert.fail(ex.getMessage());
    }
}
Also used : KeyPair(java.security.KeyPair) KeyNotSupportedException(won.cryptography.exception.KeyNotSupportedException) KeyInformationExtractorBouncyCastle(won.cryptography.key.KeyInformationExtractorBouncyCastle) KeyPairService(won.cryptography.service.KeyPairService) Test(org.junit.Test)

Example 4 with KeyPairService

use of won.cryptography.service.KeyPairService in project webofneeds by researchstudio-sat.

the class CryptographyServiceTest method testGenerateKeyPairBrainpoolp384r1.

@Test
public void testGenerateKeyPairBrainpoolp384r1() {
    KeyPairService keyPairService = context.getBean("keyPairService", KeyPairService.class);
    KeyPair keypair = keyPairService.generateNewKeyPairInBrainpoolp384r1();
    Assert.assertNotNull(keypair.getPublic());
    Assert.assertNotNull(keypair.getPrivate());
}
Also used : KeyPair(java.security.KeyPair) KeyPairService(won.cryptography.service.KeyPairService) Test(org.junit.Test)

Example 5 with KeyPairService

use of won.cryptography.service.KeyPairService in project webofneeds by researchstudio-sat.

the class CryptographyServiceTest method testGenerateKeyPairSecp384r1.

@Test
public void testGenerateKeyPairSecp384r1() {
    KeyPairService keyPairService = context.getBean("keyPairService", KeyPairService.class);
    KeyPair keypair = keyPairService.generateNewKeyPairInSecp384r1();
    Assert.assertNotNull(keypair.getPublic());
    Assert.assertNotNull(keypair.getPrivate());
}
Also used : KeyPair(java.security.KeyPair) KeyPairService(won.cryptography.service.KeyPairService) Test(org.junit.Test)

Aggregations

KeyPairService (won.cryptography.service.KeyPairService)6 KeyPair (java.security.KeyPair)4 Test (org.junit.Test)4 File (java.io.File)2 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)2 KeyNotSupportedException (won.cryptography.exception.KeyNotSupportedException)2 KeyInformationExtractorBouncyCastle (won.cryptography.key.KeyInformationExtractorBouncyCastle)2 CertificateService (won.cryptography.service.CertificateService)2 FileBasedKeyStoreService (won.cryptography.service.keystore.FileBasedKeyStoreService)2