jfrchicanog / ewp-reference-connector

MIT License
0 stars 0 forks source link

Aquí debería calcularse el “conditionsHash” #12

Closed jfrchicanog closed 3 years ago

jfrchicanog commented 3 years ago

https://github.com/jfrchicanog/ewp-reference-connector/blob/5c2636560b344f2fb453c384a15f318a92e612b3/ewp-reference-connector/src/main/java/eu/erasmuswithoutpaper/iia/control/IiaConverter.java#L70

Creo que la implementación está en otra clase, pero no se utiliza aquí al convertir.

Dalia-git commented 3 years ago

JAXBContext jaxbContext = JAXBContext.newInstance(IiasGetResponse.Iia.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

            StringWriter sw = new StringWriter();
            jaxbMarshaller.marshal(converted, sw);
            String xmlString = sw.toString();

            converted.setConditionsHash(HashCalculationUtility.calculateSha256(xmlString));
jfrchicanog commented 3 years ago

Solo hay que calcular el hash de "Cooperation Conditions", en esta implementación creo que se calcula de todo. Esto es lo que dice la documentación:

The SHA-256 digest of the cooperation-conditions element but excluding sending-contact and receiving-contact subelements. Before calculating the hash, the cooperation-conditions element should be normalized using Exclusive XML Canonicalization.

                                    This element is not required. However, if it is not present, your partner
                                    will not be able to approve your version of the agreement using EWP IIAs Approval API.
                                    If you want to get approval of your agreements, then you should always send
                                    the conditions hash.

Los detalles están aquí: https://github.com/erasmus-without-paper/ewp-specs-api-iias/blob/v6.0.1/endpoints/get-response.xsd