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

Merge branch 'master' into reqesidta

parents 3ca2efe7 8ed7db8f
......@@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'digital.wup:android-maven-publish:3.6.2'
}
}
......@@ -15,12 +15,12 @@ apply plugin: 'digital.wup.android-maven-publish'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
minSdkVersion 17
targetSdkVersion 28
targetSdkVersion 29
//testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
......@@ -74,10 +74,11 @@ configurations {
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
//implementation 'androidx.appcompat:appcompat:1.0.0'
//androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
// exclude group: 'com.android.support', module: 'support-annotations'
//})
//testImplementation 'junit:junit:4.12'
//androidTestImplementation 'com.android.support.test:runner:1.0.2'
//androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// necessary dependencies which are not packed into the aar
api 'org.slf4j:slf4j-api:1.7.25'
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.openecard</groupId>
<artifactId>clients</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.4.0-rc.4-SNAPSHOT</version>
</parent>
<groupId>org.openecard.clients</groupId>
......@@ -103,80 +103,9 @@
<scope>provided</scope>
</dependency>
<!-- name all dependencies, so that build is only triggered after these are built -->
<dependency>
<groupId>org.openecard.ifd.scio-backend</groupId>
<artifactId>android-nfc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard.wsdef</groupId>
<artifactId>android-marshaller</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard</groupId>
<artifactId>recognition</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard.ifd</groupId>
<artifactId>ifd-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard.ifd</groupId>
<artifactId>ifd-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard</groupId>
<artifactId>management</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard.sal</groupId>
<artifactId>tiny-sal</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard</groupId>
<artifactId>addon</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard.addons</groupId>
<artifactId>tr03112</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard.addons</groupId>
<artifactId>pin-management</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard.addons</groupId>
<artifactId>status</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard.addons</groupId>
<artifactId>genericcryptography</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard.ifd.protocols</groupId>
<artifactId>pace</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openecard.gui</groupId>
<artifactId>android</artifactId>
<groupId>org.openecard.clients</groupId>
<artifactId>android-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
......
......@@ -26,6 +26,7 @@ import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import iso.std.iso_iec._24727.tech.schema.ConnectionHandleType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -41,7 +42,9 @@ import org.openecard.android.system.ServiceResponse;
import org.openecard.android.utils.NfcUtils;
import org.openecard.common.event.EventObject;
import org.openecard.common.event.EventType;
import org.openecard.common.event.IfdEventObject;
import org.openecard.common.interfaces.EventCallback;
import org.openecard.common.sal.state.CardStateEntry;
import org.openecard.common.util.CombinedPromise;
import org.openecard.common.util.Promise;
import org.openecard.gui.android.AndroidGui;
......@@ -142,8 +145,18 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
final ActivationController ac = new ActivationController(octx);
// add callback to this abstract activity when card is removed
cardRecognized = false;
// check card states for already inserted card and call recognised handler
CardStateEntry availableCard = getAvailableCard();
if (availableCard != null) {
insertionHandler.signalEvent(EventType.CARD_INSERTED, new IfdEventObject(availableCard.handleCopy()));
cardDetectHandler.signalEvent(EventType.RECOGNIZED_CARD_ACTIVE, new IfdEventObject(availableCard.handleCopy()));
}
octx.getEventDispatcher().add(insertionHandler, EventType.CARD_REMOVED, EventType.CARD_INSERTED);
octx.getEventDispatcher().add(cardDetectHandler, EventType.RECOGNIZED_CARD_ACTIVE);
octx.getEventDispatcher().add(removalHandler, EventType.CARD_REMOVED);
Intent actIntent = parent.getIntent();
Uri data = actIntent.getData();
......@@ -165,6 +178,27 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
}
}
private CardStateEntry getAvailableCard() {
// look in card states for a card matching our criteria
Set<String> types = getSupportedCards();
if (types != null) {
for (String type : types) {
ConnectionHandleType query = new ConnectionHandleType();
ConnectionHandleType.RecognitionInfo rinfo = new ConnectionHandleType.RecognitionInfo();
rinfo.setCardType(type);
query.setRecognitionInfo(rinfo);
CardStateEntry entry = octx.getCardStates().getEntry(query);
if (entry != null) {
return entry;
}
}
return null;
} else {
return octx.getCardStates().getEntry(new ConnectionHandleType());
}
}
@Nullable
private Class<?> forClassName(@Nullable String className) {
if (className != null) {
......@@ -197,11 +231,13 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
public void onStop() {
// make sure nothing is running anymore
cancelAuthenticationInt(false, false);
cancelAuthenticationInt(authThread, false);
// remove callback which is set onStart
if (octx != null) {
octx.getEventDispatcher().del(insertionHandler);
octx.getEventDispatcher().del(cardDetectHandler);
octx.getEventDispatcher().del(removalHandler);
}
// unbind client
if (client != null) {
......@@ -214,6 +250,7 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
octx = null;
cardRemoveDialog = null;
androidGui = null;
cardRecognized = false;
}
private final EventCallback insertionHandler = new EventCallback() {
......@@ -236,20 +273,24 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
}
};
private boolean cardRecognized = false;
private final EventCallback cardDetectHandler = new EventCallback() {
@Override
public void signalEvent(EventType eventType, EventObject eventData) {
switch (eventType) {
case RECOGNIZED_CARD_ACTIVE:
Set<String> supportedCards = getSupportedCards();
final String type = eventData.getHandle().getRecognitionInfo().getCardType();
if (supportedCards == null || supportedCards.contains(type)) {
onCardInserted(type);
ConnectionHandleType handle = eventData.getHandle();
final String type = handle.getRecognitionInfo().getCardType();
if (supportedCards == null || supportedCards.contains(type)) {
// remove handler when the correct card is present
if (octx != null) {
octx.getEventDispatcher().del(this);
}
cardRecognized = true;
onCardInserted(type);
}
break;
default:
......@@ -259,6 +300,17 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
}
};
private final EventCallback removalHandler = new EventCallback() {
@Override
public void signalEvent(EventType eventType, EventObject eventData) {
if (cardRecognized) {
cardRecognized = false;
onCardRemoved();
}
}
};
private synchronized void handleActivationResult(final ActivationResult result) {
// only this first invocation must be processed, in order to prevent double finish when cancelling the auth job
if (authThread == null) {
......@@ -320,6 +372,12 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
LOG.info("Card recognized event received in activity: cardType={}", cardType);
}
@Override
public void onCardRemoved() {
// default implementation does nothing
LOG.info("Card removed event received in activity.");
}
@Override
public void cancelAuthentication() {
cancelAuthentication(false);
......@@ -327,26 +385,27 @@ public abstract class AbstractActivationHandler <T extends Activity, GUI extends
@Override
public void cancelAuthentication(boolean runInThread) {
cancelAuthenticationInt(true, runInThread);
cancelAuthenticationInt(authThread, runInThread);
}
private void cancelAuthenticationInt(boolean showFailure, boolean runInNewThread) {
Thread at = authThread;
private void cancelAuthenticationInt(Thread at, boolean runInNewThread) {
if (at != null) {
if (at == authThread) {
authThread = null;
}
// define function
Runnable fun = () -> {
try {
// cancel task and handle event
String msg = "";
ActivationResult result = new ActivationResult(ActivationResultCode.INTERRUPTED, msg);
onAuthenticationInterrupted(result);
LOG.info("Stopping Authentication thread ...");
at.interrupt();
at.join();
LOG.info("Authentication thread has stopped.");
// cancel task and handle event
if (showFailure) {
String msg = "";
ActivationResult r = new ActivationResult(ActivationResultCode.INTERRUPTED, msg);
handleActivationResult(r);
}
} catch (InterruptedException ex) {
LOG.error("Waiting for Authentication thread interrupted.");
} finally {
......
......@@ -53,6 +53,20 @@ public interface ActivationCallbackInterface <GUI extends AndroidGui> {
*/
void onCardInserted(String cardType);
/**
* Callback for card removed events.
* This method can be used to directly see when a card gets removed from the system.
* <p>Causes for removal are either:</p>
* <ul>
* <li>User removed the card</li>
* <li>Card gets disconnected after a finished eID process</li>
* <li>Card is removed from the system due to an error</li>
* </ul>
* <p>Given the various options why a card could have been removed, it is important to take the result of the
* eID process (cf. {@link #onAuthenticationSuccess(ActivationResult)} etc.) into consideration.</p>
*/
void onCardRemoved();
/**
* This method is called when the specific android GUI is available to the activity.
* <p>If this method is called the server data can be accessed and the PIN can be entered.</p>
......
......@@ -138,6 +138,9 @@ public class ActivationController {
default:
activationResult = new ActivationResult(INTERNAL_ERROR, result.getResultMessage());
}
activationResult.setProcessMinor(result.getAuxResultData().get(AuxDataKeys.MINOR_PROCESS_RESULT));
return activationResult;
}
......
......@@ -32,6 +32,7 @@ public class ActivationResult {
private final String redirectUrl;
private final ActivationResultCode resultCode;
private final String errorMessage;
private String processMinor;
public ActivationResult(ActivationResultCode resultCode) {
this(null, resultCode, null);
......@@ -51,6 +52,10 @@ public class ActivationResult {
this.errorMessage = errorMessage;
}
public void setProcessMinor(String processMinor) {
this.processMinor = processMinor;
}
public String getRedirectUrl() {
return redirectUrl;
}
......@@ -63,4 +68,14 @@ public class ActivationResult {
return errorMessage;
}
/**
* If present, represents the minor error code of the error leading to the termination of the process.
*
* @see ECardConstants.Minor;
* @return The minor result code or {@code null} if not present.
*/
public String getProcessResultMinor() {
return processMinor;
}
}
......@@ -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>
......@@ -18,8 +19,6 @@
<module>richclient</module>
<module>android-core</module>
<module>android-lib</module>
<module>richclient-bundle</module>
<module>richclient-jlink</module>
</modules>
</project>
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openecard.clients</groupId>
<artifactId>richclient-bundle</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Rich Client (Bundle)</name>
<properties>
<maven.compiler.release>11</maven.compiler.release>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.openecard.richclient.RichClient</mainClass>
</manifest>
</archive>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.openecard.clients</groupId>
<artifactId>richclient</artifactId>
<version>1.3.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openecard.clients</groupId>
<artifactId>richclient-jlink</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jlink</packaging>
<name>Rich Client (JLink)</name>
<properties>
<maven.compiler.release>11</maven.compiler.release>
<version.bouncycastle>1.62</version.bouncycastle>
<version.openjfx>12.0.1</version.openjfx>
<version.jaxb.runtime>2.3.2</version.jaxb.runtime>
</properties>
<repositories>
<repository>
<id>openecard-repos</id>
<name>Openecard Repos</name>
<url>https://mvn.ecsec.de/repository/openecard-public</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>openecard-repos</id>
<url>https://mvn.ecsec.de/repository/openecard-public</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<debug>true</debug>
<debuglevel>source,lines,vars</debuglevel>
<optimize>false</optimize>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jlink-plugin</artifactId>
<version>3.0.0-alpha-2-20190731</version>
<extensions>true</extensions>
<dependencies>
<!-- Use newer version of ASM -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>7.1</version>
</dependency>
</dependencies>
<configuration>
<excludeModules>
<module>javafx.baseEmpty</module>
<module>javafx.controlsEmpty</module>
<module>javafx.graphicsEmpty</module>
<module>javafx.swingEmpty</module>
</excludeModules>
<launcher>openecard=org.openecard.richclient/org.openecard.richclient.RichClient</launcher>
<ignoreSigningInformation>true</ignoreSigningInformation>
<noHeaderFiles>true</noHeaderFiles>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Open eCard RichClient Bundle -->
<dependency>
<groupId>org.openecard.clients</groupId>
<artifactId>richclient-bundle</artifactId>
<version>1.0.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.openecard.clients</groupId>
<artifactId>richclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- JavaFX -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${version.openjfx}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${version.openjfx}</version>
</dependency>
<!-- BouncyCastle -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>${version.bouncycastle}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bctls-jdk15on</artifactId>
<version>${version.bouncycastle}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>${version.bouncycastle}</version>
</dependency>
<!-- JAXB -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${version.jaxb.runtime}</version>
<exclusions>
<exclusion>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
</exclusions>
</dependency>