summaryrefslogtreecommitdiff
path: root/BKULocal
diff options
context:
space:
mode:
authormcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-08-29 12:11:34 +0000
committermcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-08-29 12:11:34 +0000
commit32d17447a258188b2d534bcb0bf65a659ba7b7d0 (patch)
tree4ad8bb267eb29f7091a7da283f6d7eec1e2188e1 /BKULocal
downloadmocca-32d17447a258188b2d534bcb0bf65a659ba7b7d0.tar.gz
mocca-32d17447a258188b2d534bcb0bf65a659ba7b7d0.tar.bz2
mocca-32d17447a258188b2d534bcb0bf65a659ba7b7d0.zip
Initial import.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKULocal')
-rw-r--r--BKULocal/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch7
-rw-r--r--BKULocal/pom.xml79
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/conf/ConfigurationUpdater.java44
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/conf/Configurator.java274
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java214
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java41
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java95
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java27
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java147
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java57
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java265
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java100
-rw-r--r--BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/SpringBKUServlet.java30
-rw-r--r--BKULocal/src/main/resources/at/gv/egiz/bku/local/Userdialog.properties27
-rw-r--r--BKULocal/src/main/resources/at/gv/egiz/bku/local/baseconfig.xml38
-rw-r--r--BKULocal/src/main/resources/at/gv/egiz/bku/local/logo.pngbin0 -> 4035 bytes
-rw-r--r--BKULocal/src/main/resources/at/gv/egiz/bku/local/truststore.jksbin0 -> 1037 bytes
-rw-r--r--BKULocal/src/main/resources/log4j.properties31
-rw-r--r--BKULocal/src/main/webapp/META-INF/MANIFEST.MF3
-rw-r--r--BKULocal/src/main/webapp/WEB-INF/applicationContext.xml69
-rw-r--r--BKULocal/src/main/webapp/WEB-INF/web.xml57
-rw-r--r--BKULocal/src/test/java/ConfigTest.java49
-rw-r--r--BKULocal/src/test/java/JustASandbox.java78
-rw-r--r--BKULocal/src/test/java/at/gv/egiz/bku/local/stal/TestSignRequest.java55
-rw-r--r--BKULocal/src/test/resources/at/gv/egiz/bku/local/stal/sigInfo.xml79
25 files changed, 1866 insertions, 0 deletions
diff --git a/BKULocal/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch b/BKULocal/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch
new file mode 100644
index 00000000..8ad2c6e2
--- /dev/null
+++ b/BKULocal/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.wst.jsdt.core.javascriptValidator"/>
+<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+</launchConfiguration>
diff --git a/BKULocal/pom.xml b/BKULocal/pom.xml
new file mode 100644
index 00000000..3f77752a
--- /dev/null
+++ b/BKULocal/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <parent>
+ <artifactId>bku</artifactId>
+ <groupId>at.gv.egiz</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>at.gv.egiz</groupId>
+ <artifactId>BKULocal</artifactId>
+ <packaging>war</packaging>
+ <name>BKU Local</name>
+ <version>1.0-SNAPSHOT</version>
+ <description />
+ <dependencies>
+ <dependency>
+ <groupId>at.gv.egiz</groupId>
+ <artifactId>STAL</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>at.gv.egiz</groupId>
+ <artifactId>bkucommon</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>at.gv.egiz</groupId>
+ <artifactId>smcc</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>at.gv.egiz</groupId>
+ <artifactId>smccSTAL</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-support</artifactId>
+ <version>2.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>quartz</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+ </dependencies>
+</project> \ No newline at end of file
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/ConfigurationUpdater.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/ConfigurationUpdater.java
new file mode 100644
index 00000000..3214f4bc
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/ConfigurationUpdater.java
@@ -0,0 +1,44 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.conf;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.scheduling.quartz.QuartzJobBean;
+
+public class ConfigurationUpdater extends QuartzJobBean {
+ private static Log log = LogFactory.getLog(ConfigurationUpdater.class);
+ private Configurator config;
+
+ @Override
+ protected void executeInternal(JobExecutionContext arg0)
+ throws JobExecutionException {
+ log.trace("Checking config update");
+ config.checkUpdate();
+ }
+
+ public Configurator getConfig() {
+ return config;
+ }
+
+ public void setConfig(Configurator config) {
+ this.config = config;
+ }
+
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/Configurator.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/Configurator.java
new file mode 100644
index 00000000..e9510101
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/conf/Configurator.java
@@ -0,0 +1,274 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.conf;
+
+import iaik.security.ecc.provider.ECCProvider;
+import iaik.xml.crypto.XSecProvider;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.security.KeyStore;
+import java.security.Provider;
+import java.security.Security;
+import java.security.cert.CertStore;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CollectionCertStoreParameters;
+import java.security.cert.PKIXBuilderParameters;
+import java.security.cert.X509CertSelector;
+import java.security.cert.X509Certificate;
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.net.ssl.CertPathTrustManagerParameters;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.ManagerFactoryParameters;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.slcommands.impl.xsect.STALProvider;
+import at.gv.egiz.smcc.SWCard;
+import at.gv.egiz.smcc.util.SMCCHelper;
+
+public class Configurator {
+ private Log log = LogFactory.getLog(Configurator.class);
+ private XMLConfiguration baseConfig;
+ private XMLConfiguration specialConfig;
+ private boolean autoSave = false;
+
+ public Configurator() {
+ super();
+ init();
+ configure();
+ }
+
+ private void init() {
+ log.debug("Initializing configuration");
+
+ baseConfig = new XMLConfiguration();
+ try {
+ baseConfig.load(getClass().getClassLoader().getResourceAsStream(
+ "./at/gv/egiz/bku/local/baseconfig.xml"));
+ log.debug("Successfully loaded base configuration");
+ } catch (ConfigurationException e) {
+ log.error("Cannot load base configuration", e);
+ }
+ autoSave = baseConfig.getBoolean("OverrideConfigurationFile[@autosave]");
+ try {
+ specialConfig = new XMLConfiguration();
+ specialConfig.setFileName(baseConfig
+ .getString("OverrideConfigurationFile"));
+ specialConfig.load();
+ } catch (Exception e) {
+ log.debug("Cannot get special configuration at: "
+ + baseConfig.getString("OverrideConfigurationFile") + ": " + e);
+ log.debug("Creating new special configuration");
+ try {
+ specialConfig = new XMLConfiguration(baseConfig);
+ specialConfig.setFileName(baseConfig
+ .getString("OverrideConfigurationFile"));
+ specialConfig.save();
+ } catch (ConfigurationException e1) {
+ log.error("Cannot load defaults " + e1);
+ }
+ }
+ specialConfig.setReloadingStrategy(new FileChangedReloadingStrategy());
+ specialConfig.setAutoSave(autoSave);
+ }
+
+ protected void configUrlConnections() {
+ HttpsURLConnection.setFollowRedirects(false);
+ HttpURLConnection.setFollowRedirects(false);
+ }
+
+ protected KeyStore loadKeyStore(String fileName, String type, String password) {
+ KeyStore ks = null;
+ try {
+ ks = KeyStore.getInstance(type);
+ InputStream is = new FileInputStream(fileName);
+ if (is == null) {
+ log.warn("Cannot load keystore from: " + fileName);
+ }
+ ks.load(is, password.toCharArray());
+ for (Enumeration<String> alias = ks.aliases(); alias.hasMoreElements();) {
+ log.debug("Found keystore alias: " + alias.nextElement());
+ }
+ } catch (Exception e) {
+ log.error("Cannot config keystore", e);
+ return null;
+ }
+ return ks;
+ }
+
+ protected void configSSL() {
+ String trustStoreName = specialConfig.getString("SSL.trustStoreFile");
+ String trustStoreType = specialConfig.getString("SSL.trustStoreType");
+ String trustStorePass = specialConfig.getString("SSL.trustStorePass");
+ String certStoreDirectory = specialConfig
+ .getString("SSL.certStoreDirectory");
+ String keyStoreName = specialConfig.getString("SSL.keyStoreFile");
+ String keyStoreType = specialConfig.getString("SSL.keyStoreType");
+ String keyStorePass = specialConfig.getString("SSL.keyStorePass");
+
+ String caIncludeDir = specialConfig.getString("SSL.caIncludeDirectory");
+
+ KeyStore trustStore = loadKeyStore(trustStoreName, trustStoreType,
+ trustStorePass);
+ KeyStore keyStore = null;
+ if (keyStoreName != null) {
+ keyStore = loadKeyStore(keyStoreName, keyStoreType, keyStorePass);
+ }
+
+ try {
+ PKIXBuilderParameters pkixParams = new PKIXBuilderParameters(trustStore,
+ new X509CertSelector());
+
+ if (certStoreDirectory != null) {
+ File dir = new File(certStoreDirectory);
+ if (dir.isDirectory()) {
+ List<X509Certificate> certCollection = new LinkedList<X509Certificate>();
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ for (File f : dir.listFiles()) {
+ log.debug("adding " + f.getName());
+ certCollection.add((X509Certificate) cf
+ .generateCertificate(new FileInputStream(f)));
+ }
+ CollectionCertStoreParameters csp = new CollectionCertStoreParameters(
+ certCollection);
+ CertStore cs = CertStore.getInstance("Collection", csp);
+ pkixParams.addCertStore(cs);
+ log.debug("Added collection certstore");
+ } else {
+ log.error("CertstoreDirectory " + certStoreDirectory
+ + " is not a directory");
+ }
+ }
+
+ if (caIncludeDir != null) {
+ File dir = new File(caIncludeDir);
+ if (dir.exists() && dir.isDirectory()) {
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ try {
+ for (File f : dir.listFiles()) {
+ FileInputStream fis = new FileInputStream(f);
+ X509Certificate cert = (X509Certificate) cf
+ .generateCertificate(fis);
+ fis.close();
+ log.debug("Adding trusted cert " + cert.getSubjectDN());
+ trustStore.setCertificateEntry(cert.getSubjectDN().getName(),
+ cert);
+ f.delete();
+ }
+ } finally {
+ trustStore.store(new FileOutputStream(trustStoreName),
+ trustStorePass.toCharArray());
+ }
+ }
+ }
+
+ pkixParams.setRevocationEnabled(specialConfig
+ .getBoolean("SSL.revocation"));
+ if (specialConfig.getBoolean("SSL.revocation")) {
+ System.setProperty("com.sun.security.enableCRLDP ", "true");
+ Security.setProperty("ocsp.enable", "true");
+ }
+ System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
+ log.debug("Setting revocation check to: "
+ + pkixParams.isRevocationEnabled());
+ ManagerFactoryParameters trustParams = new CertPathTrustManagerParameters(
+ pkixParams);
+ TrustManagerFactory trustFab = TrustManagerFactory.getInstance("PKIX");
+ trustFab.init(trustParams);
+
+ KeyManager[] km = null;
+ SSLContext sslCtx = SSLContext.getInstance(specialConfig
+ .getString("SSL.sslProtocol"));
+ if (keyStore != null) {
+ KeyManagerFactory keyFab = KeyManagerFactory.getInstance("SunX509");
+ keyFab.init(keyStore, keyStorePass.toCharArray());
+ km = keyFab.getKeyManagers();
+ }
+ sslCtx.init(km, trustFab.getTrustManagers(), null);
+ HttpsURLConnection.setDefaultSSLSocketFactory(sslCtx.getSocketFactory());
+ log.info("Successfully configured ssl");
+ } catch (Exception e) {
+ log.debug("Cannot init ssl", e);
+ }
+ }
+
+ protected void configureProviders() {
+ log.debug("Registering security providers");
+ ECCProvider.addAsProvider(false);
+ Security.addProvider(new STALProvider());
+ XSecProvider.addAsProvider(false);
+ StringBuffer sb = new StringBuffer();
+ sb.append("Following providers are now registered: ");
+ int i = 1;
+ for (Provider prov : Security.getProviders()) {
+ sb.append((i++) + ". : " + prov);
+ }
+ log.debug("Configured provider" + sb.toString());
+ }
+
+ protected void configureBKU() {
+ if (specialConfig.containsKey("BKU.useSWCard")) {
+ boolean useSWCard = specialConfig.getBoolean("BKU.useSWCard");
+ log.info("Setting SW Card to: "+useSWCard);
+ SMCCHelper.setUseSWCard(useSWCard);
+ }
+ if (specialConfig.containsKey("BKU.SWCardDirectory")) {
+ //SWCard.
+ }
+ }
+
+ public void configure() {
+ configureProviders();
+ configSSL();
+ configUrlConnections();
+ configureBKU();
+
+ }
+
+ public void checkUpdate() {
+ if (specialConfig.getReloadingStrategy().reloadingRequired()) {
+ log.info("Reloading configuration: " + specialConfig.getFileName());
+ specialConfig.setAutoSave(false);
+ specialConfig.clear();
+ try {
+ specialConfig.load();
+ } catch (ConfigurationException e) {
+ log.fatal(e);
+ }
+ specialConfig.setAutoSave(specialConfig
+ .getBoolean("OverrideConfigurationFile[@autosave]"));
+ configure();
+ specialConfig.getReloadingStrategy().reloadingPerformed();
+ }
+ }
+
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java
new file mode 100644
index 00000000..5bc6bab5
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/PINDialog.java
@@ -0,0 +1,214 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.stal;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.swing.JButton;
+import javax.swing.JPasswordField;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.PlainDocument;
+
+import at.gv.egiz.smcc.PINSpec;
+
+public class PINDialog extends javax.swing.JDialog implements ActionListener {
+
+ // Variables declaration - do not modify
+ private javax.swing.JButton okButton;
+ private javax.swing.JButton cancelButton;
+ private javax.swing.JLabel label;
+ private javax.swing.JPasswordField password;
+ // End of variables declaration
+
+ private PINSpec pinSpec;
+ private String pinString;
+ private boolean finished = false;
+
+ class PinDocument extends PlainDocument {
+ private Pattern pattern;
+
+ public PinDocument() {
+ pattern = Pattern.compile(pinSpec.getRexepPattern());
+ }
+
+ public void insertString(int offs, String str, AttributeSet a)
+ throws BadLocationException {
+ if (pinSpec.getMaxLength() >= (getLength() + str.length())) {
+ Matcher matcher = pattern.matcher(str);
+ if (matcher.matches()) {
+ super.insertString(offs, str, a);
+ }
+ }
+ okButton.setEnabled(getLength() >= pinSpec.getMinLength());
+ }
+
+ @Override
+ public void remove(int offs, int len) throws BadLocationException {
+ super.remove(offs, len);
+ okButton.setEnabled(getLength() >= pinSpec.getMinLength());
+ }
+ }
+
+ public PINDialog() {
+ }
+
+ private synchronized void finished(boolean ok) {
+ if (ok) {
+ pinString = password.getText();
+ } else {
+ pinString = null;
+ }
+ finished = true;
+ notifyAll();
+ }
+
+ public synchronized void waitFinished() {
+ while (!finished) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public String getPIN() {
+ return pinString;
+ }
+
+ /** Creates new form NewJDialog */
+ public PINDialog(java.awt.Frame parent, boolean modal, PINSpec pinSpec,
+ int retries) {
+ super(parent, modal);
+ this.pinSpec = pinSpec;
+ initComponents();
+ }
+
+ private void initComponents() {
+ okButton = new javax.swing.JButton();
+ cancelButton = new javax.swing.JButton();
+ password = new javax.swing.JPasswordField();
+ label = new javax.swing.JLabel();
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ setTitle("PIN Dialog"); // NOI18N
+ setName("Form"); // NOI18N
+
+ okButton.setText("OK"); // NOI18N
+ okButton.setName("okButton"); // NOI18N
+ okButton.setEnabled(false);
+ okButton.addActionListener(this);
+
+ cancelButton.setText("Cancel"); // NOI18N
+ cancelButton.setName("cancelButton"); // NOI18N
+ cancelButton.addActionListener(this);
+
+ password.setText(""); // NOI18N
+ password.setName("password"); // NOI18N
+ password.addActionListener(this);
+ password.setDocument(new PinDocument());
+
+ label.setText("PIN: "); // NOI18N
+ label.setName("jLabel1"); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
+ getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addGroup(
+ layout.createSequentialGroup().addContainerGap().addGroup(
+ layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addGroup(
+ layout.createSequentialGroup().addComponent(label,
+ javax.swing.GroupLayout.PREFERRED_SIZE, 61,
+ javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.RELATED,
+ javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(password,
+ javax.swing.GroupLayout.PREFERRED_SIZE, 127,
+ javax.swing.GroupLayout.PREFERRED_SIZE)).addGroup(
+ javax.swing.GroupLayout.Alignment.TRAILING,
+ layout.createSequentialGroup().addComponent(cancelButton)
+ .addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(okButton))).addContainerGap()));
+ layout.setVerticalGroup(layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addGroup(
+ layout.createSequentialGroup().addContainerGap().addGroup(
+ layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.BASELINE).addComponent(label,
+ javax.swing.GroupLayout.PREFERRED_SIZE, 33,
+ javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(password,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14,
+ Short.MAX_VALUE).addGroup(
+ layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.BASELINE).addComponent(
+ okButton).addComponent(cancelButton)).addContainerGap()));
+
+ pack();
+ }
+
+ /**
+ * @param args
+ * the command line arguments
+ */
+ public static void main(String args[]) {
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ PINDialog dialog = new PINDialog(new javax.swing.JFrame(), true,
+ new PINSpec(1, 5, "[0-9]*", "Hansi"), 10);
+ dialog.setResizable(false);
+ dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ dialog.setVisible(true);
+ }
+ });
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() instanceof JButton) {
+ JButton pressed = (JButton) e.getSource();
+ if (pressed.getName().equals("okButton")) {
+ finished(true);
+ } else if (pressed.getName().equals("cancelButton")) {
+ finished(false);
+ }
+ } else if (e.getSource() instanceof JPasswordField) {
+ JPasswordField pwf = (JPasswordField) e.getSource();
+ if (pwf.getName().equals("password")) {
+ if (password.getPassword().length >= pinSpec.getMinLength()) {
+ finished(true);
+ }
+ }
+ }
+ }
+
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java
new file mode 100644
index 00000000..5596b7bb
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/QuitRequestHandler.java
@@ -0,0 +1,41 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.stal;
+
+import at.gv.egiz.bku.smccstal.AbstractRequestHandler;
+import at.gv.egiz.bku.smccstal.SMCCSTALRequestHandler;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+
+public class QuitRequestHandler extends AbstractRequestHandler {
+
+ @Override
+ public STALResponse handleRequest(STALRequest request) {
+ return null;
+ }
+
+ @Override
+ public boolean requireCard() {
+ return false;
+ }
+
+ @Override
+ public SMCCSTALRequestHandler newInstance() {
+ return this;
+ }
+
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java
new file mode 100644
index 00000000..26ec2aa8
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTAL.java
@@ -0,0 +1,95 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.stal;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Locale;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.bku.local.ui.TrayIconDialog;
+import at.gv.egiz.bku.smccstal.AbstractRequestHandler;
+import at.gv.egiz.bku.smccstal.AbstractSMCCSTAL;
+import at.gv.egiz.bku.smccstal.STALMessageConsumer;
+import at.gv.egiz.smcc.PINProvider;
+import at.gv.egiz.smcc.util.SMCCHelper;
+import at.gv.egiz.stal.QuitRequest;
+
+public class SMCCSTAL extends AbstractSMCCSTAL implements STALMessageConsumer {
+ private static Log log = LogFactory.getLog(SMCCSTAL.class);
+
+ protected PINProvider pinProvider = new SwingPINProvider();
+ protected SwingInsertCardDialog insertCard = new SwingInsertCardDialog();
+ private boolean canceled = false;
+
+ static {
+ addRequestHandler(QuitRequest.class, new QuitRequestHandler());
+ }
+
+ public SMCCSTAL() {
+ AbstractRequestHandler.setMessageConsumer(this);
+ }
+
+ /**
+ *
+ * @return if the user canceled
+ */
+ protected boolean waitForCard() {
+ canceled = false;
+ while ((smccHelper.getResultCode() != SMCCHelper.CARD_FOUND) && (!canceled)) {
+ insertCard.setVisible(true);
+ insertCard.setAlwaysOnTop(true);
+ insertCard.addCanceledListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ canceled = true;
+ }
+ });
+ try {
+ smccHelper.update(1000);
+ } catch (Exception ex) {
+ log.info(ex);
+ }
+ }
+ insertCard.setVisible(false);
+ signatureCard = smccHelper.getSignatureCard(locale);
+ return canceled;
+ }
+
+ @Override
+ public void setLocale(Locale locale) {
+ super.setLocale(locale);
+ if (pinProvider instanceof SwingPINProvider) {
+ ((SwingPINProvider) pinProvider).setLocale(locale);
+ }
+ }
+
+ @Override
+ public void consumeNewSTALMessage(String captionId, String messageId) {
+ TrayIconDialog.getInstance().displayInfo(captionId, messageId);
+ }
+
+ @Override
+ protected BKUGUIFacade getGUI() {
+ // TODO Auto-generated method stub
+ //FIXME
+ return null;
+ }
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java
new file mode 100644
index 00000000..014d884a
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SMCCSTALFactory.java
@@ -0,0 +1,27 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.stal;
+
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.STALFactory;
+
+public class SMCCSTALFactory implements STALFactory {
+ @Override
+ public STAL createSTAL() {
+ return new SMCCSTAL();
+ }
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java
new file mode 100644
index 00000000..eb76f2f2
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingInsertCardDialog.java
@@ -0,0 +1,147 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.stal;
+
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Toolkit;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import javax.swing.ImageIcon;
+import javax.swing.JDialog;
+
+import at.gv.egiz.bku.utils.StreamUtil;
+
+public class SwingInsertCardDialog extends JDialog {
+
+ private javax.swing.JButton cancelButton;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private Locale locale = Locale.getDefault();
+
+ public SwingInsertCardDialog() {
+ super((java.awt.Frame) null, false);
+ initComponents();
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ private void initComponents() {
+ ResourceBundle rb = ResourceBundle.getBundle(
+ "at/gv/egiz/bku/local/Userdialog", locale);
+ setTitle(rb.getString("Insert.Header"));
+ jLabel1 = new javax.swing.JLabel();
+ jLabel2 = new javax.swing.JLabel();
+ cancelButton = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
+ setName("Form"); // NOI18N
+ setUndecorated(true);
+
+ jLabel1.setFont(new Font("Tahoma", Font.BOLD, 14));
+ jLabel1.setText(rb.getString("Insert.Text")); // NOI18N
+ jLabel1.setName("text"); // NOI18N
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ InputStream is = getClass().getClassLoader().getResourceAsStream(
+ "at/gv/egiz/bku/local/logo.png");
+ try {
+ StreamUtil.copyStream(is, os);
+ jLabel2.setIcon(new ImageIcon(os.toByteArray())); // NOI18N
+ } catch (IOException e) {
+ jLabel2.setText("Chipperling image missing"); // NOI18N
+ }
+ jLabel2.setName("jLabel2"); // NOI18N
+ cancelButton.setText(rb.getString("Insert.Button.Cancel")); // NOI18N
+ cancelButton.setName("jButton1"); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
+ getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addGroup(
+ layout.createSequentialGroup().addContainerGap().addComponent(jLabel2)
+ .addGroup(
+ layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.TRAILING).addGroup(
+ layout.createSequentialGroup().addGap(35, 35, 35)
+ .addComponent(jLabel1,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ Short.MAX_VALUE)).addGroup(
+ layout.createSequentialGroup().addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(cancelButton))).addGap(29, 29, 29)));
+ layout.setVerticalGroup(layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addGroup(
+ javax.swing.GroupLayout.Alignment.TRAILING,
+ layout.createSequentialGroup().addContainerGap().addGroup(
+ layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.TRAILING).addComponent(
+ jLabel2).addGroup(
+ layout.createSequentialGroup().addComponent(jLabel1,
+ javax.swing.GroupLayout.DEFAULT_SIZE, 53, Short.MAX_VALUE)
+ .addGap(35, 35, 35).addComponent(cancelButton).addGap(9, 9,
+ 9))).addContainerGap()));
+
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension frameSize = getSize();
+ if (frameSize.height > screenSize.height) {
+ frameSize.height = screenSize.height;
+ }
+ if (frameSize.width > screenSize.width) {
+ frameSize.width = screenSize.width;
+ }
+ setLocation((screenSize.width - frameSize.width) / 2,
+ (screenSize.height - frameSize.height) / 2);
+ setUndecorated(false);
+ pack();
+ }
+
+ public void addCanceledListener(ActionListener al) {
+ cancelButton.addActionListener(al);
+ }
+
+ /**
+ * @param args
+ * the command line arguments
+ */
+ public static void main(String args[]) {
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ SwingInsertCardDialog dialog = new SwingInsertCardDialog();
+ dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ //
+ }
+ });
+ }
+
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java
new file mode 100644
index 00000000..7d36e68e
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPINProvider.java
@@ -0,0 +1,57 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.stal;
+
+import java.util.Locale;
+
+import at.gv.egiz.smcc.PINProvider;
+import at.gv.egiz.smcc.PINSpec;
+
+public class SwingPINProvider implements PINProvider {
+
+ private Locale locale = Locale.getDefault();
+ SwingPinDialog dialog;
+
+ public SwingPINProvider() {
+ this.locale = Locale.getDefault();
+
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ @Override
+ public String providePIN(PINSpec pinSpec, int retries) {
+ dialog = new SwingPinDialog(null, false);
+ dialog.setResizable(false);
+ dialog.setRetries(retries);
+ dialog.setPinSpec(pinSpec);
+ dialog.initComponents();
+ dialog.setVisible(true);
+ dialog.requestFocus();
+ dialog.setAlwaysOnTop(true);
+ dialog.waitFinished();
+ dialog.dispose();
+ return dialog.getPIN();
+ }
+
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java
new file mode 100644
index 00000000..3e91972c
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/stal/SwingPinDialog.java
@@ -0,0 +1,265 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.stal;
+
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JPasswordField;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.PlainDocument;
+
+import at.gv.egiz.bku.utils.StreamUtil;
+import at.gv.egiz.smcc.PINSpec;
+
+public class SwingPinDialog extends javax.swing.JDialog implements
+ ActionListener {
+
+ private javax.swing.JButton okButton;
+ private javax.swing.JButton cancelButton;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JPasswordField password;
+
+ private PINSpec pinSpec;
+ private String pinString;
+ private boolean finished = false;
+ private int retries = -1;
+ private Locale locale = Locale.getDefault();
+ private boolean setUp = false;
+
+ class PinDocument extends PlainDocument {
+ private Pattern pattern;
+
+ public PinDocument() {
+ if ((pinSpec != null) && (pinSpec.getRexepPattern() != null)) {
+ pattern = Pattern.compile(pinSpec.getRexepPattern());
+ } else {
+ pattern = Pattern.compile(".");
+ }
+ }
+
+ public void insertString(int offs, String str, AttributeSet a)
+ throws BadLocationException {
+ if (pinSpec.getMaxLength() >= (getLength() + str.length())) {
+ Matcher matcher = pattern.matcher(str);
+ if (matcher.matches()) {
+ super.insertString(offs, str, a);
+ }
+ }
+ okButton.setEnabled(getLength() >= pinSpec.getMinLength());
+ }
+
+ @Override
+ public void remove(int offs, int len) throws BadLocationException {
+ super.remove(offs, len);
+ okButton.setEnabled(getLength() >= pinSpec.getMinLength());
+ }
+ }
+
+ /**
+ * Make sure to call initComponents
+ *
+ * @param parent
+ * @param modal
+ */
+ public SwingPinDialog(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ public void setPinSpec(PINSpec pinSpec) {
+ this.pinSpec = pinSpec;
+ }
+
+ public void setRetries(int retries) {
+ this.retries = retries;
+ }
+
+ public void initComponents() {
+ ResourceBundle rb = ResourceBundle.getBundle(
+ "at/gv/egiz/bku/local/Userdialog", locale);
+ okButton = new javax.swing.JButton();
+ cancelButton = new javax.swing.JButton();
+ password = new javax.swing.JPasswordField();
+ jLabel1 = new javax.swing.JLabel();
+ jLabel2 = new javax.swing.JLabel();
+
+ setTitle(rb.getString("Pin.Header"));
+ setName("Form");
+ setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
+
+ okButton.setText(rb.getString("Pin.Button.OK"));
+ okButton.setName("okButton");
+ okButton.setEnabled(false);
+ okButton.addActionListener(this);
+
+ cancelButton.setText(rb.getString("Pin.Button.Cancel"));
+ cancelButton.setName("cancelButton");
+ cancelButton.addActionListener(this);
+
+ password.setText("");
+ password.setDocument(new PinDocument());
+ password.setName("password");
+ password.addActionListener(this);
+ password.setDocument(new PinDocument());
+ password.setRequestFocusEnabled(true);
+ password.requestFocus();
+
+ jLabel1.setFont(new Font("Tahoma", Font.BOLD, 14));
+ String text = null;
+ Object[] args;
+ if (retries > 0) {
+ text = rb.getString("Pin.Text.Retries");
+ args = new Object[2];
+ args[0] = pinSpec.getLocalizedName();
+ args[1] = new Integer(retries);
+ } else {
+ text = rb.getString("Pin.Text.NoRetries");
+ args = new Object[1];
+ args[0] = pinSpec.getLocalizedName();
+ }
+ text = MessageFormat.format(text, args);
+ jLabel1.setText(text); // NOI18N
+ jLabel1.setName("jLabel1"); // NOI18N
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ InputStream is = getClass().getClassLoader().getResourceAsStream(
+ "at/gv/egiz/bku/local/logo.png");
+ try {
+ StreamUtil.copyStream(is, os);
+ jLabel2.setIcon(new ImageIcon(os.toByteArray())); // NOI18N
+ } catch (Exception e) {
+ jLabel2.setText("Chipperling image missing"); // NOI18N
+ }
+ jLabel2.setName("jLabel2"); // NOI18N
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
+ getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addGroup(
+ layout.createSequentialGroup().addContainerGap().addComponent(jLabel2)
+ .addGap(73, 73, 73).addGroup(
+ layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addComponent(
+ jLabel1).addGroup(
+ layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.TRAILING, false)
+ .addComponent(password,
+ javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(
+ javax.swing.GroupLayout.Alignment.LEADING,
+ layout.createSequentialGroup().addComponent(
+ cancelButton).addGap(18, 18, 18).addComponent(
+ okButton)))).addContainerGap(31,
+ Short.MAX_VALUE)));
+ layout.setVerticalGroup(layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING).addGroup(
+ layout.createSequentialGroup().addContainerGap().addGroup(
+ layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel2).addGroup(
+ layout.createSequentialGroup().addPreferredGap(
+ javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel1,
+ javax.swing.GroupLayout.PREFERRED_SIZE, 33,
+ javax.swing.GroupLayout.PREFERRED_SIZE).addGap(18,
+ 18, 18).addComponent(password,
+ javax.swing.GroupLayout.PREFERRED_SIZE,
+ javax.swing.GroupLayout.DEFAULT_SIZE,
+ javax.swing.GroupLayout.PREFERRED_SIZE).addGap(20,
+ 20, 20).addGroup(
+ layout.createParallelGroup(
+ javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(cancelButton).addComponent(
+ okButton)))).addGap(36, 36, 36)));
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension frameSize = getSize();
+ if (frameSize.height > screenSize.height) {
+ frameSize.height = screenSize.height;
+ }
+ if (frameSize.width > screenSize.width) {
+ frameSize.width = screenSize.width;
+ }
+ setLocation((screenSize.width - frameSize.width) / 2,
+ (screenSize.height - frameSize.height) / 2);
+ setUndecorated(false);
+ pack();
+ }
+
+ public String getPIN() {
+ return pinString;
+ }
+
+ private synchronized void finished(boolean ok) {
+ if (ok) {
+ pinString = password.getText();
+ } else {
+ pinString = null;
+ }
+ finished = true;
+ notifyAll();
+ }
+
+ public synchronized void waitFinished() {
+ while (!finished) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() instanceof JButton) {
+ JButton pressed = (JButton) e.getSource();
+ if (pressed.getName().equals("okButton")) {
+ finished(true);
+ } else if (pressed.getName().equals("cancelButton")) {
+ finished(false);
+ }
+ } else if (e.getSource() instanceof JPasswordField) {
+ JPasswordField pwf = (JPasswordField) e.getSource();
+ if (pwf.getName().equals("password")) {
+ if (password.getPassword().length >= pinSpec.getMinLength()) {
+ finished(true);
+ }
+ }
+ }
+ }
+
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java
new file mode 100644
index 00000000..8529949d
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/BKURequestHandler.java
@@ -0,0 +1,100 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.webapp;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.web.HttpRequestHandler;
+
+import at.gv.egiz.bku.binding.BindingProcessorManager;
+import at.gv.egiz.bku.binding.HTTPBindingProcessor;
+import at.gv.egiz.bku.binding.HttpUtil;
+import at.gv.egiz.bku.utils.StreamUtil;
+import at.gv.egiz.org.apache.tomcat.util.http.AcceptLanguage;
+
+public abstract class BKURequestHandler extends HttpServlet {
+
+ public final static String ENCODING = "UTF-8";
+
+ protected Log log = LogFactory.getLog(BKURequestHandler.class);
+
+ protected abstract BindingProcessorManager getBindingProcessorManager();
+
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+ log.debug("Got new request");
+ String lang = req.getHeader("Accept-Language");
+ Locale locale = AcceptLanguage.getLocale(lang);
+ log.debug("Using locale: "+locale);
+ HTTPBindingProcessor bindingProcessor;
+ if (req.isSecure()) {
+ bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
+ .createBindingProcessor("https", null, locale);
+ } else {
+ bindingProcessor = (HTTPBindingProcessor) getBindingProcessorManager()
+ .createBindingProcessor("http", null, locale);
+ }
+ Map<String, String> headerMap = new HashMap<String, String>();
+ for (Enumeration<String> headerName = req.getHeaderNames(); headerName
+ .hasMoreElements();) {
+ String header = headerName.nextElement();
+ if (header != null) {
+ headerMap.put(header, req.getHeader(header));
+ }
+ }
+ headerMap.put(HttpUtil.HTTP_HEADER_CONTENT_TYPE, req.getContentType()+";"+req.getCharacterEncoding());
+ bindingProcessor.setHTTPHeaders(headerMap);
+ bindingProcessor.consumeRequestStream(req.getInputStream());
+
+ // fixxme just for testing
+ bindingProcessor.run();
+ if (bindingProcessor.getRedirectURL() != null) {
+ resp.sendRedirect(bindingProcessor.getRedirectURL());
+ return;
+ }
+ resp.setStatus(bindingProcessor.getResponseCode());
+ for (Iterator<String> it = bindingProcessor.getResponseHeaders().keySet()
+ .iterator(); it.hasNext();) {
+ String header = it.next();
+ resp.setHeader(header, bindingProcessor.getResponseHeaders().get(header));
+ }
+ resp.setContentType(bindingProcessor.getResultContentType());
+ resp.setCharacterEncoding(ENCODING);
+ bindingProcessor.writeResultTo(resp.getOutputStream(), ENCODING);
+ req.getInputStream().close();
+ resp.getOutputStream().flush();
+ resp.getOutputStream().close();
+ log.debug("Finished Request");
+ }
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+ doPost(req, resp);
+ }
+}
diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/SpringBKUServlet.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/SpringBKUServlet.java
new file mode 100644
index 00000000..c573e52f
--- /dev/null
+++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/SpringBKUServlet.java
@@ -0,0 +1,30 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.webapp;
+
+import at.gv.egiz.bku.binding.BindingProcessorManager;
+
+public class SpringBKUServlet extends BKURequestHandler {
+
+ public final static String BEAN_NAME="bindingProcessorManager";
+
+ @Override
+ protected BindingProcessorManager getBindingProcessorManager() {
+ return (BindingProcessorManager) getServletContext().getAttribute(BEAN_NAME);
+ }
+
+}
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/Userdialog.properties b/BKULocal/src/main/resources/at/gv/egiz/bku/local/Userdialog.properties
new file mode 100644
index 00000000..9db6f100
--- /dev/null
+++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/Userdialog.properties
@@ -0,0 +1,27 @@
+# Copyright 2008 Federal Chancellery Austria and
+# Graz University of Technology
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#------- Insert Card Dialog -------#
+Insert.Header = Citizen Card Required
+Insert.Button.Cancel = Cancel
+Insert.Text = Please insert your Citizen Card!
+
+
+#------- PIN Dialog -------#
+Pin.Header = Please Enter PIN
+Pin.Button.OK = OK
+Pin.Button.Cancel = Cancel
+Pin.Text.Retries = <html><body>Please enter {0}.<p>{1} retries left.</body></html>
+Pin.Text.NoRetries = Please enter {0}. \ No newline at end of file
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/baseconfig.xml b/BKULocal/src/main/resources/at/gv/egiz/bku/local/baseconfig.xml
new file mode 100644
index 00000000..792bbccc
--- /dev/null
+++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/baseconfig.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2008 Federal Chancellery Austria and
+ Graz University of Technology
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<BKUConfig>
+ <!-- Allows individual configuration -->
+ <OverrideConfigurationFile autosave="true">
+ ${sys:user.home}/.bku/conf/bkuconfig.xml</OverrideConfigurationFile>
+ <SSL>
+ <!--
+ <trustStoreFile>truststore.jks</trustStoreFile>
+ <trustStoreType>JKS</trustStoreType>
+ <trustStorePass>changeMe</trustStorePass>
+ <caIncludeDirectory></caIncludeDirectory>
+ <certStoreDirectory></certStoreDirectory>
+ <keyStoreFile>keyStore.jks</keyStoreFile>
+ <keyStoreType>JKS</keyStoreType>
+ <keyStorePass>changeMe</keyStorePass>
+ -->
+ <revocation>true</revocation>
+ <sslProtocol>TLS</sslProtocol>
+ </SSL>
+ <BKU>
+ </BKU>
+</BKUConfig> \ No newline at end of file
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/logo.png b/BKULocal/src/main/resources/at/gv/egiz/bku/local/logo.png
new file mode 100644
index 00000000..eee4be4f
--- /dev/null
+++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/logo.png
Binary files differ
diff --git a/BKULocal/src/main/resources/at/gv/egiz/bku/local/truststore.jks b/BKULocal/src/main/resources/at/gv/egiz/bku/local/truststore.jks
new file mode 100644
index 00000000..c773f037
--- /dev/null
+++ b/BKULocal/src/main/resources/at/gv/egiz/bku/local/truststore.jks
Binary files differ
diff --git a/BKULocal/src/main/resources/log4j.properties b/BKULocal/src/main/resources/log4j.properties
new file mode 100644
index 00000000..49d763f8
--- /dev/null
+++ b/BKULocal/src/main/resources/log4j.properties
@@ -0,0 +1,31 @@
+# Copyright 2008 Federal Chancellery Austria and
+# Graz University of Technology
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# loglever DEBUG, appender STDOUT
+log4j.rootLogger=TRACE, STDOUT, file
+
+# STDOUT appender
+log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
+log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
+#log4j.appender.STDOUT.layout.ConversionPattern=%5p | %d{dd HH:mm:ss,SSS} | %20c | %10t | %m%n
+#log4j.appender.STDOUT.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
+log4j.appender.STDOUT.layout.ConversionPattern=%-5p |%d | %t | %c %x- %m%n
+
+### FILE appender
+log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.file.datePattern='.'yyyy-MM-dd
+log4j.appender.file.File=${user.home}/.bku/logs/bku.log
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n \ No newline at end of file
diff --git a/BKULocal/src/main/webapp/META-INF/MANIFEST.MF b/BKULocal/src/main/webapp/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..5e949512
--- /dev/null
+++ b/BKULocal/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
diff --git a/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
new file mode 100644
index 00000000..c0ffc927
--- /dev/null
+++ b/BKULocal/src/main/webapp/WEB-INF/applicationContext.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2008 Federal Chancellery Austria and
+ Graz University of Technology
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
+ <bean id="STALFactory" class="at.gv.egiz.bku.local.stal.SMCCSTALFactory"
+ scope="singleton" />
+ <bean id="commandInvoker" class="at.gv.egiz.bku.binding.SLCommandInvokerImpl" />
+ <bean id="bindingProcessorManager" class="at.gv.egiz.bku.binding.BindingProcessorManagerImpl"
+ scope="singleton">
+ <constructor-arg ref="STALFactory"></constructor-arg>
+ <constructor-arg ref="commandInvoker"></constructor-arg>
+ </bean>
+ <bean
+ class="org.springframework.web.context.support.ServletContextAttributeExporter">
+ <property name="attributes">
+ <map>
+ <entry key="bindingProcessorManager">
+ <ref bean="bindingProcessorManager" />
+ </entry>
+ </map>
+ </property>
+ </bean>
+
+ <!-- Configure Configuration -->
+ <bean id="configurator" class="at.gv.egiz.bku.local.conf.Configurator"
+ scope="singleton">
+ </bean>
+
+ <!-- Configure timer to check config update -->
+ <bean id="configUpdater"
+ class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
+ <property name="targetObject" ref="configurator" />
+ <property name="targetMethod" value="checkUpdate" />
+ </bean>
+ <bean id="configTrigger"
+ class="org.springframework.scheduling.quartz.SimpleTriggerBean">
+ <property name="jobDetail" ref="configUpdater"></property>
+ <property name="startDelay" value="10000"></property>
+ <property name="repeatInterval" value="30000"></property>
+ </bean>
+ <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
+ <property name="triggers">
+ <list>
+ <ref bean="configTrigger" />
+ </list>
+ </property>
+ <property name="quartzProperties">
+ <props>
+ <prop key="org.quartz.threadPool.threadCount">1</prop>
+ </props>
+ </property>
+ </bean>
+</beans> \ No newline at end of file
diff --git a/BKULocal/src/main/webapp/WEB-INF/web.xml b/BKULocal/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000..64f9a581
--- /dev/null
+++ b/BKULocal/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2008 Federal Chancellery Austria and
+ Graz University of Technology
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app id="WebApp_ID">
+ <display-name>http-security-layer-request</display-name>
+
+ <!-- Begin Spring Config -->
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/applicationContext.xml</param-value>
+ </context-param>
+ <listener>
+ <listener-class>
+ org.springframework.web.context.ContextLoaderListener
+ </listener-class>
+ </listener>
+ <!-- End Spring Config -->
+
+ <!-- Begin BKU Config -->
+ <servlet>
+ <servlet-name>BKUServlet</servlet-name>
+ <servlet-class>at.gv.egiz.bku.local.webapp.SpringBKUServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>BKUServlet</servlet-name>
+ <url-pattern>/http-security-layer-request</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>BKUServlet</servlet-name>
+ <url-pattern>/https-security-layer-request</url-pattern>
+ </servlet-mapping>
+ <!-- Begin BKU Config -->
+
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ <welcome-file>index.htm</welcome-file>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>default.html</welcome-file>
+ <welcome-file>default.htm</welcome-file>
+ <welcome-file>default.jsp</welcome-file>
+ </welcome-file-list>
+</web-app> \ No newline at end of file
diff --git a/BKULocal/src/test/java/ConfigTest.java b/BKULocal/src/test/java/ConfigTest.java
new file mode 100644
index 00000000..558d1c47
--- /dev/null
+++ b/BKULocal/src/test/java/ConfigTest.java
@@ -0,0 +1,49 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import java.net.URL;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.ConfigurationFactory;
+import org.junit.Ignore;
+
+@Ignore
+public class ConfigTest {
+
+
+ private void testConfig() throws ConfigurationException {
+ ConfigurationFactory factory = new ConfigurationFactory();
+ URL configURL = getClass().getResource("/config.xml");
+ factory.setConfigurationURL(configURL);
+ Configuration config = factory.getConfiguration();
+ System.out.println("-------->: "+config.getInt("hans"));
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ ConfigTest ct = new ConfigTest();
+ try {
+ ct.testConfig();
+ } catch (ConfigurationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/BKULocal/src/test/java/JustASandbox.java b/BKULocal/src/test/java/JustASandbox.java
new file mode 100644
index 00000000..b151df92
--- /dev/null
+++ b/BKULocal/src/test/java/JustASandbox.java
@@ -0,0 +1,78 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+import java.io.ByteArrayOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.net.ssl.HttpsURLConnection;
+
+import org.junit.Ignore;
+
+import at.gv.egiz.bku.local.conf.Configurator;
+import at.gv.egiz.bku.local.stal.SMCCSTALFactory;
+import at.gv.egiz.bku.utils.StreamUtil;
+import at.gv.egiz.stal.InfoboxReadRequest;
+import at.gv.egiz.stal.STAL;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.STALResponse;
+import at.gv.egiz.stal.SignRequest;
+import at.gv.egiz.stal.SignResponse;
+
+@Ignore
+public class JustASandbox {
+
+ /**
+ * @param args
+ * @throws IOException
+ */
+ public static void main(String[] args) throws IOException {
+
+ Configurator cfg = new Configurator();
+ URL url = new URL("https://demo.egiz.gv.at");
+ HttpsURLConnection uc = (HttpsURLConnection) url.openConnection();
+ uc.connect();
+ System.exit(-1);
+
+ InfoboxReadRequest req = new InfoboxReadRequest();
+ req.setInfoboxIdentifier("SecureSignatureKeypair");
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ InputStream is = JustASandbox.class.getClassLoader().getResourceAsStream("at/gv/egiz/bku/local/stal/sigInfo.xml");
+ StreamUtil.copyStream(is, os);
+ SignRequest sr = new SignRequest();
+ sr.setSignedInfo(os.toByteArray());
+ sr.setKeyIdentifier("SecureSignatureKeypair"); //os.toByteArray(), "SecureSignatureKeypair", null);
+ STAL stal = (new SMCCSTALFactory()).createSTAL();
+
+ List<STALRequest> reqList = new ArrayList<STALRequest>(2);
+ reqList.add(req);
+ reqList.add(sr);
+
+ List<STALResponse> resp = stal.handleRequest(reqList);
+ System.out.println(resp.get(0));
+ System.out.println(resp.get(1));
+ FileOutputStream fos = new FileOutputStream("c:/tmp/seq_now.der");
+ SignResponse sir = (SignResponse) resp.get(1);
+ fos.write(sir.getSignatureValue());
+ fos.close();
+ }
+
+}
diff --git a/BKULocal/src/test/java/at/gv/egiz/bku/local/stal/TestSignRequest.java b/BKULocal/src/test/java/at/gv/egiz/bku/local/stal/TestSignRequest.java
new file mode 100644
index 00000000..51e7ff7d
--- /dev/null
+++ b/BKULocal/src/test/java/at/gv/egiz/bku/local/stal/TestSignRequest.java
@@ -0,0 +1,55 @@
+/*
+* Copyright 2008 Federal Chancellery Austria and
+* Graz University of Technology
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package at.gv.egiz.bku.local.stal;
+
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Ignore;
+
+import at.gv.egiz.bku.utils.StreamUtil;
+import at.gv.egiz.smcc.SignatureCard;
+import at.gv.egiz.stal.STALRequest;
+import at.gv.egiz.stal.SignRequest;
+
+@Ignore
+public class TestSignRequest {
+
+ public void test() throws Exception {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ StreamUtil.copyStream(getClass().getClassLoader().getResourceAsStream("at/gv/egiz/bku/local/stal/sigInfo.xml"), os);
+ byte[] signedInfo = os.toByteArray();
+ SignRequest sr = new SignRequest();
+ sr.setSignedInfo(signedInfo);
+ sr.setKeyIdentifier(SignatureCard.KeyboxName.SECURE_SIGNATURE_KEYPAIR.getKeyboxName());
+ List<STALRequest> reqList = new ArrayList<STALRequest>(1);
+ reqList.add(sr);
+ System.out.println((new SMCCSTALFactory()).createSTAL().handleRequest(reqList));
+ }
+
+ public static void main(String[] args) {
+ TestSignRequest tsr = new TestSignRequest();
+ try {
+ tsr.test();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+}
diff --git a/BKULocal/src/test/resources/at/gv/egiz/bku/local/stal/sigInfo.xml b/BKULocal/src/test/resources/at/gv/egiz/bku/local/stal/sigInfo.xml
new file mode 100644
index 00000000..623a78bc
--- /dev/null
+++ b/BKULocal/src/test/resources/at/gv/egiz/bku/local/stal/sigInfo.xml
@@ -0,0 +1,79 @@
+<dsig:SignedInfo xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><dsig:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><dsig:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"/><dsig:Reference Id="signed-data-reference-0-1214921265-27289015-14960" URI=""><dsig:Transforms><dsig:Transform Algorithm="http://www.w3.org/TR/1999/REC-xslt-19991116"><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:pr="http://reference.e-government.gv.at/namespace/persondata/20020228#" xmlns:xa="http://www.egiz.gv.at/namespaces/20060713#">
+ <xsl:output method="xml"/>
+ <xsl:template match="/">
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:etsi="http://uri.etsi.org/01903/v1.1.1#">
+ <head>
+ <title>
+ <xsl:value-of select="/xa:Antrag/xa:Titel"/></title></head>
+ <body>
+ <table align="left" border="0" width="100%">
+ <tr>
+ <td align="left" colspan="3">
+ <h2>
+ <xsl:value-of select="/xa:Antrag/xa:Titel"/></h2></td></tr>
+ <tr>
+ <td bgcolor="silver" colspan="3" text="black">Absender/in</td></tr>
+ <tr>
+ <td align="right" width="17%">Vorname</td>
+ <td width="3%"/>
+ <td width="80%">
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:PhysicalPerson/pr:Name/pr:GivenName"/></td></tr>
+ <tr>
+ <td align="right" width="17%">Familienname</td>
+ <td width="3%"/>
+ <td width="80%">
+ <xsl:value-of select="Von/Title"/>
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:PhysicalPerson/pr:Name/pr:FamilyName"/></td></tr>
+ <tr>
+ <td align="right" width="17%">Geburtsdatum</td>
+ <td width="3%"/>
+ <td width="80%">
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:PhysicalPerson/pr:DateOfBirth"/></td></tr>
+ <tr>
+ <td align="right" width="17%">Geburtsort</td>
+ <td width="3%"/>
+ <td width="80%">
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:PhysicalPerson/pr:PlaceOfBirth"/></td></tr>
+ <tr>
+ <td align="right" width="17%">E-Mail zur Kontaktaufnahme</td>
+ <td width="3%"/>
+ <td width="80%">
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:InternetAddress/pr:Address"/></td></tr>
+ <tr>
+ <td bgcolor="silver" colspan="3" text="black">Dieser Antrag ergeht an:</td></tr>
+ <tr>
+ <td align="right" width="17%">Adressat</td>
+ <td width="3%"/>
+ <td width="80%">
+ <xsl:value-of select="/xa:Antrag/xa:Empfaenger/pr:PersonData/pr:CorporateBody/pr:FullName"/></td></tr>
+ <tr>
+ <td bgcolor="silver" colspan="3" text="black">Hauptwohnsitz des Antragsstellers (laut ZMR):</td></tr>
+ <tr>
+ <td align="right" width="17%">Strasse</td>
+ <td nowrap="nowrap" valign="middle" width="3%"/>
+ <td width="80%">
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:CompactPostalAddress/pr:DeliveryAddress/pr:StreetName"/></td></tr>
+ <tr>
+ <td align="right" width="17%">Hausnummer</td>
+ <td nowrap="nowrap" valign="middle" width="3%"/>
+ <td width="80%">
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:CompactPostalAddress/pr:DeliveryAddress/pr:BuildingNumber"/>
+ <xsl:if test="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:CompactPostalAddress/pr:DeliveryAddress/pr:Unit != ''">/
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:CompactPostalAddress/pr:DeliveryAddress/pr:Unit"/></xsl:if>
+ <xsl:if test="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:CompactPostalAddress/pr:DeliveryAddress/pr:DoorNumber != ''">/
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:CompactPostalAddress/pr:DeliveryAddress/pr:DoorNumber"/></xsl:if></td></tr>
+ <tr>
+ <td align="right" width="17%">Postleitzahl</td>
+ <td nowrap="nowrap" valign="middle" width="3%"/>
+ <td width="80%">
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:CompactPostalAddress/pr:PostalCode"/></td></tr>
+ <tr>
+ <td align="right" width="17%">Ort</td>
+ <td nowrap="nowrap" valign="middle" width="3%"/>
+ <td width="80%">
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:CompactPostalAddress/pr:Municipality"/></td></tr>
+ <tr>
+ <td align="right" width="17%">Staat</td>
+ <td nowrap="nowrap" valign="middle" width="3%"/>
+ <td width="80%">
+ <xsl:value-of select="/xa:Antrag/xa:Antragssteller/pr:PersonData/pr:CompactPostalAddress/pr:CountryName"/></td></tr></table></body></html></xsl:template></xsl:stylesheet></dsig:Transform><dsig:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/></dsig:Transforms><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>GPYZB80vaYfGObhjlfu4lLLpAHs=</dsig:DigestValue></dsig:Reference><dsig:Reference Id="etsi-data-reference-0-1214921265-27289015-29753" Type="http://uri.etsi.org/01903/v1.1.1#SignedProperties" URI="#xmlns(etsi=http://uri.etsi.org/01903/v1.1.1%23)%20xpointer(id('etsi-data-object-0-1214921265-27289015-3533')/child::etsi:QualifyingProperties/child::etsi:SignedProperties)"><dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><dsig:DigestValue>8DWtjO0ki1U/lxn+Y34We6GsfxU=</dsig:DigestValue></dsig:Reference></dsig:SignedInfo> \ No newline at end of file