picketlink2 / federation

PicketLink v2.1.x Federation. PicketLink v2.5.x onwards is hosted at https://github.com/picketlink
http://www.picketlink.org
14 stars 29 forks source link

Problem parsing WCF WS-trust SAML2 ticket #160

Open matejsp opened 11 years ago

matejsp commented 11 years ago

WSTRequestSecurityTokenParser.java is missing parsing of the following elements: EncryptWith SignWith CanonicalizationAlgorithm EncryptionAlgorithm KeyWrapAlgorithm

patch (with values ignored on processing):

            } else if (tag.equals("EncryptWith")) {
                subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
                if (!StaxParserUtil.hasTextAhead(xmlEventReader))
                    throw new ParsingException(ErrorCodes.EXPECTED_TEXT_VALUE + "encrypt with");

                String encryptWith = StaxParserUtil.getElementText(xmlEventReader);
                try {
                    URI encryptWithURI = new URI(encryptWith);
                    requestToken.setEncryptWith(encryptWithURI);
                } catch (URISyntaxException e) {
                    throw new ParsingException(e);
                }
            } else if (tag.equals("SignWith")) {
                subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
                if (!StaxParserUtil.hasTextAhead(xmlEventReader))
                    throw new ParsingException(ErrorCodes.EXPECTED_TEXT_VALUE + "sign with");

                String signWith = StaxParserUtil.getElementText(xmlEventReader);
                try {
                    URI signWithURI = new URI(signWith);
                    requestToken.setSignWith(signWithURI);
                } catch (URISyntaxException e) {
                    throw new ParsingException(e);
                }
            } else if (tag.equals("CanonicalizationAlgorithm")) {
                subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
                if (!StaxParserUtil.hasTextAhead(xmlEventReader))
                    throw new ParsingException(ErrorCodes.EXPECTED_TEXT_VALUE + "canonicalization algorithm");

                String canonicalizationAlgorithm = StaxParserUtil.getElementText(xmlEventReader);
                try {
                    URI canonicalizationAlgorithmURI = new URI(canonicalizationAlgorithm);
                    requestToken.setCanonicalizationAlgorithm(canonicalizationAlgorithmURI);
                } catch (URISyntaxException e) {
                    throw new ParsingException(e);
                }
            } else if (tag.equals("EncryptionAlgorithm")) {
                subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
                if (!StaxParserUtil.hasTextAhead(xmlEventReader))
                    throw new ParsingException(ErrorCodes.EXPECTED_TEXT_VALUE + "encrypt algortihm");

                String canonicalizationAlgorithm = StaxParserUtil.getElementText(xmlEventReader);
                try {
                    URI encryptionAlgorithmURI = new URI(canonicalizationAlgorithm);
                    requestToken.setEncryptionAlgorithm(encryptionAlgorithmURI);
                } catch (URISyntaxException e) {
                    throw new ParsingException(e);
                }
            } else if (tag.equals("KeyWrapAlgorithm")) {
                subEvent = StaxParserUtil.getNextStartElement(xmlEventReader);
                if (!StaxParserUtil.hasTextAhead(xmlEventReader))
                    throw new ParsingException(ErrorCodes.EXPECTED_TEXT_VALUE + "key wrap algorithm");

                String keyWrapAlgorithm = StaxParserUtil.getElementText(xmlEventReader);
                try {
                    URI keyWrapAlgorithmURI = new URI(keyWrapAlgorithm);
                    requestToken.setKeyWrapAlgorithm(keyWrapAlgorithmURI);
                } catch (URISyntaxException e) {
                    throw new ParsingException(e);
                }
            } else {