use of org.opensaml.saml.saml2.core.AuthnRequest in project ddf by codice.
the class IdpHandler method doHttpPostBinding.
private void doHttpPostBinding(HttpServletRequest request, HttpServletResponse response) throws AuthenticationFailureException {
try {
IDPSSODescriptor idpssoDescriptor = idpMetadata.getDescriptor();
if (idpssoDescriptor == null) {
throw new AuthenticationFailureException(IDP_METADATA_MISSING);
}
response.getWriter().printf(postBindingTemplate, idpMetadata.getSingleSignOnLocation(), encodeAuthnRequest(createAndSignAuthnRequest(true, idpssoDescriptor.getWantAuthnRequestsSigned()), true), createRelayState(request));
response.setStatus(200);
response.flushBuffer();
} catch (IOException e) {
LOGGER.info("Unable to post AuthnRequest to IdP", e);
throw new AuthenticationFailureException("Unable to post to IdP");
}
}
use of org.opensaml.saml.saml2.core.AuthnRequest in project ddf by codice.
the class PaosInInterceptor method checkAuthnRequest.
private void checkAuthnRequest(SOAPPart soapRequest) throws IOException {
XMLObject authnXmlObj = null;
try {
Node node = soapRequest.getEnvelope().getBody().getFirstChild();
authnXmlObj = SamlProtocol.getXmlObjectFromNode(node);
} catch (WSSecurityException | SOAPException | XMLStreamException ex) {
throw new IOException("Unable to convert AuthnRequest document to XMLObject.");
}
if (authnXmlObj == null) {
throw new IOException("AuthnRequest object is not Found.");
}
if (!(authnXmlObj instanceof AuthnRequest)) {
throw new IOException("SAMLRequest object is not AuthnRequest.");
}
}
use of org.opensaml.saml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class IdaAuthnRequestFromHubToAuthnRequestTransformerTest method shouldUseTheOriginalExpiryTimestampToSetTheNotOnOrAfter.
@Test
public void shouldUseTheOriginalExpiryTimestampToSetTheNotOnOrAfter() {
DateTime sessionExpiry = DateTime.now().plusHours(2);
IdaAuthnRequestFromHub originalRequestFromHub = anIdaAuthnRequest().withSessionExpiryTimestamp(sessionExpiry).buildFromHub();
AuthnRequest transformedRequest = transformer.apply(originalRequestFromHub);
assertThat(transformedRequest.getConditions().getNotOnOrAfter()).isEqualTo(sessionExpiry);
}
use of org.opensaml.saml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class IdaAuthnRequestFromHubToAuthnRequestTransformerTest method shouldSetProtocolBindingToPost.
@Test
public void shouldSetProtocolBindingToPost() {
IdaAuthnRequestFromHub originalRequestFromTransaction = anIdaAuthnRequest().buildFromHub();
AuthnRequest transformedRequest = transformer.apply(originalRequestFromTransaction);
assertThat(transformedRequest.getProtocolBinding()).isEqualTo(SAMLConstants.SAML2_POST_BINDING_URI);
}
use of org.opensaml.saml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class IdaAuthnRequestFromHubToAuthnRequestTransformerTest method shouldUseTheOriginalRequestIdForTheTransformedRequest.
@Test
public void shouldUseTheOriginalRequestIdForTheTransformedRequest() {
String originalRequestId = UUID.randomUUID().toString();
IdaAuthnRequestFromHub originalRequestFromHub = anIdaAuthnRequest().withId(originalRequestId).buildFromHub();
AuthnRequest transformedRequest = transformer.apply(originalRequestFromHub);
assertThat(transformedRequest.getID()).isEqualTo(originalRequestId);
}
Aggregations