/** Util method to write an attribute without the ns prefix */
  private void writeQNameAttribute(
      java.lang.String namespace,
      java.lang.String attName,
      javax.xml.namespace.QName qname,
      javax.xml.stream.XMLStreamWriter xmlWriter)
      throws javax.xml.stream.XMLStreamException {

    java.lang.String attributeNamespace = qname.getNamespaceURI();
    java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace);
    if (attributePrefix == null) {
      attributePrefix = registerPrefix(xmlWriter, attributeNamespace);
    }
    java.lang.String attributeValue;
    if (attributePrefix.trim().length() > 0) {
      attributeValue = attributePrefix + ":" + qname.getLocalPart();
    } else {
      attributeValue = qname.getLocalPart();
    }

    if (namespace.equals("")) {
      xmlWriter.writeAttribute(attName, attributeValue);
    } else {
      registerPrefix(xmlWriter, namespace);
      xmlWriter.writeAttribute(namespace, attName, attributeValue);
    }
  }
  /** Register a namespace prefix */
  private java.lang.String registerPrefix(
      javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace)
      throws javax.xml.stream.XMLStreamException {
    java.lang.String prefix = xmlWriter.getPrefix(namespace);

    if (prefix == null) {
      prefix = generatePrefix(namespace);

      javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext();

      while (true) {
        java.lang.String uri = nsContext.getNamespaceURI(prefix);

        if ((uri == null) || (uri.length() == 0)) {
          break;
        }

        prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
      }

      xmlWriter.writeNamespace(prefix, namespace);
      xmlWriter.setPrefix(prefix, namespace);
    }

    return prefix;
  }
  /** method to handle Qnames */
  private void writeQName(
      javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter)
      throws javax.xml.stream.XMLStreamException {
    java.lang.String namespaceURI = qname.getNamespaceURI();
    if (namespaceURI != null) {
      java.lang.String prefix = xmlWriter.getPrefix(namespaceURI);
      if (prefix == null) {
        prefix = generatePrefix(namespaceURI);
        xmlWriter.writeNamespace(prefix, namespaceURI);
        xmlWriter.setPrefix(prefix, namespaceURI);
      }

      if (prefix.trim().length() > 0) {
        xmlWriter.writeCharacters(
            prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
      } else {
        // i.e this is the default namespace
        xmlWriter.writeCharacters(
            org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
      }

    } else {
      xmlWriter.writeCharacters(
          org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
    }
  }
Exemplo n.º 4
0
  public void serialize(
      final javax.xml.namespace.QName parentQName, XMLStreamWriter xmlWriter, boolean serializeType)
      throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException {

    java.lang.String prefix = null;
    java.lang.String namespace = null;

    prefix = parentQName.getPrefix();
    namespace = parentQName.getNamespaceURI();

    if ((namespace != null) && (namespace.trim().length() > 0)) {
      java.lang.String writerPrefix = xmlWriter.getPrefix(namespace);
      if (writerPrefix != null) {
        xmlWriter.writeStartElement(namespace, parentQName.getLocalPart());
      } else {
        if (prefix == null) {
          prefix = generatePrefix(namespace);
        }

        xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace);
        xmlWriter.writeNamespace(prefix, namespace);
        xmlWriter.setPrefix(prefix, namespace);
      }
    } else {
      xmlWriter.writeStartElement(parentQName.getLocalPart());
    }

    if (serializeType) {

      java.lang.String namespacePrefix =
          registerPrefix(xmlWriter, "http://www.w3.org/2001/XMLSchema");
      if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) {
        writeAttribute(
            "xsi",
            "http://www.w3.org/2001/XMLSchema-instance",
            "type",
            namespacePrefix + ":integer",
            xmlWriter);
      } else {
        writeAttribute(
            "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "integer", xmlWriter);
      }
    }

    if (localInteger == null) {
      // write the nil attribute

      throw new org.apache.axis2.databinding.ADBException("integer cannot be null!!");

    } else {

      xmlWriter.writeCharacters(
          org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localInteger));
    }

    xmlWriter.writeEndElement();
  }
Exemplo n.º 5
0
  public void serialize(XMLStreamWriter writer) throws XMLStreamException {

    String localName = getName().getLocalPart();
    String namespaceURI = getName().getNamespaceURI();

    String prefix = writer.getPrefix(namespaceURI);

    if (prefix == null) {
      prefix = getName().getPrefix();
      writer.setPrefix(prefix, namespaceURI);
    }

    writer.writeStartElement(prefix, localName, namespaceURI);
    writer.writeNamespace(prefix, namespaceURI);

    // <wsp:Policy>
    writer.writeStartElement(
        SPConstants.POLICY.getPrefix(),
        SPConstants.POLICY.getLocalPart(),
        SPConstants.POLICY.getNamespaceURI());

    //
    writer.writeStartElement(prefix, getAlgoSuiteString(), namespaceURI);
    writer.writeEndElement();

    if (SPConstants.C14N.equals(getInclusiveC14n())) {
      writer.writeStartElement(prefix, SPConstants.INCLUSIVE_C14N, namespaceURI);
      writer.writeEndElement();
    }

    if (SPConstants.SNT.equals(getSoapNormalization())) {
      writer.writeStartElement(prefix, SPConstants.SOAP_NORMALIZATION_10, namespaceURI);
      writer.writeEndElement();
    }

    if (SPConstants.STRT10.equals(getStrTransform())) {
      writer.writeStartElement(prefix, SPConstants.STR_TRANSFORM_10, namespaceURI);
      writer.writeEndElement();
    }

    if (SPConstants.XPATH.equals(getXPath())) {
      writer.writeStartElement(prefix, SPConstants.XPATH10, namespaceURI);
      writer.writeEndElement();
    }

    if (SPConstants.XPATH20.equals(getXPath())) {
      writer.writeStartElement(prefix, SPConstants.XPATH_FILTER20, namespaceURI);
      writer.writeEndElement();
    }

    // </wsp:Policy>
    writer.writeEndElement();

    // </sp:AlgorithmSuite>
    writer.writeEndElement();
  }
Exemplo n.º 6
0
  public void serialize(XMLStreamWriter writer) throws XMLStreamException {
    QName name = constants.getUserNameToken();
    String localname = name.getLocalPart();
    String namespaceURI = name.getNamespaceURI();

    String prefix = writer.getPrefix(namespaceURI);
    if (prefix == null) {
      prefix = name.getPrefix();
      writer.setPrefix(prefix, namespaceURI);
    }

    // <sp:KeyValueToken
    writer.writeStartElement(prefix, localname, namespaceURI);

    writer.writeNamespace(prefix, namespaceURI);

    String inclusion;

    inclusion = constants.getAttributeValueFromInclusion(getInclusion());

    if (inclusion != null) {
      writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
    }

    if (forceRsaKeyValue) {
      String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
      if (pPrefix == null) {
        writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI());
      }

      // <wsp:Policy>
      writer.writeStartElement(
          pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());

      writer.writeEmptyElement(prefix, "RsaKeyValue", namespaceURI);

      // </wsp:Policy>
      writer.writeEndElement();
    }
    writer.writeEndElement();
    // </sp:KeyValueToken>

  }
 /** Util method to write an attribute with the ns prefix */
 private void writeAttribute(
     java.lang.String prefix,
     java.lang.String namespace,
     java.lang.String attName,
     java.lang.String attValue,
     javax.xml.stream.XMLStreamWriter xmlWriter)
     throws javax.xml.stream.XMLStreamException {
   if (xmlWriter.getPrefix(namespace) == null) {
     xmlWriter.writeNamespace(prefix, namespace);
     xmlWriter.setPrefix(prefix, namespace);
   }
   xmlWriter.writeAttribute(namespace, attName, attValue);
 }
 private void writeAttribute(
     final String prefix,
     final String namespace,
     final String attName,
     final String attValue,
     final XMLStreamWriter xmlWriter)
     throws XMLStreamException {
   if (xmlWriter.getPrefix(namespace) == null) {
     xmlWriter.writeNamespace(prefix, namespace);
     xmlWriter.setPrefix(prefix, namespace);
   }
   xmlWriter.writeAttribute(namespace, attName, attValue);
 }
 /** Register a namespace prefix */
 private java.lang.String registerPrefix(
     javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace)
     throws javax.xml.stream.XMLStreamException {
   java.lang.String prefix = xmlWriter.getPrefix(namespace);
   if (prefix == null) {
     prefix = generatePrefix(namespace);
     while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) {
       prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
     }
     xmlWriter.writeNamespace(prefix, namespace);
     xmlWriter.setPrefix(prefix, namespace);
   }
   return prefix;
 }
Exemplo n.º 10
0
  @SuppressWarnings("unused")
  private String registerPrefix(final XMLStreamWriter xmlWriter, final String namespace)
      throws XMLStreamException {
    String prefix = xmlWriter.getPrefix(namespace);
    if (prefix == null) {
      prefix = GetStatus.generatePrefix(namespace);
      while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) {
        prefix = BeanUtil.getUniquePrefix();
      }
      xmlWriter.writeNamespace(prefix, namespace);
      xmlWriter.setPrefix(prefix, namespace);
    }

    return prefix;
  }
Exemplo n.º 11
0
  public void serialize(XMLStreamWriter writer) throws XMLStreamException {
    String localName = getName().getLocalPart();
    String namespaceURI = getName().getNamespaceURI();

    String prefix = writer.getPrefix(namespaceURI);

    if (prefix == null) {
      prefix = getName().getPrefix();
      writer.setPrefix(prefix, namespaceURI);
    }

    // <sp:RecipientToken>
    writer.writeStartElement(prefix, localName, namespaceURI);

    String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
    if (pPrefix == null) {
      pPrefix = SPConstants.POLICY.getPrefix();
      writer.setPrefix(pPrefix, SPConstants.POLICY.getNamespaceURI());
    }

    // <wsp:Policy>
    writer.writeStartElement(
        pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());

    Token token = getReceipientToken();
    if (token == null) {
      throw new RuntimeException("RecipientToken doesn't contain any token assertions");
    }
    token.serialize(writer);

    // </wsp:Policy>
    writer.writeEndElement();

    // </sp:RecipientToken>
    writer.writeEndElement();
  }
Exemplo n.º 12
0
  public void serialize(XMLStreamWriter writer) throws XMLStreamException {

    String wspPrefix = writer.getPrefix(Constants.URI_POLICY_NS);

    if (wspPrefix == null) {
      wspPrefix = Constants.ATTR_WSP;
      writer.setPrefix(wspPrefix, Constants.URI_POLICY_NS);
    }

    writer.writeStartElement(wspPrefix, Constants.ELEM_POLICY_REF, Constants.URI_POLICY_NS);
    writer.writeNamespace(Constants.ATTR_WSP, Constants.URI_POLICY_NS);
    writer.writeAttribute(Constants.ATTR_URI, getURI());

    writer.writeEndElement();
  }
  private String registerPrefix(final XMLStreamWriter xmlWriter, final String namespace)
      throws XMLStreamException {
    String prefix = xmlWriter.getPrefix(namespace);
    if (prefix == null) {
      prefix = OperationRequestType.generatePrefix(namespace);
      while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) {
        prefix = BeanUtil.getUniquePrefix();
      }

      xmlWriter.writeNamespace(prefix, namespace);
      xmlWriter.setPrefix(prefix, namespace);
    }

    return prefix;
  }
Exemplo n.º 14
0
  private void writeQNames(
      javax.xml.namespace.QName[] qnames, javax.xml.stream.XMLStreamWriter xmlWriter)
      throws javax.xml.stream.XMLStreamException {
    if (qnames != null) {
      // we have to store this data until last moment since it is not possible to write any
      // namespace data after writing the charactor data
      java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer();
      java.lang.String namespaceURI = null;
      java.lang.String prefix = null;

      for (int i = 0; i < qnames.length; i++) {
        if (i > 0) {
          stringToWrite.append(" ");
        }

        namespaceURI = qnames[i].getNamespaceURI();

        if (namespaceURI != null) {
          prefix = xmlWriter.getPrefix(namespaceURI);

          if ((prefix == null) || (prefix.length() == 0)) {
            prefix = generatePrefix(namespaceURI);
            xmlWriter.writeNamespace(prefix, namespaceURI);
            xmlWriter.setPrefix(prefix, namespaceURI);
          }

          if (prefix.trim().length() > 0) {
            stringToWrite
                .append(prefix)
                .append(":")
                .append(
                    org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i]));
          } else {
            stringToWrite.append(
                org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i]));
          }
        } else {
          stringToWrite.append(
              org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i]));
        }
      }

      xmlWriter.writeCharacters(stringToWrite.toString());
    }
  }
Exemplo n.º 15
0
 /** Utility method to write an element start tag. */
 private void writeStartElement(
     java.lang.String prefix,
     java.lang.String namespace,
     java.lang.String localPart,
     javax.xml.stream.XMLStreamWriter xmlWriter)
     throws javax.xml.stream.XMLStreamException {
   java.lang.String writerPrefix = xmlWriter.getPrefix(namespace);
   if (writerPrefix != null) {
     xmlWriter.writeStartElement(namespace, localPart);
   } else {
     if ((namespace.length()) == 0) {
       prefix = "";
     } else if (prefix == null) {
       prefix = hr.ponge.pfa.axis.env.operations.UpdateUserResp.generatePrefix(namespace);
     }
     xmlWriter.writeStartElement(prefix, localPart, namespace);
     xmlWriter.writeNamespace(prefix, namespace);
     xmlWriter.setPrefix(prefix, namespace);
   }
 }
Exemplo n.º 16
0
    private void writeStartElement(
        java.lang.String prefix,
        final java.lang.String namespace,
        final java.lang.String localPart,
        final javax.xml.stream.XMLStreamWriter xmlWriter)
        throws javax.xml.stream.XMLStreamException {
      final java.lang.String writerPrefix = xmlWriter.getPrefix(namespace);
      if (writerPrefix != null) {
        xmlWriter.writeStartElement(namespace, localPart);
      } else {
        if (namespace.length() == 0) {
          prefix = "";
        } else if (prefix == null) {
          prefix = ConsultaCadastro2Result.generatePrefix(namespace);
        }

        xmlWriter.writeStartElement(prefix, localPart, namespace);
        xmlWriter.writeNamespace(prefix, namespace);
        xmlWriter.setPrefix(prefix, namespace);
      }
    }
Exemplo n.º 17
0
 private void writeQNames(
     javax.xml.namespace.QName[] qnames, javax.xml.stream.XMLStreamWriter xmlWriter)
     throws javax.xml.stream.XMLStreamException {
   if (qnames != null) {
     java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer();
     java.lang.String namespaceURI = null;
     java.lang.String prefix = null;
     for (int i = 0; i < (qnames.length); i++) {
       if (i > 0) {
         stringToWrite.append(" ");
       }
       namespaceURI = qnames[i].getNamespaceURI();
       if (namespaceURI != null) {
         prefix = xmlWriter.getPrefix(namespaceURI);
         if ((prefix == null) || ((prefix.length()) == 0)) {
           prefix =
               hr.ponge.pfa.axis.core.operations.CreateDocumentReq.generatePrefix(namespaceURI);
           xmlWriter.writeNamespace(prefix, namespaceURI);
           xmlWriter.setPrefix(prefix, namespaceURI);
         }
         if ((prefix.trim().length()) > 0) {
           stringToWrite
               .append(prefix)
               .append(":")
               .append(
                   org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i]));
         } else {
           stringToWrite.append(
               org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i]));
         }
       } else {
         stringToWrite.append(
             org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i]));
       }
     }
     xmlWriter.writeCharacters(stringToWrite.toString());
   }
 }
Exemplo n.º 18
0
 /** method to handle Qnames */
 private void writeQName(
     javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter)
     throws javax.xml.stream.XMLStreamException {
   java.lang.String namespaceURI = qname.getNamespaceURI();
   if (namespaceURI != null) {
     java.lang.String prefix = xmlWriter.getPrefix(namespaceURI);
     if (prefix == null) {
       prefix = hr.ponge.pfa.axis.env.operations.UpdateUserResp.generatePrefix(namespaceURI);
       xmlWriter.writeNamespace(prefix, namespaceURI);
       xmlWriter.setPrefix(prefix, namespaceURI);
     }
     if ((prefix.trim().length()) > 0) {
       xmlWriter.writeCharacters(
           ((prefix + ":")
               + (org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname))));
     } else {
       xmlWriter.writeCharacters(
           org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
     }
   } else {
     xmlWriter.writeCharacters(
         org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
   }
 }
Exemplo n.º 19
0
  public static String encodeQName(
      XMLStreamWriter writer, QName qname, PrefixFactory prefixFactory) {
    // NOTE: Here it is assumed that we do not serialize using default
    // namespace declarations and therefore that writer.getPrefix will
    // never return ""

    try {
      String namespaceURI = qname.getNamespaceURI();
      String localPart = qname.getLocalPart();

      if (namespaceURI == null || namespaceURI.equals("")) {
        return localPart;
      } else {
        String prefix = writer.getPrefix(namespaceURI);
        if (prefix == null) {
          prefix = prefixFactory.getPrefix(namespaceURI);
          writer.writeNamespace(prefix, namespaceURI);
        }
        return prefix + ":" + localPart;
      }
    } catch (XMLStreamException e) {
      throw new RuntimeException(e);
    }
  }
Exemplo n.º 20
0
  public void serialize(XMLStreamWriter writer) throws XMLStreamException {
    QName name = constants.getSamlToken();
    String localname = name.getLocalPart();
    String namespaceURI = name.getNamespaceURI();

    String prefix = writer.getPrefix(namespaceURI);
    if (prefix == null) {
      prefix = name.getPrefix();
      writer.setPrefix(prefix, namespaceURI);
    }

    // <sp:KerberosToken
    writer.writeStartElement(prefix, localname, namespaceURI);

    writer.writeNamespace(prefix, namespaceURI);

    String inclusion;

    inclusion = constants.getAttributeValueFromInclusion(getInclusion());

    if (inclusion != null) {
      writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
    }

    String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI());
    if (pPrefix == null) {
      pPrefix = SPConstants.POLICY.getPrefix();
      writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI());
    }

    // <wsp:Policy>
    writer.writeStartElement(
        pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI());

    if (isRequireKeyIdentifierReference()) {
      // <sp:RequireKeyIdentifierReference />
      writer.writeStartElement(prefix, SPConstants.REQUIRE_KEY_IDENTIFIER_REFERENCE, namespaceURI);
      writer.writeEndElement();
    }

    if (isV5ApReqToken11()) {
      // <sp:WssKerberosV5ApReqToken11 />
      writer.writeStartElement(prefix, SPConstants.KERBEROS_V5_AP_REQ_TOKEN_11, namespaceURI);
      writer.writeEndElement();
    } else if (isGssV5ApReqToken11()) {
      // <sp:WssGssKerberosV5ApReqToken11 />
      writer.writeStartElement(prefix, SPConstants.KERBEROS_GSS_V5_AP_REQ_TOKEN_11, namespaceURI);
      writer.writeEndElement();
    }

    if (isDerivedKeys()) {
      // <sp:RequireDerivedKeys />
      writer.writeStartElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI);
      writer.writeEndElement();
    }

    // </wsp:Policy>
    writer.writeEndElement();

    writer.writeEndElement();
    // </sp:KerberosToken>

  }
Exemplo n.º 21
0
 public java.lang.String getPrefix(java.lang.String uri) throws XMLStreamException {
   return baseWriter.getPrefix(uri);
 }
 public String getPrefix(String uri) throws XMLStreamException {
   return writer.getPrefix(uri);
 }
Exemplo n.º 23
0
 public static void writeNamespaceIfNotBound(
     XMLStreamWriter xmlStream, String prefix, String nsUri) throws XMLStreamException {
   if (!prefix.equals(xmlStream.getPrefix(nsUri))) {
     xmlStream.writeNamespace(prefix, nsUri);
   }
 }
Exemplo n.º 24
0
  public void serialize(XMLStreamWriter writer) throws XMLStreamException {

    String localname = getRealName().getLocalPart();
    String namespaceURI = getRealName().getNamespaceURI();
    String prefix;

    String writerPrefix = writer.getPrefix(namespaceURI);

    if (writerPrefix == null) {
      prefix = getRealName().getPrefix();
      writer.setPrefix(prefix, namespaceURI);
    } else {
      prefix = writerPrefix;
    }

    // <sp:SecureConversationToken>
    writer.writeStartElement(prefix, localname, namespaceURI);

    if (writerPrefix == null) {
      // xmlns:sp=".."
      writer.writeNamespace(prefix, namespaceURI);
    }

    String inclusion;

    inclusion = constants.getAttributeValueFromInclusion(getInclusion());

    if (inclusion != null) {
      writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion);
    }

    if (issuerEpr != null) {
      // <sp:Issuer>
      writer.writeStartElement(prefix, SPConstants.ISSUER, namespaceURI);

      StaxUtils.copy(issuerEpr, writer);

      writer.writeEndElement();
    }

    if (isDerivedKeys()
        || isRequireExternalUriRef()
        || isSc10SecurityContextToken()
        || bootstrapPolicy != null) {

      String wspNamespaceURI = SPConstants.POLICY.getNamespaceURI();

      String wspPrefix;

      String wspWriterPrefix = writer.getPrefix(wspNamespaceURI);

      if (wspWriterPrefix == null) {
        wspPrefix = SPConstants.POLICY.getPrefix();
        writer.setPrefix(wspPrefix, wspNamespaceURI);

      } else {
        wspPrefix = wspWriterPrefix;
      }

      // <wsp:Policy>
      writer.writeStartElement(wspPrefix, SPConstants.POLICY.getLocalPart(), wspNamespaceURI);

      if (wspWriterPrefix == null) {
        // xmlns:wsp=".."
        writer.writeNamespace(wspPrefix, wspNamespaceURI);
      }

      if (isDerivedKeys()) {
        // <sp:RequireDerivedKeys />
        writer.writeEmptyElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI);
      }

      if (isRequireExternalUriRef()) {
        // <sp:RequireExternalUriReference />
        writer.writeEmptyElement(prefix, SPConstants.REQUIRE_EXTERNAL_URI_REFERENCE, namespaceURI);
      }

      if (isSc10SecurityContextToken()) {
        // <sp:SC10SecurityContextToken />
        writer.writeEmptyElement(prefix, SPConstants.SC10_SECURITY_CONTEXT_TOKEN, namespaceURI);
      }

      if (bootstrapPolicy != null) {
        // <sp:BootstrapPolicy ..>
        writer.writeStartElement(prefix, SPConstants.BOOTSTRAP_POLICY, namespaceURI);
        bootstrapPolicy.serialize(writer);
        writer.writeEndElement();
      }

      // </wsp:Policy>
      writer.writeEndElement();
    }

    // </sp:SecureConversationToken>
    writer.writeEndElement();
  }