use of org.opensaml.soap.soap11.Envelope in project cas by apereo.
the class SamlProfileSamlSoap11FaultResponseBuilder method build.
@Override
public Envelope build(final AuthnRequest authnRequest, final HttpServletRequest request, final HttpServletResponse response, final org.jasig.cas.client.validation.Assertion casAssertion, final SamlRegisteredService service, final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) throws SamlException {
final Header header = newSoapObject(Header.class);
final Body body = newSoapObject(Body.class);
final Fault fault = newSoapObject(Fault.class);
final FaultCode faultCode = newSoapObject(FaultCode.class);
faultCode.setValue(FaultCode.SERVER);
fault.setCode(faultCode);
final FaultActor faultActor = newSoapObject(FaultActor.class);
faultActor.setValue(SamlIdPUtils.getIssuerFromSamlRequest(authnRequest));
fault.setActor(faultActor);
final FaultString faultString = newSoapObject(FaultString.class);
faultString.setValue(request.getAttribute(SamlIdPConstants.REQUEST_ATTRIBUTE_ERROR).toString());
fault.setMessage(faultString);
body.getUnknownXMLObjects().add(fault);
final Envelope envelope = newSoapObject(Envelope.class);
envelope.setHeader(header);
envelope.setBody(body);
encodeFinalResponse(request, response, service, adaptor, envelope);
return envelope;
}
use of org.opensaml.soap.soap11.Envelope in project cas by apereo.
the class CasHttpSoap11Encoder method buildAndStoreSOAPMessage.
@Override
protected void buildAndStoreSOAPMessage(final XMLObject payload) {
final XMLObjectBuilderFactory builderFactory = XMLObjectProviderRegistrySupport.getBuilderFactory();
final SOAPObjectBuilder<Envelope> envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
final Envelope envelope = envBuilder.buildObject(SOAPConstants.SOAP11_NS, Envelope.DEFAULT_ELEMENT_LOCAL_NAME, OPENSAML_11_SOAP_NS_PREFIX);
final SOAPObjectBuilder<Body> bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME);
final Body body = bodyBuilder.buildObject(SOAPConstants.SOAP11_NS, Body.DEFAULT_ELEMENT_LOCAL_NAME, OPENSAML_11_SOAP_NS_PREFIX);
if (!body.getUnknownXMLObjects().isEmpty()) {
LOGGER.warn("Existing SOAP Envelope Body already contained children");
}
body.getUnknownXMLObjects().add(payload);
envelope.setBody(body);
this.storeSOAPEnvelope(envelope);
}
use of org.opensaml.soap.soap11.Envelope in project cas by apereo.
the class ECPProfileHandlerController method handleEcpRequest.
/**
* Handle ecp request.
*
* @param response the response
* @param request the request
* @param soapContext the soap context
* @param credential the credential
*/
protected void handleEcpRequest(final HttpServletResponse response, final HttpServletRequest request, final MessageContext soapContext, final Credential credential) {
final Envelope envelope = soapContext.getSubcontext(SOAP11Context.class).getEnvelope();
SamlUtils.logSamlObject(configBean, envelope);
final AuthnRequest authnRequest = (AuthnRequest) soapContext.getMessage();
final Pair<AuthnRequest, MessageContext> authenticationContext = Pair.of(authnRequest, soapContext);
try {
final Pair<SamlRegisteredService, SamlRegisteredServiceServiceProviderMetadataFacade> serviceRequest = verifySamlAuthenticationRequest(authenticationContext, request);
final Authentication authentication = authenticateEcpRequest(credential, authenticationContext);
buildSamlResponse(response, request, authenticationContext, buildEcpCasAssertion(authentication, serviceRequest.getKey()));
} catch (final AuthenticationException e) {
LOGGER.error(e.getMessage(), e);
final String error = e.getHandlerErrors().values().stream().map(Class::getSimpleName).collect(Collectors.joining(","));
buildEcpFaultResponse(response, request, Pair.of(authnRequest, error));
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
buildEcpFaultResponse(response, request, Pair.of(authnRequest, e.getMessage()));
}
}
use of org.opensaml.soap.soap11.Envelope in project ddf by codice.
the class SamlProtocol method createSoapMessage.
public static Envelope createSoapMessage(SignableSAMLObject signableSAMLObject) {
Body body = soapBodyBuilder.buildObject();
body.getUnknownXMLObjects().add(signableSAMLObject);
Envelope envelope = soapEnvelopeBuilder.buildObject();
envelope.setBody(body);
Header header = soapHeaderBuilder.buildObject();
envelope.setHeader(header);
return envelope;
}
use of org.opensaml.soap.soap11.Envelope in project ddf by codice.
the class AttributeQueryClient method createSoapMessage.
/**
* Creates a SOAP message of the AttributeQuery request.
*
* @param attributeQuery is added to the SOAP message
* @return soapElement is the Element of the SOAP message
*/
private Element createSoapMessage(AttributeQuery attributeQuery) throws AttributeQueryException {
LOGGER.debug("Creating SOAP message from the SAML AttributeQuery.");
Envelope envelope = SamlProtocol.createSoapMessage(attributeQuery);
LOGGER.debug("SOAP message from the SAML AttributeQuery created.");
try {
return new EnvelopeMarshaller().marshall(envelope);
} catch (MarshallingException e) {
throw new AttributeQueryException("Cannot marshall SOAP object to an Element.", e);
}
}
Aggregations