本文整理汇总了Java中org.opensaml.ws.soap.soap11.Body类的典型用法代码示例。如果您正苦于以下问题:Java Body类的具体用法?Java Body怎么用?Java Body使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Body类属于org.opensaml.ws.soap.soap11包,在下文中一共展示了Body类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractRequest
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
private OIOLogoutRequest extractRequest(HttpServletRequest request) throws IOException {
InputStream is = request.getInputStream();
// Unpack the <LogoutRequest>
String xml = IOUtils.toString(is, "UTF-8");
XMLObject xmlObject = SAMLUtil.unmarshallElementFromString(xml);
if (log.isDebugEnabled()) log.debug("Request..:" + xml);
if (xmlObject != null && xmlObject instanceof Envelope) {
Envelope envelope = (Envelope) xmlObject;
Body body = envelope.getBody();
xmlObject = (XMLObject) body.getUnknownXMLObjects().get(0);
if (xmlObject != null && xmlObject instanceof LogoutRequest) {
LogoutRequest logoutRequest = (LogoutRequest) xmlObject;
return new OIOLogoutRequest(logoutRequest);
}
}
throw new RuntimeException("SOAP request did not contain a LogoutRequest on the body");
}
示例2: buildSOAPMessage
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
@Override
protected Envelope buildSOAPMessage(final SAMLObject samlMessage) {
final XMLObjectBuilderFactory builderFactory = Configuration.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);
body.getUnknownXMLObjects().add(samlMessage);
envelope.setBody(body);
return envelope;
}
示例3: buildSOAPMessage
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
/**
* Builds the SOAP message to be encoded.
*
* @param samlMessage body of the SOAP message
*
* @return the SOAP message
*/
@SuppressWarnings("unchecked")
protected Envelope buildSOAPMessage(SAMLObject samlMessage) {
log.debug("Building SOAP message");
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
SOAPObjectBuilder<Envelope> envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory
.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
Envelope envelope = envBuilder.buildObject();
log.debug("Adding SAML message to the SOAP message's body");
SOAPObjectBuilder<Body> bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory
.getBuilder(Body.DEFAULT_ELEMENT_NAME);
Body body = bodyBuilder.buildObject();
body.getUnknownXMLObjects().add(samlMessage);
envelope.setBody(body);
return envelope;
}
示例4: buildSOAPMessage
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
/**
* Builds the SOAP message to be encoded.
*
* @param samlMessage body of the SOAP message
*
* @return the SOAP message
*/
@SuppressWarnings("unchecked")
protected Envelope buildSOAPMessage(SAMLObject samlMessage) {
if (log.isDebugEnabled()) {
log.debug("Building SOAP message");
}
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
SOAPObjectBuilder<Envelope> envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory
.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
Envelope envelope = envBuilder.buildObject();
if (log.isDebugEnabled()) {
log.debug("Adding SAML message to the SOAP message's body");
}
SOAPObjectBuilder<Body> bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory
.getBuilder(Body.DEFAULT_ELEMENT_NAME);
Body body = bodyBuilder.buildObject();
body.getUnknownXMLObjects().add(samlMessage);
envelope.setBody(body);
return envelope;
}
示例5: prepareMessageContext
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
/**
* Perform final binding-specific processing of message context and prepare it for encoding
* to the transport.
*
* <p>
* This should include constructing and populating all binding-specific structure and data that needs to be
* reflected by the message context's properties.
* </p>
*
* <p>
* This method is called prior to {@link #processOutboundHandlerChain(MessageContext)}.
* </p>
*
* @param messageContext the message context to process
* @throws MessageEncodingException thrown if there is a problem preparing the message context
* for encoding
*/
protected void prepareMessageContext(MessageContext messageContext) throws MessageEncodingException {
SAMLMessageContext samlMsgCtx = (SAMLMessageContext) messageContext;
SAMLObject samlMessage = samlMsgCtx.getOutboundSAMLMessage();
if (samlMessage == null) {
throw new MessageEncodingException("No outbound SAML message contained in message context");
}
signMessage(samlMsgCtx);
log.debug("Building SOAP envelope");
Envelope envelope = envBuilder.buildObject();
Body body = bodyBuilder.buildObject();
envelope.setBody(body);
body.getUnknownXMLObjects().add(samlMessage);
messageContext.setOutboundMessage(envelope);
}
示例6: setUp
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
@Before
public void setUp() {
client.setAppliesTo(getProperty("endpoint"));
token = client.getToken();
serviceClient = client.getServiceClient();
SigningPolicy sp = new SigningPolicy(true);
sp.addPolicy(To.ELEMENT_NAME, true);
sp.addPolicy(MessageID.ELEMENT_NAME, true);
sp.addPolicy(Action.ELEMENT_NAME, true);
sp.addPolicy(Body.DEFAULT_ELEMENT_NAME, true);
sp.addPolicy(ReplyTo.ELEMENT_NAME, true);
sp.addPolicy(Timestamp.ELEMENT_NAME, true);
serviceClient.setSigningPolicy(sp);
String xml = getProperty("request");
req = SAMLUtil.loadElementFromString(xml);
serviceClient.setProtectTokens(Boolean.valueOf(getProperty("protectTokens")));
serviceCredential = credentialRepository.getCredential(getProperty("wsp.certificate"), getProperty("wsp.certificate.password"));
}
示例7: testGetTokenFault
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
@Test(expected=TrustException.class)
public void testGetTokenFault() throws Exception {
client.setAppliesTo("urn:service");
final Envelope response = SAMLUtil.buildXMLObject(Envelope.class);
response.setBody(SAMLUtil.buildXMLObject(Body.class));
Fault fault = SAMLUtil.buildXMLObject(Fault.class);
fault.setDetail(SAMLUtil.buildXMLObject(Detail.class));
response.getBody().getUnknownXMLObjects().add(fault);
context.checking(new Expectations() {{
one(soapClient).wsCall(with(equal(ADDRESS)), with(aNull(String.class)), with(aNull(String.class)), with(equal(true)), with(any(String.class)), with(equal("http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue")));
will(returnValue(response));
}});
client.getToken();
}
示例8: testJAXBRequest
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
@Test
public void testJAXBRequest() throws Exception {
final StringValueHolder holder = new StringValueHolder();
context.checking(new Expectations() {{
one(soapClient).wsCall(with(equal(ADDRESS)), with(aNull(String.class)), with(aNull(String.class)), with(equal(true)), with(holder), with(equal("urn:action")));
will(new CustomAction("test") {
public Object invoke(Invocation invocation) throws Throwable {
OIOSoapEnvelope env = new OIOSoapEnvelope((Envelope) SAMLUtil.unmarshallElementFromString(holder.getValue()));
Envelope response = SAMLUtil.buildXMLObject(Envelope.class);
response.setHeader(SAMLUtil.buildXMLObject(Header.class));
RelatesTo relatesTo = SAMLUtil.buildXMLObject(RelatesTo.class);
relatesTo.setValue(env.getMessageID());
response.getHeader().getUnknownXMLObjects().add(relatesTo);
String xml = "<test:blah xmlns:test='urn:testing'><test:more>blah</test:more></test:blah>";
response.setBody(SAMLUtil.buildXMLObject(Body.class));
response.getBody().getUnknownXMLObjects().add(new XSAnyUnmarshaller().unmarshall(SAMLUtil.loadElementFromString(xml)));
return response;
}
});
}});
client.getServiceClient().sendRequest(new TestBean(), JAXBContext.newInstance(TestBean.class), ADDRESS, "urn:action", null, null);
}
示例9: SOAP11Encoder
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
/** Constructor. */
@SuppressWarnings("unchecked")
public SOAP11Encoder() {
super();
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME);
}
示例10: buildSOAPEnvelope
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
/**
* Builds the SOAP envelope and body skeleton to be encoded.
*
* @param messageContext the message context being processed
*
* @return the minimal SOAP message envelope skeleton
*/
protected Envelope buildSOAPEnvelope(MessageContext messageContext) {
log.debug("Building SOAP envelope");
Envelope envelope = envBuilder.buildObject();
Body body = bodyBuilder.buildObject();
envelope.setBody(body);
return envelope;
}
示例11: marshallAttributes
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
Body body = (Body) xmlObject;
Attr attribute;
for (Entry<QName, String> entry : body.getUnknownAttributes().entrySet()) {
attribute = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey());
attribute.setValue(entry.getValue());
domElement.setAttributeNodeNS(attribute);
if (Configuration.isIDAttribute(entry.getKey())
|| body.getUnknownAttributes().isIDAttribute(entry.getKey())) {
attribute.getOwnerElement().setIdAttributeNode(attribute, true);
}
}
}
示例12: processAttribute
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
Body body = (Body) xmlObject;
QName attribQName = XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute
.getPrefix());
if (attribute.isId()) {
body.getUnknownAttributes().registerID(attribQName);
}
body.getUnknownAttributes().put(attribQName, attribute.getValue());
}
示例13: processChildElement
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject)
throws UnmarshallingException {
Envelope envelope = (Envelope) parentXMLObject;
if (childXMLObject instanceof Header) {
envelope.setHeader((Header) childXMLObject);
} else if (childXMLObject instanceof Body) {
envelope.setBody((Body) childXMLObject);
} else {
envelope.getUnknownXMLObjects().add(childXMLObject);
}
}
示例14: HandlerChainAwareHTTPSOAP11Encoder
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
/** Constructor. */
public HandlerChainAwareHTTPSOAP11Encoder() {
super();
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
envBuilder = (SOAPObjectBuilder<Envelope>) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
bodyBuilder = (SOAPObjectBuilder<Body>) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME);
}
示例15: makeSoapEnvelope
import org.opensaml.ws.soap.soap11.Body; //导入依赖的package包/类
private Envelope makeSoapEnvelope(XMLObject obj) {
Body body = getSoapBody();
body.getUnknownXMLObjects().add(obj);
Envelope evp = (Envelope) _bf.getBuilder(Envelope.DEFAULT_ELEMENT_NAME).
buildObject(Envelope.DEFAULT_ELEMENT_NAME);
evp.setBody(body);
return evp;
}