diff options
Diffstat (limited to 'smcc/src')
8 files changed, 82 insertions, 64 deletions
diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java b/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java index 9e56701f..2baff834 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java @@ -106,8 +106,9 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { /* (non-Javadoc) * @see at.gv.egiz.smcc.SignatureCard#getCertificate(at.gv.egiz.smcc.SignatureCard.KeyboxName) */ + @Override public byte[] getCertificate(KeyboxName keyboxName) - throws SignatureCardException { + throws SignatureCardException, InterruptedException { byte[] aid; byte[] efc; @@ -150,8 +151,9 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { /* (non-Javadoc) * @see at.gv.egiz.smcc.SignatureCard#getInfobox(java.lang.String, at.gv.egiz.smcc.PINProvider, java.lang.String) */ + @Override public byte[] getInfobox(String infobox, PINProvider provider, String domainId) - throws SignatureCardException { + throws SignatureCardException, InterruptedException { if ("IdentityLink".equals(infobox)) { @@ -181,8 +183,9 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { } + @Override public byte[] createSignature(byte[] hash, KeyboxName keyboxName, - PINProvider provider) throws SignatureCardException { + PINProvider provider) throws SignatureCardException, InterruptedException { if (hash.length != 20) { throw new IllegalArgumentException("Hash value must be of length 20."); @@ -299,8 +302,9 @@ public class ACOSCard extends AbstractSignatureCard implements SignatureCard { * @throws javax.smartcardio.CardException * @throws at.gv.egiz.smcc.SignatureCardException */ + @Override protected void verifyPIN(PINProvider pinProvider, PINSpec spec, byte kid) - throws CardException, CancelledException, SignatureCardException { + throws CardException, CancelledException, SignatureCardException, InterruptedException { int retries = -1; do { diff --git a/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java b/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java index cebc63fc..b828e8cd 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/AbstractSignatureCard.java @@ -110,7 +110,7 @@ public abstract class AbstractSignatureCard implements SignatureCard { * if VERIFY PIN fails */ protected abstract void verifyPIN(PINProvider pinProvider, PINSpec spec, - byte kid) throws CardException, SignatureCardException; + byte kid) throws CardException, SignatureCardException, InterruptedException; protected byte[] readBinary(CardChannel channel, int offset, int len) throws CardException, SignatureCardException { @@ -194,7 +194,7 @@ public abstract class AbstractSignatureCard implements SignatureCard { * @throws SignatureCardException */ protected byte[] readTLVFile(byte[] aid, byte[] ef, int maxLength) - throws SignatureCardException { + throws SignatureCardException, InterruptedException { return readTLVFilePIN(aid, ef, (byte) 0, null, null, maxLength); } @@ -215,7 +215,7 @@ public abstract class AbstractSignatureCard implements SignatureCard { */ protected byte[] readTLVFilePIN(byte[] aid, byte[] ef, byte kid, PINProvider provider, PINSpec spec, int maxLength) - throws SignatureCardException { + throws SignatureCardException, InterruptedException { try { diff --git a/smcc/src/main/java/at/gv/egiz/smcc/PINProvider.java b/smcc/src/main/java/at/gv/egiz/smcc/PINProvider.java index 844115a4..e0104618 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/PINProvider.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/PINProvider.java @@ -30,6 +30,6 @@ package at.gv.egiz.smcc; public interface PINProvider { - public String providePIN(PINSpec spec, int retries); + public String providePIN(PINSpec spec, int retries) throws InterruptedException; } diff --git a/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java b/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java index 99acbc0f..d6d02475 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/STARCOSCard.java @@ -129,8 +129,9 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard /* (non-Javadoc) * @see at.gv.egiz.smcc.SignatureCard#getCertificate(at.gv.egiz.smcc.SignatureCard.KeyboxName) */ + @Override public byte[] getCertificate(KeyboxName keyboxName) - throws SignatureCardException { + throws SignatureCardException, InterruptedException { byte[] aid; byte[] efc; @@ -169,8 +170,9 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard /* (non-Javadoc) * @see at.gv.egiz.smcc.SignatureCard#getInfobox(java.lang.String, at.gv.egiz.smcc.PINProvider, java.lang.String) */ + @Override public byte[] getInfobox(String infobox, PINProvider provider, String domainId) - throws SignatureCardException { + throws SignatureCardException, InterruptedException { if ("IdentityLink".equals(infobox)) { @@ -204,7 +206,7 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard * @see at.gv.egiz.smcc.SignatureCard#createSignature(byte[], at.gv.egiz.smcc.SignatureCard.KeyboxName, at.gv.egiz.smcc.PINProvider) */ public byte[] createSignature(byte[] hash, KeyboxName keyboxName, - PINProvider provider) throws SignatureCardException { + PINProvider provider) throws SignatureCardException, InterruptedException { if (hash.length != 20) { throw new IllegalArgumentException("Hash value must be of length 20."); @@ -399,7 +401,7 @@ public class STARCOSCard extends AbstractSignatureCard implements SignatureCard * @see at.gv.egiz.smcc.AbstractSignatureCard#verifyPIN(at.gv.egiz.smcc.PINProvider, at.gv.egiz.smcc.PINSpec, byte, int) */ protected void verifyPIN(PINProvider pinProvider, PINSpec spec, byte kid) - throws CardException, SignatureCardException { + throws CardException, SignatureCardException, InterruptedException { int retries = verifyPIN(null, kid); do { diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java b/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java index 42a4be1b..42943541 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/SWCard.java @@ -297,7 +297,8 @@ public class SWCard implements SignatureCard { } - public byte[] createSignature(byte[] hash, KeyboxName keyboxName, PINProvider provider) throws SignatureCardException { + @Override + public byte[] createSignature(byte[] hash, KeyboxName keyboxName, PINProvider provider) throws SignatureCardException, InterruptedException { // KeyStore password String password = getPassword(keyboxName); diff --git a/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java b/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java index 37bd7cf9..b6a453df 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/SignatureCard.java @@ -57,6 +57,7 @@ public interface SignatureCard { } } + @Override public boolean equals(Object obj) { if (obj instanceof String) { return obj.equals(keyboxName_); @@ -77,7 +78,7 @@ public interface SignatureCard { public void init(Card card); public byte[] getCertificate(KeyboxName keyboxName) - throws SignatureCardException; + throws SignatureCardException, InterruptedException; public void disconnect(boolean reset); @@ -88,12 +89,22 @@ public interface SignatureCard { * @param domainId may be null. * @return * @throws SignatureCardException + * @throws InterruptedException if applet is destroyed while in pin dialog */ public byte[] getInfobox(String infobox, PINProvider provider, String domainId) - throws SignatureCardException; + throws SignatureCardException, InterruptedException; + /** + * + * @param hash + * @param keyboxName + * @param provider + * @return + * @throws at.gv.egiz.smcc.SignatureCardException + * @throws java.lang.InterruptedException if applet is destroyed while in pin dialog + */ public byte[] createSignature(byte[] hash, KeyboxName keyboxName, - PINProvider provider) throws SignatureCardException; + PINProvider provider) throws SignatureCardException, InterruptedException; /** * Sets the local for evtl. required callbacks (e.g. PINSpec) diff --git a/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java b/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java index b921a5d5..13210540 100644 --- a/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java +++ b/smcc/src/test/java/at/gv/egiz/smcc/STARCOSCardTest.java @@ -37,7 +37,7 @@ public class STARCOSCardTest { * @throws CardException * @throws NoSuchAlgorithmException */ - public static void main(String[] args) throws CardException, NoSuchAlgorithmException { + public static void main(String[] args) throws CardException, NoSuchAlgorithmException, InterruptedException { SMCCHelper helper = new SMCCHelper(); while (helper.getResultCode() != SMCCHelper.CARD_FOUND) { diff --git a/smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java b/smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java index 5448fee2..38126a67 100644 --- a/smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java +++ b/smcc/src/test/java/at/gv/egiz/smcc/SWCardTest.java @@ -14,50 +14,50 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package at.gv.egiz.smcc;
-
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-import at.gv.egiz.smcc.SignatureCard.KeyboxName;
-
-public class SWCardTest implements PINProvider {
-
- SWCard swCard = new SWCard();
-
- public static void main(String[] args) throws Exception {
-
- SWCardTest swCardTest = new SWCardTest();
- swCardTest.test();
-
- }
-
- public void test() throws SignatureCardException, NoSuchAlgorithmException {
-
- swCard.getCertificate(KeyboxName.CERITIFIED_KEYPAIR);
- swCard.getCertificate(KeyboxName.SECURE_SIGNATURE_KEYPAIR);
-
- BigInteger t = BigInteger.valueOf(System.currentTimeMillis());
-
- MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
- byte[] hash = messageDigest.digest(t.toByteArray());
-
- byte[] signature;
- signature = swCard.createSignature(hash, KeyboxName.CERITIFIED_KEYPAIR, this);
- System.out.println(SignatureCardFactory.toString(signature));
-
- signature = swCard.createSignature(hash, KeyboxName.SECURE_SIGNATURE_KEYPAIR, this);
- System.out.println(SignatureCardFactory.toString(signature));
-
- byte[] infobox = swCard.getInfobox("IdentityLink", this, null);
- System.out.println(SignatureCardFactory.toString(infobox));
-
- }
-
- @Override
- public String providePIN(PINSpec spec, int retries) {
- return "buerger";
- }
-
-}
+package at.gv.egiz.smcc; + +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +import at.gv.egiz.smcc.SignatureCard.KeyboxName; + +public class SWCardTest implements PINProvider { + + SWCard swCard = new SWCard(); + + public static void main(String[] args) throws Exception { + + SWCardTest swCardTest = new SWCardTest(); + swCardTest.test(); + + } + + public void test() throws SignatureCardException, NoSuchAlgorithmException, InterruptedException { + + swCard.getCertificate(KeyboxName.CERITIFIED_KEYPAIR); + swCard.getCertificate(KeyboxName.SECURE_SIGNATURE_KEYPAIR); + + BigInteger t = BigInteger.valueOf(System.currentTimeMillis()); + + MessageDigest messageDigest = MessageDigest.getInstance("SHA-1"); + byte[] hash = messageDigest.digest(t.toByteArray()); + + byte[] signature; + signature = swCard.createSignature(hash, KeyboxName.CERITIFIED_KEYPAIR, this); + System.out.println(SignatureCardFactory.toString(signature)); + + signature = swCard.createSignature(hash, KeyboxName.SECURE_SIGNATURE_KEYPAIR, this); + System.out.println(SignatureCardFactory.toString(signature)); + + byte[] infobox = swCard.getInfobox("IdentityLink", this, null); + System.out.println(SignatureCardFactory.toString(infobox)); + + } + + @Override + public String providePIN(PINSpec spec, int retries) { + return "buerger"; + } + +} |