Package org.apache.xml.security.transforms

Examples of org.apache.xml.security.transforms.Transforms


   // if signing and c14n11 property == true explicitly add
   // C14N11 transform if needed
   if (Reference.useC14N11 && !validating &&
       !output.isOutputStreamSet() && !output.isOctetStream()) {
       if (transforms == null) {
     transforms = new Transforms(this._doc);
                 this._constructionElement.insertBefore
         (transforms.getElement(), digestMethodElem);
       }
       transforms.addTransform(Transforms.TRANSFORM_C14N11_OMIT_COMMENTS);
             output.updateOutputStream(os, true);
View Full Code Here


   *            InclusiveNamespaces to be WSI compliant.
   * @throws WSSecurityException
   */
  public void addReferencesToSign(Vector references, WSSecHeader secHeader)
      throws WSSecurityException {
    Transforms transforms = null;

    Element envelope = document.getDocumentElement();

    for (int part = 0; part < references.size(); part++) {
      WSEncryptionPart encPart = (WSEncryptionPart) references.get(part);

      String idToSign = encPart.getId();

      String elemName = encPart.getName();
      String nmSpace = encPart.getNamespace();

      /*
       * Set up the elements to sign. There are two resevered element
       * names: "Token" and "STRTransform" "Token": Setup the Signature to
       * either sign the information that points to the security token or
       * the token itself. If its a direct reference sign the token,
       * otherwise sign the KeyInfo Element. "STRTransform": Setup the
       * ds:Reference to use STR Transform
       *
       */
      transforms = new Transforms(document);
      try {
        if (idToSign != null) {
          Element toSignById = WSSecurityUtil.findElementById(
              document.getDocumentElement(), idToSign,
              WSConstants.WSU_NS);
          if (toSignById == null) {
            toSignById = WSSecurityUtil.findElementById(document
                .getDocumentElement(), idToSign, null);
          }
          transforms
              .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
          if (wssConfig.isWsiBSPCompliant()) {
            transforms.item(0).getElement().appendChild(
                new InclusiveNamespaces(document,
                    getInclusivePrefixes(toSignById))
                    .getElement());
          }
          sig.addDocument("#" + idToSign, transforms);
        } else if (elemName.equals("Token")) {
          transforms
              .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
          if (keyIdentifierType == WSConstants.BST_DIRECT_REFERENCE) {
            if (wssConfig.isWsiBSPCompliant()) {
              transforms
                  .item(0)
                  .getElement()
                  .appendChild(
                      new InclusiveNamespaces(
                          document,
                          getInclusivePrefixes(secHeader.getSecurityHeader()))
                          .getElement());
            }
            sig.addDocument("#" + certUri, transforms);
          } else {
            if (wssConfig.isWsiBSPCompliant()) {
              transforms.item(0).getElement().appendChild(
                  new InclusiveNamespaces(document,
                      getInclusivePrefixes(keyInfo
                          .getElement()))
                      .getElement());
            }
            sig.addDocument("#" + keyInfoUri, transforms);
          }
        } else if (elemName.equals("STRTransform")) { // STRTransform
          Element ctx = createSTRParameter(document);
          transforms.addTransform(
              STRTransform.implementedTransformURI, ctx);
          sig.addDocument("#" + strUri, transforms);
        } else if (elemName.equals("Assertion")) { // Assertion

          String id = null;
          id = SAMLUtil.getAssertionId(envelope, elemName, nmSpace);

          Element body = (Element) WSSecurityUtil.findElement(
              envelope, elemName, nmSpace);
          if (body == null) {
            throw new WSSecurityException(
                WSSecurityException.FAILURE, "noEncElement",
                new Object[] { nmSpace + ", " + elemName });
          }
          transforms
              .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
          if (wssConfig.isWsiBSPCompliant()) {
            transforms.item(0).getElement().appendChild(
                new InclusiveNamespaces(document,
                    getInclusivePrefixes(body))
                    .getElement());
          }
          String prefix = WSSecurityUtil.setNamespace(body,
              WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
          body.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
          sig.addDocument("#" + id, transforms);

        } else {
          Element body = (Element) WSSecurityUtil.findElement(
              envelope, elemName, nmSpace);
          if (body == null) {
            throw new WSSecurityException(
                WSSecurityException.FAILURE, "noEncElement",
                new Object[] { nmSpace + ", " + elemName });
          }
          transforms
              .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
          if (wssConfig.isWsiBSPCompliant()) {
            transforms.item(0).getElement().appendChild(
                new InclusiveNamespaces(document,
                    getInclusivePrefixes(body))
                    .getElement());
          }
          sig.addDocument("#" + setWsuId(body), transforms);
View Full Code Here

         * need to - put in a reference to the SAML token. Thus we create a STR
         * and insert it into the wsse:Security header - set a reference of the
         * created STR to the signature and use STR Transfrom during the
         * signature
         */
        Transforms transforms = null;

        try {
            if (senderVouches) {
                secRefSaml = new SecurityTokenReference(doc);
                String strSamlUri = "STRSAMLId-" + secRefSaml.hashCode();
                secRefSaml.setID(strSamlUri);

                // Decouple Reference/KeyInfo setup - quick shot here
                Reference ref = new Reference(doc);
                ref.setURI("#" + assertion.getId());
                ref.setValueType(WSConstants.WSS_SAML_NS
                        + WSConstants.WSS_SAML_ASSERTION);
                secRefSaml.setReference(ref);
                // up to here

                Element ctx = createSTRParameter(doc);
                transforms = new Transforms(doc);
                transforms.addTransform(STRTransform.implementedTransformURI,
                        ctx);
                sig.addDocument("#" + strSamlUri, transforms);
            }
        } catch (TransformationException e1) {
            throw new WSSecurityException(WSSecurityException.FAILED_SIGNATURE,
View Full Code Here

     *            InclusiveNamespaces to be WSI compliant.
     * @throws WSSecurityException
     */
    public void addReferencesToSign(Vector references, WSSecHeader secHeader)
            throws WSSecurityException {
        Transforms transforms = null;

        Element envelope = document.getDocumentElement();
        for (int part = 0; part < parts.size(); part++) {
            WSEncryptionPart encPart = (WSEncryptionPart) references.get(part);

            String idToSign = encPart.getId();

            String elemName = encPart.getName();
            String nmSpace = encPart.getNamespace();

            /*
             * Set up the elements to sign. There are two resevered element
             * names: "Token" and "STRTransform" "Token": Setup the Signature to
             * either sign the information that points to the security token or
             * the token itself. If its a direct reference sign the token,
             * otherwise sign the KeyInfo Element. "STRTransform": Setup the
             * ds:Reference to use STR Transform
             *
             */
            transforms = new Transforms(document);
            try {
                if (idToSign != null) {
                    Element toSignById = WSSecurityUtil.findElementById(
                            document.getDocumentElement(), idToSign,
                            WSConstants.WSU_NS);
                    if (toSignById == null) {
                        toSignById = WSSecurityUtil.findElementById(document
                                .getDocumentElement(), idToSign, null);
                    }
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(document,
                                        getInclusivePrefixes(toSignById))
                                        .getElement());
                    }
                    sig.addDocument("#" + idToSign, transforms);
                } else if (elemName.equals("Token")) {
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (keyIdentifierType == WSConstants.BST_DIRECT_REFERENCE) {
                        if (wssConfig.isWsiBSPCompliant()) {
                            transforms.item(0).getElement().appendChild(
                                    new InclusiveNamespaces(document,
                                            getInclusivePrefixes(secHeader
                                                    .getSecurityHeader()))
                                            .getElement());
                        }
                        sig.addDocument("#" + certUri, transforms);
                    } else {
                        if (wssConfig.isWsiBSPCompliant()) {
                            transforms.item(0).getElement().appendChild(
                                    new InclusiveNamespaces(document,
                                            getInclusivePrefixes(keyInfo
                                                    .getElement()))
                                            .getElement());
                        }
                        sig.addDocument("#" + keyInfoUri, transforms);
                    }
                } else if (elemName.equals("STRTransform")) { // STRTransform
                    Element ctx = createSTRParameter(document);
                    transforms.addTransform(
                            STRTransform.implementedTransformURI, ctx);
                    sig.addDocument("#" + strUri, transforms);
                } else {
                    Element body = (Element) WSSecurityUtil.findElement(
                            envelope, elemName, nmSpace);
                    if (body == null) {
                        throw new WSSecurityException(
                                WSSecurityException.FAILURE, "noEncElement",
                                new Object[] { nmSpace + ", " + elemName });
                    }
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(document,
                                        getInclusivePrefixes(body))
                                        .getElement());
                    }
                    sig.addDocument("#" + setWsuId(body), transforms);
View Full Code Here

     *            InclusiveNamespaces to be WSI compliant.
     * @throws WSSecurityException
     */
    public void addReferencesToSign(Vector references, WSSecHeader secHeader)
            throws WSSecurityException {
        Transforms transforms = null;

        Element envel = document.getDocumentElement();

        for (int part = 0; part < references.size(); part++) {
            WSEncryptionPart encPart = (WSEncryptionPart) references.get(part);

            String idToSign = encPart.getId();

            String elemName = encPart.getName();
            String nmSpace = encPart.getNamespace();

            /*
             * Set up the elements to sign. There are two resevered element
             * names: "Token" and "STRTransform" "Token": Setup the Signature to
             * either sign the information that points to the security token or
             * the token itself. If its a direct reference sign the token,
             * otherwise sign the KeyInfo Element. "STRTransform": Setup the
             * ds:Reference to use STR Transform
             *
             */
            transforms = new Transforms(document);
            try {
                if (idToSign != null) {
                    Element toSignById = WSSecurityUtil.findElementById(
                            document.getDocumentElement(), idToSign,
                            WSConstants.WSU_NS);
                    if (toSignById == null) {
                        toSignById = WSSecurityUtil.findElementById(document
                                .getDocumentElement(), idToSign, null);
                    }
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(document,
                                        getInclusivePrefixes(toSignById))
                                        .getElement());
                    }
                    sig.addDocument("#" + idToSign, transforms);
                } else if (elemName.equals("Token")) {
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(document,
                                        getInclusivePrefixes(keyInfo
                                                .getElement()))
                                        .getElement());
                    }
                    sig.addDocument("#" + keyInfoUri, transforms);
                } else if (elemName.equals("STRTransform")) { // STRTransform
                    Element ctx = createSTRParameter(document);
                    transforms.addTransform(
                            STRTransform.implementedTransformURI, ctx);
                    sig.addDocument("#" + strUri, transforms);
                } else if (elemName.equals("Assertion")) { // Assertion

                    String id = null;
                    id = SAMLUtil.getAssertionId(envel, elemName, nmSpace);

                    Element body = (Element) WSSecurityUtil.findElement(
                            envel, elemName, nmSpace);
                    if (body == null) {
                        throw new WSSecurityException(
                                WSSecurityException.FAILURE, "noEncElement",
                                new Object[] { nmSpace + ", " + elemName });
                    }
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(document,
                                        getInclusivePrefixes(body))
                                        .getElement());
                    }
                    String prefix = WSSecurityUtil.setNamespace(body,
                            WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
                    body.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
                    sig.addDocument("#" + id, transforms);

                } else {
                    Element body = (Element) WSSecurityUtil.findElement(
                            envel, elemName, nmSpace);
                    if (body == null) {
                        throw new WSSecurityException(
                                WSSecurityException.FAILURE, "noEncElement",
                                new Object[] { nmSpace + ", " + elemName });
                    }
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(document,
                                        getInclusivePrefixes(body))
                                        .getElement());
                    }
                    sig.addDocument("#" + setWsuId(body), transforms);
View Full Code Here

   *            InclusiveNamespaces to be WSI compliant.
   * @throws WSSecurityException
   */
  public void addReferencesToSign(Vector references, WSSecHeader secHeader)
      throws WSSecurityException {
    Transforms transforms = null;

    Element envelope = document.getDocumentElement();

    for (int part = 0; part < references.size(); part++) {
      WSEncryptionPart encPart = (WSEncryptionPart) references.get(part);

      String idToSign = encPart.getId();

      String elemName = encPart.getName();
      String nmSpace = encPart.getNamespace();

      /*
       * Set up the elements to sign. There are two resevered element
       * names: "Token" and "STRTransform" "Token": Setup the Signature to
       * either sign the information that points to the security token or
       * the token itself. If its a direct reference sign the token,
       * otherwise sign the KeyInfo Element. "STRTransform": Setup the
       * ds:Reference to use STR Transform
       *
       */
      transforms = new Transforms(document);
      try {
        if (idToSign != null) {
          Element toSignById = WSSecurityUtil.findElementById(
              document.getDocumentElement(), idToSign,
              WSConstants.WSU_NS);
          if (toSignById == null) {
            toSignById = WSSecurityUtil.findElementById(document
                .getDocumentElement(), idToSign, null);
          }
          transforms
              .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
          if (wssConfig.isWsiBSPCompliant()) {
            transforms.item(0).getElement().appendChild(
                new InclusiveNamespaces(document,
                    getInclusivePrefixes(toSignById))
                    .getElement());
          }
          sig.addDocument("#" + idToSign, transforms);
        } else if (elemName.equals("Token")) {
          transforms
              .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
          if (keyIdentifierType == WSConstants.BST_DIRECT_REFERENCE) {
            if (wssConfig.isWsiBSPCompliant()) {
              transforms
                  .item(0)
                  .getElement()
                  .appendChild(
                      new InclusiveNamespaces(
                          document,
                          getInclusivePrefixes(secHeader.getSecurityHeader()))
                          .getElement());
            }
            sig.addDocument("#" + certUri, transforms);
          } else {
            if (wssConfig.isWsiBSPCompliant()) {
              transforms.item(0).getElement().appendChild(
                  new InclusiveNamespaces(document,
                      getInclusivePrefixes(keyInfo
                          .getElement()))
                      .getElement());
            }
            sig.addDocument("#" + keyInfoUri, transforms);
          }
        } else if (elemName.equals("STRTransform")) { // STRTransform
          Element ctx = createSTRParameter(document);
          transforms.addTransform(
              STRTransform.implementedTransformURI, ctx);
          sig.addDocument("#" + strUri, transforms);
        } else if (elemName.equals("Assertion")) { // Assertion

          String id = null;
          id = SAMLUtil.getAssertionId(envelope, elemName, nmSpace);

          Element body = (Element) WSSecurityUtil.findElement(
              envelope, elemName, nmSpace);
          if (body == null) {
            throw new WSSecurityException(
                WSSecurityException.FAILURE, "noEncElement",
                new Object[] { nmSpace + ", " + elemName });
          }
          transforms
              .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
          if (wssConfig.isWsiBSPCompliant()) {
            transforms.item(0).getElement().appendChild(
                new InclusiveNamespaces(document,
                    getInclusivePrefixes(body))
                    .getElement());
          }
          String prefix = WSSecurityUtil.setNamespace(body,
              WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
          body.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
          sig.addDocument("#" + id, transforms);

        } else {
          Element body = (Element) WSSecurityUtil.findElement(
              envelope, elemName, nmSpace);
          if (body == null) {
            throw new WSSecurityException(
                WSSecurityException.FAILURE, "noEncElement",
                new Object[] { nmSpace + ", " + elemName });
          }
          transforms
              .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
          if (wssConfig.isWsiBSPCompliant()) {
            transforms.item(0).getElement().appendChild(
                new InclusiveNamespaces(document,
                    getInclusivePrefixes(body))
                    .getElement());
          }
          sig.addDocument("#" + setWsuId(body), transforms);
View Full Code Here

                    .getBodyQName().getLocalPart(), soapConstants
                    .getEnvelopeURI(), "Content");
            parts.add(encP);
        }

        Transforms transforms = null;

        for (int part = 0; part < parts.size(); part++) {
            WSEncryptionPart encPart = (WSEncryptionPart) parts.get(part);

            String idToSign = encPart.getId();

            String elemName = encPart.getName();
            String nmSpace = encPart.getNamespace();

            /*
             * Set up the elements to sign. There are two resevered element
             * names: "Token" and "STRTransform" "Token": Setup the Signature to
             * either sign the information that points to the security token or
             * the token itself. If its a direct reference sign the token,
             * otherwise sign the KeyInfo Element. "STRTransform": Setup the
             * ds:Reference to use STR Transform
             *
             */
            try {
                if (idToSign != null) {
                  Element toSignById = WSSecurityUtil
              .findElementById(doc.getDocumentElement(),
                  idToSign, WSConstants.WSU_NS);
          if (toSignById == null) {
            toSignById = WSSecurityUtil.findElementById(doc
                .getDocumentElement(), idToSign, null);
          }
                    transforms = new Transforms(doc);
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(doc,
                                        getInclusivePrefixes(toSignById))
                                        .getElement());
                    }
                    sig.addDocument("#" + idToSign, transforms);
                }
                else if (elemName.equals("Token")) {
                    transforms = new Transforms(doc);
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (keyIdentifierType == WSConstants.BST_DIRECT_REFERENCE) {
                        if (wssConfig.isWsiBSPCompliant()) {
                            transforms
                                    .item(0)
                                    .getElement()
                                    .appendChild(
                                            new InclusiveNamespaces(
                                                    doc,
                                                    getInclusivePrefixes(securityHeader))
                                                    .getElement());
                        }
                        sig.addDocument("#" + certUri, transforms);
                    } else {
                        if (wssConfig.isWsiBSPCompliant()) {
                            transforms.item(0).getElement().appendChild(
                                    new InclusiveNamespaces(doc,
                                            getInclusivePrefixes(info
                                                    .getElement()))
                                            .getElement());
                        }
                        sig.addDocument("#" + keyInfoUri, transforms);
                    }
                } else if (elemName.equals("STRTransform")) { // STRTransform
                    Element ctx = createSTRParameter(doc);
                    transforms = new Transforms(doc);
                    transforms.addTransform(
                            STRTransform.implementedTransformURI, ctx);
                    sig.addDocument("#" + strUri, transforms);
                } else if (elemName.equals("Assertion")) { // Assertion

                    String id = null;
                    id = SAMLUtil.getAssertionId(envelope, elemName, nmSpace);

                    Element body = (Element) WSSecurityUtil.findElement(
                            envelope, elemName, nmSpace);
                    if (body == null) {
                        throw new WSSecurityException(
                                WSSecurityException.FAILURE, "noEncElement",
                                new Object[] { nmSpace + ", " + elemName });
                    }
                    transforms = new Transforms(doc);
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(doc,
                                        getInclusivePrefixes(body))
                                        .getElement());
                    }
                    String prefix = WSSecurityUtil.setNamespace(body,
                            WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
                    body.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id",
                            id);
                    sig.addDocument("#" + id, transforms);

                } else {
                    Element body = (Element) WSSecurityUtil.findElement(
                            envelope, elemName, nmSpace);
                    if (body == null) {
                        throw new WSSecurityException(
                                WSSecurityException.FAILURE, "noEncElement",
                                new Object[] { nmSpace + ", " + elemName });
                    }
                    transforms = new Transforms(doc);
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(doc,
                                        getInclusivePrefixes(body))
                                        .getElement());
                    }
                    sig.addDocument("#" + setWsuId(body), transforms);
View Full Code Here

     *            InclusiveNamespaces to be WSI compliant.
     * @throws WSSecurityException
     */
    public void addReferencesToSign(Vector references, WSSecHeader secHeader)
            throws WSSecurityException {
        Transforms transforms = null;

        Element envel = document.getDocumentElement();

        for (int part = 0; part < references.size(); part++) {
            WSEncryptionPart encPart = (WSEncryptionPart) references.get(part);

            String idToSign = encPart.getId();

            String elemName = encPart.getName();
            String nmSpace = encPart.getNamespace();

            /*
             * Set up the elements to sign. There are two resevered element
             * names: "Token" and "STRTransform" "Token": Setup the Signature to
             * either sign the information that points to the security token or
             * the token itself. If its a direct reference sign the token,
             * otherwise sign the KeyInfo Element. "STRTransform": Setup the
             * ds:Reference to use STR Transform
             *
             */
            transforms = new Transforms(document);
            try {
                if (idToSign != null) {
                    Element toSignById = WSSecurityUtil.findElementById(
                            document.getDocumentElement(), idToSign,
                            WSConstants.WSU_NS);
                    if (toSignById == null) {
                        toSignById = WSSecurityUtil.findElementById(document
                                .getDocumentElement(), idToSign, null);
                    }
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(document,
                                        getInclusivePrefixes(toSignById))
                                        .getElement());
                    }
                    sig.addDocument("#" + idToSign, transforms);
                } else if (elemName.equals("Token")) {
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(document,
                                        getInclusivePrefixes(keyInfo
                                                .getElement()))
                                        .getElement());
                    }
                    sig.addDocument("#" + keyInfoUri, transforms);
                } else if (elemName.equals("STRTransform")) { // STRTransform
                    Element ctx = createSTRParameter(document);
                    transforms.addTransform(
                            STRTransform.implementedTransformURI, ctx);
                    sig.addDocument("#" + strUri, transforms);
                } else if (elemName.equals("Assertion")) { // Assertion

                    String id = null;
                    id = SAMLUtil.getAssertionId(envel, elemName, nmSpace);

                    Element body = (Element) WSSecurityUtil.findElement(
                            envel, elemName, nmSpace);
                    if (body == null) {
                        throw new WSSecurityException(
                                WSSecurityException.FAILURE, "noEncElement",
                                new Object[] { nmSpace + ", " + elemName });
                    }
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(document,
                                        getInclusivePrefixes(body))
                                        .getElement());
                    }
                    String prefix = WSSecurityUtil.setNamespace(body,
                            WSConstants.WSU_NS, WSConstants.WSU_PREFIX);
                    body.setAttributeNS(WSConstants.WSU_NS, prefix + ":Id", id);
                    sig.addDocument("#" + id, transforms);

                } else {
                    Element body = (Element) WSSecurityUtil.findElement(
                            envel, elemName, nmSpace);
                    if (body == null) {
                        throw new WSSecurityException(
                                WSSecurityException.FAILURE, "noEncElement",
                                new Object[] { nmSpace + ", " + elemName });
                    }
                    transforms
                            .addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
                    if (wssConfig.isWsiBSPCompliant()) {
                        transforms.item(0).getElement().appendChild(
                                new InclusiveNamespaces(document,
                                        getInclusivePrefixes(body))
                                        .getElement());
                    }
                    sig.addDocument("#" + setWsuId(body), transforms);
View Full Code Here

        this.secureValidation = secureValidation;
        this.baseURI = baseURI;
        Element el = XMLUtils.getNextElement(element.getFirstChild());
        if (Constants._TAG_TRANSFORMS.equals(el.getLocalName())
            && Constants.SignatureSpecNS.equals(el.getNamespaceURI())) {
            transforms = new Transforms(el, this.baseURI);
            transforms.setSecureValidation(secureValidation);
            if (secureValidation && transforms.getLength() > MAXIMUM_TRANSFORM_COUNT) {
                Object exArgs[] = { transforms.getLength(), MAXIMUM_TRANSFORM_COUNT };
               
                throw new XMLSecurityException("signature.tooManyTransforms", exArgs);
View Full Code Here

    private XMLSignatureInput getContentsAfterTransformation(
        XMLSignatureInput input, OutputStream os
    ) throws XMLSignatureException {
        try {
            Transforms transforms = this.getTransforms();
            XMLSignatureInput output = null;

            if (transforms != null) {
                output = transforms.performTransforms(input, os);
                this.transformsOutput = output;//new XMLSignatureInput(output.getBytes());

                //this.transformsOutput.setSourceURI(output.getSourceURI());
            } else {
                output = input;
View Full Code Here

TOP

Related Classes of org.apache.xml.security.transforms.Transforms

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.