summaryrefslogtreecommitdiff
path: root/smccSTAL/src/main/java/at/gv
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-03-18 22:27:28 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-03-18 22:27:28 +0000
commit2a1df5e58e44f8d77f34eb80df74e8c0d27caceb (patch)
tree5603a81674a1fe60373ba0a3ca37b03473eeb92a /smccSTAL/src/main/java/at/gv
parent2f49ed7ea3649a51a9457b99004c8cb0ca443432 (diff)
downloadmocca-2a1df5e58e44f8d77f34eb80df74e8c0d27caceb.tar.gz
mocca-2a1df5e58e44f8d77f34eb80df74e8c0d27caceb.tar.bz2
mocca-2a1df5e58e44f8d77f34eb80df74e8c0d27caceb.zip
1.1-rc5 (pinProviderFactories, gui refactoring, signatureCard, secureViewer)
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@322 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'smccSTAL/src/main/java/at/gv')
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractBKUWorker.java8
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractPINProvider.java67
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java6
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java40
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/PINProviderFactory.java47
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/PinpadPINProviderFactory.java155
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SecureViewer.java44
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java149
-rw-r--r--smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SoftwarePINProviderFactory.java140
9 files changed, 562 insertions, 94 deletions
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractBKUWorker.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractBKUWorker.java
index 23b71690..14b36e28 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractBKUWorker.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractBKUWorker.java
@@ -136,7 +136,9 @@ public abstract class AbstractBKUWorker extends AbstractSMCCSTAL implements Acti
if (oldValue != SMCCHelper.CARD_NOT_SUPPORTED) {
actionCommandList.clear();
actionCommandList.add("cancel");
- gui.showCardNotSupportedDialog(this, "cancel");
+ gui.showMessageDialog(BKUGUIFacade.TITLE_CARD_NOT_SUPPORTED,
+ BKUGUIFacade.MESSAGE_CARD_NOT_SUPPORTED, null,
+ BKUGUIFacade.BUTTON_CANCEL, this, "cancel");
oldValue = SMCCHelper.CARD_NOT_SUPPORTED;
}
break;
@@ -144,7 +146,9 @@ public abstract class AbstractBKUWorker extends AbstractSMCCSTAL implements Acti
if (oldValue != SMCCHelper.NO_CARD) {
actionCommandList.clear();
actionCommandList.add("cancel");
- gui.showInsertCardDialog(this, "cancel");
+ gui.showMessageDialog(BKUGUIFacade.TITLE_INSERTCARD,
+ BKUGUIFacade.MESSAGE_INSERTCARD, null,
+ BKUGUIFacade.BUTTON_CANCEL, this, "cancel");
oldValue = SMCCHelper.NO_CARD;
}
break;
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractPINProvider.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractPINProvider.java
new file mode 100644
index 00000000..e32f08d4
--- /dev/null
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractPINProvider.java
@@ -0,0 +1,67 @@
+/*
+ * 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.smccstal;
+
+import at.gv.egiz.smcc.PINProvider;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public abstract class AbstractPINProvider implements PINProvider, ActionListener {
+
+ protected static final Log log = LogFactory.getLog(AbstractPINProvider.class);
+
+ protected boolean retry = false;
+
+ protected String action;
+
+ private boolean actionPerformed;
+
+// protected void waitForAction() throws InterruptedException {
+// super.wait();
+// }
+
+ protected synchronized void waitForAction() throws InterruptedException {
+ try {
+ while (!actionPerformed) {
+ this.wait();
+ }
+ } catch (InterruptedException e) {
+ log.error("interrupt in waitForAction");
+ throw e;
+ }
+ actionPerformed = false;
+ }
+
+ private synchronized void actionPerformed() {
+ actionPerformed = true;
+ notify();//All();
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ log.debug("command " + e.getActionCommand());
+ action = e.getActionCommand();
+ actionPerformed();
+ }
+}
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
index 1cf81e05..71f35181 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java
@@ -121,6 +121,12 @@ public abstract class AbstractSMCCSTAL implements STAL {
return new ErrorResponse(6000);
}
+ /**
+ *
+ * @param requestList
+ * @return
+ * @throws RuntimeException with cause InterruptedException if interrupted
+ */
@Override
public List<STALResponse> handleRequest(List<? extends STALRequest> requestList) {
log.debug("Got request list containing " + requestList.size()
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
index 5a54e97f..94444922 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java
@@ -33,23 +33,26 @@ import at.gv.egiz.stal.InfoboxReadResponse;
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
-public class InfoBoxReadRequestHandler extends AbstractRequestHandler implements
- PINProvider {
+public class InfoBoxReadRequestHandler extends AbstractRequestHandler {
private static Log log = LogFactory.getLog(InfoBoxReadRequestHandler.class);
- private int retryCounter = 0;
+ protected PINProviderFactory pinProviderFactory;
@Override
public STALResponse handleRequest(STALRequest request) throws InterruptedException {
if (request instanceof InfoboxReadRequest) {
InfoboxReadRequest infoBox = (InfoboxReadRequest) request;
+ if (pinProviderFactory == null) {
+ pinProviderFactory = PINProviderFactory.getInstance(card, gui);
+ }
try {
if (infoBox.getInfoboxIdentifier().equals("IdentityLink")) {
newSTALMessage("Message.RequestCaption", "Message.IdentityLink");
log.debug("Handling identitylink infobox");
- byte[] resp = card.getInfobox(infoBox.getInfoboxIdentifier(), this,
- infoBox.getDomainIdentifier());
+ byte[] resp = card.getInfobox(infoBox.getInfoboxIdentifier(),
+ pinProviderFactory.getCardPINProvider(),
+ infoBox.getDomainIdentifier());
if (resp == null) {
log.info("Got null as result->user cancelled");
return new ErrorResponse(6001);
@@ -94,8 +97,9 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler implements
newSTALMessage("Message.RequestCaption", "Message.InfoboxReadRequest");
log.warn("Unknown infobox identifier: "
+ infoBox.getInfoboxIdentifier() + " trying generic request");
- byte[] resp = card.getInfobox(infoBox.getInfoboxIdentifier(), this,
- infoBox.getDomainIdentifier());
+ byte[] resp = card.getInfobox(infoBox.getInfoboxIdentifier(),
+ pinProviderFactory.getCardPINProvider(),
+ infoBox.getDomainIdentifier());
if (resp == null) {
return new ErrorResponse(6001);
}
@@ -110,13 +114,15 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler implements
log.info("Citizen card not activated.", e);
gui.showErrorDialog(BKUGUIFacade.ERR_CARD_NOTACTIVATED, null, this, null);
waitForAction();
- gui.showWaitDialog(null);
+ gui.showMessageDialog(BKUGUIFacade.TITLE_WAIT,
+ BKUGUIFacade.MESSAGE_WAIT);
return new ErrorResponse(6001);
} catch (LockedException e) {
log.info("Citizen card locked.", e);
gui.showErrorDialog(BKUGUIFacade.ERR_CARD_LOCKED, null, this, null);
waitForAction();
- gui.showWaitDialog(null);
+ gui.showMessageDialog(BKUGUIFacade.TITLE_WAIT,
+ BKUGUIFacade.MESSAGE_WAIT);
return new ErrorResponse(6001);
} catch (CancelledException cx) {
log.debug("User cancelled request", cx);
@@ -135,20 +141,4 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler implements
public boolean requireCard() {
return true;
}
-
- @Override
- public String providePIN(PINSpec spec, int retries) throws InterruptedException {
- if (retryCounter++ > 0) {
- log.info("PIN wrong retrying ...");
- gui.showCardPINRetryDialog(spec, retries, this, "ok", this, "cancel");
- } else {
- gui.showCardPINDialog(spec, this, "ok", this, "cancel");
- }
- waitForAction();
- gui.showWaitDialog(null);
- if (actionCommand.equals("cancel")) {
- return null;
- }
- return new String(gui.getPin());
- }
}
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/PINProviderFactory.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/PINProviderFactory.java
new file mode 100644
index 00000000..670b71dc
--- /dev/null
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/PINProviderFactory.java
@@ -0,0 +1,47 @@
+/*
+ * 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.smccstal;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.smcc.PINProvider;
+import at.gv.egiz.smcc.SignatureCard;
+import at.gv.egiz.stal.signedinfo.SignedInfoType;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public abstract class PINProviderFactory {
+
+ BKUGUIFacade gui;
+
+ public static PINProviderFactory getInstance(SignatureCard forCard,
+ BKUGUIFacade gui) {
+ if (forCard.ifdSupportsFeature(SignatureCard.FEATURE_VERIFY_PIN_DIRECT)) {
+ return new PinpadPINProviderFactory(gui);
+ } else {
+ return new SoftwarePINProviderFactory(gui);
+ }
+ }
+
+ public abstract PINProvider getSignaturePINProvider(SecureViewer viewer,
+ SignedInfoType signedInfo);
+
+ public abstract PINProvider getCardPINProvider();
+
+}
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/PinpadPINProviderFactory.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/PinpadPINProviderFactory.java
new file mode 100644
index 00000000..55321b72
--- /dev/null
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/PinpadPINProviderFactory.java
@@ -0,0 +1,155 @@
+/*
+ * 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.smccstal;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.smcc.CancelledException;
+import at.gv.egiz.smcc.PINProvider;
+import at.gv.egiz.smcc.PINSpec;
+import at.gv.egiz.stal.HashDataInput;
+import at.gv.egiz.stal.signedinfo.SignedInfoType;
+import java.util.List;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class PinpadPINProviderFactory extends PINProviderFactory {
+
+ protected PinpadPINProviderFactory(BKUGUIFacade gui) {
+ this.gui = gui;
+ }
+
+ @Override
+ public PINProvider getSignaturePINProvider(SecureViewer viewer,
+ SignedInfoType signedInfo) {
+
+ return new SignaturePinProvider(viewer, signedInfo);
+ }
+
+ @Override
+ public PINProvider getCardPINProvider() {
+ return new CardPinProvider();
+ }
+
+ class SignaturePinProvider extends AbstractPINProvider {
+
+// protected BKUGUIFacade gui;
+ protected SecureViewer viewer;
+ protected SignedInfoType signedInfo;
+ protected List<HashDataInput> hashDataInputs;
+
+ private SignaturePinProvider(SecureViewer viewer,
+ SignedInfoType signedInfo) {
+ this.viewer = viewer;
+ this.signedInfo = signedInfo;
+ }
+
+ @Override
+ public char[] providePIN(PINSpec spec, int retries)
+ throws CancelledException, InterruptedException {
+
+ showPinpadPINDialog(retries, spec);
+ retry = true;
+ return null;
+
+// do {
+// waitForAction();
+// gui.showWaitDialog(null);
+//
+// if ("hashData".equals(action)) {
+// // show pin dialog in background
+// gui.showSignaturePINDialog(spec, (retry) ? retries : -1,
+// this, "sign",
+// this, "cancel",
+// this, "hashData");
+//
+// viewer.displayDataToBeSigned(signedInfo.getReference());
+//
+// } else if ("sign".equals(action)) {
+// retry = true;
+// return gui.getPin();
+// } else if ("hashDataDone".equals(action)) {
+// gui.showSignaturePINDialog(spec, (retry) ? retries : -1,
+// this, "sign",
+// this, "cancel",
+// this, "hashData");
+// } else if ("cancel".equals(action) ||
+// "error".equals(action)) {
+// throw new CancelledException(spec.getLocalizedName() +
+// " entry cancelled");
+// }
+// } while (true);
+ }
+
+ private void showPinpadPINDialog(int retries, PINSpec pinSpec) {
+ String title, message;
+ Object[] params;
+ if (retry) {
+ title = BKUGUIFacade.TITLE_RETRY;
+ message = BKUGUIFacade.MESSAGE_RETRIES;
+ params = new Object[]{String.valueOf(retries)};
+ } else {
+ title = BKUGUIFacade.TITLE_SIGN;
+ message = BKUGUIFacade.MESSAGE_ENTERPIN_PINPAD;
+ String pinSize = String.valueOf(pinSpec.getMinLength());
+ if (pinSpec.getMinLength() != pinSpec.getMaxLength()) {
+ pinSize += "-" + pinSpec.getMaxLength();
+ }
+ params = new Object[]{pinSpec.getLocalizedName(), pinSize};
+ }
+ gui.showMessageDialog(title, message, params);
+ }
+ }
+
+ class CardPinProvider extends AbstractPINProvider {
+
+ private CardPinProvider() {
+ }
+
+ @Override
+ public char[] providePIN(PINSpec spec, int retries)
+ throws CancelledException, InterruptedException {
+
+ showPinpadPINDialog(retries, spec);
+ retry = true;
+ return null;
+
+ }
+
+ private void showPinpadPINDialog(int retries, PINSpec pinSpec) {
+ String title, message;
+ Object[] params;
+ if (retry) {
+ title = BKUGUIFacade.TITLE_RETRY;
+ message = BKUGUIFacade.MESSAGE_RETRIES;
+ params = new Object[]{String.valueOf(retries)};
+ } else {
+ title = BKUGUIFacade.TITLE_CARDPIN;
+ message = BKUGUIFacade.MESSAGE_ENTERPIN_PINPAD;
+ String pinSize = String.valueOf(pinSpec.getMinLength());
+ if (pinSpec.getMinLength() != pinSpec.getMaxLength()) {
+ pinSize += "-" + pinSpec.getMaxLength();
+ }
+ params = new Object[]{pinSpec.getLocalizedName(), pinSize};
+ }
+ gui.showMessageDialog(title, message, params);
+ }
+ }
+}
+
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SecureViewer.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SecureViewer.java
new file mode 100644
index 00000000..c395679a
--- /dev/null
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SecureViewer.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.smccstal;
+
+import at.gv.egiz.stal.signedinfo.ReferenceType;
+import java.security.DigestException;
+import java.util.List;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public interface SecureViewer {
+
+ /**
+ * Displays the hashdata inputs for all provided dsig:SignedReferences.
+ * Implementations may verify the digest value if necessary.
+ * (LocalSignRequestHandler operates on DataObjectHashDataInput,
+ * other SignRequestHandlers should cache the HashDataInputs obtained by webservice calls,
+ * or simply forward to a HashDataInputServlet.)
+ * @param signedReferences The caller may select a subset of the references in SignedInfo to be displayed.
+ * @throws java.security.DigestException if digest values are verified and do not correspond
+ * (or any other digest computation error occurs)
+ * @throws java.lang.Exception
+ */
+ void displayDataToBeSigned(List<ReferenceType> signedReferences)
+ throws DigestException, Exception;
+
+}
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
index d041a8cb..ac510f38 100644
--- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SignRequestHandler.java
@@ -17,7 +17,6 @@
package at.gv.egiz.bku.smccstal;
import at.gv.egiz.bku.gui.BKUGUIFacade;
-import java.awt.event.ActionEvent;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.security.MessageDigest;
@@ -35,12 +34,11 @@ import at.gv.egiz.smcc.CancelledException;
import at.gv.egiz.smcc.LockedException;
import at.gv.egiz.smcc.NotActivatedException;
import at.gv.egiz.smcc.PINProvider;
-import at.gv.egiz.smcc.PINSpec;
import at.gv.egiz.smcc.SignatureCard;
import at.gv.egiz.smcc.SignatureCardException;
import at.gv.egiz.smcc.SignatureCard.KeyboxName;
+import at.gv.egiz.smcc.TimeoutException;
import at.gv.egiz.stal.ErrorResponse;
-import at.gv.egiz.stal.HashDataInput;
import at.gv.egiz.stal.STALRequest;
import at.gv.egiz.stal.STALResponse;
import at.gv.egiz.stal.SignRequest;
@@ -48,13 +46,12 @@ import at.gv.egiz.stal.SignResponse;
import at.gv.egiz.stal.signedinfo.ObjectFactory;
import at.gv.egiz.stal.signedinfo.SignedInfoType;
import at.gv.egiz.stal.util.JCEAlgorithmNames;
-import java.security.DigestException;
-import java.util.List;
-public abstract class SignRequestHandler extends AbstractRequestHandler implements HashDataInputDisplay {
+public abstract class SignRequestHandler extends AbstractRequestHandler implements SecureViewer {
private static Log log = LogFactory.getLog(SignRequestHandler.class);
private static JAXBContext jaxbContext;
+ private PINProviderFactory pinProviderFactory;
static {
try {
@@ -84,7 +81,14 @@ public abstract class SignRequestHandler extends AbstractRequestHandler implemen
MessageDigest md = MessageDigest.getInstance(jceName);
md.update(signReq.getSignedInfo());
KeyboxName kb = SignatureCard.KeyboxName.getKeyboxName(signReq.getKeyIdentifier());
- byte[] resp = card.createSignature(md.digest(), kb, new STALPinProvider(si.getValue()));
+
+ if (pinProviderFactory == null) {
+ pinProviderFactory = PINProviderFactory.getInstance(card, gui);
+ }
+ PINProvider pinProvider = pinProviderFactory.
+ getSignaturePINProvider(this, si.getValue());
+
+ byte[] resp = card.createSignature(md.digest(), kb, pinProvider);
if (resp == null) {
return new ErrorResponse(6001);
}
@@ -95,17 +99,28 @@ public abstract class SignRequestHandler extends AbstractRequestHandler implemen
log.info("Citizen card not activated.", e);
gui.showErrorDialog(BKUGUIFacade.ERR_CARD_NOTACTIVATED, null, this, null);
waitForAction();
- gui.showWaitDialog(null);
+ gui.showMessageDialog(BKUGUIFacade.TITLE_WAIT,
+ BKUGUIFacade.MESSAGE_WAIT);
return new ErrorResponse(6001);
} catch (LockedException e) {
log.info("Citizen card locked.", e);
gui.showErrorDialog(BKUGUIFacade.ERR_CARD_LOCKED, null, this, null);
waitForAction();
- gui.showWaitDialog(null);
+ gui.showMessageDialog(BKUGUIFacade.TITLE_WAIT,
+ BKUGUIFacade.MESSAGE_WAIT);
return new ErrorResponse(6001);
} catch (CancelledException cx) {
log.debug("User cancelled request");
return new ErrorResponse(6001);
+ } catch (TimeoutException ex) {
+ log.error("Timeout during pin entry");
+ gui.showMessageDialog(BKUGUIFacade.TITLE_ENTRY_TIMEOUT,
+ BKUGUIFacade.ERR_PIN_TIMEOUT, null,
+ BKUGUIFacade.BUTTON_CANCEL, this, null);
+ waitForAction();
+ gui.showMessageDialog(BKUGUIFacade.TITLE_WAIT,
+ BKUGUIFacade.MESSAGE_WAIT);
+ return new ErrorResponse(6001);
} catch (SignatureCardException e) {
log.error("Error while creating signature: " + e);
return new ErrorResponse(4000);
@@ -127,64 +142,64 @@ public abstract class SignRequestHandler extends AbstractRequestHandler implemen
return true;
}
- class STALPinProvider implements PINProvider {
-
- protected SignedInfoType signedInfo;
- protected List<HashDataInput> hashDataInputs;
- private int retryCounter = 0;
-
- public STALPinProvider(SignedInfoType signedInfo) {
- this.signedInfo = signedInfo;
- }
-
- private void showSignaturePINDialog(PINSpec spec, int retries) {
- if (retryCounter > 0) {
- gui.showSignaturePINRetryDialog(spec, retries, SignRequestHandler.this, "sign", SignRequestHandler.this,
- "cancel", SignRequestHandler.this, "hashData");
- } else {
- gui.showSignaturePINDialog(spec, SignRequestHandler.this, "sign", SignRequestHandler.this, "cancel", SignRequestHandler.this,
- "hashData");
- }
- }
-
- @Override
- public String providePIN(PINSpec spec, int retries) throws InterruptedException {
-
- showSignaturePINDialog(spec, retries);
-
- do {
- waitForAction();
- gui.showWaitDialog(null);
- if (actionCommand.equals("cancel")) {
- return null;
- } else if (actionCommand.equals("hashData")) {
-
- showSignaturePINDialog(spec, retries);
-
- try {
- displayHashDataInputs(signedInfo.getReference());
- } catch (DigestException ex) {
- log.error("Bad digest value: " + ex.getMessage());
- gui.showErrorDialog(BKUGUIFacade.ERR_INVALID_HASH, new Object[] {ex.getMessage()}, SignRequestHandler.this, "error");
- } catch (Exception ex) {
- log.error("Could not display hashdata inputs: " + ex.getMessage());
- gui.showErrorDialog(BKUGUIFacade.ERR_DISPLAY_HASHDATA, new Object[] {ex.getMessage()}, SignRequestHandler.this, "error");
- }
-
- } else if (actionCommand.equals("sign")) {
- retryCounter++;
- return new String(gui.getPin());
- } else if (actionCommand.equals("hashDataDone")) {
- showSignaturePINDialog(spec, retries);
- } else if (actionCommand.equals("error")) {
- return null;
- }
- } while (true);
- }
-
+// class SoftwarePinProvider implements PINProvider {
+//
+// protected SignedInfoType signedInfo;
+// protected List<HashDataInput> hashDataInputs;
+// private boolean retry = false;
+//
+// public SoftwarePinProvider(SignedInfoType signedInfo) {
+// this.signedInfo = signedInfo;
+// }
+//
+// private void showSignaturePINDialog(PINSpec spec, int retries) {
+// if (retry) {
+// gui.showSignaturePINRetryDialog(spec, retries, SignRequestHandler.this, "sign", SignRequestHandler.this,
+// "cancel", SignRequestHandler.this, "hashData");
+// } else {
+// gui.showSignaturePINDialog(spec, SignRequestHandler.this, "sign", SignRequestHandler.this, "cancel", SignRequestHandler.this,
+// "hashData");
+// }
+// }
+//
// @Override
-// public void actionPerformed(ActionEvent e) {
-// throw new UnsupportedOperationException("Not supported yet.");
+// public char[] providePIN(PINSpec spec, int retries)
+// throws CancelledException, InterruptedException {
+// showSignaturePINDialog(spec, retries);
+//
+// do {
+// waitForAction();
+// gui.showWaitDialog(null);
+// if (actionCommand.equals("hashData")) {
+//
+// showSignaturePINDialog(spec, retries);
+//
+// try {
+// displayHashDataInputs(signedInfo.getReference());
+//
+// } catch (DigestException ex) {
+// log.error("Bad digest value: " + ex.getMessage());
+// gui.showErrorDialog(BKUGUIFacade.ERR_INVALID_HASH,
+// new Object[] {ex.getMessage()},
+// SignRequestHandler.this, "error");
+// } catch (Exception ex) {
+// log.error("Could not display hashdata inputs: " +
+// ex.getMessage());
+// gui.showErrorDialog(BKUGUIFacade.ERR_DISPLAY_HASHDATA,
+// new Object[] {ex.getMessage()},
+// SignRequestHandler.this, "error");
+// }
+// } else if (actionCommand.equals("sign")) {
+// retry = true;
+// return gui.getPin();
+// } else if (actionCommand.equals("hashDataDone")) {
+// showSignaturePINDialog(spec, retries);
+// } else if (actionCommand.equals("cancel") ||
+// actionCommand.equals("error")) {
+// throw new CancelledException(spec.getLocalizedName() +
+// " entry cancelled");
+// }
+// } while (true);
// }
- }
+// }
}
diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SoftwarePINProviderFactory.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SoftwarePINProviderFactory.java
new file mode 100644
index 00000000..54a34280
--- /dev/null
+++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SoftwarePINProviderFactory.java
@@ -0,0 +1,140 @@
+/*
+ * 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.smccstal;
+
+import at.gv.egiz.bku.gui.BKUGUIFacade;
+import at.gv.egiz.smcc.*;
+import at.gv.egiz.stal.HashDataInput;
+import at.gv.egiz.stal.signedinfo.SignedInfoType;
+import java.security.DigestException;
+import java.util.List;
+
+/**
+ *
+ * @author Clemens Orthacker <clemens.orthacker@iaik.tugraz.at>
+ */
+public class SoftwarePINProviderFactory extends PINProviderFactory {
+
+ protected SoftwarePINProviderFactory(BKUGUIFacade gui) {
+ this.gui = gui;
+ }
+
+ @Override
+ public PINProvider getSignaturePINProvider(SecureViewer viewer,
+ SignedInfoType signedInfo) {
+ return new SignaturePinProvider(viewer, signedInfo);
+ }
+
+ @Override
+ public PINProvider getCardPINProvider() {
+ return new CardPinProvider();
+ }
+
+ class SignaturePinProvider extends AbstractPINProvider {
+
+// protected BKUGUIFacade gui;
+ protected SecureViewer viewer;
+ protected SignedInfoType signedInfo;
+ protected List<HashDataInput> hashDataInputs;
+
+ private SignaturePinProvider(SecureViewer viewer,
+ SignedInfoType signedInfo) {
+ this.viewer = viewer;
+ this.signedInfo = signedInfo;
+ }
+
+ @Override
+ public char[] providePIN(PINSpec spec, int retries)
+ throws CancelledException, InterruptedException {
+
+ gui.showSignaturePINDialog(spec, (retry) ? retries : -1,
+ this, "sign",
+ this, "cancel",
+ this, "hashData");
+
+ do {
+ waitForAction();
+ gui.showMessageDialog(BKUGUIFacade.TITLE_WAIT,
+ BKUGUIFacade.MESSAGE_WAIT);
+
+ if ("hashData".equals(action)) {
+ // show pin dialog in background
+ gui.showSignaturePINDialog(spec, (retry) ? retries : -1,
+ this, "sign",
+ this, "cancel",
+ this, "hashData");
+
+ try {
+ viewer.displayDataToBeSigned(signedInfo.getReference());
+ } catch (DigestException ex) {
+ log.error("Bad digest value: " + ex.getMessage());
+ gui.showErrorDialog(BKUGUIFacade.ERR_INVALID_HASH,
+ new Object[]{ex.getMessage()},
+ this, "error");
+ } catch (Exception ex) {
+ log.error("Could not display hashdata inputs: " +
+ ex.getMessage());
+ gui.showErrorDialog(BKUGUIFacade.ERR_DISPLAY_HASHDATA,
+ new Object[]{ex.getMessage()},
+ this, "error");
+ }
+ } else if ("sign".equals(action)) {
+ retry = true;
+ return gui.getPin();
+ } else if ("hashDataDone".equals(action)) {
+ gui.showSignaturePINDialog(spec, (retry) ? retries : -1,
+ this, "sign",
+ this, "cancel",
+ this, "hashData");
+ } else if ("cancel".equals(action) ||
+ "error".equals(action)) {
+ throw new CancelledException(spec.getLocalizedName() +
+ " entry cancelled");
+ }
+ } while (true);
+ }
+ }
+
+ class CardPinProvider extends AbstractPINProvider {
+
+// protected BKUGUIFacade gui;
+
+ private CardPinProvider() {
+ }
+
+ @Override
+ public char[] providePIN(PINSpec spec, int retries)
+ throws CancelledException, InterruptedException {
+
+ gui.showCardPINDialog(spec, (retry) ? retries : -1,
+ this, "ok",
+ this, "cancel");
+
+ waitForAction();
+
+ gui.showMessageDialog(BKUGUIFacade.TITLE_WAIT,
+ BKUGUIFacade.MESSAGE_WAIT);
+
+ if ("cancel".equals(action)) {
+ throw new CancelledException(spec.getLocalizedName() +
+ " entry cancelled");
+ }
+ retry = true;
+ return gui.getPin();
+ }
+ }
+}