List of usage examples for com.lowagie.text.pdf PdfDate decode
public static Calendar decode(String s)
From source file:es.gob.afirma.signers.pades.ltv.PdfDocumentSecurityStore.java
License:Open Source License
/** Constructor para inicializar la clase con una estructura DSS ya creada. * @param dss Diccionario DSS//from w ww .j ava 2s . c o m * @throws IOException En caso de errores de entrada / salida */ PdfDocumentSecurityStore(final PdfDictionary dss) throws IOException { int i = 0; PdfArray arrayCerts = dss.getAsArray(new PdfName(PDF_NAME_CERTS)); if (arrayCerts != null) { for (final Iterator<PdfObject> iterator = arrayCerts.listIterator(); iterator.hasNext();) { final PdfIndirectReference reference = (PdfIndirectReference) iterator.next(); this.certificates.put(Integer.valueOf(i), getContentBytesFromContentObject(PdfReader.getPdfObject(reference))); i++; } } PdfArray arrayOcsps = dss.getAsArray(new PdfName(PDF_NAME_OCSPS)); if (arrayOcsps != null) { i = 0; for (final Iterator<PdfObject> iterator = arrayOcsps.listIterator(); iterator.hasNext();) { final PdfIndirectReference reference = (PdfIndirectReference) iterator.next(); this.ocsps.put(Integer.valueOf(i), getContentBytesFromContentObject(PdfReader.getPdfObject(reference))); i++; } } PdfArray arrayCrls = dss.getAsArray(new PdfName(PDF_NAME_CRLS)); if (arrayCrls != null) { i = 0; for (final Iterator<PdfObject> iterator = arrayCrls.listIterator(); iterator.hasNext();) { final PdfIndirectReference reference = (PdfIndirectReference) iterator.next(); this.crls.put(Integer.valueOf(i), getContentBytesFromContentObject(PdfReader.getPdfObject(reference))); i++; } } final PdfDictionary vri = dss.getAsDict(new PdfName(PDF_NAME_VRI)); if (vri != null) { PdfName key; ValidationInformation val; for (final Iterator<PdfName> iterator = vri.getKeys().iterator(); iterator.hasNext(); this.signatures .put(key.toString().substring(1), val)) { key = iterator.next(); final PdfDictionary vriEntry = vri.getAsDict(key); arrayCerts = vriEntry.getAsArray(new PdfName(PDF_NAME_CERT)); int certId[]; if (arrayCerts != null) { certId = new int[arrayCerts.size()]; for (i = 0; i < arrayCerts.size(); i++) { final PdfIndirectReference reference = (PdfIndirectReference) arrayCerts.getPdfObject(i); final byte referenceBytes[] = getContentBytesFromContentObject( PdfReader.getPdfObject(reference)); final Iterator<Integer> iteratorKeys = this.certificates.keySet().iterator(); do { if (!iteratorKeys.hasNext()) { break; } final int index = iteratorKeys.next().intValue(); if (Arrays.equals(referenceBytes, this.certificates.get(Integer.valueOf(index)))) { certId[i] = index; } } while (true); } } else { certId = new int[0]; } arrayOcsps = vriEntry.getAsArray(new PdfName(PDF_NAME_OCSP)); int ocspId[]; if (arrayOcsps != null) { ocspId = new int[arrayOcsps.size()]; i = 0; for (final Iterator<PdfObject> iteratorOcsps = arrayOcsps.listIterator(); iteratorOcsps .hasNext();) { final PdfIndirectReference reference = (PdfIndirectReference) iteratorOcsps.next(); final byte referenceBytes[] = getContentBytesFromContentObject( PdfReader.getPdfObject(reference)); final Iterator<Integer> iteratorKeys = this.ocsps.keySet().iterator(); do { if (!iteratorKeys.hasNext()) { break; } final int index = iteratorKeys.next().intValue(); if (Arrays.equals(referenceBytes, this.ocsps.get(Integer.valueOf(index)))) { ocspId[i] = index; } } while (true); i++; } } else { ocspId = new int[0]; } arrayCrls = vriEntry.getAsArray(new PdfName(PDF_NAME_CRL)); int crlId[]; if (arrayCrls != null) { crlId = new int[arrayCrls.size()]; i = 0; for (final Iterator<PdfObject> iteratorCRLs = arrayCrls.listIterator(); iteratorCRLs .hasNext();) { final PdfIndirectReference reference = (PdfIndirectReference) iteratorCRLs.next(); final byte referenceBytes[] = getContentBytesFromContentObject( PdfReader.getPdfObject(reference)); final Iterator<Integer> iteratorKeys = this.crls.keySet().iterator(); do { if (!iteratorKeys.hasNext()) { break; } final int index = iteratorKeys.next().intValue(); if (Arrays.equals(referenceBytes, this.crls.get(Integer.valueOf(index)))) { crlId[i] = index; } } while (true); i++; } } else { crlId = new int[0]; } Calendar date = null; if (vriEntry.get(PdfName.TU) != null) { if (vriEntry.get(PdfName.TU) instanceof PdfDate) { date = PdfDate.decode(((PdfDate) vriEntry.get(PdfName.TU)).getEncoding()); } if (vriEntry.get(PdfName.TU) instanceof PdfString) { date = PdfDate.decode(vriEntry.getAsString(PdfName.TU).getEncoding()); } } val = new ValidationInformation(key, certId, ocspId, crlId, date); } } }
From source file:org.jrimum.bopepo.pdf.PdfDocInfo.java
License:Apache License
/** * @return Data de criao do documento */ public Calendar creation() { return PdfDate.decode(docInfo.get(DOC_CREATION_DATE)); }
From source file:org.jrimum.bopepo.pdf.PdfDocInfo.java
License:Apache License
/** * @return Data de modificao do documento */ public Calendar modification() { return PdfDate.decode(docInfo.get(DOC_MODIFACTION_DATE)); }