private int getExpectedKeySize(String encryptionAlgo, List<Algo> algos) { int expectedSize = 0; for (Algo algo : algos) { if (Utils.areStringsEqual(algo.getValue(), encryptionAlgo)) { String size = algo.getSize(); if (Utils.isStringDigits(size)) { expectedSize = Integer.parseInt(size); } } } return expectedSize; }
@Test public void testUnmarshalling() throws Exception { ConstraintsParameters constraintsParameters = unmarshal(new File("src/test/resources/constraint.xml")); Algo algo = constraintsParameters.getSignatureConstraints().getBasicSignatureConstraints().getCryptographic().getMiniPublicKeySize().getAlgo().get(0); assertNotNull(algo); String algoName = algo.getValue(); assertEquals("DSA", algoName); assertEquals("128", algo.getSize()); JAXBContext jc = JAXBContext.newInstance("eu.europa.esig.jaxb.policy"); Marshaller marshaller = jc.createMarshaller(); marshaller.marshal(constraintsParameters, new FileOutputStream("target/constraint.xml")); }