Examples of DKIMSignature


Examples of org.jboss.resteasy.security.doseta.DKIMSignature

   @Test
   public void testBasicVerification() throws Exception
   {
      //ResteasyClient client = new ResteasyClient();
      WebTarget target = client.target(TestPortProvider.generateURL("/signed"));
      DKIMSignature contentSignature = new DKIMSignature();
      contentSignature.setDomain("samplezone.org");
      contentSignature.setSelector("test");
      contentSignature.setPrivateKey(keys.getPrivate());
      Response response = target.request().header(DKIMSignature.DKIM_SIGNATURE, contentSignature)
                                          .post(Entity.text("hello world"));
      Assert.assertEquals(204, response.getStatus());
      response.close();
   }
View Full Code Here

Examples of org.jboss.resteasy.security.doseta.DKIMSignature

   @Test
   public void testManualVerification() throws Exception
   {
      //ResteasyClient client = new ResteasyClient();
      WebTarget target = client.target(TestPortProvider.generateURL("/signed/verify-manual"));
      DKIMSignature contentSignature = new DKIMSignature();
      contentSignature.setDomain("samplezone.org");
      contentSignature.setSelector("test");
      contentSignature.setAttribute("code", "hello");
      contentSignature.setPrivateKey(keys.getPrivate());
      Response response = target.request().header(DKIMSignature.DKIM_SIGNATURE, contentSignature)
              .post(Entity.text("hello world"));
      Assert.assertEquals(204, response.getStatus());
      response.close();
View Full Code Here

Examples of org.jboss.resteasy.security.doseta.DKIMSignature

   public void testBasicVerificationRepository() throws Exception
   {
      //ResteasyClient client = new ResteasyClient();
      WebTarget target = client.target(TestPortProvider.generateURL("/signed"));
      target.property(KeyRepository.class.getName(), repository);
      DKIMSignature contentSignature = new DKIMSignature();
      contentSignature.setSelector("test");
      contentSignature.setDomain("samplezone.org");
      Response response = target.request().header(DKIMSignature.DKIM_SIGNATURE, contentSignature)
              .post(Entity.text("hello world"));
      Assert.assertEquals(204, response.getStatus());
      response.close();
   }
View Full Code Here

Examples of org.jboss.resteasy.security.doseta.DKIMSignature

   @Test
   public void testBasicVerificationBadSignature() throws Exception
   {
      //ResteasyClient client = new ResteasyClient();
      WebTarget target = client.target(TestPortProvider.generateURL("/signed"));
      DKIMSignature contentSignature = new DKIMSignature();
      contentSignature.setSelector("test");
      contentSignature.setDomain("samplezone.org");
      contentSignature.setPrivateKey(badKey);
      Response response = target.request().header(DKIMSignature.DKIM_SIGNATURE, contentSignature)
              .post(Entity.text("hello world"));
      Assert.assertEquals(401, response.getStatus());
      response.close();
   }
View Full Code Here

Examples of org.jboss.resteasy.security.doseta.DKIMSignature

   }

   @Test
   public void testTimestampSignature() throws Exception
   {
      DKIMSignature signature = new DKIMSignature();
      signature.setTimestamp();
      signature.setSelector("test");
      signature.setDomain("samplezone.org");
      signature.sign(new HashMap(), "hello world".getBytes(), keys.getPrivate());
      String sig = signature.toString();
      System.out.println(DKIMSignature.DKIM_SIGNATURE + ": " + sig);
      signature = new DKIMSignature(sig);

   }
View Full Code Here

Examples of org.jboss.resteasy.security.doseta.DKIMSignature

      Assert.assertEquals(200, response.getStatus());
      String signatureHeader = response.getHeaderString(DKIMSignature.DKIM_SIGNATURE);
      Assert.assertNotNull(signatureHeader);
      System.out.println(DKIMSignature.DKIM_SIGNATURE + ":  " + signatureHeader);

      DKIMSignature contentSignature = new DKIMSignature(signatureHeader);

      MarshalledEntity<String> entity =  response.readEntity(new GenericType<MarshalledEntity<String>>(){});
      boolean failedVerification = false;

      try
      {
         contentSignature.verify(response.getStringHeaders(), entity.getMarshalledBytes(), keys.getPublic());
      }
      catch (SignatureException e)
      {
         failedVerification = true;
      }
View Full Code Here

Examples of org.jboss.resteasy.security.doseta.DKIMSignature

      Assert.assertEquals(200, response.getStatus());
      String signatureHeader = response.getHeaderString(DKIMSignature.DKIM_SIGNATURE);
      Assert.assertNotNull(signatureHeader);
      System.out.println(DKIMSignature.DKIM_SIGNATURE + ":  " + signatureHeader);

      DKIMSignature contentSignature = new DKIMSignature(signatureHeader);

      MarshalledEntity<String> entity =  response.readEntity(new GenericType<MarshalledEntity<String>>(){});

      boolean failedVerification = false;
      try
      {
         contentSignature.verify(response.getStringHeaders(), entity.getMarshalledBytes(), keys.getPublic());
      }
      catch (SignatureException e)
      {
         failedVerification = true;
      }
View Full Code Here

Examples of org.jboss.resteasy.security.doseta.DKIMSignature

   @Test
   public void testBasicVerificationBadSignature() throws Exception
   {
      ClientRequest request = new ClientRequest(TestPortProvider.generateURL("/signed"), executor);
      DKIMSignature contentSignature = new DKIMSignature();
      contentSignature.setSelector("test");
      contentSignature.setDomain("samplezone.org");
      contentSignature.setPrivateKey(badKey);
      request.header(DKIMSignature.DKIM_SIGNATURE, contentSignature);
      request.body("text/plain", "hello world");
      ClientResponse response = request.post();
      Assert.assertEquals(401, response.getStatus());
      response.releaseConnection();
View Full Code Here

Examples of org.jboss.resteasy.security.doseta.DKIMSignature

   }

   @Test
   public void testTimestampSignature() throws Exception
   {
      DKIMSignature signature = new DKIMSignature();
      signature.setTimestamp();
      signature.setSelector("test");
      signature.setDomain("samplezone.org");
      signature.sign(new HashMap(), "hello world".getBytes(), keys.getPrivate());
      String sig = signature.toString();
      System.out.println(DKIMSignature.DKIM_SIGNATURE + ": " + sig);
      signature = new DKIMSignature(sig);

   }
View Full Code Here

Examples of org.jboss.resteasy.security.doseta.DKIMSignature

      Assert.assertEquals(200, response.getStatus());
      String signatureHeader = response.getResponseHeaders().getFirst(DKIMSignature.DKIM_SIGNATURE);
      Assert.assertNotNull(signatureHeader);
      System.out.println(DKIMSignature.DKIM_SIGNATURE + ":  " + signatureHeader);

      DKIMSignature contentSignature = new DKIMSignature(signatureHeader);

      MarshalledEntity<String> entity = response.getEntity(new GenericType<MarshalledEntity<String>>()
      {
      });
      boolean failedVerification = false;

      try
      {
         contentSignature.verify(response.getResponseHeaders(), entity.getMarshalledBytes(), keys.getPublic());
      }
      catch (SignatureException e)
      {
         failedVerification = true;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.