From 1c8feb0dd0ee0cf74e60d93853e6f5d57b034bee Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Thu, 9 Oct 2014 13:40:38 +0200 Subject: WebServices with CXF, removed DB dependencies to pdf-as-web-db --- pdf-as-moa/src/main/java/META-INF/MANIFEST.MF | 3 - .../at.gv.egiz.pdfas.lib.impl.verify.IVerifier | 1 - pdf-as-moa/src/main/resources/META-INF/MANIFEST.MF | 3 + .../at.gv.egiz.pdfas.lib.impl.verify.IVerifier | 1 + pdf-as-web-db/.gitignore | 1 + pdf-as-web-db/build.gradle | 27 +++++ .../at/gv/egiz/pdfas/web/store/DBRequestStore.java | 122 +++++++++++++++++++++ .../at/gv/egiz/pdfas/web/store/db/Request.java | 52 +++++++++ pdf-as-web/build.gradle | 13 +-- .../pdfas/web/servlets/SoapServiceServlet.java | 48 ++++++++ .../at/gv/egiz/pdfas/web/store/DBRequestStore.java | 121 -------------------- .../at/gv/egiz/pdfas/web/store/db/Request.java | 52 --------- .../at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java | 117 ++++++++++++-------- .../main/webapp/META-INF/cxf/org.apache.cxf.Logger | 1 + pdf-as-web/src/main/webapp/WEB-INF/sun-jaxws.xml | 11 -- pdf-as-web/src/main/webapp/WEB-INF/web.xml | 20 +++- settings.gradle | 2 +- 17 files changed, 343 insertions(+), 252 deletions(-) delete mode 100644 pdf-as-moa/src/main/java/META-INF/MANIFEST.MF delete mode 100644 pdf-as-moa/src/main/java/META-INF/services/at.gv.egiz.pdfas.lib.impl.verify.IVerifier create mode 100644 pdf-as-moa/src/main/resources/META-INF/MANIFEST.MF create mode 100644 pdf-as-moa/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.impl.verify.IVerifier create mode 100644 pdf-as-web-db/.gitignore create mode 100644 pdf-as-web-db/build.gradle create mode 100644 pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java create mode 100644 pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/db/Request.java create mode 100644 pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SoapServiceServlet.java delete mode 100644 pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java delete mode 100644 pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/store/db/Request.java create mode 100644 pdf-as-web/src/main/webapp/META-INF/cxf/org.apache.cxf.Logger delete mode 100644 pdf-as-web/src/main/webapp/WEB-INF/sun-jaxws.xml diff --git a/pdf-as-moa/src/main/java/META-INF/MANIFEST.MF b/pdf-as-moa/src/main/java/META-INF/MANIFEST.MF deleted file mode 100644 index 5e949512..00000000 --- a/pdf-as-moa/src/main/java/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/pdf-as-moa/src/main/java/META-INF/services/at.gv.egiz.pdfas.lib.impl.verify.IVerifier b/pdf-as-moa/src/main/java/META-INF/services/at.gv.egiz.pdfas.lib.impl.verify.IVerifier deleted file mode 100644 index 1ace6960..00000000 --- a/pdf-as-moa/src/main/java/META-INF/services/at.gv.egiz.pdfas.lib.impl.verify.IVerifier +++ /dev/null @@ -1 +0,0 @@ -at.gv.egiz.pdfas.moa.MOAVerifier #MOA Verifier \ No newline at end of file diff --git a/pdf-as-moa/src/main/resources/META-INF/MANIFEST.MF b/pdf-as-moa/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 00000000..5e949512 --- /dev/null +++ b/pdf-as-moa/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/pdf-as-moa/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.impl.verify.IVerifier b/pdf-as-moa/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.impl.verify.IVerifier new file mode 100644 index 00000000..1ace6960 --- /dev/null +++ b/pdf-as-moa/src/main/resources/META-INF/services/at.gv.egiz.pdfas.lib.impl.verify.IVerifier @@ -0,0 +1 @@ +at.gv.egiz.pdfas.moa.MOAVerifier #MOA Verifier \ No newline at end of file diff --git a/pdf-as-web-db/.gitignore b/pdf-as-web-db/.gitignore new file mode 100644 index 00000000..ae3c1726 --- /dev/null +++ b/pdf-as-web-db/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/pdf-as-web-db/build.gradle b/pdf-as-web-db/build.gradle new file mode 100644 index 00000000..c29fff66 --- /dev/null +++ b/pdf-as-web-db/build.gradle @@ -0,0 +1,27 @@ +apply plugin: 'java' +apply plugin: 'eclipse' + +jar { + manifest { + attributes 'Implementation-Title': 'PDF-AS-4 Web Extension Library', 'JARMANIFEST': 'PDF-AS-LIB' + } +} + +repositories { + mavenLocal() + mavenCentral() +} + +dependencies { + compile project (':pdf-as-web') + compile "org.hibernate:hibernate-core:4.3.6.Final" + compile "org.hibernate:hibernate-entitymanager:4.3.6.Final" + compile group: 'log4j', name: 'log4j', version: '1.2.17' + compile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion + testCompile group: 'junit', name: 'junit', version: '4.+' +} + +task releases(type: Copy) { + from jar.outputs + into rootDir.toString() + "/releases/" + version +} \ No newline at end of file diff --git a/pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java b/pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java new file mode 100644 index 00000000..a1b88270 --- /dev/null +++ b/pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java @@ -0,0 +1,122 @@ +package at.gv.egiz.pdfas.web.store; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +import org.hibernate.Query; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.Configuration; +import org.hibernate.service.ServiceRegistry; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.pdfas.api.ws.PDFASSignRequest; +import at.gv.egiz.pdfas.web.config.WebConfiguration; +import at.gv.egiz.pdfas.web.store.IRequestStore; +import at.gv.egiz.pdfas.web.store.db.Request; + +public class DBRequestStore implements IRequestStore { + + private static final Logger logger = LoggerFactory + .getLogger(DBRequestStore.class); + + private SessionFactory sessions; + private ServiceRegistry serviceRegistry; + + public DBRequestStore() { + Configuration cfg = new Configuration(); + cfg.addAnnotatedClass(Request.class); + cfg.setProperties(WebConfiguration.getHibernateProps()); + + serviceRegistry = new StandardServiceRegistryBuilder().applySettings( + cfg.getProperties()).build(); + + sessions = cfg.buildSessionFactory(serviceRegistry); + } + + private void cleanOldRequests() { + int seconds = WebConfiguration.getDBTimeout(); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.SECOND, (-1)* seconds); + Date date = calendar.getTime(); + SimpleDateFormat dt = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss"); + logger.info("Clearing Entries before: " + dt.format(date)); + Session session = null; + Transaction tx = null; + try { + session = sessions.openSession(); + tx = session.beginTransaction(); + Query query = session.createQuery("delete from Request as req" + + " where req.created < :date"); + query.setCalendar("date", calendar); + query.executeUpdate(); + } catch(Throwable e) { + logger.error("Failed to save Request", e); + tx.rollback(); + } finally { + if(session != null) { + session.close(); + } + } + } + + public String createNewStoreEntry(PDFASSignRequest request) { + // Clean Old Requests + this.cleanOldRequests(); + Session session = null; + Transaction tx = null; + try { + session = sessions.openSession(); + tx = session.beginTransaction(); + Request dbRequest = new Request(); + dbRequest.setSignRequest(request); + dbRequest.setCreated(Calendar.getInstance().getTime()); + session.save(dbRequest); + + tx.commit(); + return dbRequest.getId(); + } catch(Throwable e) { + logger.error("Failed to save Request", e); + tx.rollback(); + return null; + } finally { + if(session != null) { + session.close(); + } + } + } + + public PDFASSignRequest fetchStoreEntry(String id) { + // Clean Old Requests + this.cleanOldRequests(); + + Session session = null; + Transaction tx = null; + try { + session = sessions.openSession(); + tx = session.beginTransaction(); + Request dbRequest = (Request) session.get(Request.class, id); + + PDFASSignRequest request = dbRequest.getSignRequest(); + + session.delete(dbRequest); + + tx.commit(); + return request; + } catch(Throwable e) { + logger.error("Failed to fetch Request", e); + tx.rollback(); + return null; + } finally { + if(session != null) { + session.close(); + } + } + + } + +} diff --git a/pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/db/Request.java b/pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/db/Request.java new file mode 100644 index 00000000..d7377166 --- /dev/null +++ b/pdf-as-web-db/src/main/java/at/gv/egiz/pdfas/web/store/db/Request.java @@ -0,0 +1,52 @@ +package at.gv.egiz.pdfas.web.store.db; + +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +import org.hibernate.annotations.GenericGenerator; + +import at.gv.egiz.pdfas.api.ws.PDFASSignRequest; + +@Entity +@Table(name = "requests") +public class Request { + + private String uuid; + private Date created; + private PDFASSignRequest signRequest; + + @Id + @GeneratedValue(generator = "uuid") + @GenericGenerator(name = "uuid", strategy = "uuid2") + @Column(name = "id", unique = true) + public String getId() { + return this.uuid; + } + + public void setId(String uuid) { + this.uuid = uuid; + } + + @Column(name = "created", nullable = false) + public Date getCreated() { + return this.created; + } + + public void setCreated(Date created) { + this.created = created; + } + + @Column(name = "signRequest", nullable = false, length = 52428800) + public PDFASSignRequest getSignRequest() { + return this.signRequest; + } + + public void setSignRequest(PDFASSignRequest signRequest) { + this.signRequest = signRequest; + } +} diff --git a/pdf-as-web/build.gradle b/pdf-as-web/build.gradle index 64111a3a..d854a365 100644 --- a/pdf-as-web/build.gradle +++ b/pdf-as-web/build.gradle @@ -21,20 +21,13 @@ dependencies { compile project (':signature-standards:sigs-pkcs7detached') compile project (':signature-standards:sigs-pades') compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.1' - compile 'org.apache.commons:commons-collections4:4.0' - compile 'commons-io:commons-io:2.4' compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.7' + compile 'org.slf4j:slf4j-log4j12:1.7.7' compile group: 'opensymphony', name: 'sitemesh', version: '2.4.2' - compile 'javax.xml.ws:jaxws-api:2.2.11' compile "commons-codec:commons-codec:1.9" - compile 'com.sun.xml.ws:jaxws-rt:2.2.8' - compile 'com.sun.xml.bind:jaxb-impl:2.2.7' compile 'org.apache.commons:commons-lang3:3.3.2' - compile 'org.apache.httpcomponents:httpclient:4.3.5' - compile "org.hibernate:hibernate-core:4.3.6.Final" - compile "org.hibernate:hibernate-entitymanager:4.3.6.Final" - //compile "mysql:mysql-connector-java:5.1.33" - compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '1.8.5' + compile 'org.apache.cxf:cxf-rt-transports-http:3.0.1' + compile 'org.apache.cxf:cxf-rt-frontend-jaxws:3.0.1' providedCompile "javax.servlet:servlet-api:2.5" testCompile group: 'junit', name: 'junit', version: '4.+' } diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SoapServiceServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SoapServiceServlet.java new file mode 100644 index 00000000..71395304 --- /dev/null +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/SoapServiceServlet.java @@ -0,0 +1,48 @@ +package at.gv.egiz.pdfas.web.servlets; + +import javax.servlet.ServletConfig; +import javax.xml.ws.Endpoint; + +import org.apache.cxf.Bus; +import org.apache.cxf.BusFactory; +import org.apache.cxf.feature.LoggingFeature; +import org.apache.cxf.interceptor.LoggingInInterceptor; +import org.apache.cxf.interceptor.LoggingOutInterceptor; +import org.apache.cxf.transport.servlet.CXFNonSpringServlet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.pdfas.web.ws.PDFASSigningImpl; +import at.gv.egiz.pdfas.web.ws.PDFASVerificationImpl; + +public class SoapServiceServlet extends CXFNonSpringServlet { + + private static final Logger logger = LoggerFactory + .getLogger(SoapServiceServlet.class); + + /** + * + */ + private static final long serialVersionUID = -8903883276191902043L; + + @Override + protected void loadBus(ServletConfig sc) { + super.loadBus(sc); + + // You could add the endpoint publish codes here + Bus bus = this.getBus(); + BusFactory.setDefaultBus(bus); + Endpoint signEp = Endpoint.publish("/wssign", new PDFASSigningImpl()); + /* + * SOAPBinding signBinding = (SOAPBinding)signEp.getBinding(); + signBinding.setMTOMEnabled(true); + */ + + Endpoint verifyEp = Endpoint.publish("/wsverify", new PDFASVerificationImpl()); + /* + SOAPBinding verifyBinding = (SOAPBinding)verifyEp.getBinding(); + verifyBinding.setMTOMEnabled(true); + */ + + } +} diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java deleted file mode 100644 index 6ca6d9a4..00000000 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/store/DBRequestStore.java +++ /dev/null @@ -1,121 +0,0 @@ -package at.gv.egiz.pdfas.web.store; - -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; - -import org.hibernate.Query; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.Transaction; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.cfg.Configuration; -import org.hibernate.service.ServiceRegistry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.gv.egiz.pdfas.api.ws.PDFASSignRequest; -import at.gv.egiz.pdfas.web.config.WebConfiguration; -import at.gv.egiz.pdfas.web.store.db.Request; - -public class DBRequestStore implements IRequestStore { - - private static final Logger logger = LoggerFactory - .getLogger(DBRequestStore.class); - - private SessionFactory sessions; - private ServiceRegistry serviceRegistry; - - public DBRequestStore() { - Configuration cfg = new Configuration(); - cfg.addAnnotatedClass(Request.class); - cfg.setProperties(WebConfiguration.getHibernateProps()); - - serviceRegistry = new StandardServiceRegistryBuilder().applySettings( - cfg.getProperties()).build(); - - sessions = cfg.buildSessionFactory(serviceRegistry); - } - - private void cleanOldRequests() { - int seconds = WebConfiguration.getDBTimeout(); - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.SECOND, (-1)* seconds); - Date date = calendar.getTime(); - SimpleDateFormat dt = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss"); - logger.info("Clearing Entries before: " + dt.format(date)); - Session session = null; - Transaction tx = null; - try { - session = sessions.openSession(); - tx = session.beginTransaction(); - Query query = session.createQuery("delete from Request as req" + - " where req.created < :date"); - query.setCalendar("date", calendar); - query.executeUpdate(); - } catch(Throwable e) { - logger.error("Failed to save Request", e); - tx.rollback(); - } finally { - if(session != null) { - session.close(); - } - } - } - - public String createNewStoreEntry(PDFASSignRequest request) { - // Clean Old Requests - this.cleanOldRequests(); - Session session = null; - Transaction tx = null; - try { - session = sessions.openSession(); - tx = session.beginTransaction(); - Request dbRequest = new Request(); - dbRequest.setSignRequest(request); - dbRequest.setCreated(Calendar.getInstance().getTime()); - session.save(dbRequest); - - tx.commit(); - return dbRequest.getId(); - } catch(Throwable e) { - logger.error("Failed to save Request", e); - tx.rollback(); - return null; - } finally { - if(session != null) { - session.close(); - } - } - } - - public PDFASSignRequest fetchStoreEntry(String id) { - // Clean Old Requests - this.cleanOldRequests(); - - Session session = null; - Transaction tx = null; - try { - session = sessions.openSession(); - tx = session.beginTransaction(); - Request dbRequest = (Request) session.get(Request.class, id); - - PDFASSignRequest request = dbRequest.getSignRequest(); - - session.delete(dbRequest); - - tx.commit(); - return request; - } catch(Throwable e) { - logger.error("Failed to fetch Request", e); - tx.rollback(); - return null; - } finally { - if(session != null) { - session.close(); - } - } - - } - -} diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/store/db/Request.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/store/db/Request.java deleted file mode 100644 index d7377166..00000000 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/store/db/Request.java +++ /dev/null @@ -1,52 +0,0 @@ -package at.gv.egiz.pdfas.web.store.db; - -import java.util.Date; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; - -import org.hibernate.annotations.GenericGenerator; - -import at.gv.egiz.pdfas.api.ws.PDFASSignRequest; - -@Entity -@Table(name = "requests") -public class Request { - - private String uuid; - private Date created; - private PDFASSignRequest signRequest; - - @Id - @GeneratedValue(generator = "uuid") - @GenericGenerator(name = "uuid", strategy = "uuid2") - @Column(name = "id", unique = true) - public String getId() { - return this.uuid; - } - - public void setId(String uuid) { - this.uuid = uuid; - } - - @Column(name = "created", nullable = false) - public Date getCreated() { - return this.created; - } - - public void setCreated(Date created) { - this.created = created; - } - - @Column(name = "signRequest", nullable = false, length = 52428800) - public PDFASSignRequest getSignRequest() { - return this.signRequest; - } - - public void setSignRequest(PDFASSignRequest signRequest) { - this.signRequest = signRequest; - } -} diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java index 02c1af5e..6df63a3b 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java @@ -53,91 +53,110 @@ public class PDFASSigningImpl implements PDFASSigning { private static final Logger logger = LoggerFactory .getLogger(PDFASSigningImpl.class); - - /*public byte[] signPDFDokument(byte[] inputDocument, - PDFASSignParameters parameters) { - checkSoapSignEnabled(); - try { - return PdfAsHelper.synchornousServerSignature(inputDocument, - parameters); - } catch (Throwable e) { - logger.error("Server Signature failed.", e); - if (WebConfiguration.isShowErrorDetails()) { - throw new WebServiceException("Server Signature failed.", e); - } else { - throw new WebServiceException("Server Signature failed."); - } - } - }*/ + + /* + * public byte[] signPDFDokument(byte[] inputDocument, PDFASSignParameters + * parameters) { checkSoapSignEnabled(); try { return + * PdfAsHelper.synchornousServerSignature(inputDocument, parameters); } + * catch (Throwable e) { logger.error("Server Signature failed.", e); if + * (WebConfiguration.isShowErrorDetails()) { throw new + * WebServiceException("Server Signature failed.", e); } else { throw new + * WebServiceException("Server Signature failed."); } } } + */ public PDFASSignResponse signPDFDokument(PDFASSignRequest request) { + logger.debug("Starting SOAP Sign Request"); checkSoapSignEnabled(); if (request == null) { logger.warn("SOAP Sign Request is null!"); return null; } + PDFASSignResponse response = new PDFASSignResponse(); try { - if(request.getParameters().getConnector().equals(Connector.MOA) || - request.getParameters().getConnector().equals(Connector.JKS)) { + if(request.getParameters().getConnector() == null) { + throw new WebServiceException( + "Invalid connector value!"); + } + + if (request.getParameters().getConnector().equals(Connector.MOA) + || request.getParameters().getConnector() + .equals(Connector.JKS)) { // Plain server based signatures!! - response = PdfAsHelper.synchornousServerSignature(request.getInputData(), - request.getParameters()); - - + response = PdfAsHelper.synchornousServerSignature( + request.getInputData(), request.getParameters()); + VerifyResult verifyResult = null; - if(request.getVerificationLevel().equals(VerificationLevel.FULL_CERT_PATH)) { - List verResults = PdfAsHelper.synchornousVerify(response.getSignedPDF(), -1, - SignatureVerificationLevel.FULL_VERIFICATION); - - if(verResults.size() != 1) { - throw new WebServiceException("Document verification failed!"); + if (request.getVerificationLevel() != null && + request.getVerificationLevel().equals( + VerificationLevel.FULL_CERT_PATH)) { + List verResults = PdfAsHelper + .synchornousVerify( + response.getSignedPDF(), + -1, + SignatureVerificationLevel.FULL_VERIFICATION); + + if (verResults.size() != 1) { + throw new WebServiceException( + "Document verification failed!"); } verifyResult = verResults.get(0); } else { - List verResults = PdfAsHelper.synchornousVerify(response.getSignedPDF(), -1, - SignatureVerificationLevel.INTEGRITY_ONLY_VERIFICATION); - - if(verResults.size() != 1) { - throw new WebServiceException("Document verification failed!"); + List verResults = PdfAsHelper + .synchornousVerify( + response.getSignedPDF(), + -1, + SignatureVerificationLevel.INTEGRITY_ONLY_VERIFICATION); + + if (verResults.size() != 1) { + throw new WebServiceException( + "Document verification failed!"); } verifyResult = verResults.get(0); } - - response.getVerificationResponse().setCertificateCode(verifyResult.getCertificateCheck().getCode()); - response.getVerificationResponse().setValueCode(verifyResult.getValueCheckCode().getCode()); + + response.getVerificationResponse().setCertificateCode( + verifyResult.getCertificateCheck().getCode()); + response.getVerificationResponse().setValueCode( + verifyResult.getValueCheckCode().getCode()); } else { // Signatures with user interaction!! - String id = RequestStore.getInstance().createNewStoreEntry(request); - - if(id == null) { + String id = RequestStore.getInstance().createNewStoreEntry( + request); + + if (id == null) { throw new WebServiceException("Failed to store request"); } - + String userEntryURL = PdfAsHelper.generateUserEntryURL(id); - + logger.debug("Generated request store: " + id); logger.debug("Generated UI URL: " + userEntryURL); - - if(userEntryURL == null) { - throw new WebServiceException("Failed to generate User Entry URL"); + + if (userEntryURL == null) { + throw new WebServiceException( + "Failed to generate User Entry URL"); } - + response.setRedirectUrl(userEntryURL); } } catch (Throwable e) { + logger.error("Error in Soap Service", e); if (e.getCause() != null) { response.setError(e.getCause().getMessage()); } else { response.setError(e.getMessage()); } + } finally { + logger.debug("Done SOAP Sign Request"); } response.setRequestID(request.getRequestID()); return response; } public PDFASBulkSignResponse signPDFDokument(PDFASBulkSignRequest request) { + logger.debug("Starting SOAP BulkSign Request"); checkSoapSignEnabled(); List responses = new ArrayList(); if (request.getSignRequests() != null) { @@ -150,9 +169,11 @@ public class PDFASSigningImpl implements PDFASSigning { } PDFASBulkSignResponse response = new PDFASBulkSignResponse(); response.setSignResponses(responses); + logger.debug("Done SOAP Sign Request"); return response; } logger.error("Server Signature failed. [PDFASBulkSignRequest is NULL]"); + if (WebConfiguration.isShowErrorDetails()) { throw new WebServiceException("PDFASBulkSignRequest is NULL"); } else { @@ -161,9 +182,9 @@ public class PDFASSigningImpl implements PDFASSigning { } private void checkSoapSignEnabled() { - if(!WebConfiguration.getSoapSignEnabled()) { + if (!WebConfiguration.getSoapSignEnabled()) { throw new WebServiceException("Service disabled!"); } - } - + } + } diff --git a/pdf-as-web/src/main/webapp/META-INF/cxf/org.apache.cxf.Logger b/pdf-as-web/src/main/webapp/META-INF/cxf/org.apache.cxf.Logger new file mode 100644 index 00000000..067508e1 --- /dev/null +++ b/pdf-as-web/src/main/webapp/META-INF/cxf/org.apache.cxf.Logger @@ -0,0 +1 @@ +org.apache.cxf.common.logging.Slf4jLogger \ No newline at end of file diff --git a/pdf-as-web/src/main/webapp/WEB-INF/sun-jaxws.xml b/pdf-as-web/src/main/webapp/WEB-INF/sun-jaxws.xml deleted file mode 100644 index f62b8484..00000000 --- a/pdf-as-web/src/main/webapp/WEB-INF/sun-jaxws.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/pdf-as-web/src/main/webapp/WEB-INF/web.xml b/pdf-as-web/src/main/webapp/WEB-INF/web.xml index 82d00fdf..f8b886ca 100644 --- a/pdf-as-web/src/main/webapp/WEB-INF/web.xml +++ b/pdf-as-web/src/main/webapp/WEB-INF/web.xml @@ -29,15 +29,15 @@ /* - + - + SignServlet @@ -46,6 +46,12 @@ at.gv.egiz.pdfas.web.servlets.ExternSignServlet 0 + + CXFServlet + CXFServlet + + at.gv.egiz.pdfas.web.servlets.SoapServiceServlet + ProvidePDF ProvidePDF @@ -116,9 +122,13 @@ servlet mappings, including zero. It is also legal to define more than one mapping for the same servlet, if you wish to. --> - + + + CXFServlet + /services/* SignServlet diff --git a/settings.gradle b/settings.gradle index eaf6c71b..546c2d6c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ -include "pdf-as-common", "signature-standards:sigs-pkcs7detached", "signature-standards:sigs-pades", "pdf-as-lib", "pdf-as-moa", "pdf-as-tests", "pdf-as-cli", "pdf-as-legacy", "pdf-as-web", "pdf-as-web-client" +include "pdf-as-common", "signature-standards:sigs-pkcs7detached", "signature-standards:sigs-pades", "pdf-as-lib", "pdf-as-moa", "pdf-as-tests", "pdf-as-cli", "pdf-as-legacy", "pdf-as-web", "pdf-as-web-db", "pdf-as-web-client" -- cgit v1.2.3