Java 类javax.xml.ws.handler.soap.SOAPMessageContext 实例源码

项目:programacaoweb    文件:UsuarioHandlerMessage.java   
@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean request = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (!request) {
        try {
            SOAPMessage msg = context.getMessage();
            SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
            SOAPHeader header = env.getHeader();
            if (header == null) {
                header = env.addHeader();
                return false;
            }
            Node node = (Node) header.getElementsByTagName("token").item(0);
            String token = node.getChildNodes().item(0).getNodeValue();
            if (token != null && token.equals("Kalango Lab")) {
                System.out.println("Token válido");
                return true;
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
    return true;
}
项目:oscm    文件:SamlAssertionBreakHandler.java   
private void modifyAssertion(SOAPMessageContext context) throws Exception {

    if (isOutboundMessage(context).booleanValue()) {
        Document messageDoc = context.getMessage().getSOAPBody()
                .getOwnerDocument();
        String tagName = getModifyTagName(messageDoc);

        if (tagName != null && tagName.length() != 0) {
            NodeList nodes = messageDoc.getElementsByTagName(tagName);
            if (nodes.getLength() == 0) {
                throw new Exception("Can not modify SAML assertion.");
            }
            Node node = nodes.item(0);
            removeLastCharacter(node);
        }

    }
}
项目:oscm    文件:UpdateFieldAdapter.java   
@Override
public void exec(SOAPMessageContext context, ModificationDetail detail)
        throws SOAPException {
    UpdateFieldDetail upd_detail = (UpdateFieldDetail) detail;

    if (!detail.getType().equals(ModificationType.UPDATEFIELD)) {
        return;
    }
    if (detail.getPart().equals(ModificationPart.EXCEPTION)
            || detail.getPart().equals(ModificationPart.METHOD)) {
        return;
    }

    if (detail.getPart().equals(ModificationPart.RETURNVALUE)) {
        updateForResponse(context, upd_detail);
    }

    if (detail.getPart().equals(ModificationPart.PARAMETER)) {
        updateForRequest(context, upd_detail);
    }
}
项目:oscm    文件:UpdateAdapter.java   
@Override
public void exec(SOAPMessageContext soapMessageContext,
        ModificationDetail detail) throws SOAPException {
    if (detail instanceof UpdateDetail) {
        UpdateDetail upd_detail = (UpdateDetail) detail;
        if (ModificationPart.PARAMETER.equals(upd_detail.getPart())) {
            renameParameter(soapMessageContext, upd_detail.getOldVariable()
                    .getVariableName(), upd_detail.getVariable()
                    .getVariableName());
        } else if (ModificationPart.METHOD.equals(upd_detail.getPart())) {
            if (upd_detail.isRequest()) {
                renameMethod(soapMessageContext,
                        METHODPREFIX + upd_detail.getOldMethodName(),
                        METHODPREFIX + upd_detail.getNewMethodName());
            } else {
                renameMethod(soapMessageContext,
                        METHODPREFIX + upd_detail.getOldMethodName()
                                + RESPONSESUFFIX,
                        METHODPREFIX + upd_detail.getNewMethodName()
                                + RESPONSESUFFIX);
            }
        }
    }
}
项目:oscm    文件:UpdateAdapter.java   
private void renameParameter(SOAPMessageContext context, String oldName,
        String newName) throws SOAPException {
    NodeList nodelist = context.getMessage().getSOAPBody()
            .getElementsByTagName(oldName);
    Node node;
    if (null != nodelist) {
        int size = nodelist.getLength();
        for (int j = 0; j < size; j++) {
            node = nodelist.item(0);
            if (null != node) {
                Element newNode = node.getOwnerDocument().createElement(
                        newName);
                NodeList list = node.getChildNodes();
                int childrenSize = list.getLength();
                for (int i = 0; i < childrenSize; i++) {
                    newNode.appendChild(list.item(0));
                }
                node.getParentNode().replaceChild(newNode, node);
            }
        }
    }
}
项目:helium    文件:SoapLoggingHandler.java   
private void logToSystemOut(SOAPMessageContext smc) {
    if (LOGGER.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder();
        Boolean outboundProperty = (Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
        if (outboundProperty.booleanValue())
            sb.append("Missatge SOAP enviat: ");
        else
            sb.append("Missatge SOAP rebut: ");
        SOAPMessage message = smc.getMessage();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            message.writeTo(baos);
            sb.append(baos.toString());
        } catch (Exception ex) {
            sb.append("Error al processar el missatge XML: " + ex.getMessage());
        }
        LOGGER.debug(sb.toString());
    }
}
项目:rpb    文件:LoggingHandler.java   
@Override
public boolean handleMessage(SOAPMessageContext c) {

    SOAPMessage msg = c.getMessage();
    boolean request = ((Boolean) c.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY));
    try {
        if (request) { // This is a request message.
            // Write the message to the output stream
            log.debug("Request:\n"
                    + Util.documentToString(msg.getSOAPBody().getOwnerDocument()));
        }
        else { // This is the response message
            log.debug("Response:\n"
                    + Util.documentToString(msg.getSOAPBody().getOwnerDocument()));
        }
    }
    catch (Exception e) {
        log.error(e);
    }

    return Boolean.TRUE;
}
项目:rpb    文件:EventDefListAllHandler.java   
@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (!isRequest) { // only incoming messages
        try {
            SOAPMessage soapMsg = context.getMessage();
            SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
            SOAPBody soapBody = soapEnv.getBody();
            if (soapBody != null) {
                // Should have a SOAPBody and a listall response...
                NodeList nodeList = soapBody.getElementsByTagNameNS(EVENTDEF_NS, EVENTDEF_LIST_ALL_RESPONSE);
                if (nodeList.getLength() > 0) { // check for listAllResponse
                                                // tag first!
                    nodeList = soapBody.getElementsByTagNameNS(EVENTDEF_NS, EVENTDEF_ELEMENT);
                    recursiveRenamespace(nodeList); // renamespace...
                    soapMsg.saveChanges();
                }
            }
        } catch (Exception e) {
            catchMessages(e);
        }
    }
    return true;
}
项目:rpb    文件:StudyListAllHandler.java   
@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (!isRequest) { // only incoming messages
        try {
            SOAPMessage soapMsg = context.getMessage();
            SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
            SOAPBody soapBody = soapEnv.getBody();
            if (soapBody != null) {
                // Should have a SOAPBody and a listall response...
                NodeList nodeList = soapBody.getElementsByTagNameNS(STUDIES_NS, STUDY_LIST_ALL_RESPONSE);
                if (nodeList.getLength() > 0) { // check for listAllResponse
                                                // tag first!
                    nodeList = soapBody.getElementsByTagNameNS(STUDIES_NS, STUDIES_ELEMENT);
                    recursiveRenamespace(nodeList); // renamespace...
                    soapMsg.saveChanges();
                }
            }
        } catch (Exception e) {
            catchMessages(e);
        }
    }
    return true;
}
项目:OntologyBasedInormationExtractor    文件:AwsHandlerResolver.java   
public boolean handleMessage(SOAPMessageContext messagecontext) {
    Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (outbound) {
        try {
            SOAPMessage soapMessage = messagecontext.getMessage();
            SOAPBody soapBody = soapMessage.getSOAPBody();
            Node firstChild = soapBody.getFirstChild();

            String timeStamp = getTimestamp();
            String signature = getSignature(firstChild.getLocalName(), timeStamp, secretBytes);

            appendTextElement(firstChild, "Signature", signature);
            appendTextElement(firstChild, "Timestamp", timeStamp);
        } catch(SOAPException se) {
            throw new RuntimeException("SOAPException was thrown.", se);
        }
    }
    return true;
}
项目:jbossws-cxf    文件:RoutingHandler.java   
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
   log.info("handleInbound");

   try
   {
      SOAPMessage soapMessage = msgContext.getMessage();
      SOAPBody soapBody = soapMessage.getSOAPBody();

      SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
      SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
      String value = soapElement.getValue();
      soapElement.setValue(value + "|RoutIn");
   }
   catch (SOAPException e)
   {
      throw  new WebServiceException(e);
   }

   return true;
}
项目:jbossws-cxf    文件:CustomHandler.java   
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext)
{
   log.info("handleOutbound");

   try
   {
      SOAPMessage soapMessage = msgContext.getMessage();
      SOAPBody soapBody = soapMessage.getSOAPBody();

      SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
      SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
      String value = soapElement.getValue();
      soapElement.setValue(value + "|CustomOut");
   }
   catch (SOAPException e)
   {
      throw  new WebServiceException(e);
   }

   return true;
}
项目:jbossws-cxf    文件:JBWS1283TestCase.java   
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
   SOAPMessage soapMessage = msgContext.getMessage();
   Iterator<?> it = soapMessage.getAttachments();
   while(it.hasNext())
   {
      try
      {
         AttachmentPart attachment = (AttachmentPart)it.next();
         System.out.println("Recv " + attachment.getContentType() + " attachment:");
         System.out.println("'"+attachment.getContent()+"'");
         return true;
      }
      catch (SOAPException e)
      {
         throw new RuntimeException("Failed to access attachment data");
      }
   }

   throw new IllegalStateException("Missing attachment on the client side");
}
项目:jbossws-cxf    文件:RoutingHandler.java   
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
   log.info("handleInbound");

   try
   {
      SOAPMessage soapMessage = msgContext.getMessage();
      SOAPBody soapBody = soapMessage.getSOAPBody();

      SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
      SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
      String value = soapElement.getValue();
      soapElement.setValue(value + "|RoutIn");
   }
   catch (SOAPException e)
   {
      throw  new WebServiceException(e);
   }

   return true;
}
项目:jbossws-cxf    文件:MTOMProtocolHandler.java   
private boolean verifyXOPPackage(MessageContext context)
{
   try
   {
      SOAPMessageContext msgContext = (SOAPMessageContext)context;
      SOAPMessage soapMsg = msgContext.getMessage();
      SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
      SOAPBody body = soapEnv.getBody();
      boolean found = scanNodes(body.getChildNodes());

      if(found) throw new IllegalStateException("XOP request not properly inlined");

   }
   catch (SOAPException ex)
   {
      throw new WebServiceException(ex);
   }

   return true;
}
项目:mycarenet    文件: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 {
        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);
    }
}
项目:jbossws-cxf    文件:ClientSOAPHandler.java   
protected boolean handleOutbound(final SOAPMessageContext msgContext)
{
   try
   {
      SOAPFault fault = null;
      MessageFactory factory = MessageFactory.newInstance(); 
      SOAPMessage resMessage = factory.createMessage();
      fault = resMessage.getSOAPBody().addFault();
      fault.setFaultString("this is an exception thrown by client outbound");
      throw new SOAPFaultException(fault);
   }
   catch (SOAPException e)
   {
      //ignore
   }
   return true;
}
项目:development    文件:UpdateAdapter.java   
@Override
public void exec(SOAPMessageContext soapMessageContext,
        ModificationDetail detail) throws SOAPException {
    if (detail instanceof UpdateDetail) {
        UpdateDetail upd_detail = (UpdateDetail) detail;
        if (ModificationPart.PARAMETER.equals(upd_detail.getPart())) {
            renameParameter(soapMessageContext, upd_detail.getOldVariable()
                    .getVariableName(), upd_detail.getVariable()
                    .getVariableName());
        } else if (ModificationPart.METHOD.equals(upd_detail.getPart())) {
            if (upd_detail.isRequest()) {
                renameMethod(soapMessageContext,
                        METHODPREFIX + upd_detail.getOldMethodName(),
                        METHODPREFIX + upd_detail.getNewMethodName());
            } else {
                renameMethod(soapMessageContext,
                        METHODPREFIX + upd_detail.getOldMethodName()
                                + RESPONSESUFFIX,
                        METHODPREFIX + upd_detail.getNewMethodName()
                                + RESPONSESUFFIX);
            }
        }
    }
}
项目:development    文件:UpdateAdapter.java   
private void renameParameter(SOAPMessageContext context, String oldName,
        String newName) throws SOAPException {
    NodeList nodelist = context.getMessage().getSOAPBody()
            .getElementsByTagName(oldName);
    Node node;
    if (null != nodelist) {
        int size = nodelist.getLength();
        for (int j = 0; j < size; j++) {
            node = nodelist.item(0);
            if (null != node) {
                Element newNode = node.getOwnerDocument().createElement(
                        newName);
                NodeList list = node.getChildNodes();
                int childrenSize = list.getLength();
                for (int i = 0; i < childrenSize; i++) {
                    newNode.appendChild(list.item(0));
                }
                node.getParentNode().replaceChild(newNode, node);
            }
        }
    }
}
项目:rpb    文件:LoggingHandler.java   
@Override
public boolean handleMessage(SOAPMessageContext c) {

    SOAPMessage msg = c.getMessage();
    boolean request = ((Boolean) c.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY));
    try {
        if (request) { // This is a request message.
            // Write the message to the output stream
            log.debug("Request:\n"
                    + Util.documentToString(msg.getSOAPBody().getOwnerDocument()));
        }
        else { // This is the response message
            log.debug("Response:\n"
                    + Util.documentToString(msg.getSOAPBody().getOwnerDocument()));
        }
    }
    catch (Exception e) {
        log.error(e);
    }

    return Boolean.TRUE;
}
项目:rpb    文件:EventDefListAllHandler.java   
@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (!isRequest) { // only incoming messages
        try {
            SOAPMessage soapMsg = context.getMessage();
            SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
            SOAPBody soapBody = soapEnv.getBody();
            if (soapBody != null) {
                // Should have a SOAPBody and a listall response...
                NodeList nodeList = soapBody.getElementsByTagNameNS(EVENTDEF_NS, EVENTDEF_LIST_ALL_RESPONSE);
                if (nodeList.getLength() > 0) { // check for listAllResponse
                                                // tag first!
                    nodeList = soapBody.getElementsByTagNameNS(EVENTDEF_NS, EVENTDEF_ELEMENT);
                    recursiveRenamespace(nodeList); // renamespace...
                    soapMsg.saveChanges();
                }
            }
        } catch (Exception e) {
            catchMessages(e);
        }
    }
    return true;
}
项目:winrm4j    文件:StripShellResponseHandler.java   
@Override
public boolean handleMessage(SOAPMessageContext context) {
    boolean isResponse = Boolean.FALSE.equals(context.get (MessageContext.MESSAGE_OUTBOUND_PROPERTY));
    if (isResponse) {
        QName action = (QName) context.get(SOAPMessageContext.WSDL_OPERATION);
        if ("Create".equals(action.getLocalPart())) {
            Iterator<?> childIter = getBodyChildren(context);
            while(childIter.hasNext()) {
                Object node = childIter.next();
                if (node instanceof SOAPElement) {
                    SOAPElement el = (SOAPElement) node;
                    if ("Shell".equals(el.getLocalName())) {
                        childIter.remove();
                    }
                }
            }
        }
    }
    return true;
}
项目:jbossws-cxf    文件:AuthorizationHandler.java   
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext)
{
   log.info("handleOutbound");

   try
   {
      SOAPMessage soapMessage = msgContext.getMessage();
      SOAPBody soapBody = soapMessage.getSOAPBody();

      SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
      SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
      String value = soapElement.getValue();
      soapElement.setValue(value + "|AuthOut");
   }
   catch (SOAPException e)
   {
      throw  new WebServiceException(e);
   }

   return true;
}
项目:jbossws-cxf    文件:ServerMimeHandler.java   
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
   log.info("handleInbound");

   // legacy JBossWS-Native approach...
   SOAPMessage soapMessage = msgContext.getMessage();
   MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
   String[] cookies = mimeHeaders.getHeader("Cookie");

   // proper approach through MessageContext.HTTP_REQUEST_HEADERS
   if (cookies == null) {
      @SuppressWarnings("unchecked")
      Map<String, List<String>> httpHeaders = (Map<String, List<String>>) msgContext.get(MessageContext.HTTP_REQUEST_HEADERS);
      List<String> l = httpHeaders.get("Cookie");
      if (l != null && !l.isEmpty()) {
         cookies = l.toArray(new String[l.size()]);
      }
   }

   if (cookies != null && cookies.length == 1 && cookies[0].equals("client-cookie=true"))
      setCookieOnResponse = true;

   return true;
}
项目:jbossws-cxf    文件:TestHandler.java   
@Override
public boolean handleOutbound(SOAPMessageContext context)
{
   try
   {
      SOAPMessage soapMessage = context.getMessage();
      soapMessage.saveChanges();
      checkEnvelope(soapMessage);
      checkContentType(soapMessage);
      return true;
   }
   catch (Exception e)
   {
      throw new RuntimeException(e);
   }
}
项目:jbossws-cxf    文件:EndpointHandler.java   
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
   log.info("handleInbound");

   try
   {
      SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
      SOAPBody soapBody = soapMessage.getSOAPBody();

      SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
      SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
      String value = soapElement.getValue();
      soapElement.setValue(value + "|EpIn");
   }
   catch (SOAPException e)
   {
      throw  new WebServiceException(e);
   }

   return true;
}
项目:jbossws-cxf    文件:ClientMimeHandler.java   
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext)
{
   log.info("handleOutbound");

   // legacy JBossWS-Native approach
   SOAPMessage soapMessage = msgContext.getMessage();
   MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
   mimeHeaders.setHeader("Cookie", "client-cookie=true");

   // proper approach through MessageContext.HTTP_REQUEST_HEADERS
   Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();
   httpHeaders.put("Cookie", Collections.singletonList("client-cookie=true"));
   msgContext.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);

   inboundCookie = null;

   return true;
}
项目:jbossws-cxf    文件:ProtocolHandler.java   
private boolean appendHandlerName(MessageContext msgContext)
{
   try
   {
      SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
      SOAPElement soapElement = (SOAPElement)soapMessage.getSOAPBody().getChildElements().next();
      soapElement = (SOAPElement)soapElement.getChildElements().next();
      String value = soapElement.getValue();

      String handlerName = getHandlerName();
      soapElement.setValue(value + ":" + handlerName);

      return true;
   }
   catch (SOAPException ex)
   {
      throw new WebServiceException(ex);
   }
}
项目:jbossws-cxf    文件:CustomHandler.java   
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
   log.info("handleInbound");

   try
   {
      SOAPMessage soapMessage = msgContext.getMessage();
      SOAPBody soapBody = soapMessage.getSOAPBody();

      SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
      SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
      String value = soapElement.getValue();
      soapElement.setValue(value + "|CustomIn");
   }
   catch (SOAPException e)
   {
      throw  new WebServiceException(e);
   }

   return true;
}
项目:jbossws-cxf    文件:CDIHandler.java   
@Override
public boolean handleInbound(SOAPMessageContext msgContext)
{
   if (bean == null) {
      throw new RuntimeException("Injection doesn't work");
   }
   try
   {
      SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
      SOAPElement soapElement = (SOAPElement)soapMessage.getSOAPBody().getChildElements().next();
      soapElement = (SOAPElement)soapElement.getChildElements().next();

      String oldValue = soapElement.getValue();
      String newValue = "Mr. " + oldValue;
      soapElement.setValue(newValue);

      return true;
   }
   catch (SOAPException ex)
   {
      throw new WebServiceException(ex);
   }
}
项目:jbossws-cxf    文件:ServerMimeHandler.java   
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext)
{
   log.info("handleOutbound");

   if (setCookieOnResponse)
   {
      // legacy JBossWS-Native approach
      SOAPMessage soapMessage = msgContext.getMessage();
      MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
      mimeHeaders.setHeader("Set-Cookie", "server-cookie=true");

      // proper approach through MessageContext.HTTP_REQUEST_HEADERS
      Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();
      httpHeaders.put("Set-Cookie", Collections.singletonList("server-cookie=true"));
      msgContext.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders);

      setCookieOnResponse = false;
   }

   return true;
}
项目:oscm    文件:STSSoapHandlerServiceImpl.java   
private synchronized void addMessage(final SOAPMessageContext context) {
    final SOAPMessage msg = context.getMessage();
    final String msgText = soapMessage2String(msg);
    final String dateTime = DateConverter
            .convertLongToIso8601DateTimeFormat(System.currentTimeMillis(),
                    TimeZone.getTimeZone("GMT"));
    messageList.add(dateTime + "\n" + msgText);
}
项目:oscm    文件:SamlAssertionBreakHandler.java   
@Override
public boolean handleMessage(SOAPMessageContext context) {
    try {
        modifyAssertion(context);
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return true;
}
项目:oscm    文件:LoginHandler.java   
protected String getUserKeyFromContext(SOAPMessageContext context)
        throws UserIdNotFoundException, NamingException, SQLException, NotExistentTenantException {

    String userId = getUserIdFromContext(context);
    String tenantId = getTenantIdFromContext(context);
    String orgId = getOrganizationIdFromContext(context);

    return getUserKey(userId, orgId, tenantId);
}
项目:oscm    文件:LoginHandler.java   
protected String getUserIdFromContext(SOAPMessageContext context)
            throws UserIdNotFoundException {

//        String userId;
//
//        SAMLAssertion samlAssertion = getSamlAssertion(context);
//        SAMLResponseExtractor samlResponseExtractor = new SAMLResponseExtractor();
//        userId = samlResponseExtractor.getUserId(samlAssertion);
//        return userId;
        return "";
    }
项目:oscm    文件:LoginHandler.java   
protected String getTenantIdFromContext(SOAPMessageContext context) throws NotExistentTenantException {

        String tenantId;

//        SAMLAssertion samlAssertion = getSamlAssertion(context);
//        SAMLResponseExtractor samlResponseExtractor = new SAMLResponseExtractor();
//        tenantId = samlResponseExtractor.getTenantId(samlAssertion);
//
//        if(StringUtils.isEmpty(tenantId)){
//            throw new NotExistentTenantException(Reason.MISSING_TEANT_ID_IN_SAML);
//        }

//        return tenantId;
        return "";
    }
项目:oscm    文件:SOAPSecurityHandler.java   
@Override
public boolean handleMessage(final SOAPMessageContext msgCtx) {

    // Indicator telling us which direction this message is going in
    final Boolean outInd = (Boolean) msgCtx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

    // Handler must only add security headers to outbound messages
    if (outInd.booleanValue()) {
        try {
            // Get the SOAP Envelope
            final SOAPEnvelope envelope = msgCtx.getMessage().getSOAPPart().getEnvelope();

            // Header may or may not exist yet
            SOAPHeader header = envelope.getHeader();
            if (header == null)
                header = envelope.addHeader();

            // Add WSS Usertoken Element Tree 
            final SOAPElement security = header.addChildElement("Security", "wsse",
                    "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
            final SOAPElement userToken = security.addChildElement("UsernameToken", "wsse");
            userToken.addChildElement("Username", "wsse").addTextNode(userId);
            userToken.addChildElement("Password", "wsse").addAttribute(new QName("Type"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText").addTextNode(password);

        } catch (final Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
项目:oscm    文件:VersionHandlerCtmg.java   
/**
 * The method is invoked for normal processing of outbound messages.
 * 
 * @param context
 *            the message context.
 * @return An indication of whether handler processing should continue for
 *         the current message. Return <code>true</code> to continue
 *         processing.
 * 
 * @throws Exception
 *             Causes the JAX-WS runtime to cease fault message processing.
 **/
@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean request_p = (Boolean) context
            .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (request_p.booleanValue()) {
        try {
            SOAPMessage msg = context.getMessage();
            SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
            SOAPHeader hdr = env.getHeader();
            if (hdr == null) {
                hdr = env.addHeader();
            }
            QName qname_user = new QName("http://com/auth/", "auth");
            SOAPHeaderElement helem_user = hdr.addHeaderElement(qname_user);
            helem_user.setActor(VERSION);
            if (version != null && version.trim().length() != 0) {
                helem_user.addTextNode(version);
            }

            msg.saveChanges();
            message = soapMessage2String(msg);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return true;
}
项目:oscm    文件:VersionHandler.java   
/**
 * The method is invoked for normal processing of outbound messages.
 * 
 * @param context
 *            the message context.
 * @return An indication of whether handler processing should continue for
 *         the current message. Return <code>true</code> to continue
 *         processing.
 * 
 * @throws Exception
 *             Causes the JAX-WS runtime to cease fault message processing.
 **/
@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean request_p = (Boolean) context
            .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (request_p.booleanValue()) {
        try {
            SOAPMessage msg = context.getMessage();
            SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
            SOAPHeader hdr = env.getHeader();
            if (hdr == null) {
                hdr = env.addHeader();
            }
            QName qname_user = new QName("http://com/auth/", "auth");
            SOAPHeaderElement helem_user = hdr.addHeaderElement(qname_user);
            helem_user.setActor(VERSION);
            if (version == null || version.trim().length() == 0) {
                helem_user.addTextNode(apiVersionInfo.getProperty(VERSION));
            } else {
                helem_user.addTextNode(version);
            }

            msg.saveChanges();
            message = soapMessage2String(msg);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return true;
}
项目:oscm    文件:SoapRequestParser.java   
public static String parseApiVersion(SOAPMessageContext context)
        throws SOAPException {

    SOAPMessage soapMessage = context.getMessage();

    SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
    SOAPHeader soapHeader = soapEnvelope.getHeader();
    if (soapHeader == null) {
        return "";
    }

    Iterator<?> it = null;
    Iterator<?> itCm = soapHeader.extractHeaderElements(VERSION_CM);
    if (itCm == null || !itCm.hasNext()) {
        Iterator<?> itCtmg = soapHeader.extractHeaderElements(VERSION_CTMG);
        if (itCtmg == null || !itCtmg.hasNext()) {
            return "";
        } else {
            it = itCtmg;
        }
    } else {
        it = itCm;
    }

    Node node = (Node) it.next();
    String value = node == null ? null : node.getValue();

    return value;
}