use of org.jboss.resteasy.security.doseta.Verifier in project resteasy by resteasy.
the class SigningTest method testExpiresDays.
@Test
public void testExpiresDays() throws Exception {
Verifier verifier = new Verifier();
Verification verification = verifier.addNew();
verification.setRepository(repository);
// ResteasyClientImpl client = new ResteasyClientImpl();
WebTarget target = client.target(TestPortProvider.generateURL("/signed/expires-day"));
Invocation.Builder request = target.request();
request.property(Verifier.class.getName(), verifier);
Response response = request.get();
// System.out.println(response.getHeaderString(DKIMSignature.DKIM_SIGNATURE));
Assert.assertEquals(200, response.getStatus());
String output = response.readEntity(String.class);
response.close();
}
use of org.jboss.resteasy.security.doseta.Verifier in project resteasy by resteasy.
the class SigningTest method testManualWithHeader.
@Test
public void testManualWithHeader() throws Exception {
Verifier verifier = new Verifier();
Verification verification = verifier.addNew();
verification.setRepository(repository);
// ResteasyClientImpl client = new ResteasyClientImpl();
WebTarget target = client.target(TestPortProvider.generateURL("/signed/header"));
Invocation.Builder request = target.request();
request.property(Verifier.class.getName(), verifier);
Response response = request.get();
// System.out.println(response.getHeaderString(DKIMSignature.DKIM_SIGNATURE));
Assert.assertNotNull(response.getHeaderString(DKIMSignature.DKIM_SIGNATURE));
Assert.assertEquals(200, response.getStatus());
String output = response.readEntity(String.class);
Assert.assertEquals("hello world", output);
response.close();
}
use of org.jboss.resteasy.security.doseta.Verifier in project resteasy by resteasy.
the class SigningTest method testTimestamp.
@Test
public void testTimestamp() throws Exception {
Verifier verifier = new Verifier();
Verification verification = verifier.addNew();
verification.setRepository(repository);
verification.setStaleCheck(true);
verification.setStaleSeconds(100);
// ResteasyClientImpl client = new ResteasyClientImpl();
WebTarget target = client.target(TestPortProvider.generateURL("/signed/stamped"));
Invocation.Builder request = target.request();
request.property(Verifier.class.getName(), verifier);
Response response = request.get();
// System.out.println(response.getHeaderString(DKIMSignature.DKIM_SIGNATURE));
Assert.assertEquals(200, response.getStatus());
try {
String output = response.readEntity(String.class);
} catch (Exception e) {
throw e;
}
response.close();
}
use of org.jboss.resteasy.security.doseta.Verifier in project resteasy by resteasy.
the class SigningTest method testStaleTimestamp.
/**
* @tpTestDetails Stale timestamp test
* @tpSince RESTEasy 3.0.16
*/
@Test
public void testStaleTimestamp() throws Exception {
Verifier verifier = new Verifier();
Verification verification = verifier.addNew();
verification.setRepository(repository);
verification.setStaleCheck(true);
verification.setStaleSeconds(1);
WebTarget target = client.target(generateURL("/signed/stamped"));
Invocation.Builder request = target.request();
request.property(Verifier.class.getName(), verifier);
Response response = request.get();
logger.info(response.getHeaderString(DKIMSignature.DKIM_SIGNATURE));
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
Thread.sleep(1500);
try {
response.readEntity(String.class);
Assert.fail("Validation error excepted.");
} catch (ProcessingException pe) {
UnauthorizedSignatureException e = (UnauthorizedSignatureException) pe.getCause();
MatcherAssert.assertThat("Unexcepted error", e.getMessage(), containsString("Failed to verify signatures:\r\n"));
MatcherAssert.assertThat("Unexcepted error", e.getMessage(), containsString("Signature is stale"));
}
response.close();
}
use of org.jboss.resteasy.security.doseta.Verifier in project resteasy by resteasy.
the class SigningTest method testExpiresYears.
/**
* @tpTestDetails Year expiration test (expires attribute in Signed annotation in REST end-point is used).
* @tpSince RESTEasy 3.0.16
*/
@Test
public void testExpiresYears() throws Exception {
Verifier verifier = new Verifier();
Verification verification = verifier.addNew();
verification.setRepository(repository);
WebTarget target = client.target(generateURL("/signed/expires-year"));
Invocation.Builder request = target.request();
request.property(Verifier.class.getName(), verifier);
Response response = request.get();
logger.info(response.getHeaderString(DKIMSignature.DKIM_SIGNATURE));
Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
response.readEntity(String.class);
response.close();
}
Aggregations