private Date getExpirationDate(String algoToFind, List<Algo> algos, String format) { SimpleDateFormat dateFormat = new SimpleDateFormat(Utils.isStringEmpty(format) ? DATE_FORMAT : format); Date result = null; for (Algo algo : algos) { if (Utils.areStringsEqual(algoToFind, algo.getValue()) && Utils.isStringNotEmpty(algo.getDate())) { try { result = dateFormat.parse(algo.getDate()); } catch (Exception e) { LOG.warn("Unable to parse date with pattern '{}' : {}", dateFormat.toPattern(), e.getMessage()); } } } return result; }
private Date extractExpirationDate(final String algorithm, CryptographicConstraint signatureCryptographicConstraint) { AlgoExpirationDate algoExpirationDate = signatureCryptographicConstraint.getAlgoExpirationDate(); String dateFormat = DateUtils.DEFAULT_DATE_FORMAT; if (algoExpirationDate != null) { if (Utils.isStringNotEmpty(algoExpirationDate.getFormat())) { dateFormat = algoExpirationDate.getFormat(); } List<Algo> algos = algoExpirationDate.getAlgo(); String foundExpirationDate = null; for (Algo algo : algos) { if (Utils.areStringsEqualIgnoreCase(algo.getValue(), algorithm)) { foundExpirationDate = algo.getDate(); } } if (Utils.isStringNotEmpty(foundExpirationDate)) { return DateUtils.parseDate(dateFormat, foundExpirationDate); } } return null; }