List of usage examples for javax.xml.ws.handler MessageContext MESSAGE_OUTBOUND_PROPERTY
String MESSAGE_OUTBOUND_PROPERTY
To view the source code for javax.xml.ws.handler MessageContext MESSAGE_OUTBOUND_PROPERTY.
Click Source Link
From source file:be.fedict.hsm.ws.impl.JAASSOAPHandler.java
@Override public boolean handleFault(SOAPMessageContext context) { Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty) { try {//from ww w .ja va2 s .co m logout(context); } catch (LoginException e) { this.securityAuditGeneratorBean.webServiceAuthenticationError(); throw new ProtocolException("JAAS logout error: " + e.getMessage(), e); } } return true; }
From source file:be.fedict.eid.idp.protocol.saml2.artifact.ArtifactServiceServerHandler.java
public boolean handleMessage(SOAPMessageContext soapMessageContext) { Boolean outbound = (Boolean) soapMessageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); SOAPMessage soapMessage = soapMessageContext.getMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); if (outbound) { handleOutboundDocument(soapPart, soapMessageContext); } else {/* www. j a v a2s .c om*/ handleInboundDocument(soapPart); } return true; }
From source file:be.fedict.eid.idp.sp.protocol.saml2.artifact.ArtifactServiceClientHandler.java
/** * {@inheritDoc}//from w ww.ja va 2s . c o m */ public boolean handleMessage(SOAPMessageContext soapMessageContext) { Boolean outbound = (Boolean) soapMessageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); SOAPMessage soapMessage = soapMessageContext.getMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); if (outbound) { handleOutboundDocument(soapPart); } else { handleInboundDocument(soapPart); } return true; }
From source file:be.fedict.trust.client.WSSecurityClientHandler.java
public boolean handleMessage(SOAPMessageContext soapMessageContext) { Boolean outboundProperty = (Boolean) soapMessageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); SOAPMessage soapMessage = soapMessageContext.getMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); if (false == outboundProperty.booleanValue()) { /*/*from ww w.j a va 2 s .co m*/ * Validate incoming WS-Security header if present */ return handleInboundDocument(soapPart, soapMessageContext); } return true; }
From source file:be.fedict.trust.xkms2.WSSecurityServerHandler.java
/** * {@inheritDoc}/*from ww w .jav a 2s . co m*/ */ public boolean handleMessage(SOAPMessageContext soapMessageContext) { LOG.debug("handle message"); Boolean outboundProperty = (Boolean) soapMessageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); SOAPMessage soapMessage = soapMessageContext.getMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); if (true == outboundProperty.booleanValue()) { handleOutboundDocument(soapPart, soapMessageContext); } else { handleInboundDocument(soapPart, soapMessageContext); } return true; }
From source file:hornet.framework.webservice.SOAPLoggingHandler.java
/** * log le message SOAP//from w ww . ja v a2 s .c om * * @param smc * SOAPMessageContext */ private void logSOAP(final SOAPMessageContext smc) { final Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty.booleanValue()) { LOGGER.debug("\nMessage SOAP envoye:"); } else { LOGGER.debug("\nMessage SOAP recu:"); } final SOAPMessage message = smc.getMessage(); try { // Create transformer final TransformerFactory tff = TransformerFactory.newInstance(); final Transformer tranf = tff.newTransformer(); // Get reply content final Source src = message.getSOAPPart().getContent(); // Set output transformation final ByteArrayOutputStream streamOut = new ByteArrayOutputStream(); final StreamResult result = new StreamResult(streamOut); tranf.transform(src, result); LOGGER.debug(streamOut.toString(CharEncoding.UTF_8)); } catch (final TransformerConfigurationException e) { LOGGER.error(ERROR_MSG, e); } catch (final SOAPException e) { LOGGER.error(ERROR_MSG, e); } catch (final TransformerException e) { LOGGER.error(ERROR_MSG, e); } catch (final UnsupportedEncodingException e) { LOGGER.error(ERROR_MSG, e); } }
From source file:org.apache.juddi.xlt.util.LoggingHandler.java
private boolean isOutboundMessage(MessageContext context) { Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); return outboundProperty.booleanValue(); }
From source file:org.springframework.integration.sqs.AWSSecurityHandler.java
private void logMessage(final SOAPMessageContext smc) { Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); SOAPMessage message = smc.getMessage(); if (outboundProperty.booleanValue()) { logMessage("Outbound message: ", message); } else {/* w ww . ja v a 2 s . c o m*/ logMessage("Inbound message: ", message); } }
From source file:org.springframework.integration.sqs.AWSSecurityHandler.java
/** * {@inheritDoc}/*from w ww . ja va 2 s . c o m*/ */ public boolean handleMessage(final SOAPMessageContext context) { logMessage(context); Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outboundProperty) { return true; } /* * Example SOAP header from * http://docs.amazonwebservices.com/AWSSimpleQueueService * /2008-01-01/SQSDeveloperGuide * /MakingRequests_MakingSOAPRequestsArticle.html * * <soapenv:Header * xmlns:aws="http://security.amazonaws.com/doc/2007-01-01/"> * <aws:AWSAccessKeyId>1D9FVRAYCP1VJS767E02EXAMPLE</aws:AWSAccessKeyId> * <aws:Timestamp>2008-02-10T23:59:59Z</aws:Timestamp> * <aws:Signature>SZf1CHmQ/nrZbsrC13hCZS061ywsEXAMPLE</aws:Signature> * </soapenv:Header> */ SOAPMessage aSOAPMessage = context.getMessage(); try { SOAPEnvelope aEnvelope = aSOAPMessage.getSOAPPart().getEnvelope(); SOAPHeader aHeader = aEnvelope.addHeader(); String aTimestampStr = this.getTimestamp(); // ADD AWS SECURITY HEADER ---------------------------------------- aHeader.addNamespaceDeclaration(NAMESPACE_AWS_PREFIX, NAMESPACE_AWS); // ADD ACCESS KEY ------------------------------------------------- Name aKeyName = aEnvelope.createName("AWSAccessKeyId", NAMESPACE_AWS_PREFIX, NAMESPACE_AWS); SOAPHeaderElement aKey = aHeader.addHeaderElement(aKeyName); aKey.addTextNode(s_key); // ADD TIMESTAMP -------------------------------------------------- Name aTimestampName = aEnvelope.createName("Timestamp", NAMESPACE_AWS_PREFIX, NAMESPACE_AWS); SOAPHeaderElement aTimestamp = aHeader.addHeaderElement(aTimestampName); aTimestamp.addTextNode(aTimestampStr); // ADD SIGNATURE -------------------------------------------------- Name aSignatureName = aEnvelope.createName("Signature", NAMESPACE_AWS_PREFIX, NAMESPACE_AWS); SOAPHeaderElement aSignature = aHeader.addHeaderElement(aSignatureName); SOAPBody aBody = aEnvelope.getBody(); Iterator<?> aChildren = aBody.getChildElements(); SOAPBodyElement aAction = (SOAPBodyElement) aChildren.next(); if (aChildren.hasNext()) { throw new IllegalStateException( "Unexpected number of actions in soap request. Cannot calculate signature."); } aSignature.addTextNode(this.calculateSignature(aAction.getLocalName(), aTimestampStr)); aSOAPMessage.saveChanges(); logMessage("Final out message: ", aSOAPMessage); } catch (Exception e) { throw new IllegalStateException("Failed to add aws headers!", e); } return true; }
From source file:org.wso2.carbon.device.mgt.mobile.windows.api.services.enrollment.util.MessageHandler.java
/** * This method adds Timestamp for SOAP header, and adds Content-length for HTTP header for * avoiding HTTP chunking./*from w ww . ja va2 s. co m*/ * * @param context - Context of the SOAP Message */ @Override public boolean handleMessage(SOAPMessageContext context) { Boolean outBoundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outBoundProperty) { SOAPMessage message = context.getMessage(); SOAPHeader header = null; SOAPEnvelope envelope = null; try { header = message.getSOAPHeader(); envelope = message.getSOAPPart().getEnvelope(); } catch (SOAPException e) { Response.serverError().entity("SOAP message content cannot be read.").build(); } try { if ((header == null) && (envelope != null)) { header = envelope.addHeader(); } } catch (SOAPException e) { Response.serverError().entity("SOAP header cannot be added.").build(); } SOAPFactory soapFactory = null; try { soapFactory = SOAPFactory.newInstance(); } catch (SOAPException e) { Response.serverError().entity("Cannot get an instance of SOAP factory.").build(); } QName qNamesSecurity = new QName(PluginConstants.WS_SECURITY_TARGET_NAMESPACE, PluginConstants.CertificateEnrolment.SECURITY); SOAPHeaderElement Security = null; Name attributeName = null; try { if (header != null) { Security = header.addHeaderElement(qNamesSecurity); } if (soapFactory != null) { attributeName = soapFactory.createName(PluginConstants.CertificateEnrolment.TIMESTAMP_ID, PluginConstants.CertificateEnrolment.TIMESTAMP_U, PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY); } } catch (SOAPException e) { Response.serverError().entity("Security header cannot be added.").build(); } QName qNameTimestamp = new QName(PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY, PluginConstants.CertificateEnrolment.TIMESTAMP); SOAPHeaderElement timestamp = null; try { if (header != null) { timestamp = header.addHeaderElement(qNameTimestamp); timestamp.addAttribute(attributeName, PluginConstants.CertificateEnrolment.TIMESTAMP_0); } } catch (SOAPException e) { Response.serverError().entity("Exception while adding timestamp header.").build(); } DateTime dateTime = new DateTime(); DateTime expiredDateTime = dateTime.plusMinutes(VALIDITY_TIME); String createdISOTime = dateTime.toString(ISODateTimeFormat.dateTime()); String expiredISOTime = expiredDateTime.toString(ISODateTimeFormat.dateTime()); createdISOTime = createdISOTime.substring(TIMESTAMP_BEGIN_INDEX, createdISOTime.length() - TIMESTAMP_END_INDEX); createdISOTime = createdISOTime + TIME_ZONE; expiredISOTime = expiredISOTime.substring(TIMESTAMP_BEGIN_INDEX, expiredISOTime.length() - TIMESTAMP_END_INDEX); expiredISOTime = expiredISOTime + TIME_ZONE; QName qNameCreated = new QName(PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY, PluginConstants.CertificateEnrolment.CREATED); SOAPHeaderElement SOAPHeaderCreated = null; try { if (header != null) { SOAPHeaderCreated = header.addHeaderElement(qNameCreated); SOAPHeaderCreated.addTextNode(createdISOTime); } } catch (SOAPException e) { Response.serverError().entity("Exception while creating SOAP header.").build(); } QName qNameExpires = new QName(PluginConstants.CertificateEnrolment.WSS_SECURITY_UTILITY, PluginConstants.CertificateEnrolment.EXPIRES); SOAPHeaderElement SOAPHeaderExpires = null; ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); String messageString = null; try { if (header != null) { SOAPHeaderExpires = header.addHeaderElement(qNameExpires); SOAPHeaderExpires.addTextNode(expiredISOTime); } if ((timestamp != null) && (Security != null)) { timestamp.addChildElement(SOAPHeaderCreated); timestamp.addChildElement(SOAPHeaderExpires); Security.addChildElement(timestamp); } message.saveChanges(); message.writeTo(outputStream); messageString = new String(outputStream.toByteArray(), PluginConstants.CertificateEnrolment.UTF_8); } catch (SOAPException e) { Response.serverError().entity("Exception while creating timestamp SOAP header.").build(); } catch (IOException e) { Response.serverError().entity("Exception while writing message to output stream.").build(); } Map<String, List<String>> headers = (Map<String, List<String>>) context .get(MessageContext.HTTP_REQUEST_HEADERS); headers = new HashMap<String, List<String>>(); if (messageString != null) { headers.put(PluginConstants.CONTENT_LENGTH, Arrays.asList(String.valueOf(messageString.length()))); } context.put(MessageContext.HTTP_REQUEST_HEADERS, headers); } return true; }