Last active
May 25, 2018 14:41
-
-
Save nelsondspy/320de87b448cb908a796c05fed01034e to your computer and use it in GitHub Desktop.
[Servidor]signPdf.jsp, [Cliente-Desktop]FirmaPDF.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.datosparaguay; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileNotFoundException; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.net.ConnectException; | |
import java.security.GeneralSecurityException; | |
import java.security.Principal; | |
import java.security.PrivateKey; | |
import java.security.Security; | |
import java.security.cert.CRL; | |
import java.security.cert.Certificate; | |
import java.security.cert.CertificateEncodingException; | |
import java.security.cert.X509CRL; | |
import java.security.cert.X509Certificate; | |
import java.util.ArrayList; | |
import java.util.Calendar; | |
import java.util.Date; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import javax.sql.RowSetWriter; | |
import org.bouncycastle.asn1.x500.RDN; | |
import org.bouncycastle.asn1.x500.X500Name; | |
import org.bouncycastle.asn1.x500.style.BCStyle; | |
import org.bouncycastle.asn1.x500.style.IETFUtils; | |
import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder; | |
import org.bouncycastle.cert.ocsp.BasicOCSPResp; | |
import com.itextpdf.text.DocumentException; | |
import com.itextpdf.text.ExceptionConverter; | |
import com.itextpdf.text.Font; | |
import com.itextpdf.text.Rectangle; | |
import com.itextpdf.text.Font.FontFamily; | |
import com.itextpdf.text.FontFactory; | |
import com.itextpdf.text.Phrase; | |
import com.itextpdf.text.pdf.AcroFields; | |
import com.itextpdf.text.pdf.BaseFont; | |
import com.itextpdf.text.pdf.ColumnText; | |
import com.itextpdf.text.pdf.PdfAConformanceLevel; | |
import com.itextpdf.text.pdf.PdfAStamper; | |
import com.itextpdf.text.pdf.PdfAnnotation; | |
import com.itextpdf.text.pdf.PdfFormField; | |
import com.itextpdf.text.pdf.PdfReader; | |
import com.itextpdf.text.pdf.PdfSigLockDictionary; | |
import com.itextpdf.text.pdf.PdfSignatureAppearance; | |
import com.itextpdf.text.pdf.PdfStamper; | |
import com.itextpdf.text.pdf.parser.PdfReaderContentParser; | |
import com.itextpdf.text.pdf.parser.TextMarginFinder; | |
import com.itextpdf.text.pdf.PdfSigLockDictionary.LockPermissions; | |
import com.itextpdf.text.pdf.security.BouncyCastleDigest; | |
import com.itextpdf.text.pdf.security.CRLVerifier; | |
import com.itextpdf.text.pdf.security.CertificateInfo; | |
import com.itextpdf.text.pdf.security.CrlClient; | |
import com.itextpdf.text.pdf.security.ExternalDigest; | |
import com.itextpdf.text.pdf.security.ExternalSignature; | |
import com.itextpdf.text.pdf.security.LtvTimestamp; | |
import com.itextpdf.text.pdf.security.LtvVerification; | |
import com.itextpdf.text.pdf.security.MakeSignature; | |
import com.itextpdf.text.pdf.security.OcspClient; | |
import com.itextpdf.text.pdf.security.PdfPKCS7; | |
import com.itextpdf.text.pdf.security.PrivateKeySignature; | |
import com.itextpdf.text.pdf.security.TSAClient; | |
import com.itextpdf.text.pdf.security.VerificationException; | |
import com.itextpdf.text.pdf.security.VerificationOK; | |
import com.itextpdf.text.pdf.security.MakeSignature.CryptoStandard; | |
import com.itextpdf.text.pdf.security.OCSPVerifier; | |
import com.itextpdf.text.Element; | |
import org.bouncycastle.jce.provider.BouncyCastleProvider; | |
public class FirmaPDF { | |
private TokenWrapper tokenWrapper; | |
// propiedades del field de firma | |
protected static float LLY = 752; // punto B1 | |
protected static float LLX = 380; // punto B2 | |
protected static float URY = 780; // punto D1 | |
protected static float URX = 600; // punto D2 | |
protected static String DEFAULT_FIELD_NAME = "firma"; | |
protected static String DEFAULT_FIELD_NAME_HIDDEN = "firma_invisible"; | |
public static final String FONT = "/fonts/Hasklig-Regular.otf"; | |
protected static float SEPARATION = 2; | |
public FirmaPDF() { | |
BouncyCastleProvider providerBC = new BouncyCastleProvider(); | |
Security.addProvider(providerBC); | |
} | |
public FirmaPDF(TokenWrapper tw) { | |
tokenWrapper = tw; | |
} | |
public String addSignFields(InputStream src, String dest, String fieldName, Integer cantidadFirmas) | |
throws IOException, DocumentException { | |
System.out.println("addSignFields"); | |
PdfReader reader = new PdfReader(src); | |
PdfAStamper stamper = new PdfAStamper(reader, new FileOutputStream(dest), PdfAConformanceLevel.PDF_A_1A); | |
String newFieldName = null; | |
int cantidad = cantidadFirmas == null ? 0 : cantidadFirmas.intValue(); | |
for (int firmas = cantidad; firmas > 0; firmas--) { | |
// create a signature form field | |
PdfFormField field = PdfFormField.createSignature(stamper.getWriter()); | |
newFieldName = fieldName + "_" + firmas; | |
field.setFieldName(newFieldName); | |
// set the widget properties | |
float lly = LLY - ((firmas - 1) * 40); | |
float ury = URY - ((firmas - 1) * 40); | |
float llx = LLX - ((firmas - 1) * 40); | |
float urx = URX - ((firmas - 1) * 40); | |
field.setWidget(new Rectangle(llx, lly, urx, ury), PdfAnnotation.HIGHLIGHT_OUTLINE); | |
field.setFlags(PdfAnnotation.FLAGS_PRINT); | |
// add the annotation | |
stamper.addAnnotation(field, 1); | |
} | |
// close the stamper | |
stamper.close(); | |
return newFieldName; | |
} | |
public void signWithTokenFromURL(String url, String dest, | |
String digestAlgorithm, | |
CryptoStandard subfilter, | |
boolean firstSigner, boolean lock, String fieldName, Integer cantidadFirmas, boolean visible, boolean lastPage, boolean checkSameSigner) | |
throws GeneralSecurityException, IOException, DocumentException { | |
InputStream srcStream = HttpClientUtils.getFileFromUrl(url); | |
signWithToken(srcStream, dest, digestAlgorithm, subfilter, firstSigner, lock, fieldName, cantidadFirmas, visible, lastPage, checkSameSigner); | |
} | |
public void signWithTokenFromFile(String path, String dest, | |
String digestAlgorithm, | |
CryptoStandard subfilter, | |
boolean firstSigner, boolean lock, String fieldName, Integer cantidadFirmas, boolean visible, boolean lastPage, boolean checkSameSigner) | |
throws GeneralSecurityException, IOException, DocumentException { | |
InputStream srcStream = new FileInputStream(path); | |
signWithToken(srcStream, dest, digestAlgorithm, subfilter, firstSigner, lock, fieldName, cantidadFirmas, visible, lastPage, checkSameSigner); | |
} | |
public void signWithToken(InputStream srcStream, String dest, | |
String digestAlgorithm, | |
CryptoStandard subfilter, | |
boolean firstSigner, boolean lock, String fieldName, Integer cantidadFirmas, boolean visible, boolean lastPage, boolean checkSameSigner) | |
throws GeneralSecurityException, IOException, DocumentException { | |
if (!tokenWrapper.isInitialized()) { | |
return; | |
} | |
signPDF(srcStream, dest, tokenWrapper.getChain(), tokenWrapper.getPk(), digestAlgorithm, | |
tokenWrapper.getProviderName(), subfilter, | |
tokenWrapper.getOcspClient(), tokenWrapper.getTsaClient(), tokenWrapper.getCrlList(), | |
fieldName, lock, | |
visible, lastPage,cantidadFirmas, checkSameSigner); | |
} | |
public void signPDF(InputStream src, String dest, Certificate[] chain, | |
PrivateKey pk, String digestAlgorithm, String provider, | |
CryptoStandard subfilter, OcspClient ocsp, TSAClient tsa, | |
List<CrlClient> crlList, String fieldName, boolean lock, boolean visible, boolean lastPage, Integer cantidadFirmas, boolean checkSameSigner) | |
throws GeneralSecurityException, IOException, DocumentException { | |
// Creating the reader and the stamper | |
File srcFile = null; | |
if (cantidadFirmas != null && fieldName == null) { | |
String fileWithFieldSignature = dest + "_temp"; | |
fieldName = addSignFields(src, fileWithFieldSignature, DEFAULT_FIELD_NAME, cantidadFirmas); | |
srcFile = new File(fileWithFieldSignature); | |
srcFile.deleteOnExit(); | |
src = new FileInputStream(srcFile); | |
} | |
boolean useTempFile = false; | |
if (src == null) { | |
throw new RuntimeException("Archivo no encontrado"); | |
} | |
PdfReader reader = new PdfReader(src); | |
boolean validPdfA = false; | |
byte [] metadata = reader.getMetadata(); | |
if (metadata != null) { | |
String xmlMetadata = new String(metadata); | |
//System.out.println("xmlMetadata: " + xmlMetadata); | |
validPdfA = Util.isPdfACompliant(xmlMetadata); | |
} | |
if (checkSameSigner && verifyAlreadySigned(reader)) { | |
throw new RuntimeException("Ya ha firmado este documento"); | |
} | |
if (!validPdfA) { | |
//throw new RuntimeException("El archivo PDF no obedece el estándar PDF/A"); | |
System.out.println("El archivo no es PDF/A Compliant"); | |
} | |
FileOutputStream os = null; | |
try { | |
os = new FileOutputStream(dest); | |
} catch (FileNotFoundException e) { | |
throw new RuntimeException("No se puede crear el archivo " + dest | |
+ ". Verifique que no esté abierto con otra aplicación"); | |
} | |
PdfStamper stamper; | |
int firmas = 0; | |
boolean firstSigner = true; | |
//numero de campos de firmas existentes | |
AcroFields af = reader.getAcroFields(); | |
ArrayList<String> names = af.getSignatureNames(); | |
firmas = names.size(); | |
System.out.println("Cantidad de firmas: " + firmas); | |
if (firmas > 0) { | |
firstSigner = false; | |
} | |
if (firstSigner) { | |
stamper = PdfAStamper.createSignature(reader, os, '\0'); | |
} else { | |
stamper = PdfAStamper.createSignature(reader, os, '\0', null, true); | |
} | |
float alto = 35; | |
float columnas = 5f; | |
//PdfReaderContentParser parser = new PdfReaderContentParser(reader); | |
//TextMarginFinder finder = parser.processContent(reader.getNumberOfPages(), new TextMarginFinder()); | |
Rectangle finder = reader.getPageSize(reader.getNumberOfPages()); | |
float rawLly = finder.getBottom() + alto; | |
float rawLlx = finder.getLeft() + alto; | |
float ancho = finder.getWidth() / 5; | |
int fila = firmas / (int) columnas; | |
Rectangle rectangle = null; | |
LLY = (rawLly + (alto * 1.5f)) - ((fila * alto) + SEPARATION); | |
URY = (rawLly + (alto * 1.5f)) - (alto + ((fila * alto) + SEPARATION)); | |
LLX = rawLly; | |
URX = rawLly + ancho; | |
// Creating the appearance | |
PdfSignatureAppearance appearance = stamper.getSignatureAppearance(); | |
if (visible) { | |
if (fieldName == null) { | |
fieldName = DEFAULT_FIELD_NAME + "_" + (firmas + 1); | |
float llx = LLX + ((firmas % columnas) * (ancho + SEPARATION)); | |
float urx = URX + ((firmas % columnas) * (ancho + SEPARATION)); | |
int page = 1; | |
if (lastPage) { | |
page = reader.getNumberOfPages(); | |
} | |
rectangle = new Rectangle(llx, LLY, urx, URY); | |
appearance.setVisibleSignature(rectangle, page, fieldName); | |
} else { | |
appearance.setVisibleSignature(fieldName); | |
} | |
String firmante = "Firmante"; | |
//for (Certificate cert : chain) { | |
//System.out.println("Certificate is: " + cert); | |
if (chain.length > 0) { | |
Certificate x = chain[0]; | |
if (x instanceof X509Certificate) { | |
X509Certificate cert = (X509Certificate) x; | |
X500Name subject = new JcaX509CertificateHolder(cert).getSubject(); | |
RDN subjectO = subject.getRDNs(BCStyle.O)[0]; | |
RDN subjectG = subject.getRDNs(BCStyle.GIVENNAME)[0]; | |
RDN subjectSN = subject.getRDNs(BCStyle.SURNAME)[0]; | |
RDN subjectCN = subject.getRDNs(BCStyle.CN)[0]; | |
RDN subjectOU = subject.getRDNs(BCStyle.OU)[0]; | |
String gString = IETFUtils.valueToString(subjectG.getFirst().getValue()); | |
String snString = IETFUtils.valueToString(subjectSN.getFirst().getValue()); | |
firmante = gString + "\n" + snString; | |
System.out.println("firmante : " + firmante); | |
} | |
} | |
//} | |
float fontSize1 = 5f; | |
final Font font1 = FontFactory.getFont(FONT, | |
BaseFont.WINANSI, BaseFont.EMBEDDED, fontSize1, Font.BOLD); | |
float fontSize2 = 6f; | |
final Font font2 = FontFactory.getFont(FONT, | |
BaseFont.WINANSI, BaseFont.EMBEDDED, fontSize1); | |
// final ColumnText ct1 = new ColumnText(appearance.getAppearance()); | |
// ct1.setSimpleColumn(new Phrase("Firma:\n", font1), rectangle.getLeft(), rectangle.getBottom() + (ancho/2), rectangle.getRight(), rectangle.getTop(), 6f, Element.ALIGN_LEFT); | |
// ct1.go(); | |
// final ColumnText ct2 = new ColumnText(appearance.getAppearance()); | |
// ct2.setSimpleColumn(new Phrase(firmante, font2), rectangle.getLeft(), rectangle.getBottom(), rectangle.getRight(), rectangle.getTop() - (ancho/2), 7f, Element.ALIGN_LEFT); | |
// ct2.go(); | |
appearance.setLayer2Text("Firma:\n" + firmante); | |
appearance.setLayer2Font(font2); | |
} else { | |
fieldName = DEFAULT_FIELD_NAME_HIDDEN + "_" + (firmas + 1); | |
appearance.setVisibleSignature(new Rectangle(0, 0, 0, 0), 1, fieldName); | |
} | |
PdfSigLockDictionary lockDic = null; | |
if (lock && firstSigner) { | |
appearance | |
.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED); | |
} else if (lock) { | |
appearance | |
.setCertificationLevel(PdfSignatureAppearance.NOT_CERTIFIED); | |
lockDic = new PdfSigLockDictionary(LockPermissions.NO_CHANGES_ALLOWED); | |
stamper.getWriter().addToBody(lockDic).getIndirectReference(); | |
} else if (firstSigner) { | |
appearance | |
.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING); | |
} else { | |
appearance | |
.setCertificationLevel(PdfSignatureAppearance.NOT_CERTIFIED); | |
} | |
//appearance.setReason(reason); | |
//appearance.setLocation(location); | |
// Creating the signature | |
ExternalDigest digest = new BouncyCastleDigest(); | |
ExternalSignature signature = new PrivateKeySignature(pk, | |
digestAlgorithm, provider); | |
//addLtv(stamper, appearance, ocsp, crlList.get(0), tsa, fieldName); | |
try { | |
MakeSignature.signDetached(appearance, digest, signature, chain, crlList, | |
ocsp, tsa, 0, subfilter); | |
} catch (ExceptionConverter e) { | |
System.out.println(e.getCause().toString() + " cause"); | |
if (e.getCause().toString().startsWith("java.net.ConnectException")) { | |
throw new RuntimeException("Problemas de comunicación con el servidor TSA/CRL"); | |
} else { | |
throw e; | |
} | |
} | |
reader.close(); | |
stamper.close(); | |
//borrar archivo temporal | |
if (cantidadFirmas != null && fieldName == null) { | |
try { | |
if (srcFile.delete()) { | |
System.out.println(srcFile.getName() + " borrado"); | |
} else { | |
System.out.println("No se pudo borrar el archivo temporal: " + srcFile.getName()); | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
public void addLtv(PdfStamper stp, PdfSignatureAppearance appearance, OcspClient ocsp, CrlClient crl, TSAClient tsa, String fieldName) | |
throws IOException, DocumentException, GeneralSecurityException { | |
LtvVerification v = stp.getLtvVerification(); | |
// AcroFields fields = stp.getAcroFields(); | |
// List<String> names = fields.getSignatureNames(); | |
// String sigName = names.get(names.size() - 1); | |
// PdfPKCS7 pkcs7 = fields.verifySignature(sigName); | |
// if (pkcs7.isTsp()) { | |
// v.addVerification(fieldName, ocsp, crl, LtvVerification.CertificateOption.SIGNING_CERTIFICATE, | |
// LtvVerification.Level.OCSP_CRL, LtvVerification.CertificateInclusion.NO); | |
// } else { | |
// for (String name : names) { | |
// v.addVerification(name, ocsp, crl, LtvVerification.CertificateOption.WHOLE_CHAIN, | |
// LtvVerification.Level.OCSP_CRL, LtvVerification.CertificateInclusion.NO); | |
// } | |
// } | |
LtvTimestamp.timestamp(appearance, tsa, fieldName); | |
} | |
public boolean verifyAlreadySigned(PdfReader reader) throws IOException, GeneralSecurityException { | |
AcroFields af = reader.getAcroFields(); | |
ArrayList<String> names = af.getSignatureNames(); | |
for (String name : names) { | |
PdfPKCS7 pk = af.verifySignature(name); | |
if (CertificateInfo.getSubjectFields(tokenWrapper.getSignCert()).toString().equals(CertificateInfo.getSubjectFields(pk | |
.getSigningCertificate()).toString())) { | |
System.out.println("Ya hay firma de: " + CertificateInfo.getSubjectFields(tokenWrapper.getSignCert()).toString()); | |
return true; | |
} | |
} | |
return false; | |
} | |
public Map<String, Object> verify(String documentoFirmado) throws IOException, GeneralSecurityException { | |
PdfReader reader = new PdfReader(documentoFirmado); | |
AcroFields af = reader.getAcroFields(); | |
ArrayList<String> names = af.getSignatureNames(); | |
String mensaje = ""; | |
Map<String, Object> result = new HashMap<String, Object>(); | |
boolean ok = true; | |
for (String name : names) { | |
PdfPKCS7 pk = af.verifySignature(name); | |
if (!pk.verify()) { | |
ok = false; | |
mensaje = mensaje | |
+ "\n" | |
+ CertificateInfo.getSubjectFields(pk | |
.getSigningCertificate()); | |
} | |
Calendar cal = pk.getSignDate(); | |
System.out.println(name + " - Verificaci\u00F3n de integridad OK? " + pk.verify()); | |
System.out.println("Fecha " + Util.calendarToSimpleDate(cal)); | |
} | |
System.out.println("Cantidad de firmas: " + names.size()); | |
X509Certificate cert = tokenWrapper.getSignCert(); | |
result.put("certInfo", Util.getCertInfo(cert)); | |
result.put("nro_firma", names.size()); | |
if (ok) { | |
mensaje = "OK"; | |
} | |
reader.close(); | |
result.put("mensaje", mensaje); | |
return result; | |
} | |
public String verifyAllSigns(String documentoFirmado) throws IOException, GeneralSecurityException { | |
PdfReader reader = new PdfReader(documentoFirmado); | |
AcroFields af = reader.getAcroFields(); | |
ArrayList<String> names = af.getSignatureNames(); | |
String resumen = ""; | |
if (names.size() == 0) { | |
resumen = "Archivo no firmado"; | |
} | |
for (String name : names) { | |
PdfPKCS7 pk = af.verifySignature(name); | |
String validez = "Firma válida en campo: " + name + "\n"; | |
if (!pk.verify()) { | |
validez = "Firma NO válida en campo: " + name + "\n"; | |
} | |
Calendar cal = pk.getSignDate(); | |
validez += "Fecha de firmado: " + Util.calendarToSimpleDate(cal) + "\n"; | |
X509Certificate cert = pk.getSigningCertificate(); | |
X500Name subject = new JcaX509CertificateHolder(cert).getSubject(); | |
RDN subjectO = subject.getRDNs(BCStyle.O)[0]; | |
RDN subjectG = subject.getRDNs(BCStyle.GIVENNAME).length == 0 ? null: subject.getRDNs(BCStyle.GIVENNAME)[0]; | |
RDN subjectSN = subject.getRDNs(BCStyle.SURNAME).length == 0 ? null: subject.getRDNs(BCStyle.SURNAME)[0]; | |
RDN subjectCN = subject.getRDNs(BCStyle.CN).length ==0? null: subject.getRDNs(BCStyle.CN)[0]; | |
//RDN subjectOU = subject.getRDNs(BCStyle.OU).length ==0? null: subject.getRDNs(BCStyle.OU)[0]; | |
String gString =""; | |
String snString =""; | |
if (subjectG != null) | |
gString = IETFUtils.valueToString(subjectG.getFirst().getValue()); | |
if (subjectSN != null) | |
snString = IETFUtils.valueToString(subjectSN.getFirst().getValue()); | |
String firmante = gString + " " + snString; | |
validez += "Firmante: " + firmante +",CN="+IETFUtils.valueToString(subjectCN.getFirst().getValue())+ "\n"; | |
/*Control de revocacion*/ | |
validez += checkRevocationConsole(pk, cert); | |
System.out.println(name + " - Verificaci\u00F3n de integridad: " + pk.verify()); | |
resumen += validez + "\n"; | |
} | |
reader.close(); | |
return resumen; | |
} | |
/** | |
* Determina si un certificado sera verificado contra su CRL, segun el valor de su CN. | |
* Se puede sobreescribir convenientemente. | |
* Por ejemplo retornando siempre true, si siempre se quiere verificar. | |
* */ | |
private boolean requireRevocationCondition(X509Certificate issuerCert) { | |
final String CN_REQUIRE_VERIF = "MIC"; | |
try { | |
X500Name subject = new JcaX509CertificateHolder(issuerCert).getSubject(); | |
RDN subjectCN = subject.getRDNs(BCStyle.CN).length == 0 ? null : subject.getRDNs(BCStyle.CN)[0]; | |
if (subjectCN != null) { | |
String CNstr = IETFUtils.valueToString(subjectCN.getFirst().getValue()); | |
if (CNstr.contains(CN_REQUIRE_VERIF)) { | |
return true; | |
} | |
} | |
} catch (Exception e) { | |
return false; | |
} | |
return false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ page import="java.util.Map" language="java" contentType="application/x-java-jnlp-file; UTF-8" | |
pageEncoding="UTF-8" %> | |
<% String appVersion = (String) request.getAttribute("appVersion"); %> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<jnlp spec="1.0+" | |
codebase=<%= "\"" + request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/\"" + " href=\"signPdf.jnlp" + (request.getQueryString() == null ? "\"" : "?" + request.getQueryString().replace("&", "&") + "\"") %>> | |
<information> | |
<title>App Signer PDF</title> | |
<vendor>VUE MIC</vendor> | |
<description>Firma de PDF</description> | |
<icon href="icon.png" kind="splash"/> | |
<icon href="icon.png" kind="shortcut" /> | |
<offline-allowed/> | |
<shortcut online="false" install="true"> | |
<desktop/> | |
<menu submenu="Firma Digital"/> | |
</shortcut> | |
</information> | |
<security> | |
<all-permissions/> | |
</security> | |
<resources> | |
<j2se href="http://java.sun.com/products/autodl/j2se" initial-heap-size="32m" max-heap-size="512m" | |
version="1.6+"/> | |
<property name="jnlp.versionEnabled" value="true"/> | |
<property name="SWT_GTK3" value="0"/> | |
<jar href="lib/itextpdf.jar" version="5.5.10"/> | |
<jar href="lib/itext-pdfa.jar" version="5.5.10"/> | |
<jar href="lib/bcpkix-jdk15on.jar" version="1.51"/> | |
<jar href="lib/bcprov-jdk15on.jar" version="1.51"/> | |
<jar href="lib/jackson-core.jar" version="2.4.4"/> | |
<jar href="lib/jackson-databind.jar" version="2.4.4"/> | |
<jar href="lib/jackson-annotations.jar" version="2.4.0"/> | |
<jar href="lib/httpclient.jar" version="4.3.6"/> | |
<jar href="lib/commons-logging.jar" version="1.1.3"/> | |
<jar href="lib/commons-codec.jar" version="1.6"/> | |
<jar href="lib/httpmime.jar" version="4.3.6"/> | |
<jar href="lib/httpcore.jar" version="4.3.3"/> | |
<jar href="lib/xercesImpl.jar" version="2.11.0"/> | |
<jar href="lib/xml-apis.jar" version="1.4.01"/> | |
<jar href="lib/xml-resolver.jar" version="1.2"/> | |
<jar href="lib/app-signer-common.jar" version="<%= appVersion %>"/> | |
<jar href="lib/org.eclipse.ui.workbench.jar" version="3.7.1.v20120104-1859"/> | |
<jar href="lib/org.eclipse.jface.jar" version="3.7.0.v20110928-1505"/> | |
<jar href="lib/org.eclipse.equinox.common.jar" version="3.6.0.v20110523"/> | |
<jar href="lib/org.eclipse.core.commands.jar" version="3.6.0.I20110111-0800"/> | |
<jar href="lib/org.eclipse.osgi.jar" version="3.7.2.v20120110-1415"/> | |
</resources> | |
<resources arch="x86" os="Windows"> | |
<jar href="lib/org.eclipse.swt.win32.win32.x86.jar" version="4.3.2"/> | |
<jar href="lib/app-signer-client-windows-x86.jar" version="<%= appVersion %>" main="true"/> | |
</resources> | |
<resources arch="x86_64" os="Windows"> | |
<jar href="lib/org.eclipse.swt.win32.win32.x86_64.jar" version="4.3.2"/> | |
<jar href="lib/app-signer-client-windows-x86_64.jar" version="<%= appVersion %>" main="true"/> | |
</resources> | |
<resources arch="amd64" os="Windows"> | |
<jar href="lib/org.eclipse.swt.win32.win32.x86_64.jar" version="4.3.2"/> | |
<jar href="lib/app-signer-client-windows-x86_64.jar" version="<%= appVersion %>" main="true"/> | |
</resources> | |
<resources arch="x86_64" os="Linux"> | |
<jar href="lib/org.eclipse.swt.gtk.linux.x86_64.jar" version="4.3.2"/> | |
<jar href="lib/app-signer-client-linux-x86_64.jar" version="<%= appVersion %>" main="true"/> | |
</resources> | |
<resources arch="amd64" os="Linux"> | |
<jar href="lib/org.eclipse.swt.gtk.linux.x86_64.jar" version="4.3.2"/> | |
<jar href="lib/app-signer-client-linux-x86_64.jar" version="<%= appVersion %>" main="true"/> | |
</resources> | |
<resources arch="x86" os="Linux"> | |
<jar href="lib/org.eclipse.swt.gtk.linux.x86.jar" version="4.3.2"/> | |
<jar href="lib/app-signer-client-linux-x86.jar" version="<%= appVersion %>" main="true"/> | |
</resources> | |
<application-desc main-class="org.datosparaguay.Main"> | |
<% | |
Map<String, String[]> requestParams = request.getParameterMap(); | |
// %1s tsa server | |
String param = "<argument>{\"mode\":\"DESKTOP\",\"type\":\"PDF\"" + | |
"%1$s}</argument>\n "; | |
String tsa = null; | |
String tsaArg = ",\"tsa\":\"%1$s\""; | |
String arg = ""; | |
for (Map.Entry<String, String[]> entry : requestParams.entrySet()) { | |
String key = entry.getKey(); // parameter name | |
String[] value = entry.getValue(); // parameter values as array of String | |
if (key.compareTo("tsa") == 0) { | |
tsa = value[0]; | |
} | |
} | |
out.write(" "); | |
if (tsa != null) { | |
tsaArg = String.format(tsaArg, tsa); | |
System.out.println("***** tsa arg " + tsaArg); | |
} else { | |
tsaArg = ""; | |
} | |
arg = String.format(param, tsaArg); | |
out.write(arg); | |
System.out.println("***** arg pdf " + arg); | |
%> | |
</application-desc> | |
</jnlp> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment