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.eid.dss.client.LoggingSoapHandler.java
public boolean handleMessage(SOAPMessageContext context) { LOG.debug("handle message"); Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); LOG.debug("outbound message: " + outboundProperty); SOAPMessage soapMessage = context.getMessage(); ByteArrayOutputStream output = new ByteArrayOutputStream(); try {/*from w w w.j a v a2 s . c o m*/ if (this.logToFile) { File tmpFile = File.createTempFile( "eid-dss-soap-" + (outboundProperty ? "outbound" : "inbound") + "-", ".xml"); FileOutputStream fileOutputStream = new FileOutputStream(tmpFile); soapMessage.writeTo(fileOutputStream); fileOutputStream.close(); LOG.debug("tmp file: " + tmpFile.getAbsolutePath()); } soapMessage.writeTo(output); } catch (Exception e) { LOG.error("SOAP error: " + e.getMessage()); } LOG.debug("SOAP message: " + output.toString()); return true; }
From source file:it.govpay.web.handler.MessageLoggingHandlerUtils.java
@SuppressWarnings("unchecked") public static boolean logToSystemOut(SOAPMessageContext smc, String tipoServizio, int versioneServizio, Logger log) {//w w w. j a v a 2s . co m Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); GpContext ctx = null; Message msg = new Message(); SOAPMessage message = smc.getMessage(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { message.writeTo(baos); msg.setContent(baos.toByteArray()); } catch (Exception e) { log.error("Exception in handler: " + e); } Map<String, List<String>> httpHeaders = null; if (outboundProperty.booleanValue()) { ctx = GpThreadLocal.get(); httpHeaders = (Map<String, List<String>>) smc.get(MessageContext.HTTP_RESPONSE_HEADERS); msg.setType(MessageType.RESPONSE_OUT); ctx.getContext().getResponse().setOutDate(new Date()); ctx.getContext().getResponse().setOutSize(Long.valueOf(baos.size())); } else { try { ctx = new GpContext(smc, tipoServizio, versioneServizio); ThreadContext.put("op", ctx.getTransactionId()); GpThreadLocal.set(ctx); } catch (Exception e) { log.error(e.getMessage(), e); return false; } httpHeaders = (Map<String, List<String>>) smc.get(MessageContext.HTTP_REQUEST_HEADERS); msg.setType(MessageType.REQUEST_IN); msg.setContentType(((HttpServletRequest) smc.get(MessageContext.SERVLET_REQUEST)).getContentType()); ctx.getContext().getRequest().setInDate(new Date()); ctx.getContext().getRequest().setInSize(Long.valueOf(baos.size())); } if (httpHeaders != null) { for (String key : httpHeaders.keySet()) { if (httpHeaders.get(key) != null) { if (key == null) msg.addHeader(new Property("Status-line", httpHeaders.get(key).get(0))); else if (httpHeaders.get(key).size() == 1) msg.addHeader(new Property(key, httpHeaders.get(key).get(0))); else msg.addHeader(new Property(key, ArrayUtils.toString(httpHeaders.get(key)))); } } } ctx.log(msg); return true; }
From source file:be.fedict.hsm.ws.impl.LoggingSOAPHandler.java
@Override public boolean handleFault(SOAPMessageContext context) { Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); LOG.debug("outbound message: " + outboundProperty); SOAPMessage soapMessage = context.getMessage(); ByteArrayOutputStream output = new ByteArrayOutputStream(); try {// w ww. j av a 2s . c o m soapMessage.writeTo(output); } catch (Exception e) { LOG.error("SOAP error: " + e.getMessage()); } LOG.debug("SOAP fault: " + output.toString()); return true; }
From source file:be.agiv.security.handler.WSTrustHandler.java
public boolean handleMessage(SOAPMessageContext context) { Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (false == outboundProperty) { try {/*from w ww. j a va 2 s .co m*/ handleInboundMessage(context); } catch (Exception e) { throw new ProtocolException(e); } } else { try { handleOutboundMessage(context); } catch (Exception e) { LOG.error("error: " + e.getMessage(), e); throw new ProtocolException(e); } } return true; }
From source file:be.e_contract.mycarenet.common.LoggingHandler.java
private void logMessage(SOAPMessageContext context) { Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); LOG.debug("outbound message: " + outboundProperty); SOAPMessage soapMessage = context.getMessage(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try {/*ww w . j a v a2 s . c om*/ soapMessage.writeTo(outputStream); } catch (Exception e) { LOG.error("SOAP error: " + e.getMessage()); } String message = outputStream.toString(); LOG.debug("SOAP message: " + message); if (false == outboundProperty) { @SuppressWarnings("unchecked") Map<String, DataHandler> inboundMessageAttachments = (Map<String, DataHandler>) context .get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS); Set<String> attachmentContentIds = inboundMessageAttachments.keySet(); LOG.debug("attachment content ids: " + attachmentContentIds); } }
From source file:be.e_contract.dssp.client.LoggingSOAPHandler.java
private void logMessage(SOAPMessageContext context) { Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); LOG.debug("outbound message: " + outboundProperty); SOAPMessage soapMessage = context.getMessage(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try {//from w ww. j a v a 2s . c o m soapMessage.writeTo(outputStream); } catch (Exception e) { LOG.error("SOAP error: " + e.getMessage()); } String message = outputStream.toString(); LOG.debug("SOAP message: " + message); if (false == outboundProperty) { Map<String, DataHandler> inboundMessageAttachments = (Map<String, DataHandler>) context .get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS); Set<String> attachmentContentIds = inboundMessageAttachments.keySet(); LOG.debug("attachment content ids: " + attachmentContentIds); } }
From source file:com.vmware.identity.sts.ws.handlers.SoapMsgMetricsCollector.java
@Override public boolean handleMessage(SOAPMessageContext context) { Validate.notNull(context);// www .j a va 2 s . c om Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound != null && outbound.equals(Boolean.TRUE)) { reportTime(context, PerfMeasurementInterface.ISoapMsgHandlerOB); return true; } setMsgStartTs(); return true; }
From source file:com.vmware.identity.sts.ws.handlers.LogContextHandler.java
@Override public boolean handleMessage(SOAPMessageContext context) { Validate.notNull(context, "SOAPMessageContext should not be null."); Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outbound != null && outbound.equals(Boolean.TRUE)) { return true; } else {// w w w. ja v a2 s . c o m String tenant = null; String correlationId = null; // http://docs.oracle.com/javase/7/docs/api/javax/xml/ws/handler/MessageContext.html : // static final String HTTP_REQUEST_HEADERS // Standard property: HTTP request headers. // Type: java.util.Map<java.lang.String, java.util.List<java.lang.String>> // // static final String SERVLET_REQUEST // Standard property: servlet request object. // Type: javax.servlet.http.HttpServletRequest HttpServletRequest request = (HttpServletRequest) (context.get(MessageContext.SERVLET_REQUEST)); Validate.notNull(request, "HttpServletRequest should not be null."); @SuppressWarnings("unchecked") Map<String, List<String>> headers = (Map<String, List<String>>) (context .get(MessageContext.HTTP_REQUEST_HEADERS)); if (headers != null) { List<String> correlationIds = headers.get(WsConstants.ACTIVITY_CORRELATION_ID_CUSTOM_HEADER); if ((correlationIds != null) && (correlationIds.size() > 1)) { correlationId = correlationIds.get(0); correlationId = LogContextHandler.removeNewline(correlationId); correlationId = LogContextHandler.truncate(correlationId, 200); } } if ((correlationId == null) || (correlationId.isEmpty())) { correlationId = UUID.randomUUID().toString(); logger.debug("unable to extract correlation id from request. generated new correllation id [{}]", correlationId); } else { logger.debug("extracted correlation id [{}] from the request", correlationId); } try { tenant = TenantExtractor.extractTenantName(request.getPathInfo()); tenant = LogContextHandler.removeNewline(tenant); tenant = LogContextHandler.truncate(tenant, 200); logger.debug("extracted tenant [{}] from the request", tenant); } catch (NoSuchIdPException ex) { logger.error("failed to extract tenant from the request", ex); } if ((tenant == null) || (tenant.isEmpty())) { tenant = WsConstants.DEFAULT_TENANT; logger.debug( "unable to extract explicit tenant name from request. Using default tenant marker [{}].", tenant); } else { logger.debug("extracted tenant name [{}] from the request", tenant); } this._diagCtxt = DiagnosticsContextFactory.createContext(correlationId, tenant); } return true; }
From source file:com.konakart.bl.modules.ordertotal.thomson.HeaderSecrityHandler.java
public boolean handleMessage(SOAPMessageContext smc) { Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty.booleanValue()) { SOAPMessage message = smc.getMessage(); if (log.isInfoEnabled()) { log.info("Adding Credentials : " + getUName() + "/" + getPWord()); }/*from w w w .ja v a 2 s. c o m*/ try { SOAPEnvelope envelope = message.getSOAPPart().getEnvelope(); envelope.setPrefix("soapenv"); envelope.getBody().setPrefix("soapenv"); SOAPHeader header = envelope.addHeader(); SOAPElement security = header.addChildElement("Security", "wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"); SOAPElement usernameToken = security.addChildElement("UsernameToken", "wsse"); usernameToken.addAttribute(new QName("wsu:Id"), "UsernameToken-1"); usernameToken.setAttribute("wsu:Id", "UsernameToken-1"); usernameToken.addAttribute(new QName("xmlns:wsu"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); SOAPElement username = usernameToken.addChildElement("Username", "wsse"); username.addTextNode(getUName()); SOAPElement password = usernameToken.addChildElement("Password", "wsse"); password.setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"); password.addTextNode(getPWord()); SOAPElement encodingType = usernameToken.addChildElement("Nonce", "wsse"); encodingType.setAttribute("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"); encodingType.addTextNode("Encoding"); } catch (Exception e) { e.printStackTrace(); } } return outboundProperty; }
From source file:com.hiperium.integration.access.control.SoapSessionHandler.java
@SuppressWarnings("unchecked") @Override/*from w ww.j a va 2 s. c om*/ public boolean handleMessage(SOAPMessageContext context) { LOGGER.debug("handleMessage - BEGIN"); // Only message arriving from the client. Not processing responses. Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (!outbound) { Map<String, List<String>> map = (Map<String, List<String>>) context .get(MessageContext.HTTP_REQUEST_HEADERS); List<String> sessionHeader = this.getHTTPHeader(map, CommonsUtil.SESSIONID); if (sessionHeader == null) { SOAPMessage msg = context.getMessage(); this.generateFault(msg, Resources.getResourceBundle(EnumI18N.SECURITY, Locale.getDefault()) .getString("ilegalAccessResource")); } // Get the sessionId from the entire HTTP Message StringBuffer sessionIdBuffer = new StringBuffer(); for (String session : sessionHeader) { sessionIdBuffer.append(session); } // Validate that the session ID is valid if (StringUtils.isNotBlank(sessionIdBuffer.toString()) && !this.securityBusinessDelegate .getSessionManagerBO().findIfHomeLoggedIn(sessionIdBuffer.toString())) { SOAPMessage msg = context.getMessage(); this.generateFault(msg, Resources.getResourceBundle(EnumI18N.SECURITY, Locale.getDefault()) .getString("ilegalAccessResource")); } } LOGGER.debug("handleMessage - END"); return true; //continue other handler chain }