Search in sources :

Example 1 with DosetaKeyRepository

use of org.jboss.resteasy.security.doseta.DosetaKeyRepository in project resteasy by resteasy.

the class LocalTest method setup.

@BeforeClass
public static void setup() throws Exception {
    repository = new DosetaKeyRepository();
    repository.setKeyStoreFile(filePath);
    repository.setKeyStorePassword("password");
    repository.setUseDns(false);
    repository.start();
    PrivateKey privateKey = repository.getKeyStore().getPrivateKey("test._domainKey.samplezone.org");
    if (privateKey == null) {
        throw new Exception("Private Key is null.");
    }
    PublicKey publicKey = repository.getKeyStore().getPublicKey("test._domainKey.samplezone.org");
    keys = new KeyPair(publicKey, privateKey);
    KeyPairGenerator.getInstance("RSA").generateKeyPair();
}
Also used : DosetaKeyRepository(org.jboss.resteasy.security.doseta.DosetaKeyRepository) KeyPair(java.security.KeyPair) PrivateKey(java.security.PrivateKey) PublicKey(java.security.PublicKey) SignatureException(java.security.SignatureException) BeforeClass(org.junit.BeforeClass)

Example 2 with DosetaKeyRepository

use of org.jboss.resteasy.security.doseta.DosetaKeyRepository in project resteasy by resteasy.

the class SigningTest method setup.

@BeforeClass
public static void setup() throws Exception {
    server = new NettyJaxrsServer();
    server.setPort(TestPortProvider.getPort());
    server.setRootResourcePath("/");
    deployment = server.getDeployment();
    deployment.start();
    repository = new DosetaKeyRepository();
    repository.setKeyStorePath("test.jks");
    repository.setKeyStorePassword("password");
    repository.setUseDns(false);
    repository.start();
    PrivateKey privateKey = repository.getKeyStore().getPrivateKey("test._domainKey.samplezone.org");
    if (privateKey == null)
        throw new Exception("Private Key is null!!!");
    PublicKey publicKey = repository.getKeyStore().getPublicKey("test._domainKey.samplezone.org");
    keys = new KeyPair(publicKey, privateKey);
    KeyPair keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
    badKey = keyPair.getPrivate();
    deployment.getDispatcher().getDefaultContextObjects().put(KeyRepository.class, repository);
    addPerRequestResource(SignedResource.class);
    server.start();
    client = (ResteasyClient) ClientBuilder.newClient();
}
Also used : DosetaKeyRepository(org.jboss.resteasy.security.doseta.DosetaKeyRepository) KeyPair(java.security.KeyPair) PrivateKey(java.security.PrivateKey) NettyJaxrsServer(org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer) PublicKey(java.security.PublicKey) ProcessingException(jakarta.ws.rs.ProcessingException) SignatureException(java.security.SignatureException) ResponseProcessingException(jakarta.ws.rs.client.ResponseProcessingException) UnauthorizedSignatureException(org.jboss.resteasy.security.doseta.UnauthorizedSignatureException) BeforeClass(org.junit.BeforeClass)

Example 3 with DosetaKeyRepository

use of org.jboss.resteasy.security.doseta.DosetaKeyRepository in project resteasy by resteasy.

the class SigningTest method setup.

@BeforeClass
public static void setup() throws Exception {
    repository = new DosetaKeyRepository();
    repository.setKeyStoreFile(testJksPath);
    repository.setKeyStorePassword("password");
    repository.setUseDns(false);
    repository.start();
    PrivateKey privateKey = repository.getKeyStore().getPrivateKey("test._domainKey.samplezone.org");
    if (privateKey == null) {
        throw new Exception("Private Key is null!!!");
    }
    PublicKey publicKey = repository.getKeyStore().getPublicKey("test._domainKey.samplezone.org");
    keys = new KeyPair(publicKey, privateKey);
    KeyPair keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
    badKey = keyPair.getPrivate();
}
Also used : DosetaKeyRepository(org.jboss.resteasy.security.doseta.DosetaKeyRepository) KeyPair(java.security.KeyPair) PrivateKey(java.security.PrivateKey) PublicKey(java.security.PublicKey) ResponseProcessingException(jakarta.ws.rs.client.ResponseProcessingException) ProcessingException(jakarta.ws.rs.ProcessingException) SignatureException(java.security.SignatureException) UnauthorizedSignatureException(org.jboss.resteasy.security.doseta.UnauthorizedSignatureException) BeforeClass(org.junit.BeforeClass)

Example 4 with DosetaKeyRepository

use of org.jboss.resteasy.security.doseta.DosetaKeyRepository in project resteasy by resteasy.

the class SigningDnsTest method setup.

@BeforeClass
public static void setup() throws Exception {
    server = new NettyJaxrsServer();
    server.setPort(TestPortProvider.getPort());
    server.setRootResourcePath("/");
    deployment = server.getDeployment();
    deployment.start();
    clientRepository = new DosetaKeyRepository();
    clientRepository.setKeyStorePath("test1.jks");
    clientRepository.setKeyStorePassword("password");
    clientRepository.setUseDns(true);
    clientRepository.setDnsUri("dns://localhost:6363");
    clientRepository.start();
    serverRepository = new DosetaKeyRepository();
    serverRepository.setKeyStorePath("test2.jks");
    serverRepository.setKeyStorePassword("password");
    serverRepository.setUseDns(true);
    serverRepository.setDnsUri("dns://localhost:6363");
    serverRepository.start();
    KeyPair keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
    badKey = keyPair.getPrivate();
    deployment.getDispatcher().getDefaultContextObjects().put(KeyRepository.class, serverRepository);
    addPerRequestResource(SignedResource.class);
    configureDNS();
    server.start();
    client = ClientBuilder.newClient();
}
Also used : DosetaKeyRepository(org.jboss.resteasy.security.doseta.DosetaKeyRepository) KeyPair(java.security.KeyPair) NettyJaxrsServer(org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer) BeforeClass(org.junit.BeforeClass)

Aggregations

KeyPair (java.security.KeyPair)4 DosetaKeyRepository (org.jboss.resteasy.security.doseta.DosetaKeyRepository)4 BeforeClass (org.junit.BeforeClass)4 PrivateKey (java.security.PrivateKey)3 PublicKey (java.security.PublicKey)3 SignatureException (java.security.SignatureException)3 ProcessingException (jakarta.ws.rs.ProcessingException)2 ResponseProcessingException (jakarta.ws.rs.client.ResponseProcessingException)2 NettyJaxrsServer (org.jboss.resteasy.plugins.server.netty.NettyJaxrsServer)2 UnauthorizedSignatureException (org.jboss.resteasy.security.doseta.UnauthorizedSignatureException)2