diff options
9 files changed, 184 insertions, 31 deletions
diff --git a/simpleSigning/build.gradle b/simpleSigning/build.gradle index 58d3680..084b739 100644 --- a/simpleSigning/build.gradle +++ b/simpleSigning/build.gradle @@ -4,20 +4,32 @@ apply plugin: 'eclipse-wtp' apply plugin: 'war' sourceCompatibility = 1.6 -version = '1.0-RC1' +version = '1.0-RC2' +revision = getCheckedOutGitCommitHash() -jar { - manifest { - attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version - } + +war { + manifest { + attributes provider: 'EGIZ', 'Specification-Version': getCheckedOutGitCommitHash(), 'Implementation-Title': 'Einfach Signieren', 'Implementation-Version': version + } } -repositories { - mavenCentral() +repositories { mavenCentral() } + + +def getCheckedOutGitCommitHash() { + def gitFolder = "$projectDir/../.git/" + def takeFromHash = 40 + def head = new File(gitFolder + "HEAD").text.split(":") // .git/HEAD + def isCommit = head.length == 1 + if(isCommit) return head[0].trim().take(takeFromHash) + + def refHead = new File(gitFolder + head[1].trim()) + refHead.text.trim().take takeFromHash } dependencies { - compile group: 'commons-collections', name: 'commons-collections', version: '3.2' + compile group: 'commons-collections', name: 'commons-collections', version: '3.2' compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.2' compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2' compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.5' @@ -25,17 +37,13 @@ dependencies { //compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '1.8.5' compile 'com.lowagie:itext:4.2.0' providedCompile 'javax.servlet:javax.servlet-api:3.1.0' - testCompile group: 'junit', name: 'junit', version: '4.+' + testCompile group: 'junit', name: 'junit', version: '4.+' } -test { - systemProperties 'property': 'value' -} +test { systemProperties 'property': 'value' } uploadArchives { - repositories { - flatDir { - dirs 'repos' - } - } + repositories { + flatDir { dirs 'repos' } + } } diff --git a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/ErrorSignature.java b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/ErrorSignature.java index c8128b0..0ebeeab 100644 --- a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/ErrorSignature.java +++ b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/ErrorSignature.java @@ -5,7 +5,6 @@ import java.io.OutputStream; import java.net.URLDecoder; import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -16,7 +15,6 @@ import org.slf4j.LoggerFactory; import at.gv.egiz.simpleSigning.helper.SessionHelper; -@WebServlet("/Error") public class ErrorSignature extends HttpServlet { /** diff --git a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/FinishSignature.java b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/FinishSignature.java index 33ad8fd..f8cc26a 100644 --- a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/FinishSignature.java +++ b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/FinishSignature.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.io.OutputStream; import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -15,7 +14,6 @@ import org.slf4j.LoggerFactory; import at.gv.egiz.simpleSigning.helper.SessionHelper; -@WebServlet("/Finish") public class FinishSignature extends HttpServlet { /** diff --git a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/JQueryServlet.java b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/JQueryServlet.java index 87693b5..96a8cc3 100644 --- a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/JQueryServlet.java +++ b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/JQueryServlet.java @@ -4,14 +4,12 @@ import java.io.IOException; import java.io.OutputStream; import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.FileUtils; -@WebServlet("/jquery.js") public class JQueryServlet extends HttpServlet { /** diff --git a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/PDFASJsServlet.java b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/PDFASJsServlet.java index 4ea456e..b2a6201 100644 --- a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/PDFASJsServlet.java +++ b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/PDFASJsServlet.java @@ -1,6 +1,5 @@ package at.gv.egiz.simpleSigning; -import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; diff --git a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/Provider.java b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/Provider.java index 7cde301..918956e 100644 --- a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/Provider.java +++ b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/Provider.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.io.OutputStream; import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -14,7 +13,6 @@ import org.slf4j.LoggerFactory; import at.gv.egiz.simpleSigning.helper.SessionHelper; -@WebServlet("/Provide") public class Provider extends HttpServlet { /** * diff --git a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java index e88e85a..e018499 100644 --- a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java +++ b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/StartSignature.java @@ -4,14 +4,11 @@ import java.io.IOException; import java.io.OutputStream; import java.net.MalformedURLException; import java.net.URL; -import java.util.Iterator; import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.Part; import org.apache.commons.fileupload.FileItemIterator; import org.apache.commons.fileupload.FileItemStream; @@ -21,12 +18,11 @@ import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import at.gv.egiz.simpleSigning.helper.SessionHelper.Type; import at.gv.egiz.simpleSigning.cfg.Configuration; import at.gv.egiz.simpleSigning.helper.PDFHelper; import at.gv.egiz.simpleSigning.helper.SessionHelper; +import at.gv.egiz.simpleSigning.helper.SessionHelper.Type; -@WebServlet(urlPatterns = { "/Start" }) public class StartSignature extends HttpServlet { private static final Logger logger = LoggerFactory diff --git a/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/VersionServlet.java b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/VersionServlet.java new file mode 100644 index 0000000..4e03834 --- /dev/null +++ b/simpleSigning/src/main/java/at/gv/egiz/simpleSigning/VersionServlet.java @@ -0,0 +1,86 @@ +package at.gv.egiz.simpleSigning; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.jar.Attributes; +import java.util.jar.Manifest; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class VersionServlet extends HttpServlet { + + /** + * + */ + private static final long serialVersionUID = 6716170050447201588L; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + this.doProcess(req, resp); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + this.doProcess(req, resp); + } + + protected void doProcess(HttpServletRequest req, HttpServletResponse resp) + throws ServletException, IOException { + StringBuilder sb = new StringBuilder(); + sb.append("{\"version\": \""); + sb.append(getVersion()); + sb.append("\", \"scm\": \""); + sb.append(getSCMRevision()); + sb.append("\"}"); + + resp.setContentType("application/json"); + OutputStream os = resp.getOutputStream(); + os.write(sb.toString().getBytes()); + os.close(); + } + + /** + * Gets the PDF-AS SCM Revision + * + * @return + */ + public String getSCMRevision() { + try { + ServletContext application = getServletConfig().getServletContext(); + InputStream inputStream = application + .getResourceAsStream("/META-INF/MANIFEST.MF"); + Manifest manifest = new Manifest(inputStream); + Attributes attributes = manifest.getMainAttributes(); + String impVersion = attributes.getValue("Specification-Version"); + return impVersion; + } catch (Throwable e) { + return "UNKOWN"; + } + } + + /** + * Gets the PDF-AS Version + * + * @return PDF-AS Verison string + */ + public String getVersion() { + try { + ServletContext application = getServletConfig().getServletContext(); + InputStream inputStream = application + .getResourceAsStream("/META-INF/MANIFEST.MF"); + Manifest manifest = new Manifest(inputStream); + Attributes attributes = manifest.getMainAttributes(); + String impVersion = attributes.getValue("Implementation-Version"); + return impVersion; + } catch (Throwable e) { + return "UNKOWN"; + } + } +} diff --git a/simpleSigning/src/main/webapp/WEB-INF/web.xml b/simpleSigning/src/main/webapp/WEB-INF/web.xml index 83c9904..4e292a8 100644 --- a/simpleSigning/src/main/webapp/WEB-INF/web.xml +++ b/simpleSigning/src/main/webapp/WEB-INF/web.xml @@ -15,7 +15,55 @@ <servlet-class>at.gv.egiz.simpleSigning.PDFASJsServlet</servlet-class> <load-on-startup>0</load-on-startup> </servlet> + + <servlet> + <servlet-name>StartSignature</servlet-name> + <display-name>StartSignature</display-name> + <description></description> + <servlet-class>at.gv.egiz.simpleSigning.StartSignature</servlet-class> + <load-on-startup>0</load-on-startup> + </servlet> + + <servlet> + <servlet-name>Provider</servlet-name> + <display-name>Provider</display-name> + <description></description> + <servlet-class>at.gv.egiz.simpleSigning.Provider</servlet-class> + <load-on-startup>0</load-on-startup> + </servlet> + + <servlet> + <servlet-name>JQueryServlet</servlet-name> + <display-name>JQueryServlet</display-name> + <description></description> + <servlet-class>at.gv.egiz.simpleSigning.JQueryServlet</servlet-class> + <load-on-startup>0</load-on-startup> + </servlet> + <servlet> + <servlet-name>FinishSignature</servlet-name> + <display-name>FinishSignature</display-name> + <description></description> + <servlet-class>at.gv.egiz.simpleSigning.FinishSignature</servlet-class> + <load-on-startup>0</load-on-startup> + </servlet> + + <servlet> + <servlet-name>ErrorSignature</servlet-name> + <display-name>ErrorSignature</display-name> + <description></description> + <servlet-class>at.gv.egiz.simpleSigning.ErrorSignature</servlet-class> + <load-on-startup>0</load-on-startup> + </servlet> + + <servlet> + <servlet-name>VersionServlet</servlet-name> + <display-name>VersionServlet</display-name> + <description></description> + <servlet-class>at.gv.egiz.simpleSigning.VersionServlet</servlet-class> + <load-on-startup>0</load-on-startup> + </servlet> + <!-- Define mappings that are used by the servlet container to translate a particular request URI (context-relative) to a particular servlet. The examples below correspond to the servlet descriptions above. Thus, a request @@ -29,6 +77,30 @@ <servlet-name>PDFASJsServlet</servlet-name> <url-pattern>/pdfas.js</url-pattern> </servlet-mapping> + <servlet-mapping> + <servlet-name>StartSignature</servlet-name> + <url-pattern>/Start</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>Provider</servlet-name> + <url-pattern>/Provide</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>JQueryServlet</servlet-name> + <url-pattern>/jquery.js</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>FinishSignature</servlet-name> + <url-pattern>/Finish</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>ErrorSignature</servlet-name> + <url-pattern>/Error</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>VersionServlet</servlet-name> + <url-pattern>/version</url-pattern> + </servlet-mapping> <!-- Define the default session timeout for your application, in minutes. From a servlet or JSP page, you can modify the timeout for a particular session dynamically by using HttpSession.getMaxInactiveInterval(). --> |