Commit ab7ef744 authored by Tobias Wich's avatar Tobias Wich
Browse files

Merge branch 'master' into reqesidta

parents 3ca2efe7 8ed7db8f
......@@ -75,15 +75,15 @@ public interface EacGui extends AndroidGui {
PinStatus getPinStatus() throws InterruptedException;
/**
* Enter the PIN and if needed also the CAN.
* Enter the user's password (usually PIN) and if needed also the CAN.
* In case the CAN is not needed, the parameter may be null.
*
* @param can
* @param pin
* @return rue if PIN is accepted, false otherwise.
* @param password
* @return {@code true} if PIN is accepted, {@code false} otherwise.
* @throws InterruptedException Thrown if waiting for the value has been interrupted.
*/
boolean enterPin(String can, String pin) throws InterruptedException;
boolean enterPin(String can, String password) throws InterruptedException;
/**
* Cancel EAC process.
......
......@@ -146,7 +146,7 @@ public class EacGuiImpl implements EacGui {
@Override
public synchronized void cancel() {
LOG.debug("Cancel of Android EAC GUI called.", new Exception("Print Stacktrace"));
LOG.debug("Cancel of Android EAC GUI called.");
if (! cancelPromise.isDelivered() && ! cancelPromise.isCancelled()) {
cancelPromises(false);
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.openecard</groupId>
<artifactId>gui</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.4.0-rc.4-SNAPSHOT</version>
</parent>
<groupId>org.openecard.gui</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.openecard</groupId>
<artifactId>gui</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.4.0-rc.4-SNAPSHOT</version>
</parent>
<groupId>org.openecard.gui</groupId>
......
......@@ -4,8 +4,9 @@
<parent>
<groupId>org.openecard</groupId>
<artifactId>app</artifactId>
<version>1.3.1-SNAPSHOT</version>
<artifactId>src-parent</artifactId>
<version>1.4.0-rc.4-SNAPSHOT</version>
<relativePath>../src-parent/</relativePath>
</parent>
<groupId>org.openecard</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.openecard</groupId>
<artifactId>gui</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.4.0-rc.4-SNAPSHOT</version>
</parent>
<groupId>org.openecard.gui</groupId>
......
......@@ -4,8 +4,9 @@
<parent>
<groupId>org.openecard</groupId>
<artifactId>app</artifactId>
<version>1.3.1-SNAPSHOT</version>
<artifactId>src-parent</artifactId>
<version>1.4.0-rc.4-SNAPSHOT</version>
<relativePath>../src-parent/</relativePath>
</parent>
<groupId>org.openecard</groupId>
......
......@@ -26,7 +26,7 @@ dg01=Document type
install_qualified_certificate=Install signature certificate
install_certificate=Install non-qualified signature certificate
pin_management=PIN Management
can_allowed=CAN allowed
can_allowed=On-Site Verification
privileged_terminal=Privileged Terminal
restricted_identification=Restricted Identification
community_id_verification=Address verification
......
......@@ -26,7 +26,7 @@ dg01=Dokumentenart
install_qualified_certificate=Signatur-Zertifikat installieren
install_certificate=nicht-qualifiziertes Signatur-Zertifikat installieren
pin_management=PIN-Management
can_allowed=CAN erlaubt
can_allowed=Vor-Ort Auslesen
privileged_terminal=Privilegiertes Terminal
restricted_identification=Pseudonym
community_id_verification=Wohnortbestätigung
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.openecard</groupId>
<artifactId>ifd</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.4.0-rc.4-SNAPSHOT</version>
</parent>
<groupId>org.openecard.ifd</groupId>
......
/****************************************************************************
* Copyright (C) 2015 ecsec GmbH.
* Copyright (C) 2015-2019 ecsec GmbH.
* All rights reserved.
* Contact: ecsec GmbH (info@ecsec.de)
*
......@@ -154,9 +154,9 @@ public enum SCIOErrorCode {
/** No PIN was presented to the smart card. */
SCARD_W_CARD_NOT_AUTHENTICATED (0x8010006F);
private final int[] codes;
private final long[] codes;
private SCIOErrorCode(int... codes) {
private SCIOErrorCode(long... codes) {
this.codes = codes;
}
......@@ -166,8 +166,8 @@ public enum SCIOErrorCode {
* @param code Code to test.
* @return {@code true} if the code represents this enum instance, {@code false} otherwise.
*/
public boolean matchesCode(int code) {
for (int c : codes) {
public boolean matchesCode(long code) {
for (long c : codes) {
if (c == code) {
return true;
}
......@@ -181,15 +181,25 @@ public enum SCIOErrorCode {
* @param code The code for which to look up the enum entry.
* @return The entry matching the given code, or {@link #SCARD_F_UNKNOWN_ERROR} if no known code has been given.
*/
public static SCIOErrorCode getErrorCode(int code) {
public static SCIOErrorCode getErrorCode(long code) {
// no index, just walk over each code, doesn't happen so often that performance should be a problem
for (SCIOErrorCode next : SCIOErrorCode.values()) {
if (next.matchesCode(code)) {
return next;
}
}
// no match found, unkown error
// no match found, unknown error
return SCARD_F_UNKNOWN_ERROR;
}
public static long getLong(SCIOErrorCode code) {
for (SCIOErrorCode next : SCIOErrorCode.values()) {
if (next.name().equals(code.name())) {
return next.codes[0];
}
}
// no match found, unknown error (SCARD_F_UNKNOWN_ERROR)
return SCARD_F_UNKNOWN_ERROR.SCARD_F_UNKNOWN_ERROR.codes[0];
}
}
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.openecard</groupId>
<artifactId>ifd</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.4.0-rc.4-SNAPSHOT</version>
</parent>
<groupId>org.openecard.ifd</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.openecard.ifd</groupId>
<artifactId>ifd-protocols</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.4.0-rc.4-SNAPSHOT</version>
</parent>
<groupId>org.openecard.ifd.protocols</groupId>
......
......@@ -25,6 +25,7 @@ package org.openecard.ifd.protocol.pace;
import java.security.GeneralSecurityException;
import java.util.List;
import org.openecard.common.ECardConstants;
import org.openecard.common.WSHelper;
import org.openecard.common.apdu.GeneralAuthenticate;
import org.openecard.common.apdu.common.CardCommandAPDU;
import org.openecard.common.apdu.common.CardResponseAPDU;
......@@ -135,7 +136,7 @@ public class PACEImplementation {
if (e.getCause() instanceof Exception) {
throw (Exception) e.getCause();
} else {
throw new ProtocolException(ECardConstants.Minor.IFD.UNKNOWN_ERROR, e.getMessage());
throw new ProtocolException(e.getResultMinor(), e.getMessage());
}
}
......
......@@ -26,6 +26,7 @@ import iso.std.iso_iec._24727.tech.schema.EstablishChannel;
import iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse;
import java.io.UnsupportedEncodingException;
import org.openecard.common.ECardConstants;
import org.openecard.common.ECardException;
import org.openecard.common.WSHelper;
import org.openecard.common.apdu.common.CardResponseAPDU;
import org.openecard.common.apdu.utils.CardUtils;
......@@ -121,7 +122,7 @@ public class PACEProtocol implements Protocol {
response.setResult(WSHelper.makeResultError(
ECardConstants.Minor.IFD.IO.UNKNOWN_PIN_FORMAT,
"Cannot encode the PIN in " + PACEConstants.PIN_CHARSET + " charset."));
} catch (ProtocolException ex) {
} catch (ECardException ex) {
logger.error(ex.getMessage(), ex);
response.setResult(WSHelper.makeResult(ex));
} catch (Throwable ex) {
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.openecard</groupId>
<artifactId>ifd</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.4.0-rc.4-SNAPSHOT</version>
</parent>
<groupId>org.openecard.ifd</groupId>
......
......@@ -4,8 +4,9 @@
<parent>
<groupId>org.openecard</groupId>
<artifactId>app</artifactId>
<version>1.3.1-SNAPSHOT</version>
<artifactId>src-parent</artifactId>
<version>1.4.0-rc.4-SNAPSHOT</version>
<relativePath>../src-parent/</relativePath>
</parent>
<groupId>org.openecard</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.openecard.ifd</groupId>
<artifactId>scio-backend</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.4.0-rc.4-SNAPSHOT</version>
</parent>
<groupId>org.openecard.ifd.scio-backend</groupId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.openecard.ifd</groupId>
<artifactId>scio-backend</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.4.0-rc.4-SNAPSHOT</version>
</parent>
<groupId>org.openecard.ifd.scio-backend</groupId>
......@@ -24,6 +24,11 @@
<artifactId>wsdef-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.github.jnasmartcardio</groupId>
<artifactId>jnasmartcardio</artifactId>
<version>0.2.7</version>
</dependency>
</dependencies>
</project>
/****************************************************************************
* Copyright (C) 2015-2018 ecsec GmbH.
* Copyright (C) 2015-2019 ecsec GmbH.
* All rights reserved.
* Contact: ecsec GmbH (info@ecsec.de)
*
......@@ -22,12 +22,10 @@
package org.openecard.scio;
import java.lang.reflect.Field;
import javax.annotation.Nonnull;
import javax.smartcardio.CardException;
import jnasmartcardio.Smartcardio.JnaPCSCException;
import org.openecard.common.ifd.scio.SCIOErrorCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
......@@ -37,60 +35,20 @@ import org.slf4j.LoggerFactory;
*/
public class PCSCExceptionExtractor {
private static final Logger LOG = LoggerFactory.getLogger(PCSCExceptionExtractor.class);
public static SCIOErrorCode getCode(@Nonnull CardException mainException) {
return getCode((Exception) mainException);
return getCode((JnaPCSCException) mainException);
}
/**
* Gets the actual error code from the given CardException.
* This method uses reflections to access the actual error code which is hidden in the Java SmartcardIO. In case no
* error code can be found, {@link SCIOErrorCode#SCARD_F_UNKNOWN_ERROR} is returned.
* Gets the actual error code from the given JnaPCSCException.
* In case no error code can be found, {@link SCIOErrorCode#SCARD_F_UNKNOWN_ERROR} is returned.
*
* @param mainException The exception coming from the Java SmartcardIO.
* @return The code extracted from the exception, or {@link SCIOErrorCode#SCARD_F_UNKNOWN_ERROR} if no code could be
* extracted.
*/
public static SCIOErrorCode getCode(@Nonnull Exception mainException) {
Throwable cause = getPCSCException(mainException);
// check the type of the cause over reflections because these classes might not be available (sun internal)
if (cause != null) {
try {
Class<?> c = cause.getClass();
Field f = c.getDeclaredField("code");
f.setAccessible(true);
int code = f.getInt(cause);
return SCIOErrorCode.getErrorCode(code);
} catch (NoSuchFieldException ex) {
LOG.error("Failed to find field 'code' in PCSCException.");
// fallthrough as this only reduces the quality of the exceptions
} catch (IllegalAccessException ex) {
LOG.error("Failed to read field 'code' in PCSCException.");
// fallthrough as this only reduces the quality of the exceptions
} catch (SecurityException ex) {
LOG.error("Failed access field 'code' in PCSCException or change its accessibility.");
// fallthrough as this only reduces the quality of the exceptions
}
}
return SCIOErrorCode.SCARD_F_UNKNOWN_ERROR;
}
public static boolean hasPCSCException(Exception mainException) {
return getPCSCException(mainException) != null;
}
private static Throwable getPCSCException(Exception mainException) {
Throwable cause = mainException.getCause();
// check the type of the cause over reflections because these classes might not be available (sun internal)
if (cause != null) {
Class<?> c = cause.getClass();
if ("sun.security.smartcardio.PCSCException".equals(c.getName())) {
return cause;
}
}
return null;
public static SCIOErrorCode getCode(@Nonnull JnaPCSCException mainException) {
return SCIOErrorCode.getErrorCode(mainException.code);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment