From 95f6c6fe321d33dc8fa9e18c7d96bd9b21ef10cc Mon Sep 17 00:00:00 2001 From: tknall Date: Wed, 14 Jan 2009 11:39:31 +0000 Subject: Switching to itext-2.1.5-rev3628. itext library: minor adjustments for pdf-as Adding new error code (103) for invalid pdfa/1b font configuration. Minor updates for PDF/A support. Support for local MOCCA CCS added. Multi language for web application. Encoding issue for web application fixed by implementing an EncodingFilter. Dynamic sign upload form implemented. Order of input fields for dynamic upload form changed. MOCCA logo added to sign upload form. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@319 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../commandline/CommandlineConnectorChooser.java | 2 +- .../at/gv/egiz/pdfas/exceptions/ErrorCode.java | 1 + .../gv/egiz/pdfas/web/filter/EncodingFilter.java | 123 +++++++++++++ .../pdfas/web/i18n/LanguageDecoratorMapper.java | 64 ++++--- .../gv/egiz/pdfas/web/i18n/LocaleParamFilter.java | 96 ++++++++++ .../gv/egiz/pdfas/web/i18n/SetLanguageServlet.java | 59 ------- .../java/at/knowcenter/wag/egov/egiz/PdfAS.java | 2 +- .../egov/egiz/exceptions/SettingsException.java | 58 +++--- .../wag/egov/egiz/pdf/PDFSignatureObjectIText.java | 5 +- .../egov/egiz/sig/connectors/bku/BKUHelper.java | 3 + .../egiz/sig/connectors/bku/BKUPostConnection.java | 11 +- .../sig/connectors/bku/DetachedBKUConnector.java | 13 +- .../moa/MOASoapWithAttachmentConnector.java | 9 - .../mocca/LocRefDetachedMOCCAConnector.java | 139 +-------------- .../egiz/sig/connectors/mocca/MOCCAHelper.java | 194 +++++++++++++++++++++ .../wag/egov/egiz/web/servlets/DataURLServlet.java | 17 +- .../egov/egiz/web/servlets/ProvidePDFServlet.java | 4 +- .../wag/egov/egiz/web/servlets/SignServlet.java | 7 +- .../egov/egiz/web/servlets/UpdateFormServlet.java | 41 +++++ .../egiz/web/servlets/VerifyPreviewServlet.java | 5 +- .../wag/exactparser/parsing/PDFUtils.java | 3 +- src/main/resources/DefaultConfiguration.zip | Bin 181257 -> 648596 bytes .../at/gv/egiz/pdfas/web/i18n/language.properties | 96 ++++++++++ .../gv/egiz/pdfas/web/i18n/language_de.properties | 96 ++++++++++ src/main/webapp/META-INF/context.xml | 2 +- src/main/webapp/WEB-INF/decorators.xml | 3 +- src/main/webapp/WEB-INF/web.xml | 40 ++++- src/main/webapp/images/button-search.jpg | Bin 0 -> 778 bytes src/main/webapp/images/chiperling.jpg | Bin 0 -> 22511 bytes src/main/webapp/images/menu-divider.jpg | Bin 0 -> 485 bytes src/main/webapp/images/signatur-logo_en-100.png | Bin 0 -> 10037 bytes src/main/webapp/images/signatur-logo_en.png | Bin 0 -> 60055 bytes src/main/webapp/jsp/SIGNATURBLOCK.jsp | 110 ++++++++++++ src/main/webapp/jsp/SIGNATURBLOCK_DE.jsp | 61 ------- src/main/webapp/jsp/dataok.jsp | 15 +- src/main/webapp/jsp/download.jsp | 16 +- src/main/webapp/jsp/error.jsp | 23 ++- src/main/webapp/jsp/error_verify.jsp | 12 +- src/main/webapp/jsp/language.jsp | 9 + src/main/webapp/jsp/null_request_page.jsp | 52 ++++-- src/main/webapp/jsp/please_wait.jsp | 16 ++ src/main/webapp/jsp/results.jsp | 28 +-- src/main/webapp/jsp/signpreview.jsp | 26 ++- src/main/webapp/jsp/signupload.jsp | 174 ++++++++++++++---- src/main/webapp/jsp/verifylist.jsp | 17 +- src/main/webapp/jsp/verifypreview.jsp | 17 +- src/main/webapp/jsp/verifyupload.jsp | 23 +-- .../sitemesh/buergerkarte/pdf-as-template-de.jsp | 140 +++++++++++++++ .../sitemesh/buergerkarte/pdf-as-template.jsp | 160 +++++++++++++++++ .../buergerkarte/test-pdf-as-template-de.jsp | 140 +++++++++++++++ .../sitemesh/buergerkarte/test-pdf-as-template.jsp | 160 +++++++++++++++++ src/main/webapp/sitemesh/standalone.jsp | 4 +- 52 files changed, 1834 insertions(+), 462 deletions(-) create mode 100644 src/main/java/at/gv/egiz/pdfas/web/filter/EncodingFilter.java create mode 100644 src/main/java/at/gv/egiz/pdfas/web/i18n/LocaleParamFilter.java delete mode 100644 src/main/java/at/gv/egiz/pdfas/web/i18n/SetLanguageServlet.java create mode 100644 src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/MOCCAHelper.java create mode 100644 src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/UpdateFormServlet.java create mode 100644 src/main/resources/at/gv/egiz/pdfas/web/i18n/language.properties create mode 100644 src/main/resources/at/gv/egiz/pdfas/web/i18n/language_de.properties create mode 100644 src/main/webapp/images/button-search.jpg create mode 100644 src/main/webapp/images/chiperling.jpg create mode 100644 src/main/webapp/images/menu-divider.jpg create mode 100644 src/main/webapp/images/signatur-logo_en-100.png create mode 100644 src/main/webapp/images/signatur-logo_en.png create mode 100644 src/main/webapp/jsp/SIGNATURBLOCK.jsp delete mode 100644 src/main/webapp/jsp/SIGNATURBLOCK_DE.jsp create mode 100644 src/main/webapp/jsp/language.jsp create mode 100644 src/main/webapp/jsp/please_wait.jsp create mode 100644 src/main/webapp/sitemesh/buergerkarte/pdf-as-template-de.jsp create mode 100644 src/main/webapp/sitemesh/buergerkarte/pdf-as-template.jsp create mode 100644 src/main/webapp/sitemesh/buergerkarte/test-pdf-as-template-de.jsp create mode 100644 src/main/webapp/sitemesh/buergerkarte/test-pdf-as-template.jsp (limited to 'src/main') diff --git a/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java b/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java index 7a8283e..904bd9d 100644 --- a/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java +++ b/src/main/java/at/gv/egiz/pdfas/commandline/CommandlineConnectorChooser.java @@ -71,7 +71,7 @@ public class CommandlineConnectorChooser if (sig_kz == null) { - log.debug("sig_kz is null -> chose an old enveloped base64 connector"); //$NON-NLS-1$ + log.debug("sig_kz is null -> choosing an old enveloped base64 connector"); //$NON-NLS-1$ return chooseEnvelopingBase64ConnectorOld(connectorType); } diff --git a/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java b/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java index ab8914c..f6b5602 100644 --- a/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java +++ b/src/main/java/at/gv/egiz/pdfas/exceptions/ErrorCode.java @@ -19,6 +19,7 @@ public final class ErrorCode public static final int SETTING_NOT_FOUND = 100; public static final int SETTINGS_EXCEPTION = 101; public static final int KZ_SETTING_NOT_FOUND = 102; + public static final int NO_EMBEDABLE_TTF_CONFIGURED_FOR_PDFA = 103; public static final int DOCUMENT_CANNOT_BE_READ = 201; public static final int TEXT_EXTRACTION_EXCEPTION = 202; diff --git a/src/main/java/at/gv/egiz/pdfas/web/filter/EncodingFilter.java b/src/main/java/at/gv/egiz/pdfas/web/filter/EncodingFilter.java new file mode 100644 index 0000000..5267918 --- /dev/null +++ b/src/main/java/at/gv/egiz/pdfas/web/filter/EncodingFilter.java @@ -0,0 +1,123 @@ +package at.gv.egiz.pdfas.web.filter; + +import java.io.IOException; +import java.nio.charset.Charset; + +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.log4j.Logger; + +/** + * @author Thomas Knall + */ +public class EncodingFilter implements javax.servlet.Filter { + + private static final String SERVLET_INIT_PARAM_ENCODING = "encoding"; + + private static final String SERVLET_INIT_PARAM_SET_REQUEST_ENCODING = "setRequestEncoding"; + private static final String SERVLET_INIT_PARAM_FORCE_REQUEST_ENCODING = "forceRequestEncoding"; + + private static final String SERVLET_INIT_PARAM_SET_RESPONSE_ENCODING = "setResponseEncoding"; + private static final String SERVLET_INIT_PARAM_FORCE_RESPONSE_ENCODING = "forceResponseEncoding"; + + private static final boolean DEFAULT_SET_REQUEST_ENCODING_VALUE = true; + private static final boolean DEFAULT_FORCE_REQUEST_ENCODING_VALUE = true; + private static final boolean DEFAULT_SET_RESPONSE_ENCODING_VALUE = false; + private static final boolean DEFAULT_FORCE_RESPONSE_ENCODING_VALUE = false; + + private Logger log = Logger.getLogger(getClass().getName()); + + private String encoding = null; + + private boolean setRequestEncoding; + private boolean forceRequestEncoding; + + private boolean setResponseEncoding; + private boolean forceResponseEncoding; + + private boolean enabled = false; + + private boolean parseBooleanInitParameter(final FilterConfig filterConfig, String parameterName, boolean defaultValue) { + String paramValue = filterConfig.getInitParameter(parameterName); + if (paramValue == null) { + return defaultValue; + } + paramValue = paramValue.trim(); + if (paramValue.equalsIgnoreCase("true")) { + return true; + } else if (paramValue.equalsIgnoreCase("false")){ + return false; + } else { + log.warn("Unknown value \"" + paramValue + "\" for init parameter \"" + parameterName + "\" detected. Should be \"true\" or \"false\". Using default value \"" + defaultValue + "\"."); + return defaultValue; + } + } + + public void init(final FilterConfig filterConfig) throws ServletException { + log.debug("Initializing encoding filter (" + getClass().getName() + ")."); + + // mandatory parameter encoding + String desiredEncoding = filterConfig.getInitParameter(SERVLET_INIT_PARAM_ENCODING); + if (StringUtils.isEmpty(desiredEncoding)) { + log.warn("Unable to initialize encoding filter (" + getClass().getName() + "). Init parameter \"" + SERVLET_INIT_PARAM_ENCODING + "\" empty or not supplied."); + } else if (!Charset.isSupported(desiredEncoding)) { + log.warn("Unable to initialize encoding filter (" + getClass().getName() + "). Encoding \"" + desiredEncoding + "\" is not supported."); + } else { + this.encoding = desiredEncoding; + this.enabled = true; + this.setRequestEncoding = this.parseBooleanInitParameter(filterConfig, SERVLET_INIT_PARAM_SET_REQUEST_ENCODING, DEFAULT_SET_REQUEST_ENCODING_VALUE); + this.forceRequestEncoding = this.parseBooleanInitParameter(filterConfig, SERVLET_INIT_PARAM_FORCE_REQUEST_ENCODING, DEFAULT_FORCE_REQUEST_ENCODING_VALUE); + this.setResponseEncoding = this.parseBooleanInitParameter(filterConfig, SERVLET_INIT_PARAM_SET_RESPONSE_ENCODING, DEFAULT_SET_RESPONSE_ENCODING_VALUE); + this.forceResponseEncoding = this.parseBooleanInitParameter(filterConfig, SERVLET_INIT_PARAM_FORCE_RESPONSE_ENCODING, DEFAULT_FORCE_RESPONSE_ENCODING_VALUE); + log.debug("Encoding filter \"" + getClass().getName() + "\" configured: " + this.toString(true)); + + } + } + + public String toString(boolean verbose) { + if (verbose) { + return new ToStringBuilder(this) + .append(SERVLET_INIT_PARAM_ENCODING, this.encoding) + .append(SERVLET_INIT_PARAM_SET_REQUEST_ENCODING, this.setRequestEncoding) + .append(SERVLET_INIT_PARAM_FORCE_REQUEST_ENCODING, this.forceRequestEncoding) + .append(SERVLET_INIT_PARAM_SET_RESPONSE_ENCODING, this.setResponseEncoding) + .append(SERVLET_INIT_PARAM_FORCE_RESPONSE_ENCODING, this.forceResponseEncoding) + .toString(); + } else { + return super.toString(); + } + } + + public void doFilter(ServletRequest request, ServletResponse response, final FilterChain filterChain) throws IOException, ServletException { + if (this.enabled) { + if (this.setRequestEncoding) { + if (this.forceRequestEncoding) { + log.trace("Forcing request encoding \"" + this.encoding + "\"."); + request.setCharacterEncoding(this.encoding); + } else if (request.getCharacterEncoding() == null) { + log.trace("Request character encoding not set. Setting to \"" + this.encoding + "\"."); + request.setCharacterEncoding("UTF8"); + } + } + if (this.setResponseEncoding) { + if (this.forceResponseEncoding) { + log.trace("Forcing response encoding \"" + this.encoding + "\"."); + response.setCharacterEncoding(this.encoding); + } else if (response.getCharacterEncoding() == null) { + log.trace("Response character encoding not set. Setting to \"" + this.encoding + "\"."); + response.setCharacterEncoding("UTF8"); + } + } + } + filterChain.doFilter(request, response); + } + + public void destroy() { + } +} diff --git a/src/main/java/at/gv/egiz/pdfas/web/i18n/LanguageDecoratorMapper.java b/src/main/java/at/gv/egiz/pdfas/web/i18n/LanguageDecoratorMapper.java index 1db7e3b..c610e42 100644 --- a/src/main/java/at/gv/egiz/pdfas/web/i18n/LanguageDecoratorMapper.java +++ b/src/main/java/at/gv/egiz/pdfas/web/i18n/LanguageDecoratorMapper.java @@ -18,9 +18,10 @@ import com.opensymphony.module.sitemesh.mapper.DefaultDecorator; public class LanguageDecoratorMapper extends AbstractDecoratorMapper { - public static final String LOCALE_SESSION_KEY = "at.gv.egiz.pdfas.web.i18n:currentLocale"; - private Logger log = Logger.getLogger(LanguageDecoratorMapper.class); + private String decoratorParameter = null; + + private static final Logger LOG = Logger.getLogger(LanguageDecoratorMapper.class); public void init(Config config, Properties properties, DecoratorMapper parent) throws InstantiationException { super.init(config, properties, parent); @@ -37,29 +38,42 @@ public class LanguageDecoratorMapper extends AbstractDecoratorMapper { } return null; } + + public static Locale getLocale(HttpServletRequest request, String decoratorParameter) { + Locale locale = null; + HttpSession session = request.getSession(); + + LOG.trace("Looking for locale in session (ID=" + session.getId() + ")."); + locale = (Locale) session.getAttribute(LocaleParamFilter.LOCALE_SESSION_KEY); + if (locale == null) { + LOG.debug("Unable to find locale in session. Trying to create new locale based on Accept-Language header entry."); + String acceptLanguage = request.getHeader("Accept-Language"); + if (acceptLanguage != null) { + LOG.trace("Accept-Language header entry: " + acceptLanguage); + } else { + LOG.trace("No header entry found."); + } + if (acceptLanguage != null && acceptLanguage.length() >= 2) { + locale = new Locale(acceptLanguage.substring(0, 2)); + LOG.debug("New Locale created: " + locale); + LOG.trace("Setting language to " + locale.getDisplayLanguage() + "."); + session.setAttribute(LocaleParamFilter.LOCALE_SESSION_KEY, locale); + } + } else { + LOG.debug("Locale found: " + locale); + } + + return locale; + } public Decorator getDecorator(HttpServletRequest request, Page page) { + LOG.trace("SiteMesh language resource decorator mapper invoked."); + try { Decorator result = null; final Decorator d = super.getDecorator(request, page); - HttpSession session = request.getSession(); - log.trace("Looking for Locale in session."); - Locale locale = (Locale) session.getAttribute(LOCALE_SESSION_KEY); - if (locale == null) { - log.debug("Unable to find Locale in session. Creating new Locale based on Accept-Language header entry."); - String acceptLanguage = request.getHeader("Accept-Language"); - if (acceptLanguage != null) { - log.trace("Accept-Language header entry: " + acceptLanguage); - } else { - log.trace("No header entry found."); - } - if (acceptLanguage != null && acceptLanguage.length() >= 2) { - locale = new Locale(acceptLanguage.substring(0, 2)); - log.debug("New Locale created: " + locale); - } - } else { - log.debug("Locale found: " + locale); - } + Locale locale = getLocale(request, this.decoratorParameter); + String path; if (locale != null) { path = modifyPath(d.getPage(), locale.getLanguage()); @@ -69,7 +83,7 @@ public class LanguageDecoratorMapper extends AbstractDecoratorMapper { File decFile = new File(config.getServletContext().getRealPath(path)); - log.debug("Looking for decorator \"" + path + "\"."); + LOG.debug("Looking for decorator \"" + path + "\"."); if (decFile.isFile()) { result = new DefaultDecorator(d.getName(), path, null) { public String getInitParameter(String paramName) { @@ -79,15 +93,15 @@ public class LanguageDecoratorMapper extends AbstractDecoratorMapper { } if (result != null) { - log.debug("Decorator found (\"" + result.getName() + "\", \"" + getFirstNotNull(new Object[] { result.getURIPath(), result.getPage(), ""}) + "\")."); + LOG.debug("Decorator found (\"" + result.getName() + "\", \"" + getFirstNotNull(new Object[] { result.getURIPath(), result.getPage(), ""}) + "\")."); return result; } else { - log.trace("No decorator found. Delegating to super class."); + LOG.trace("No decorator found. Delegating to super class."); result = super.getDecorator(request, page); if (result != null) { - log.debug("Super class returned decorator (\"" + result.getName() + "\", \"" + getFirstNotNull(new Object[] { result.getURIPath(), result.getPage(), ""}) + "\")."); + LOG.debug("Super class returned decorator (\"" + result.getName() + "\", \"" + getFirstNotNull(new Object[] { result.getURIPath(), result.getPage(), ""}) + "\")."); } else { - log.trace("Super class did not return a decorator."); + LOG.trace("Super class did not return a decorator."); } return result; } diff --git a/src/main/java/at/gv/egiz/pdfas/web/i18n/LocaleParamFilter.java b/src/main/java/at/gv/egiz/pdfas/web/i18n/LocaleParamFilter.java new file mode 100644 index 0000000..598b23b --- /dev/null +++ b/src/main/java/at/gv/egiz/pdfas/web/i18n/LocaleParamFilter.java @@ -0,0 +1,96 @@ +package at.gv.egiz.pdfas.web.i18n; + +import java.io.IOException; +import java.util.Locale; +import java.util.StringTokenizer; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.commons.lang.LocaleUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; + +public class LocaleParamFilter implements Filter { + + private static final Logger LOG = Logger.getLogger(LocaleParamFilter.class); + public static final String LOCALE_SESSION_KEY = "at.gv.egiz.pdfas.web.i18n:currentLocale"; + public static final String LOCALE_PARAM_KEY = "locale"; + + public void destroy() { + } + + public static String normalizeLocaleString(String localeString) { + if (localeString == null) { + return null; + } + int jsessionIdIndex = localeString.toLowerCase().indexOf(";jsessionid"); + if (jsessionIdIndex != -1) { + localeString = localeString.substring(0, jsessionIdIndex); + } + StringTokenizer tokenizer = new StringTokenizer(localeString, "_", false); + StringBuffer buffer = new StringBuffer(); + int index = 0; + while (tokenizer.hasMoreTokens()) { + String token = tokenizer.nextToken(); + switch (++index) { + case 1: + buffer.append(token.toLowerCase()); + break; + case 2: + buffer.append(token.toUpperCase()); + break; + default: + buffer.append(token); + break; + } + if (tokenizer.hasMoreTokens()) { + buffer.append("_"); + } + } + return buffer.toString(); + } + + public static Locale getLocale(HttpServletRequest request) { + Locale locale = null; + HttpSession session = request.getSession(); + + LOG.trace("Looking for locale parameter \"" + LOCALE_PARAM_KEY + "\"."); + String language = request.getParameter(LOCALE_PARAM_KEY); + if (!StringUtils.isEmpty(language)) { + LOG.debug("Locale parameter \"" + language + "\" found."); + String code = normalizeLocaleString(language.trim()); + LOG.debug("Normalizing locale -> " + code); + try { + locale = LocaleUtils.toLocale(code); + LOG.info("Setting locale flag in session (ID=" + session.getId() + ") to \"" + locale.toString() + "\"."); + session.setAttribute(LOCALE_SESSION_KEY, locale); + } catch (IllegalArgumentException e) { + LOG.error("Locale \"" + code + "\" is not valid. Flag will not be set."); + } + } else { + LOG.trace("No locale parameter found."); + } + + return locale; + } + + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + HttpServletRequest request = (HttpServletRequest) servletRequest; + + LOG.trace("LocaleParamFilter invoked."); + getLocale(request); + + filterChain.doFilter(servletRequest, servletResponse); + } + + public void init(FilterConfig filterConfig) throws ServletException { + } + +} diff --git a/src/main/java/at/gv/egiz/pdfas/web/i18n/SetLanguageServlet.java b/src/main/java/at/gv/egiz/pdfas/web/i18n/SetLanguageServlet.java deleted file mode 100644 index 582f765..0000000 --- a/src/main/java/at/gv/egiz/pdfas/web/i18n/SetLanguageServlet.java +++ /dev/null @@ -1,59 +0,0 @@ -package at.gv.egiz.pdfas.web.i18n; - -import java.io.IOException; -import java.util.Locale; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; - -public class SetLanguageServlet extends HttpServlet { - - private static final long serialVersionUID = 1L; - - public static final String LANGUAGE_PARAMETER = "code"; - private Logger log = Logger.getLogger(LanguageDecoratorMapper.class); - - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - this.doPost(request, response); - } - - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - HttpSession session = request.getSession(); - - // check manual language override (should be two-letter ISO-639 code) - Locale currentManualSetLanguage = (Locale) session.getAttribute(LanguageDecoratorMapper.LOCALE_SESSION_KEY); - String language = request.getParameter(LANGUAGE_PARAMETER); - if (!StringUtils.isEmpty(language)) { - String code = language.trim().toLowerCase(); - if (!ArrayUtils.contains(Locale.getISOLanguages(), code)) { - log.error("Manually set language code \"" + code + "\" is not a valid ISO 639 language. Do not switch language."); - } else { - currentManualSetLanguage = new Locale(code); - log.info("Switching language to " + currentManualSetLanguage.getDisplayLanguage() + "."); - session.setAttribute(LanguageDecoratorMapper.LOCALE_SESSION_KEY, currentManualSetLanguage); - } - } - -// if (currentManualSetLanguage != null) { -// log.info("Forcing language " + currentManualSetLanguage.getDisplayLanguage() + "."); -// super.getServletContext().setAttribute(LanguageDecoratorMapper.LOCALE_SESSION_KEY, currentManualSetLanguage); -// } - -// response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/")); - RequestDispatcher rd = request.getRequestDispatcher("/"); - rd.forward(request, response); - - } - - - -} diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java index 2ffc7b2..3824a98 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java @@ -96,7 +96,7 @@ public abstract class PdfAS * The current version of the pdf-as library. This version string is logged on every invocation * of the api or the web application. */ - public static final String PDFAS_VERSION = "3.0.8-20081119"; + public static final String PDFAS_VERSION = "3.0.8-20090113"; /** * The key of the strict mode setting. diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/exceptions/SettingsException.java b/src/main/java/at/knowcenter/wag/egov/egiz/exceptions/SettingsException.java index d781577..1a41982 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/exceptions/SettingsException.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/exceptions/SettingsException.java @@ -29,28 +29,38 @@ import at.gv.egiz.pdfas.exceptions.ErrorCode; * * @author wprinz */ -public class SettingsException extends PresentableException -{ - - /** - * SVUID. - */ - private static final long serialVersionUID = -99979541706943372L; - - /** - * @param message - */ - public SettingsException(String message) - { - super(ErrorCode.SETTINGS_EXCEPTION, message); - } - - /** - * @param message - * @param cause - */ - public SettingsException(String message, Throwable cause) - { - super(ErrorCode.SETTINGS_EXCEPTION, message, cause); - } +public class SettingsException extends PresentableException { + + /** + * SVUID. + */ + private static final long serialVersionUID = -99979541706943372L; + + /** + * @param message + */ + public SettingsException(String message) { + super(ErrorCode.SETTINGS_EXCEPTION, message); + } + + /** + * @param message + * @param cause + */ + public SettingsException(String message, Throwable cause) { + super(ErrorCode.SETTINGS_EXCEPTION, message, cause); + } + + public SettingsException(int errorCode, String message, Throwable cause) { + super(errorCode, message, cause); + } + + public SettingsException(int errorCode, String message) { + super(errorCode, message); + } + + public SettingsException(int errorCode, Throwable cause) { + super(errorCode, cause); + } + } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java index b1b1a5a..0467bad 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/PDFSignatureObjectIText.java @@ -359,8 +359,9 @@ public class PDFSignatureObjectIText implements PDFSignatureObject } else { - if(pdfaValid) - throw new PDFDocumentException(0,"PDF/A modus requires an embedable true type font"); + if (pdfaValid) { + throw new PDFDocumentException(ErrorCode.NO_EMBEDABLE_TTF_CONFIGURED_FOR_PDFA, "PDF/A modus requires an embedable true type font"); + } cell_font = getCellFont(font_string); } Phrase text_phrase = new Phrase(text, cell_font); diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java index 9253955..cec8d6f 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUHelper.java @@ -156,6 +156,9 @@ public final class BKUHelper public static SignSignatureObject parseCreateXMLResponse(String xmlResponse, IdFormatter id_formatter) throws ConnectorException { + if (log.isDebugEnabled()) { + log.debug("xmlResponse = " + xmlResponse); + } Pattern sig_val_p_s = Pattern.compile("<[\\w]*:?SignatureValue>"); //$NON-NLS-1$ Pattern sig_val_p_e = Pattern.compile(""); //$NON-NLS-1$ Pattern iss_nam_p_s = Pattern.compile("<[\\w]*:?X509IssuerName>"); //$NON-NLS-1$ diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java index 1a720d8..b582715 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/BKUPostConnection.java @@ -40,6 +40,11 @@ public final class BKUPostConnection */ public static final String BKU_SERVER_HEADER_KEY = "BKU-Server-Header"; //$NON-NLS-1$ + /** + * The response Properties key that identifies the BKU User-Agent header. + */ + public static final String BKU_USER_AGENT_HEADER_KEY = "BKU-User-Agent-Header"; //$NON-NLS-1$ + /** * The log. */ @@ -119,7 +124,11 @@ public final class BKUPostConnection } } Header server_header = post_method.getResponseHeader("Server"); //$NON-NLS-1$ - response_properties.setProperty(BKU_SERVER_HEADER_KEY, server_header.getValue()); + if (server_header != null) { + response_properties.setProperty(BKU_SERVER_HEADER_KEY, server_header.getValue()); + } else { + log.warn("BKU response header \"Server\" is empty."); + } log.debug(post_method.getResponseCharSet()); if (!post_method.getResponseCharSet().equals("UTF-8")) //$NON-NLS-1$ diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java index 5dbc0a6..d10afc6 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java @@ -21,7 +21,9 @@ import at.knowcenter.wag.egov.egiz.sig.connectors.Connector; import at.knowcenter.wag.egov.egiz.sig.connectors.LocalConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.TemplateReplaces; import at.knowcenter.wag.egov.egiz.sig.connectors.moa.DetachedLocRefMOAConnector; +import at.knowcenter.wag.egov.egiz.sig.connectors.mocca.MOCCAHelper; import at.knowcenter.wag.egov.egiz.sig.sigid.DetachedIdFormatter; +import at.knowcenter.wag.egov.egiz.sig.sigid.DetachedMOCIdFormatter; import at.knowcenter.wag.egov.egiz.sig.sigkz.SigKZIDHelper; import at.knowcenter.wag.egov.egiz.tools.CodingHelper; import at.knowcenter.wag.egov.egiz.tools.FileHelper; @@ -123,10 +125,19 @@ public class DetachedBKUConnector implements Connector, LocalConnector log.debug("analyzeSignResponse:"); //$NON-NLS-1$ String response_string = response_properties.getProperty(BKUPostConnection.RESPONSE_STRING_KEY); + String bkuServerHeader = response_properties.getProperty(BKUPostConnection.BKU_SERVER_HEADER_KEY); + String bkuUserAgentHeader = response_properties.getProperty(BKUPostConnection.BKU_USER_AGENT_HEADER_KEY); BKUHelper.checkResponseForError(response_string); - SignSignatureObject so = BKUHelper.parseCreateXMLResponse(response_string, new DetachedIdFormatter()); + SignSignatureObject so; + if (MOCCAHelper.isMOCCACCEId(bkuServerHeader == null ? bkuUserAgentHeader : bkuServerHeader)) { + log.debug("Evaluating response as MOCCA response."); + so = MOCCAHelper.parseCreateXMLResponse(response_string, new DetachedMOCIdFormatter()); + } else { + so = BKUHelper.parseCreateXMLResponse(response_string, new DetachedIdFormatter()); + } + so.response_properties = response_properties; log.debug("analyzeSignResponse finished."); //$NON-NLS-1$ diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java index 44a7c38..b45303d 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/MOASoapWithAttachmentConnector.java @@ -4,15 +4,7 @@ package at.knowcenter.wag.egov.egiz.sig.connectors.moa; import java.security.cert.X509Certificate; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; import java.util.Properties; -import java.util.SimpleTimeZone; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -22,7 +14,6 @@ import at.gv.egiz.pdfas.framework.ConnectorParameters; import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException; import at.knowcenter.wag.egov.egiz.exceptions.SettingsException; -import at.knowcenter.wag.egov.egiz.exceptions.SignatureException; import at.knowcenter.wag.egov.egiz.sig.SignatureData; import at.knowcenter.wag.egov.egiz.sig.SignatureResponse; import at.knowcenter.wag.egov.egiz.sig.connectors.Connector; diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java index 8ae6d5f..fcfe006 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java @@ -1,10 +1,5 @@ package at.knowcenter.wag.egov.egiz.sig.connectors.mocca; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.Properties; import java.util.regex.Matcher; @@ -15,16 +10,11 @@ import org.apache.commons.logging.LogFactory; import at.gv.egiz.pdfas.exceptions.ErrorCode; import at.gv.egiz.pdfas.framework.ConnectorParameters; -import at.gv.egiz.pdfas.web.helper.SigningTimeHelper; import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException; -import at.knowcenter.wag.egov.egiz.exceptions.PresentableException; import at.knowcenter.wag.egov.egiz.exceptions.SettingsException; -import at.knowcenter.wag.egov.egiz.exceptions.SignatureException; import at.knowcenter.wag.egov.egiz.sig.SignatureData; -import at.knowcenter.wag.egov.egiz.sig.SignatureObject; import at.knowcenter.wag.egov.egiz.sig.SignatureResponse; -import at.knowcenter.wag.egov.egiz.sig.X509Cert; import at.knowcenter.wag.egov.egiz.sig.connectors.Connector; import at.knowcenter.wag.egov.egiz.sig.connectors.LocalConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.TemplateReplaces; @@ -32,7 +22,6 @@ import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUHelper; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUPostConnection; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject; import at.knowcenter.wag.egov.egiz.sig.sigid.DetachedMOCIdFormatter; -import at.knowcenter.wag.egov.egiz.sig.sigid.IdFormatter; import at.knowcenter.wag.egov.egiz.tools.CodingHelper; import at.knowcenter.wag.egov.egiz.tools.FileHelper; @@ -126,138 +115,12 @@ public class LocRefDetachedMOCCAConnector implements Connector, LocalConnector { log.debug("analyzeSignResponse:"); String response_string = response_properties.getProperty(BKUPostConnection.RESPONSE_STRING_KEY); BKUHelper.checkResponseForError(response_string); - SignSignatureObject so = this.parseCreateXMLResponse(response_string, new DetachedMOCIdFormatter()); + SignSignatureObject so = MOCCAHelper.parseCreateXMLResponse(response_string, new DetachedMOCIdFormatter()); so.response_properties = response_properties; log.debug("analyzeSignResponse finished."); return so; } - /** - * This method parses the signature creation response of the signature device. - * @param xmlResponse The response string. - * @return Returns the parsed signature object holding the data. - * @see SignatureObject - * @see CodingHelper - * @see X509Cert - */ - public SignSignatureObject parseCreateXMLResponse(String xmlResponse, IdFormatter id_formatter) throws ConnectorException { - - Pattern iss_nam_p_s = Pattern.compile("<[\\w]*:?X509IssuerName>"); - Pattern iss_nam_p_e = Pattern.compile(""); - Pattern sig_tim_p_s = Pattern.compile("<[\\w]*:?SigningTime>"); - Pattern sig_tim_p_e = Pattern.compile(""); - Pattern ser_num_p_s = Pattern.compile("<[\\w]*:?X509SerialNumber>"); - Pattern ser_num_p_e = Pattern.compile(""); - Pattern sig_cer_p_s = Pattern.compile("<[\\w]*:?X509Certificate>"); - Pattern sig_cer_p_e = Pattern.compile(""); - - Matcher iss_nam_m_s = iss_nam_p_s.matcher(xmlResponse); - Matcher iss_nam_m_e = iss_nam_p_e.matcher(xmlResponse); - Matcher sig_tim_m_s = sig_tim_p_s.matcher(xmlResponse); - Matcher sig_tim_m_e = sig_tim_p_e.matcher(xmlResponse); - Matcher ser_num_m_s = ser_num_p_s.matcher(xmlResponse); - Matcher ser_num_m_e = ser_num_p_e.matcher(xmlResponse); - Matcher sig_cer_m_s = sig_cer_p_s.matcher(xmlResponse); - Matcher sig_cer_m_e = sig_cer_p_e.matcher(xmlResponse); - - // SignatureValue - String sig_val = null; - Matcher signatureValueMatcher = Pattern.compile("<(\\w+:)?SignatureValue( Id=\"[\\w-]+\")?>\\s*(.*)\\s*").matcher(xmlResponse); - if (signatureValueMatcher.find()) { - sig_val = signatureValueMatcher.group(3); - } - log.debug("sig_val = " + sig_val); - - // X509IssuerName - String iss_nam = null; - if (iss_nam_m_s.find() && iss_nam_m_e.find()) { - iss_nam = xmlResponse.substring(iss_nam_m_s.end(), iss_nam_m_e.start()); - } - log.debug("iss_nam = " + iss_nam); - - // X509SerialNumber - String ser_num = null; - if (ser_num_m_s.find() && ser_num_m_e.find()) { - ser_num = BKUHelper.removeAllWhitespace(xmlResponse.substring(ser_num_m_s.end(), ser_num_m_e.start())); - } - log.debug("ser_num = " + ser_num); - - // SigningTime - String sig_tim = null; - if (sig_tim_m_s.find() && sig_tim_m_e.find()) { - sig_tim = xmlResponse.substring(sig_tim_m_s.end(), sig_tim_m_e.start()); - } - log.debug("sig_tim = " + sig_tim); - - // X509Certificate - X509Certificate cert = null; - if (sig_cer_m_s.find() && sig_cer_m_e.find()) { - String sig_cer = BKUHelper.removeAllWhitespace(xmlResponse.substring(sig_cer_m_s.end(), sig_cer_m_e.start())); - - try { - byte[] der = CodingHelper.decodeBase64(sig_cer); - ByteArrayInputStream bais = new ByteArrayInputStream(der); - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - cert = (X509Certificate) cf.generateCertificate(bais); - bais.close(); - } catch (UnsupportedEncodingException e) { - throw new ConnectorException(300, e); - } catch (CertificateException e) { - throw new ConnectorException(300, e); - } catch (IOException e) { - throw new ConnectorException(300, e); - } - } - log.debug("X509Certificate = " + cert); - - if (log.isDebugEnabled()) { - - String cert_iss = cert.getIssuerDN().getName(); - log.debug("certificate's issuer = " + cert_iss); - log.debug("response's issuer = " + iss_nam); - log.debug("issuer matches = " + cert_iss.equals(iss_nam)); - log.debug("ser number matches = " + cert.getSerialNumber().toString().equals(ser_num)); - } - - // extract Signature Id's - String[] ids = extractIds(xmlResponse); - String final_ids = id_formatter.formatIds(ids); - - SignSignatureObject so = new SignSignatureObject(); - so.date = sig_tim; - so.issuer = iss_nam; - so.signatureValue = sig_val; - so.x509Certificate = cert; - - so.id = final_ids; - - return so; - } - - /** - * Extraction of the id attributes from the xml response. - * @param xmlResponse The xml response. - * @return The parsed id attributes. - */ - public final static String[] extractIds(String xmlResponse) { - return new String[] { extractId(xmlResponse) }; - } - - /** - * There is only one special common part of all id attributes of this connector that has to be - * stored. This method returns that single part. - * @param xmlResponse The xml response. - * @return The parsed common part of all id attributes. - */ - private final static String extractId(String xmlResponse) { - final Pattern ID_PATTERN = Pattern.compile("Id\\s*=\\s*\"\\s*Signature-([\\p{XDigit}]+)-\\d+\\s*\""); - Matcher matcher = ID_PATTERN.matcher(xmlResponse); - if (matcher.find() && matcher.groupCount() > 0) { - return matcher.group(1); - } - return null; - } - /** * Verification is not supported by MOCCA. Therefore this method always throws a * {@link ConnectorException} with error code {@link ErrorCode#SIGNATURE_VERIFICATION_NOT_SUPPORTED}. diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/MOCCAHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/MOCCAHelper.java new file mode 100644 index 0000000..1bb89be --- /dev/null +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/MOCCAHelper.java @@ -0,0 +1,194 @@ +package at.knowcenter.wag.egov.egiz.sig.connectors.mocca; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException; +import at.knowcenter.wag.egov.egiz.sig.SignatureObject; +import at.knowcenter.wag.egov.egiz.sig.X509Cert; +import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUHelper; +import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject; +import at.knowcenter.wag.egov.egiz.sig.sigid.IdFormatter; +import at.knowcenter.wag.egov.egiz.tools.CodingHelper; + +/** + * Provides useful methods for the usage of the open source cce mocca. + * + * @author tknall + */ +public final class MOCCAHelper { + + /** + * Prevents this plain util class from being instantiated. + */ + private MOCCAHelper() { + } + + /** + * The logging implementation. + */ + private final static Log log = LogFactory.getLog(MOCCAHelper.class); + + /** + * The pattern that identifies a mocca response (that matches the header value "Server" or "User-Agent"). + */ + private final static Pattern MOCCA_PATTERN = Pattern.compile("(citizen-card-environment/\\d+(\\.\\d+) MOCCA[ /].*)|(Jetty(.*))"); + + /** + * Checks if the given header value for "Server" or "User-Agent" respectively indicates that + * the response was from a mocca cce. + * @param cceId The value of the http header "Server" or "User-Agent". + * @see http://www.buergerkarte.at/konzept/securitylayer/spezifikation/aktuell/bindings/bindings.html#http.kodierung + * @return true if the id points to a mocca response, false if not. + */ + public final static boolean isMOCCACCEId(String cceId) { + if (cceId == null) { + return false; + } + return MOCCA_PATTERN.matcher(cceId).matches(); + } + + /** + * This method parses the signature creation response of the signature + * device mocca. + * + * @param xmlResponse The response string. + * @return Returns the parsed signature object holding the data. + * @see SignatureObject + * @see CodingHelper + * @see X509Cert + */ + public final static SignSignatureObject parseCreateXMLResponse(String xmlResponse, IdFormatter id_formatter) throws ConnectorException { + + if (log.isDebugEnabled()) { + log.debug("xmlResponse = " + xmlResponse); + } + + Pattern iss_nam_p_s = Pattern.compile("<[\\w]*:?X509IssuerName>"); + Pattern iss_nam_p_e = Pattern.compile(""); + Pattern sig_tim_p_s = Pattern.compile("<[\\w]*:?SigningTime>"); + Pattern sig_tim_p_e = Pattern.compile(""); + Pattern ser_num_p_s = Pattern.compile("<[\\w]*:?X509SerialNumber>"); + Pattern ser_num_p_e = Pattern.compile(""); + Pattern sig_cer_p_s = Pattern.compile("<[\\w]*:?X509Certificate>"); + Pattern sig_cer_p_e = Pattern.compile(""); + + Matcher iss_nam_m_s = iss_nam_p_s.matcher(xmlResponse); + Matcher iss_nam_m_e = iss_nam_p_e.matcher(xmlResponse); + Matcher sig_tim_m_s = sig_tim_p_s.matcher(xmlResponse); + Matcher sig_tim_m_e = sig_tim_p_e.matcher(xmlResponse); + Matcher ser_num_m_s = ser_num_p_s.matcher(xmlResponse); + Matcher ser_num_m_e = ser_num_p_e.matcher(xmlResponse); + Matcher sig_cer_m_s = sig_cer_p_s.matcher(xmlResponse); + Matcher sig_cer_m_e = sig_cer_p_e.matcher(xmlResponse); + + // SignatureValue + String sig_val = null; + Matcher signatureValueMatcher = Pattern.compile("<(\\w+:)?SignatureValue( Id=\"[\\w-]+\")?>\\s*(.*)\\s*").matcher(xmlResponse); + if (signatureValueMatcher.find()) { + sig_val = signatureValueMatcher.group(3); + } + log.debug("sig_val = " + sig_val); + + // X509IssuerName + String iss_nam = null; + if (iss_nam_m_s.find() && iss_nam_m_e.find()) { + iss_nam = xmlResponse.substring(iss_nam_m_s.end(), iss_nam_m_e.start()); + } + log.debug("iss_nam = " + iss_nam); + + // X509SerialNumber + String ser_num = null; + if (ser_num_m_s.find() && ser_num_m_e.find()) { + ser_num = BKUHelper.removeAllWhitespace(xmlResponse.substring(ser_num_m_s.end(), ser_num_m_e.start())); + } + log.debug("ser_num = " + ser_num); + + // SigningTime + String sig_tim = null; + if (sig_tim_m_s.find() && sig_tim_m_e.find()) { + sig_tim = xmlResponse.substring(sig_tim_m_s.end(), sig_tim_m_e.start()); + } + log.debug("sig_tim = " + sig_tim); + + // X509Certificate + X509Certificate cert = null; + if (sig_cer_m_s.find() && sig_cer_m_e.find()) { + String sig_cer = BKUHelper.removeAllWhitespace(xmlResponse.substring(sig_cer_m_s.end(), sig_cer_m_e.start())); + + try { + byte[] der = CodingHelper.decodeBase64(sig_cer); + ByteArrayInputStream bais = new ByteArrayInputStream(der); + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + cert = (X509Certificate) cf.generateCertificate(bais); + bais.close(); + } catch (UnsupportedEncodingException e) { + throw new ConnectorException(300, e); + } catch (CertificateException e) { + throw new ConnectorException(300, e); + } catch (IOException e) { + throw new ConnectorException(300, e); + } + } + log.debug("X509Certificate = " + cert); + + if (log.isDebugEnabled()) { + + String cert_iss = cert.getIssuerDN().getName(); + log.debug("certificate's issuer = " + cert_iss); + log.debug("response's issuer = " + iss_nam); + log.debug("issuer matches = " + cert_iss.equals(iss_nam)); + log.debug("ser number matches = " + cert.getSerialNumber().toString().equals(ser_num)); + } + + // extract Signature Id's + String[] ids = extractIds(xmlResponse); + String final_ids = id_formatter.formatIds(ids); + + SignSignatureObject so = new SignSignatureObject(); + so.date = sig_tim; + so.issuer = iss_nam; + so.signatureValue = sig_val; + so.x509Certificate = cert; + + so.id = final_ids; + + return so; + } + + /** + * Extraction of the id attributes from the xml response. + * + * @param xmlResponse The xml response. + * @return The parsed id attributes. + */ + public final static String[] extractIds(String xmlResponse) { + return new String[] { extractId(xmlResponse) }; + } + + /** + * There is only one special common part of all id attributes of this + * connector that has to be stored. This method returns that single part. + * + * @param xmlResponse The xml response. + * @return The parsed common part of all id attributes. + */ + private final static String extractId(String xmlResponse) { + final Pattern ID_PATTERN = Pattern.compile("Id\\s*=\\s*\"\\s*Signature-([\\p{XDigit}]+)-\\d+\\s*\""); + Matcher matcher = ID_PATTERN.matcher(xmlResponse); + if (matcher.find() && matcher.groupCount() > 0) { + return matcher.group(1); + } + return null; + } + +} diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java index 2adc4b1..16352de 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/DataURLServlet.java @@ -126,6 +126,7 @@ public class DataURLServlet extends HttpServlet { Object sessionObject = SessionHelper.getSession(request); + // obsolete since EncodingFilter is set in web.xml checkRequestCharacterEncoding(request); if (sessionObject instanceof SignSessionInformation) @@ -152,8 +153,6 @@ public class DataURLServlet extends HttpServlet protected void checkRequestCharacterEncoding(HttpServletRequest request) throws UnsupportedEncodingException { - log.debug("Request character encoding = " + request.getCharacterEncoding()); //$NON-NLS-1$ -// if (request.getCharacterEncoding() == null || request.getCharacterEncoding().equals("UTF-8")) //$NON-NLS-1$ if (request.getCharacterEncoding() == null || request.getCharacterEncoding().length() <= 0) //$NON-NLS-1$ { log.info("The BKU didn't set a character encoding for the request."); //$NON-NLS-1$ @@ -220,12 +219,20 @@ public class DataURLServlet extends HttpServlet response.setCharacterEncoding("UTF-8"); response.getWriter().println(request_string); } - else + else if (xml_response != null) { log.debug("Received a normal response -> storing the response."); //$NON-NLS-1$ Properties response_properties = new Properties(); response_properties.setProperty(BKUPostConnection.RESPONSE_STRING_KEY, xml_response); + + String userAgent = request.getHeader("User-Agent"); + if (userAgent != null) { + response_properties.setProperty(BKUPostConnection.BKU_USER_AGENT_HEADER_KEY, userAgent); + } else { + log.warn("BKU request/response header \"User-Agent\" is empty."); + } + si.response_properties = response_properties; log.debug("All requests have been processed -> processing the responses."); //$NON-NLS-1$ @@ -294,7 +301,9 @@ public class DataURLServlet extends HttpServlet // do not insert any code within this else block ! } - } + } else { + log.debug("No XMLResponse found. Do nothing."); + } } protected void processVerify(HttpServletRequest request, HttpServletResponse response, VerifySessionInformation si) throws ServletException, IOException, ConnectorException, InvalidIDException diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java index a8ff426..1efc64f 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/ProvidePDFServlet.java @@ -59,8 +59,8 @@ public class ProvidePDFServlet extends HttpServlet { log.debug("Signed pdf found."); session.removeAttribute(SessionAttributes.SIGNED_PDF_DOCUMENT); log.debug("Returning signed pdf to browser."); - log.debug("Invalidating session."); - session.invalidate(); +// log.debug("Invalidating session."); +// session.invalidate(); SignServletHelper.returnSignResponse(si, response); return; } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java index 124b2a3..589de7c 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/SignServlet.java @@ -244,8 +244,11 @@ public class SignServlet extends HttpServlet catch (Exception e) { // Error retrieving data - request.setAttribute("error", "Fehler beim Upload der Daten"); - request.setAttribute("cause", "Beim Upload der Daten ist ein Fehler aufgetreten."); +// request.setAttribute("error", "Fehler beim Upload der Daten"); +// request.setAttribute("cause", "Beim Upload der Daten ist ein Fehler aufgetreten."); + request.setAttribute("error", "signservlet.error"); + request.setAttribute("cause", "signservlet.cause"); + request.setAttribute("resourcebundle", Boolean.TRUE); dispatch(request, response, "/jsp/error.jsp"); return; } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/UpdateFormServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/UpdateFormServlet.java new file mode 100644 index 0000000..ba5d43e --- /dev/null +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/UpdateFormServlet.java @@ -0,0 +1,41 @@ +package at.knowcenter.wag.egov.egiz.web.servlets; + +import java.io.IOException; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import at.knowcenter.wag.egov.egiz.web.FormFields; + +public class UpdateFormServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + public static final String UPLOADFORM_SIGNATURE_TYPE_KEY = "signupload.jsp:signatureType"; + public static final String UPLOADFORM_SIGNATURE_MODE_KEY = "signupload.jsp:signatureMode"; + public static final String UPLOADFORM_SIGNATURE_DEVICE_KEY = "signupload.jsp:signatureKey"; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + this.doPost(request, response); + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String mode = request.getParameter(FormFields.FIELD_MODE); + String device = request.getParameter(FormFields.FIELD_CONNECTOR); + String type = request.getParameter(FormFields.FIELD_SIGNATURE_TYPE); + + HttpSession session = request.getSession(); + session.setAttribute(UPLOADFORM_SIGNATURE_DEVICE_KEY, device); + session.setAttribute(UPLOADFORM_SIGNATURE_MODE_KEY, mode); + session.setAttribute(UPLOADFORM_SIGNATURE_TYPE_KEY, type); + + RequestDispatcher dispatcher = request.getRequestDispatcher("/jsp/signupload.jsp"); + dispatcher.forward(request, response); +// response.sendRedirect(response.encodeRedirectURL(request.getContextPath() + "/jsp/signupload.jsp")); + } + +} diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java index 5e1819e..0eb417b 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/web/servlets/VerifyPreviewServlet.java @@ -699,8 +699,9 @@ public class VerifyPreviewServlet extends HttpServlet } catch (FileUploadException e) { - request.setAttribute("error", "Fehler beim Upload der Daten"); - request.setAttribute("cause", "Beim Upload der Daten ist ein Fehler aufgetreten."); + request.setAttribute("error", "verifypreviewservlet.error"); + request.setAttribute("cause", "verifypreviewservlet.cause"); + request.setAttribute("resourcebundle", Boolean.TRUE); dispatch(request, response, "/jsp/error.jsp"); } catch (PresentableException e) diff --git a/src/main/java/at/knowcenter/wag/exactparser/parsing/PDFUtils.java b/src/main/java/at/knowcenter/wag/exactparser/parsing/PDFUtils.java index 1387fb2..88476be 100644 --- a/src/main/java/at/knowcenter/wag/exactparser/parsing/PDFUtils.java +++ b/src/main/java/at/knowcenter/wag/exactparser/parsing/PDFUtils.java @@ -387,7 +387,8 @@ public abstract class PDFUtils while (isNumeric(pdf[index]) || pdf[index] == '.') { - number += (char) pdf[index]; + char digit = (char) pdf[index]; + number += digit; index++; } diff --git a/src/main/resources/DefaultConfiguration.zip b/src/main/resources/DefaultConfiguration.zip index a8c4e6a..a7f41b5 100644 Binary files a/src/main/resources/DefaultConfiguration.zip and b/src/main/resources/DefaultConfiguration.zip differ diff --git a/src/main/resources/at/gv/egiz/pdfas/web/i18n/language.properties b/src/main/resources/at/gv/egiz/pdfas/web/i18n/language.properties new file mode 100644 index 0000000..fc07625 --- /dev/null +++ b/src/main/resources/at/gv/egiz/pdfas/web/i18n/language.properties @@ -0,0 +1,96 @@ + +common.back = back +common.backtolist = back to list +common.binary = binary +common.bku = Local CCS +common.locale.param = locale=en +common.mocca = Online CCS +common.textual = textual +common.title = PDF Signature + +dataok.heading2 = Data modification +dataok.taken = Data modification successfully applied. + +download.button.alreadydone = Document already downloaded +download.button.download = Download signed document +download.heading2 = Sign document +download.note = Signature procedure successfully completed. The signed document is ready for download.
Note: The document can only be downloaded once. The document will not be stored on the server. +download.title = PDF Signature: Download + +error.cause = Cause +error.heading2 = An error occurred +error.title = PDF Signature: Result + +errorverify.cause = Cause +errorverify.heading2 = An error occurred +errorverify.title = PDF Signature: Result + +nullrequestpage.button.pleasewait = Please wait... +nullrequestpage.button.submit = Submit... +nullrequestpage.heading2 = Sign pdf document +nullrequestpage.note = Contacting your citizen card software... +nullrequestpage.title = PDF Signature: Local Connection + +pleasewait.body = Please wait.
\r\nLoading applet... +pleasewait.title = Online CCS + +results.certificate = Certificate +results.certificatecheck = Certificate-Check +results.heading2 = Validation result +results.issuer = Issuer +results.manifestcheck = Manifest-Check +results.property = Property +results.serialnumber = Serial Number +results.signaturecheck = Signature-Check +results.signer = Signer + +signaturblock.issuer.value.cn = Issuername +signaturblock.issuer.value.o = Issuerorganisation +signaturblock.signer.value = will be taken from certificate + +signpreview.button.sign = Sign... +signpreview.heading2 = Preview: Sign document +signpreview.showpreview = Show preview... +signpreview.title = PDF Signature: Preview + +signservlet.cause = An error occurred uploading the data. +signservlet.error = Error uploading data + +signupload.button.preview = Preview +signupload.button.sign = Sign document +signupload.documentnotselected = Please select a pdf document to be signed. +signupload.documentnotselected.preview = Please select a pdf document to be signed for preview. +signupload.file = PDF document +signupload.heading2 = Sign document +signupload.note = Documents signed in textual mode can only be verified if the underlying certificate can be retrieved from a directory service. +signupload.note.prefix = Please note +signupload.noteonsigmark = The appearance of the signature mark depends on the signature type, signature mode, on the particular citizen card and on the given citizen card software. +signupload.selectfilenote = Please select the signature parameters and the pdf document to be signed with your citizen card. +signupload.signaturedevice = Signature device +signupload.signaturemode = Signature mode +signupload.signaturetype = Signature type +signupload.signaturetype.signaturblock.de = German default signature +signupload.signaturetype.signaturblock.en = English default signature + +test.common.title = PDF Signature (test) + +verifylist.button.preview = Preview... +verifylist.button.verifyallsignatures = Verify all +verifylist.button.verifysinglesignature = Verify this signature only +verifylist.heading2.plural = Verify document signatures +verifylist.heading2.singular = Verify document signature + +verifypreview.applyvalues = Commit values +verifypreview.applyvaluesandverify = Commit values and verify +verifypreview.heading2 = Preview: Verify document +verifypreview.reconstruction = Reconstruction of the signature mark + +verifypreviewservlet.cause = An error occurred uploading the data. +verifypreviewservlet.error = Error uploading data + +verifyupload.button.listsignatures = List signatures +verifyupload.button.verifyallsignatures = Verify all +verifyupload.heading2 = Verify document signature +verifyupload.note = Please enter the complete document text together with the signature block. +verifyupload.verifydevice = Verification device +verifyupload.verifymode = Verification mode diff --git a/src/main/resources/at/gv/egiz/pdfas/web/i18n/language_de.properties b/src/main/resources/at/gv/egiz/pdfas/web/i18n/language_de.properties new file mode 100644 index 0000000..93818b2 --- /dev/null +++ b/src/main/resources/at/gv/egiz/pdfas/web/i18n/language_de.properties @@ -0,0 +1,96 @@ + +common.back = zurück +common.backtolist = zurück zur Liste +common.binary = binär +common.bku = Lokale BKU +common.locale.param = locale=de +common.mocca = Online BKU +common.textual = textuell +common.title = PDF-Signatur + +dataok.heading2 = Datenänderung +dataok.taken = Die Daten wurden erfolgreich übernommen. + +download.button.alreadydone = Download bereits erfolgt +download.button.download = Signiertes Dokument herunterladen +download.heading2 = Dokument Signatur erstellen +download.note = Der Signatur-Vorgang ist abgeschlossen. Das signierte Dokument kann nun heruntergeladen werden.
Hinweis: Der Download ist nur einmalig möglich. Das Dokument wird nicht am Server gespeichert. +download.title = PDF-Signatur: Download + +error.cause = Ursache +error.heading2 = Ein Fehler ist aufgetreten +error.title = PDF-Signatur: Resultat + +errorverify.cause = Ursache +errorverify.heading2 = Ein Fehler ist aufgetreten +errorverify.title = PDF-Signatur: Resultat + +nullrequestpage.button.pleasewait = Bitte warten... +nullrequestpage.button.submit = Absenden... +nullrequestpage.heading2 = PDF Dokument signieren +nullrequestpage.note = Die Verbindung zu Ihrer Bürgerkartenumgebung wird hergestellt... +nullrequestpage.title = PDF-Signatur: Lokale Verbindung + +pleasewait.body = Bitte warten.
\r\nApplet wird geladen... +pleasewait.title = Online BKU + +results.certificate = Zertifikat +results.certificatecheck = Zertifikats-Prüfung +results.heading2 = Prüfergebnis +results.issuer = Aussteller +results.manifestcheck = Manifest-Prüfung +results.property = Eigenschaft +results.serialnumber = Seriennummer +results.signaturecheck = Signatur-Prüfung +results.signer = Signator + +signaturblock.issuer.value.cn = Ausstellername +signaturblock.issuer.value.o = Ausstellerorganisation +signaturblock.signer.value = wird aus dem Zertifikat extrahiert + +signpreview.button.sign = Signieren... +signpreview.heading2 = Vorschau: Dokument Signieren +signpreview.showpreview = Vorschaudokument anzeigen... +signpreview.title = PDF-Signatur: Vorschau + +signservlet.cause = Beim Upload der Daten ist ein Fehler aufgetreten. +signservlet.error = Fehler beim Upload der Daten + +signupload.button.preview = Vorschau +signupload.button.sign = Signatur erstellen +signupload.documentnotselected = Bitte wählen Sie das zu signierende PDF-Dokument aus. +signupload.documentnotselected.preview = Bitte wählen Sie das zu signierende PDF-Dokument für die Vorschau aus. +signupload.file = PDF Dokument +signupload.heading2 = Dokument Signatur erstellen +signupload.note = Im textuellen Modus signierte Dokumente können nur dann geprüft werden, wenn das Zertifikat in einem Verzeichnisdienst verfügbar ist. +signupload.note.prefix = Bitte beachten Sie +signupload.noteonsigmark = Das Erscheinungsbild der Signaturmarke kann abhängig vom Signaturtyp, vom Signaturmodus, von der verwendeten Bürgerkarte, sowie von der verwendeten Bürgerkartenumgebung variieren. +signupload.selectfilenote = Bitte wählen Sie die Signaturparameter sowie das zu signierende PDF Dokument. Dieses wird mit Ihrer Bürgerkarte signiert. +signupload.signaturedevice = Signaturgerät +signupload.signaturemode = Signaturmodus +signupload.signaturetype = Signaturtyp +signupload.signaturetype.signaturblock.de = Standardsignatur Deutsch +signupload.signaturetype.signaturblock.en = Standardsignatur Englisch + +test.common.title = PDF-Signatur (Test) + +verifylist.button.preview = Vorschau... +verifylist.button.verifyallsignatures = Alle prüfen +verifylist.button.verifysinglesignature = Nur diese Signatur prüfen +verifylist.heading2.plural = Dokument Signaturen prüfen +verifylist.heading2.singular = Dokument Signatur prüfen + +verifypreview.applyvalues = Werte übernehmen +verifypreview.applyvaluesandverify = Werte übernehmen und prüfen +verifypreview.heading2 = Vorschau: Dokument prüfen +verifypreview.reconstruction = Rekonstruktion der Signaturmarke + +verifypreviewservlet.cause = Beim Upload der Daten ist ein Fehler aufgetreten. +verifypreviewservlet.error = Fehler beim Upload der Daten + +verifyupload.button.listsignatures = Signaturen auflisten +verifyupload.button.verifyallsignatures = Alle prüfen +verifyupload.heading2 = Dokument Signatur prüfen +verifyupload.note = Hier bitte den vollständigen Dokumenttext samt Signaturblock eingeben. +verifyupload.verifydevice = Prüf-Applikation +verifyupload.verifymode = Prüf-Modus diff --git a/src/main/webapp/META-INF/context.xml b/src/main/webapp/META-INF/context.xml index b27ca81..a0de89e 100644 --- a/src/main/webapp/META-INF/context.xml +++ b/src/main/webapp/META-INF/context.xml @@ -1,5 +1,5 @@ - + diff --git a/src/main/webapp/WEB-INF/decorators.xml b/src/main/webapp/WEB-INF/decorators.xml index 64ee415..a88892d 100644 --- a/src/main/webapp/WEB-INF/decorators.xml +++ b/src/main/webapp/WEB-INF/decorators.xml @@ -2,13 +2,14 @@ /bku-erkennung/* + /jsp/please_wait.jsp /css/* /img/* *.pdf /*.pdf - + /* diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 3b97dab..ce82e9a 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -26,11 +26,43 @@ at.gv.egiz.pdfas.web.i18n.language + + encodingFilter + at.gv.egiz.pdfas.web.filter.EncodingFilter + + encoding + UTF-8 + + + setRequestEncoding + true + + + forceRequestEncoding + false + + + + + localeparam + at.gv.egiz.pdfas.web.i18n.LocaleParamFilter + + sitemesh com.opensymphony.module.sitemesh.filter.PageFilter + + encodingFilter + /* + + + + localeparam + /* + + sitemesh /* @@ -86,8 +118,8 @@ - SetLanguage - at.gv.egiz.pdfas.web.i18n.SetLanguageServlet + UpdateForm + at.knowcenter.wag.egov.egiz.web.servlets.UpdateFormServlet @@ -136,8 +168,8 @@ - SetLanguage - /SetLanguage + UpdateForm + /UpdateForm diff --git a/src/main/webapp/images/button-search.jpg b/src/main/webapp/images/button-search.jpg new file mode 100644 index 0000000..3a17347 Binary files /dev/null and b/src/main/webapp/images/button-search.jpg differ diff --git a/src/main/webapp/images/chiperling.jpg b/src/main/webapp/images/chiperling.jpg new file mode 100644 index 0000000..fcb633a Binary files /dev/null and b/src/main/webapp/images/chiperling.jpg differ diff --git a/src/main/webapp/images/menu-divider.jpg b/src/main/webapp/images/menu-divider.jpg new file mode 100644 index 0000000..53272d7 Binary files /dev/null and b/src/main/webapp/images/menu-divider.jpg differ diff --git a/src/main/webapp/images/signatur-logo_en-100.png b/src/main/webapp/images/signatur-logo_en-100.png new file mode 100644 index 0000000..0d84ca7 Binary files /dev/null and b/src/main/webapp/images/signatur-logo_en-100.png differ diff --git a/src/main/webapp/images/signatur-logo_en.png b/src/main/webapp/images/signatur-logo_en.png new file mode 100644 index 0000000..505e6a5 Binary files /dev/null and b/src/main/webapp/images/signatur-logo_en.png differ diff --git a/src/main/webapp/jsp/SIGNATURBLOCK.jsp b/src/main/webapp/jsp/SIGNATURBLOCK.jsp new file mode 100644 index 0000000..dc21f9a --- /dev/null +++ b/src/main/webapp/jsp/SIGNATURBLOCK.jsp @@ -0,0 +1,110 @@ +<%@ page contentType="text/html; charset=UTF-8" language="java" errorPage=""%> + +<%@ page import="org.apache.commons.lang.time.DateFormatUtils" %> +<%@ page import="java.util.Date" %> +<%@ page import="at.gv.egiz.pdfas.api.commons.Constants" %> +<%@ page import="at.knowcenter.wag.egov.egiz.web.servlets.UpdateFormServlet"%> +<%@ page import="at.knowcenter.wag.egov.egiz.web.FormFields" %> + +<%@ include file="language.jsp" %> + + <% + String mode = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_MODE_KEY); + String device = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_DEVICE_KEY); + String type = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_TYPE_KEY); + + String sbValue; + String sbLabel; + String sbMeta; + String sbName; + String sbDate; + String sbIssuer; + String sbNumber; + String sbKZ; + String sbID; + String sbMetaValue; + if ("SIGNATURBLOCK_DE".equals(type)) { + sbValue = "Signaturwert"; + sbLabel = "signatur-logo_de-100.png"; + sbMetaValue = "Informationen zur Prüfung der elektronischen Signatur und des Ausdrucks finden Sie unter: "; + sbName = "Unterzeichner"; + sbDate = "Datum/Zeit-UTC"; + sbIssuer = "Aussteller-Zertifikat"; + sbNumber = "Serien-Nr."; + sbKZ = "Methode"; + sbID = "Parameter"; + sbMeta = "Prüfinformation"; + } else { + sbValue = "Signature Value"; + sbLabel = "signatur-logo_en-100.png"; + sbMetaValue = "Information about the verification of the electronic signature and of the printout can be found at: "; + sbName = "Signatory"; + sbDate = "Date/Time-UTC"; + sbIssuer = "Issuer-Certificate"; + sbNumber = "Serial-No."; + sbKZ = "Method"; + sbID = "Parameter"; + sbMeta = "Verification"; + } + + %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <% } // end if %> + + + + + +
<%= sbValue %> +
Aqs3vMeF81wm/UJjIcLOzUs9
+
dxTBzhi2RC8avQyMAmc3v
+
WEj9HT1DI3iish4smRr
+
Signatur-Logo<%= sbName %>" readonly="readonly" disabled="disabled" size="40" maxlength="255"/>
<%= sbDate %><%= DateFormatUtils.formatUTC(new Date(), "yyyy-MM-dd'T'HH:mm:ss'Z'", request.getLocale()) %>
<%= sbIssuer %> +
CN=,
+
O=,
+
C=AT
+
<%= sbNumber %>123456
<%= sbKZ %> +
urn:pdfsigfilter:
+
bka.gv.at:
+
<%= FormFields.VALUE_MODE_TEXTUAL.equals(mode) ? "text" : "binaer" %>:v1.1.0
+
<%= sbID %> + <% if (Constants.SIGNATURE_DEVICE_MOC.equals(device)) { %> +
etsi-moc-1.0@12345678
+ <% } else { %> +
etsi-bka-1.0@1234567890-123456789@
+
12345-1234-
+
0-
+
12345-
+
12345
<%= sbMeta %><%= sbMetaValue %>
+ \ No newline at end of file diff --git a/src/main/webapp/jsp/SIGNATURBLOCK_DE.jsp b/src/main/webapp/jsp/SIGNATURBLOCK_DE.jsp deleted file mode 100644 index 3b48294..0000000 --- a/src/main/webapp/jsp/SIGNATURBLOCK_DE.jsp +++ /dev/null @@ -1,61 +0,0 @@ -<%@ page contentType="text/html; charset=UTF-8" language="java" errorPage=""%> - -<%@ page import="org.apache.commons.lang.time.DateFormatUtils" %> -<%@ page import="java.util.Date" %> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Signaturwert -
Aqs3vMeF81wm/UJjIcLOzUs9
-
dxTBzhi2RC8avQyMAmc3v
-
WEj9HT1DI3iish4smRr
-
Signatur-LogoUnterzeichner
Datum/Zeit-UTC<%= DateFormatUtils.formatUTC(new Date(), "yyyy-MM-dd'T'HH:mm:ss'Z'", request.getLocale()) %>
Aussteller-Zertifikat -
CN=Ausstellername,
-
O=Ausstellerorganisation,
-
C=AT
-
Serien-Nr.123456
Methode -
urn:pdfsigfilter:
-
bka.gv.at:
-
text:v1.1.0
-
Parameter -
etsi-bka-1.0@1234567890-123456789@
-
12345-1234-
-
0-
-
12345-
-
12345
Prüfinformation - Informationen zur Prüfung der elektronischen Signatur und des Ausdrucks finden Sie unter: -
diff --git a/src/main/webapp/jsp/dataok.jsp b/src/main/webapp/jsp/dataok.jsp index c77fb46..ae209ab 100644 --- a/src/main/webapp/jsp/dataok.jsp +++ b/src/main/webapp/jsp/dataok.jsp @@ -1,24 +1,25 @@ + +<%@ include file="language.jsp" %> + -PDF-AS Amtssignaturen +<fmt:message key="common.title"/>
-

PDF-AS Amtssignaturen

-
-
Datenänderung
+

+

-Die Daten wurden erfolgreich übernommen. +

-
<% String btlurl = (String)request.getAttribute("btlurl"); %> -zurück zur Liste +
\ No newline at end of file diff --git a/src/main/webapp/jsp/download.jsp b/src/main/webapp/jsp/download.jsp index 76180cc..95109e3 100644 --- a/src/main/webapp/jsp/download.jsp +++ b/src/main/webapp/jsp/download.jsp @@ -1,5 +1,7 @@ <%@ page contentType="text/html; charset=UTF-8"%> +<%@ include file="language.jsp" %> + <%@ page import="at.knowcenter.wag.egov.egiz.web.SessionAttributes" %> <%@ page import="at.knowcenter.wag.egov.egiz.web.LocalRequestHelper" %> @@ -9,7 +11,7 @@ - PDF-Signaturen Lokale Verbindung + <fmt:message key="download.title"/> -

PDF-Signaturen

-

Dokument Signatur erstellen

-
Die Verbindung zu Ihrer Bürgerkartenumgebung wird hergestellt...
+

+

+
+ <% if (isOnlineMOCCA) { %> +
+ + + + + <% if (locale != null) { %> + + <% } // end if %> +
+
+ + <% } else { %>
-
- - - -
+
+ + + " /> +
+ <% } // end if %>
- zurück + + <% + String device = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_DEVICE_KEY); + if (device == null) { + device = Constants.SIGNATURE_DEVICE_MOC; + session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_DEVICE_KEY, device); + } + String mode = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_MODE_KEY); + if (forceTextualForMocca && Constants.SIGNATURE_DEVICE_MOC.equals(device)) { + mode = FormFields.VALUE_MODE_TEXTUAL; + session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_MODE_KEY, mode); + } + if (mode == null) { + mode = FormFields.VALUE_MODE_TEXTUAL; + session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_MODE_KEY, mode); + } + String type = (String) session.getAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_TYPE_KEY); + if (type == null) { + Locale locale = (Locale) session.getAttribute(LocaleParamFilter.LOCALE_SESSION_KEY); + if (locale == null) { + locale = request.getLocale(); + } + type = Locale.GERMAN.getLanguage().equals(locale.getLanguage()) ? "SIGNATURBLOCK_DE" : "SIGNATURBLOCK_EN"; + session.setAttribute(UpdateFormServlet.UPLOADFORM_SIGNATURE_TYPE_KEY, type); + } + + %> -

PDF-Signaturen

-

Dokument Signatur erstellen

-
Bitte wählen Sie die zu signierende PDF-Datei. Diese wird mit Ihrer Bürgerkarte signiert.
-
+ <% + if (testMode) { + %> + + <% } else { %> + + <% } // end if %> + +

+
+ + + + + +
- - - - - + - + - + + + + +
- + +
- + <% if (forceTextualForMocca && Constants.SIGNATURE_DEVICE_MOC.equals(device)) {%> + + + <% } else { %> + + <% } %>
- + +
-
Bitte beachten Sie: Im textuellen Modus signierte Dokumente können nur dann geprüft werden, wenn das Zertifikat in einem Verzeichnisdienst verfügbar ist.
+
:
- + -
Das Erscheinungsbild der Signaturmarke kann abhängig vom Signatur Typ, vom Signatur Modus, von der verwendeten Bürgerkarte, sowie von der verwendeten Bürgerkartenumgebung variieren.
-
- - - -
- - +
+ <% if (Constants.SIGNATURE_DEVICE_BKU.equals(device)) { %> +
+ + + +
+ <% } else if (Constants.SIGNATURE_DEVICE_MOC.equals(device)) { %> +
+ <fmt:message key="/> +
+ <% } else { %> +
+ <% } // end if %> +
+ " onclick="return submitForm(false);"/> + " onclick="return submitForm(true);"/> +
- \ No newline at end of file + diff --git a/src/main/webapp/jsp/verifylist.jsp b/src/main/webapp/jsp/verifylist.jsp index fac5755..c04928a 100644 --- a/src/main/webapp/jsp/verifylist.jsp +++ b/src/main/webapp/jsp/verifylist.jsp @@ -7,6 +7,7 @@ <%@ page import="at.knowcenter.wag.egov.egiz.web.servlets.VerifyPreviewServlet" %> <%@ page import="at.gv.egiz.pdfas.web.VerifySessionInformation" %> <%@ page import="at.gv.egiz.pdfas.web.helper.SessionHelper"%> +<%@ include file="language.jsp" %> <% VerifySessionInformation si = (VerifySessionInformation) SessionHelper.getSession(request); @@ -18,16 +19,16 @@ - PDF-Signaturen + <fmt:message key="common.title"/> -

PDF-Signaturen

+

<% if (signature_holders.size() > 1) { %> -

Dokument Signaturen prüfen

+

<% } else { %> -

Dokument Signatur prüfen

+

<% } %> @@ -44,7 +45,7 @@ style="float:left;"> - + " />
" accept-charset="UTF-8" @@ -52,7 +53,7 @@ style="float:left;"> - + " />
<% @@ -65,9 +66,9 @@ method="get"> - + " />
- zurück + diff --git a/src/main/webapp/jsp/verifypreview.jsp b/src/main/webapp/jsp/verifypreview.jsp index 1b0adfa..5b6ae6e 100644 --- a/src/main/webapp/jsp/verifypreview.jsp +++ b/src/main/webapp/jsp/verifypreview.jsp @@ -8,6 +8,7 @@ <%@ page import="at.knowcenter.wag.egov.egiz.web.servlets.VerifyPreviewServlet" %> <%@ page import="at.gv.egiz.pdfas.web.VerifySessionInformation" %> <%@ page import="at.gv.egiz.pdfas.web.helper.SessionHelper"%> +<%@ include file="language.jsp" %> <% String btlurl = (String)request.getAttribute("btlurl"); @@ -21,7 +22,7 @@ - PDF-Signaturen + <fmt:message key="common.title"/> -

PDF-Signaturen

-

Vorschau: Dokument prüfen

+

+

" name="submitform" enctype="multipart/form-data" accept-charset="UTF-8" method="post"> -
+
<%= VerifyPreviewServlet.renderRequiredKeys(signature_holder.getSignatureObject(), "", false) %>
- - + " /> + " onclick="document.submitform.verify.value='true'" />
-zurück -zurück zur Liste + +