use of org.apache.cxf.rs.security.httpsignature.provider.MockSecurityProvider in project cxf by apache.
the class MessageVerifierTest method defaultRequiredHeaderPresent.
@Test
public void defaultRequiredHeaderPresent() throws IOException {
Map<String, List<String>> headers = createMockHeaders();
headers.put("Test", Collections.singletonList("value"));
headers.put(HTTPSignatureConstants.REQUEST_TARGET, Collections.singletonList("12345"));
createAndAddSignature(headers);
MessageVerifier headerVerifier = new MessageVerifier(keyId -> keyPair.getPublic(), Collections.singletonList("test"));
headerVerifier.setSecurityProvider(new MockSecurityProvider());
headerVerifier.setAlgorithmProvider(new MockAlgorithmProvider());
headerVerifier.verifyMessage(headers, METHOD, URI, new MessageImpl(), MESSAGE_BODY.getBytes());
}
use of org.apache.cxf.rs.security.httpsignature.provider.MockSecurityProvider in project cxf by apache.
the class MessageVerifierTest method defaultRequiredHeaderNotPresent.
@Test(expected = InvalidDataToVerifySignatureException.class)
public void defaultRequiredHeaderNotPresent() throws IOException {
Map<String, List<String>> headers = createMockHeaders();
headers.put("Test", Collections.singletonList("value"));
createAndAddSignature(headers);
MessageVerifier headerVerifier = new MessageVerifier(keyId -> keyPair.getPublic(), Collections.singletonList("test"));
headerVerifier.setSecurityProvider(new MockSecurityProvider());
headerVerifier.setAlgorithmProvider(new MockAlgorithmProvider());
headerVerifier.verifyMessage(headers, METHOD, URI, new MessageImpl(), MESSAGE_BODY.getBytes());
}
use of org.apache.cxf.rs.security.httpsignature.provider.MockSecurityProvider in project cxf by apache.
the class MessageVerifierTest method requiredHeaderPresentButNotSigned.
@Test(expected = InvalidDataToVerifySignatureException.class)
public void requiredHeaderPresentButNotSigned() throws IOException {
Map<String, List<String>> headers = createMockHeaders();
createAndAddSignature(headers);
headers.put("Test", Collections.singletonList("value"));
MessageVerifier headerVerifier = new MessageVerifier(keyId -> keyPair.getPublic(), Collections.singletonList("test"));
headerVerifier.setAddDefaultRequiredHeaders(false);
headerVerifier.setSecurityProvider(new MockSecurityProvider());
headerVerifier.setAlgorithmProvider(new MockAlgorithmProvider());
headerVerifier.verifyMessage(headers, METHOD, URI, new MessageImpl(), MESSAGE_BODY.getBytes());
}
use of org.apache.cxf.rs.security.httpsignature.provider.MockSecurityProvider in project cxf by apache.
the class MessageVerifierTest method setUp.
@BeforeClass
public static void setUp() {
try {
keyPair = KeyPairGenerator.getInstance(KEY_PAIR_GENERATOR_ALGORITHM).generateKeyPair();
messageVerifier = new MessageVerifier(keyId -> keyPair.getPublic());
messageVerifier.setSecurityProvider(new MockSecurityProvider());
messageVerifier.setAlgorithmProvider(new MockAlgorithmProvider());
messageVerifier.setAddDefaultRequiredHeaders(false);
messageSigner = new MessageSigner(keyId -> keyPair.getPrivate(), KEY_ID);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
use of org.apache.cxf.rs.security.httpsignature.provider.MockSecurityProvider in project cxf by apache.
the class MessageVerifierTest method requiredHeaderPresent.
@Test
public void requiredHeaderPresent() throws IOException {
Map<String, List<String>> headers = createMockHeaders();
headers.put("Test", Collections.singletonList("value"));
createAndAddSignature(headers);
MessageVerifier headerVerifier = new MessageVerifier(keyId -> keyPair.getPublic(), Collections.singletonList("test"));
headerVerifier.setAddDefaultRequiredHeaders(false);
headerVerifier.setSecurityProvider(new MockSecurityProvider());
headerVerifier.setAlgorithmProvider(new MockAlgorithmProvider());
headerVerifier.verifyMessage(headers, METHOD, URI, new MessageImpl(), MESSAGE_BODY.getBytes());
}
Aggregations