amzn / amazon-pay-sdk-java

Amazon Pay Java SDK
https://pay.amazon.com/documentation
Apache License 2.0
58 stars 51 forks source link

IllegalArgumentException because of accessExternalDTD not supported on the Parser #38

Open marceloprof opened 3 years ago

marceloprof commented 3 years ago

Hi!

After the last commit on src/com/amazon/pay/impl/PayLogUtil.java (Line 128)

image

it generates a IllegalArgumentException calling the com.amazon.pay.response.parser.Parser methods, probably because there the accessExternalDTD has been set as not supported:

image

Stacktrace:

java.lang.IllegalArgumentException: Not supported: http://javax.xml.XMLConstants/property/accessExternalDTD at org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:571) at com.amazon.pay.impl.PayLogUtil.getSanitizedData(PayLogUtil.java:126) at com.amazon.pay.impl.PayLogUtil.sanitizeString(PayLogUtil.java:75) at com.amazon.pay.response.parser.ResponseData.<init>(ResponseData.java:36) at com.amazon.pay.response.parser.GetOrderReferenceDetailsResponseData.<init>(GetOrderReferenceDetailsResponseData.java:30) at com.amazon.pay.response.parser.Parser.getOrderReferenceDetails(Parser.java:61)

bjguillot commented 3 years ago

Can you share what version of Java you were running this against, and which XML parsing related jars/libraries you are using? The changes worked against our internal integration tests. I'll need to know more about your environment so that we can troubleshoot further.

yuki-naki commented 3 years ago

I have same problems of this issues.

because TransformerFactory and Xalan Dependency Conflict so when try call some API can not working

※java version 11

jamesgorrie commented 11 months ago

We have seen this from the same update which was introduced in 3.6.4: https://github.com/amzn/amazon-pay-sdk-java/compare/3.6.2...3.6.4#diff-d6aa52c278cef70f54019b3ccbbec94e6985cf71dbd86e732d66f9dae9b8ac24R126-R127

We are using:

The solution we have settled on is by overriding the TransformerFactory class: https://www.google.com/url?sa=j&url=https%3A%2F%2Fgithub.com%2Fguardian%2Fsupport-frontend%2Fpull%2F5355&uct=1697555454&usg=lbVWXUIxK4Zq4p3bIt-oEfjEWCE.&opi=82159412&source=chat

A Java style implementation of this can be seen here: https://stackoverflow.com/a/64364531

I do wonder, that given not all Transformers support this if there should be check or similar before setting these properties?