use of ddf.security.samlp.SimpleSign in project ddf by codice.
the class IdpEndpoint method validatePost.
void validatePost(HttpServletRequest request, SignableSAMLObject samlObject, String requestId) throws ValidationException {
if (strictSignature) {
SamlValidator.Builder validator = new SamlValidator.Builder(new SimpleSign(systemCrypto));
if (requestId != null) {
validator.setRequestId(requestId);
}
validator.buildAndValidate(request.getRequestURL().toString(), SamlProtocol.Binding.HTTP_POST, samlObject);
}
}
use of ddf.security.samlp.SimpleSign in project ddf by codice.
the class IdpEndpoint method getSamlPostResponse.
private Response getSamlPostResponse(SignableSAMLObject samlObject, String targetUrl, String relayState, SamlProtocol.Type samlType) throws SimpleSign.SignatureException, WSSecurityException {
Document doc = DOMUtils.createDocument();
doc.appendChild(doc.createElement("root"));
LOGGER.debug("Signing SAML POST Response.");
new SimpleSign(systemCrypto).signSamlObject(samlObject);
LOGGER.debug("Converting SAML Response to DOM");
String assertionResponse = DOM2Writer.nodeToString(OpenSAMLUtil.toDom(samlObject, doc));
String encodedSamlResponse = Base64.getEncoder().encodeToString(assertionResponse.getBytes(StandardCharsets.UTF_8));
return Response.ok(HtmlResponseTemplate.getPostPage(targetUrl, samlType, encodedSamlResponse, relayState)).build();
}
use of ddf.security.samlp.SimpleSign in project ddf by codice.
the class LogoutMessageImpl method signSamlGet.
private URI signSamlGet(@NotNull SAMLObject samlObject, @NotNull URI target, String relayState, @NotNull String requestType) throws WSSecurityException, SimpleSign.SignatureException, IOException {
Document doc = DOMUtils.createDocument();
doc.appendChild(doc.createElement("root"));
String encodedResponse = URLEncoder.encode(RestSecurity.deflateAndBase64Encode(DOM2Writer.nodeToString(OpenSAMLUtil.toDom(samlObject, doc, false))), "UTF-8");
String requestToSign = String.format("%s=%s&%s=%s", requestType, encodedResponse, SSOConstants.RELAY_STATE, relayState);
UriBuilder uriBuilder = UriBuilder.fromUri(target);
uriBuilder.queryParam(requestType, encodedResponse);
uriBuilder.queryParam(SSOConstants.RELAY_STATE, relayState);
new SimpleSign(systemCrypto).signUriString(requestToSign, uriBuilder);
return uriBuilder.build();
}
use of ddf.security.samlp.SimpleSign in project ddf by codice.
the class TestAttributeQueryClaimsHandler method setUp.
@Before
public void setUp() throws IOException {
signatureProperties = mock(Object.class);
encryptionProperties = mock(Object.class);
service = mock(Service.class);
dispatch = (Dispatch<StreamSource>) mock(Dispatch.class);
encryptionService = mock(EncryptionService.class);
systemCrypto = new SystemCrypto("encryption.properties", "signature.properties", encryptionService);
simpleSign = new SimpleSign(systemCrypto);
supportedClaims = new ArrayList<>();
supportedClaims.add("Role");
supportedClaims.add("NameIdentifier");
supportedClaims.add("Email");
AttributeQueryClaimsHandlerTest attributeQueryClaimsHandler = new AttributeQueryClaimsHandlerTest();
spyAttributeQueryClaimsHandler = spy(attributeQueryClaimsHandler);
spyAttributeQueryClaimsHandler.setWsdlLocation("wsdlLocation");
spyAttributeQueryClaimsHandler.setServiceName("serviceName");
spyAttributeQueryClaimsHandler.setPortName("portName");
spyAttributeQueryClaimsHandler.setSimpleSign(simpleSign);
spyAttributeQueryClaimsHandler.setSupportedClaims(supportedClaims);
spyAttributeQueryClaimsHandler.setExternalAttributeStoreUrl(EXTERNAL_ATTRIBUTE_STORE);
spyAttributeQueryClaimsHandler.setIssuer(ISSUER);
spyAttributeQueryClaimsHandler.setDestination(DESTINATION);
spyAttributeQueryClaimsHandler.setAttributeMapLocation(getClass().getClassLoader().getResource("attributeMap.properties").getPath());
spyAttributeQueryClaimsHandler.setSignatureProperties(signatureProperties);
spyAttributeQueryClaimsHandler.setEncryptionProperties(encryptionProperties);
doReturn(service).when(spyAttributeQueryClaimsHandler).createService();
doReturn(dispatch).when(spyAttributeQueryClaimsHandler).createDispatcher(service);
cannedResponse = Resources.toString(Resources.getResource(getClass(), "/SAMLResponse.xml"), Charsets.UTF_8);
}
use of ddf.security.samlp.SimpleSign in project ddf by codice.
the class TestAttributeQueryClient method setUp.
@Before
public void setUp() throws IOException {
dispatch = mock(Dispatch.class);
encryptionService = mock(EncryptionService.class);
systemCrypto = new SystemCrypto("encryption.properties", "signature.properties", encryptionService);
SimpleSign simpleSign = new SimpleSign(systemCrypto);
spySimpleSign = spy(simpleSign);
attributeQueryClient = new AttributeQueryClient(dispatch, spySimpleSign, EXTERNAL_ATTRIBUTE_STORE, ISSUER, DESTINATION);
attributeQueryClient.setDispatch(dispatch);
attributeQueryClient.setSimpleSign(spySimpleSign);
attributeQueryClient.setExternalAttributeStoreUrl(EXTERNAL_ATTRIBUTE_STORE);
attributeQueryClient.setIssuer(ISSUER);
attributeQueryClient.setDestination(DESTINATION);
cannedResponse = Resources.toString(Resources.getResource(getClass(), "/SAMLResponse.xml"), Charsets.UTF_8);
}
Aggregations