As an addendum to my previous post, if you need to receive a SAML Response in a Java servlet using OpenSAML you can use this code. This is, obviously, more likely than needing to create a Response object from an XML file. The 'request' variable is just an input to the processRequest method on the servlet.
import org.opensaml.ws.message.MessageContext;
import org.opensaml.ws.transport.http.HttpServletRequestAdapter;
import org.opensaml.common.binding.BasicSAMLMessageContext;
import org.opensaml.saml2.binding.decoding.HTTPPostDecoder;
import org.opensaml.saml2.core.Response;
//get the message context
MessageContext messageContext = new BasicSAMLMessageContext();
messageContext.setInboundMessageTransport(new HttpServletRequestAdapter(request));
HTTPPostDecoder samlMessageDecoder = new HTTPPostDecoder();
samlMessageDecoder.decode(messageContext);
//get the SAML Response
Response samlResponse = (Response)messageContext.getInboundMessage();
2 comments:
hey thank you very much. actually i am beginner can please help me more on this, by posting more code for parsing in servlet.
Yogesh, you can read my other post to get more information about how to parse the Response: http://kevnls.blogspot.com/2011/09/receiving-and-processing-saml-20.html
Post a Comment