mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Chris Ridd
01.39.2014 e357d2ac06db139c1de9e29d1c103cd876076aa1
Fix OPENDJ-1187: DSML Gateway SOAP 1.2 Support
1 files modified
25 ■■■■ changed files
opends/src/dsml/org/opends/dsml/protocol/DSMLServlet.java 25 ●●●● patch | view | raw | blame | history
opends/src/dsml/org/opends/dsml/protocol/DSMLServlet.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2013 ForgeRock AS
 *      Portions Copyright 2011-2014 ForgeRock AS
 */
package org.opends.dsml.protocol;
@@ -63,6 +63,7 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.soap.*;
import javax.xml.soap.SOAPConstants;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
@@ -131,9 +132,12 @@
  private static JAXBContext jaxbContext;
  private ObjectFactory objFactory;
  private MessageFactory messageFactory;
  private DocumentBuilder db;
  private static Schema schema;
  private MessageFactory messageFactory;
  private MessageFactory messageFactorySOAP_1_1;
  private MessageFactory messageFactorySOAP_1_2;
  private String contentType;
  // this extends the default handler of SAX parser. It helps to retrieve the
  // requestID value when the xml request is malformed and thus unparsable
@@ -225,7 +229,8 @@
      }
      objFactory = new ObjectFactory();
      messageFactory = MessageFactory.newInstance();
      messageFactorySOAP_1_1 = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
      messageFactorySOAP_1_2 = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      dbf.setNamespaceAware(true);
      db = dbf.newDocumentBuilder();
@@ -376,7 +381,17 @@
    while (en.hasMoreElements()) {
      String headerName = (String) en.nextElement();
      String headerVal = req.getHeader(headerName);
      if (headerName.equalsIgnoreCase("authorization")) {
      if (headerName.equalsIgnoreCase("content-type")) {
        if (headerVal.startsWith(SOAPConstants.SOAP_1_1_CONTENT_TYPE)) {
          messageFactory = messageFactorySOAP_1_1;
          contentType = SOAPConstants.SOAP_1_1_CONTENT_TYPE;
        } else if (headerVal.startsWith(SOAPConstants.SOAP_1_2_CONTENT_TYPE)) {
          messageFactory = messageFactorySOAP_1_2;
          contentType = SOAPConstants.SOAP_1_2_CONTENT_TYPE;
        } else {
          throw new ServletException("Content-Type does not match SOAP 1.1 or SOAP 1.2");
        }
      } else if (headerName.equalsIgnoreCase("authorization")) {
        if (headerVal.startsWith("Basic ")) {
          authenticationInHeader = true;
          String authorization = headerVal.substring(6).trim();
@@ -770,7 +785,7 @@
    header.detachNode();
    SOAPBody replyBody = reply.getSOAPBody();
    res.setHeader("Content-Type", "text/xml");
    res.setHeader("Content-Type", contentType);
    replyBody.addDocument(doc);