if ((acceptableEncryptionAlgo != null) && Utils.isCollectionNotEmpty(acceptableEncryptionAlgo.getAlgo())) { if (!isIn(token.getEncryptionAlgoUsedToSignThisToken(), acceptableEncryptionAlgo.getAlgo())) { errorMessage = MessageTag.ASCCM_ANS_1; return false; if ((acceptableDigestAlgo != null) && Utils.isCollectionNotEmpty(acceptableDigestAlgo.getAlgo())) { if (!isIn(token.getDigestAlgoUsedToSignThisToken(), acceptableDigestAlgo.getAlgo())) { errorMessage = MessageTag.ASCCM_ANS_2; return false; if ((miniPublicKeySize != null) && Utils.isCollectionNotEmpty(miniPublicKeySize.getAlgo())) { String keySize = token.getKeyLengthUsedToSignThisToken(); int tokenKeySize = 0; tokenKeySize = Integer.parseInt(keySize); int expectedMinimumKeySize = getExpectedKeySize(token.getEncryptionAlgoUsedToSignThisToken(), miniPublicKeySize.getAlgo()); if (tokenKeySize < expectedMinimumKeySize) { errorMessage = MessageTag.ASCCM_ANS_3;
@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")); }