Skip to content

Commit

Permalink
Add revision: v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GovernikusAusweisApp2 committed Jul 4, 2024
1 parent 8cf8642 commit 97a9563
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 89 deletions.
2 changes: 1 addition & 1 deletion ausweisapp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configurations.maybeCreate("default")
artifacts.add("default", file('ausweisapp2.aar'))
artifacts.add("default", file('ausweisapp.aar'))
group = 'com.governikus'
version = ausweisapp_version
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
ext.kotlin_version = '1.9.22'
ext.ausweisapp_version = '2.1.1'
ext.sdkwrapper_version = "$ausweisapp_version.0"
ext.ausweisapp_version = '2.2.0'
ext.sdkwrapper_version = "$ausweisapp_version"

repositories {
google()
Expand All @@ -21,7 +21,7 @@ buildscript {
}

plugins {
id("org.sonarqube") version "4.4.1.3373"
id("org.sonarqube") version "5.0.0.4638"
id("java")
}

Expand Down
4 changes: 2 additions & 2 deletions sdkwrapper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {

defaultConfig {
buildToolsVersion "34.0.0"
minSdkVersion 26
minSdkVersion 28
targetSdkVersion 34
versionCode 4
versionName sdkwrapper_version
Expand Down Expand Up @@ -137,7 +137,7 @@ afterEvaluate {
}
}

def useLocal = file("${rootDir}/ausweisapp/ausweisapp2.aar").exists();
def useLocal = file("${rootDir}/ausweisapp/ausweisapp.aar").exists();

dependencies {
if (useLocal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ interface WorkflowCallbacks {
*/
fun onInsertCard(error: String?)

/**
* Called if the SDK is waiting on a certain condition to be met.
*
* After resolving the cause of the issue, the workflow has to be resumed by calling [WorkflowController.continueWorkflow].
*
* @param cause The cause for the waiting condition
*/
fun onPause(cause: Cause)

/**
* A specific reader was recognized or has vanished. Also called as a response to [WorkflowController.getReader].
*
Expand Down Expand Up @@ -178,19 +187,6 @@ interface WorkflowCallbacks {
*/
fun onStatus(workflowProgress: WorkflowProgress)

/**
* Provides information about the supported API level of the employed AusweisApp2
*
* Response to a call to WorkflowController.getApiLevel() and WorkflowController.setApiLevel().
*
* @param error Optional error message if WorkflowController.setApiLevel() failed.
* @param apiLevel Contains information about the supported and employed API level.
*/
fun onApiLevel(
error: String?,
apiLevel: ApiLevel?,
)

/**
* Provides information about the AusweisApp2 that is used in the SDK Wrapper.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import android.nfc.tech.IsoDep
import android.util.Log
import de.governikus.ausweisapp2.sdkwrapper.SDKWrapper
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.getAccessRights
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.getApiLevel
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.getAuthResult
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.getCertificateDescription
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.getReaderFromReaderMember
Expand All @@ -22,16 +21,15 @@ import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.getWorkflowPro
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Accept
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Cancel
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Command
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.ContinueWorkflow
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.GetAccessRights
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.GetApiLevel
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.GetCertificate
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.GetInfo
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.GetReader
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.GetReaderList
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.GetStatus
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Message
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_ACCESS_RIGHTS
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_API_LEVEL
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_AUTH
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_BAD_STATE
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_CERTIFICATE
Expand All @@ -44,14 +42,14 @@ import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messa
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_INSERT_CARD
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_INTERNAL_ERROR
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_INVALID
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_PAUSE
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_READER
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_READER_LIST
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_STATUS
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Messages.MSG_UNKNOWN_COMMAND
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.RunAuth
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.RunChangePin
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.SetAccessRights
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.SetApiLevel
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.SetCan
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.SetCard
import de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.SetNewPin
Expand Down Expand Up @@ -236,30 +234,6 @@ class WorkflowController internal constructor(private val sdkConnection: SdkConn
send(GetAccessRights())
}

/**
* Set supported API level of your application.
*
* If you initially develop your application against the SDK Wrapper you should check
* the highest supported level with getApiLevel() and set this value with this command
* when you connect to the SDK Wrapper.
* This will set the SDK Wrapper to act with the defined level even if a newer level is available.
* The SDK Wrapper will call [WorkflowCallbacks.onApiLevel] as an answer.
*
* @param level Supported API level of your app.
*/
fun setApiLevel(level: Int) {
send(SetApiLevel(level))
}

/**
* Returns information about the available and current API level.
*
* The SDK will call [WorkflowCallbacks.onApiLevel] as an answer.
*/
fun getApiLevel() {
send(GetApiLevel())
}

/**
* Provides information about the utilized AusweisApp2.
*
Expand Down Expand Up @@ -401,6 +375,13 @@ class WorkflowController internal constructor(private val sdkConnection: SdkConn
send(Cancel())
}

/**
* Resumes the workflow after a callback to [WorkflowCallbacks.onPause].
*/
fun continueWorkflow() {
send(ContinueWorkflow())
}

/**
* Request the certificate of current authentication.
*
Expand Down Expand Up @@ -480,9 +461,6 @@ class WorkflowController internal constructor(private val sdkConnection: SdkConn

private fun handleMessage(message: Message) {
when (message.msg) {
MSG_API_LEVEL -> {
callback { onApiLevel(message.error, message.getApiLevel()) }
}
MSG_INFO -> {
when (val info = message.getVersionInfo()) {
null -> {
Expand Down Expand Up @@ -584,6 +562,23 @@ class WorkflowController internal constructor(private val sdkConnection: SdkConn
}
}
}
MSG_PAUSE -> {
val rawCause = message.cause
if (rawCause == null) {
val error = WrapperError(message.msg, "Missing cause object")
callback { onWrapperError(error) }
return
}

val cause = Cause.fromRawName(rawCause)
if (cause == null) {
val error = WrapperError(message.msg, "Failed to map cause \"$rawCause\" to PauseReason")
callback { onWrapperError(error) }
return
}

callback { onPause(cause) }
}
MSG_READER -> {
callback { onReader(message.getReaderFromRoot()) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,46 @@ data class AuxiliaryData(
/**
* Provides information about inserted card.
*
* An unknown card (without eID function) is represented by all properties set to null.
*
* @property inoperative True if PUK is inoperative and cannot unblock PIN, otherwise false. This can be recognized if user enters a correct PUK only. It is not possible to read this data before a user tries to unblock the PIN.
* @property deactivated True if eID functionality is deactivated, otherwise false.
* @property pinRetryCounter Count of possible retries for the PIN. If you enter a PIN it will be decreased if PIN was incorrect.
*/
@Parcelize
data class Card(
val deactivated: Boolean,
val inoperative: Boolean,
val pinRetryCounter: Int,
val deactivated: Boolean?,
val inoperative: Boolean?,
val pinRetryCounter: Int?,
) : Parcelable

/**
* Optional definition of files for the Simulator reader.
* Convenience method to check if an unknown card (without eID function) was detected.
*/
fun Card.isUnknown(): Boolean = inoperative == null && deactivated == null && pinRetryCounter == null

/**
* List of possible causes in [WorkflowCallbacks.onPause]
*/
enum class Cause(val rawName: String) {
BadCardPosition("BadCardPosition"), // Denotes an unstable or lost card connection.
;

companion object {
fun fromRawName(name: String?): Cause? = values().firstOrNull { it.rawName == name }
}
}

/**
* Optional definition of files and keys for the Simulator reader.
*
* @property files List of Filesystem definitions. See [SimulatorFile].
* @property keys List of SimulatorKey definitions. See [SimulatorKey].
*/
@Parcelize
data class Simulator(
val files: List<SimulatorFile>,
val keys: List<SimulatorKey>?,
) : Parcelable

/**
Expand All @@ -122,15 +143,14 @@ data class SimulatorFile(
) : Parcelable

/**
* Provides information about the API Level of the underlying AusweisApp2.
* Keys for Simulator reader
*
* @property available List of all available API levels of the employed AusweisApp2.
* @property current The currently set API level.
* The keys are used to check the blacklist and calculate the pseudonym for the service provider.
*/
@Parcelize
data class ApiLevel(
val available: List<Int>?,
val current: Int,
data class SimulatorKey(
val id: Int,
val content: String,
) : Parcelable

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2
import android.net.Uri
import de.governikus.ausweisapp2.sdkwrapper.card.core.AccessRight
import de.governikus.ausweisapp2.sdkwrapper.card.core.AccessRights
import de.governikus.ausweisapp2.sdkwrapper.card.core.ApiLevel
import de.governikus.ausweisapp2.sdkwrapper.card.core.AuthResult
import de.governikus.ausweisapp2.sdkwrapper.card.core.AuthResultData
import de.governikus.ausweisapp2.sdkwrapper.card.core.AuxiliaryData
Expand Down Expand Up @@ -58,15 +57,6 @@ internal fun Message.getCard(): Card? {
)
}

internal fun Message.getApiLevel(): ApiLevel? {
val current = current ?: return null

return ApiLevel(
available,
current,
)
}

internal fun Message.getReaderFromRoot(): Reader? {
val name = name ?: return null
val insertable = insertable ?: return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ package de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol

internal data class Simulator(
val files: List<SimulatorFile>,
val keys: List<SimulatorKey>?,
)

internal data class SimulatorFile(
val fileId: String,
val shortFileId: String,
val content: String,
)

internal data class SimulatorKey(
val id: Int,
val content: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ internal class Cancel : Command {
override val cmd = "CANCEL"
}

internal class SetApiLevel(val level: Int) : Command {
override val cmd = "SET_API_LEVEL"
}

internal class GetApiLevel : Command {
override val cmd = "GET_API_LEVEL"
internal class ContinueWorkflow : Command {
override val cmd = "CONTINUE"
}

internal class GetCertificate : Command {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.google.gson.annotations.SerializedName

internal object Messages {
const val MSG_ACCESS_RIGHTS = "ACCESS_RIGHTS"
const val MSG_API_LEVEL = "API_LEVEL"
const val MSG_AUTH = "AUTH"
const val MSG_BAD_STATE = "BAD_STATE"
const val MSG_CERTIFICATE = "CERTIFICATE"
Expand All @@ -21,6 +20,7 @@ internal object Messages {
const val MSG_INSERT_CARD = "INSERT_CARD"
const val MSG_INTERNAL_ERROR = "INTERNAL_ERROR"
const val MSG_INVALID = "INVALID"
const val MSG_PAUSE = "PAUSE"
const val MSG_READER = "READER"
const val MSG_READER_LIST = "READER_LIST"
const val MSG_STATUS = "STATUS"
Expand All @@ -30,10 +30,9 @@ internal object Messages {
internal data class Message(
val attached: Boolean?,
val aux: Aux?,
val available: List<Int>?,
val card: Card?,
val cause: String?,
val chat: Chat?,
val current: Int?,
val description: Description?,
val error: String?,
val insertable: Boolean?,
Expand Down Expand Up @@ -83,9 +82,9 @@ internal data class Aux(
)

internal data class Card(
val inoperative: Boolean,
val deactivated: Boolean,
val retryCounter: Int,
val inoperative: Boolean?,
val deactivated: Boolean?,
val retryCounter: Int?,
)

internal data class Reader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ package de.governikus.ausweisapp2.sdkwrapper.card.core.util

internal typealias WorkflowSimulator = de.governikus.ausweisapp2.sdkwrapper.card.core.Simulator
internal typealias WorkflowSimulatorFile = de.governikus.ausweisapp2.sdkwrapper.card.core.SimulatorFile
internal typealias WorkflowSimulatorKey = de.governikus.ausweisapp2.sdkwrapper.card.core.SimulatorKey

internal typealias CommandSimulator = de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.Simulator
internal typealias CommandSimulatorFile = de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.SimulatorFile
internal typealias CommandSimulatorKey = de.governikus.ausweisapp2.sdkwrapper.card.core.ausweisapp2.protocol.SimulatorKey

internal fun workflowSimulatorToCommandSimulator(simulator: WorkflowSimulator?): CommandSimulator? {
simulator ?: return null
return CommandSimulator(
simulator.files.map { workflowSimulatorFileToCommandSimulatorFile(it) },
simulator.keys?.map { workflowSimulatorKeyToCommandSimulatorKey(it) },
)
}

Expand All @@ -20,3 +23,10 @@ internal fun workflowSimulatorFileToCommandSimulatorFile(file: WorkflowSimulator
file.content,
)
}

internal fun workflowSimulatorKeyToCommandSimulatorKey(key: WorkflowSimulatorKey): CommandSimulatorKey {
return CommandSimulatorKey(
key.id,
key.content,
)
}
Loading

0 comments on commit 97a9563

Please sign in to comment.