コード例 #1
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();
  }
コード例 #2
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();
  }