Skip to content

Commit

Permalink
Merge branch 'ipzs-rebase' of https://github.com/teamdigitale/io-cie-…
Browse files Browse the repository at this point in the history
…android-sdk into ipzs-rebase (#13)

# Conflicts:
#	cieidsdk/src/main/java/it/ipzs/cieidsdk/common/CieIDSdk.kt
#	cieidsdk/src/main/java/it/ipzs/cieidsdk/network/NetworkClient.kt
#	cieidsdk/src/main/java/it/ipzs/cieidsdk/nfc/ApduResponse.kt
#	cieidsdk/src/main/java/it/ipzs/cieidsdk/nfc/AppUtil.kt
#	cieidsdk/src/main/java/it/ipzs/cieidsdk/nfc/Asn1Tag.kt
#	cieidsdk/src/main/java/it/ipzs/cieidsdk/nfc/Ias.kt

refactor enum from enum to class
  • Loading branch information
fventola-ipzs authored Oct 18, 2019
1 parent 17f0db0 commit 72ce38d
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 64 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/it/ipzs/cieidsdk/sampleapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.os.Bundle
import android.util.Log
import it.ipzs.cieidsdk.common.Callback
import it.ipzs.cieidsdk.common.CieIDSdk
import it.ipzs.cieidsdk.common.Event
import kotlinx.android.synthetic.main.activity_main.*
import android.text.InputType
import android.widget.EditText
Expand All @@ -14,6 +13,7 @@ import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import it.ipzs.cieidsdk.event.Event


class MainActivity : AppCompatActivity(), Callback {
Expand Down Expand Up @@ -61,8 +61,8 @@ class MainActivity : AppCompatActivity(), Callback {
}

//url service provider regione toscana collaudo
webView.loadUrl("https://servizi.torinofacile.it/cgi-bin/accesso/base/index.cgi")
//webView.loadUrl("https://accessosicuro-trial.rete.toscana.it/portal/accessError?targetSeviceUrl=https%3A%2F%2Firistest.rete.toscana.it%3A443%2Fprivate&errorCode=auth.access.error.message.noURLCertAuth&minRequiredAuthLevel=2&goToUrl=https%3A%2F%2Faccessosicuro-trial.rete.toscana.it%3A443%2Fopensso%2FSSOPOST%2FmetaAlias%2Fidp%3FReqID%3Ds259b63f03ead27188c8876de2b443ed99e9636638%26spEntityId%3Dhttps%253A%252F%252Firistest.rete.toscana.it%253A443%252Fprivate")
//webView.loadUrl("https://servizi.torinofacile.it/cgi-bin/accesso/base/index.cgi")
webView.loadUrl("https://accessosicuro-trial.rete.toscana.it/portal/accessError?targetSeviceUrl=https%3A%2F%2Firistest.rete.toscana.it%3A443%2Fprivate&errorCode=auth.access.error.message.noURLCertAuth&minRequiredAuthLevel=2&goToUrl=https%3A%2F%2Faccessosicuro-trial.rete.toscana.it%3A443%2Fopensso%2FSSOPOST%2FmetaAlias%2Fidp%3FReqID%3Ds259b63f03ead27188c8876de2b443ed99e9636638%26spEntityId%3Dhttps%253A%252F%252Firistest.rete.toscana.it%253A443%252Fprivate")


webView.webViewClient = object : WebViewClient() {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.5.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions cieidsdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ android {

//ambienti
//PRODUZIONE
buildConfigField "String", "BASE_URL_IDP", "\"https://idserver.servizicie.interno.gov.it/idp/\""
//buildConfigField "String", "BASE_URL_IDP", "\"https://idserver.servizicie.interno.gov.it/idp/\""
//COLLAUDO
//buildConfigField "String", "BASE_URL_IDP", "\"https://idserver.servizicie.interno.gov.it:8443/idp/\""
buildConfigField "String", "BASE_URL_IDP", "\"https://idserver.servizicie.interno.gov.it:8443/idp/\""

}

Expand Down
54 changes: 1 addition & 53 deletions cieidsdk/src/main/java/it/ipzs/cieidsdk/common/CieIDSdk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import android.provider.Settings
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.observers.DisposableSingleObserver
import io.reactivex.schedulers.Schedulers
import it.ipzs.cieidsdk.event.*
import it.ipzs.cieidsdk.exceptions.BlockedPinException
import it.ipzs.cieidsdk.exceptions.NoCieException
import it.ipzs.cieidsdk.exceptions.PinInputNotValidException
Expand All @@ -35,58 +36,6 @@ val CERTIFICATE_EXPIRED: CharSequence = "SSLV3_ALERT_CERTIFICATE_EXPIRED"
val CERTIFICATE_REVOKED: CharSequence = "SSLV3_ALERT_CERTIFICATE_REVOKED"


interface EventValue {
val nameEvent: String
}

enum class EventTag : EventValue {
//tag
ON_TAG_DISCOVERED_NOT_CIE,
ON_TAG_DISCOVERED,
ON_TAG_LOST;

override val nameEvent: String = name
}
enum class EventCard: EventValue {
//card
ON_CARD_PIN_LOCKED,
ON_PIN_ERROR;

override val nameEvent: String = name

}
enum class EventCertificate : EventValue {
//certificate
CERTIFICATE_EXPIRED,
CERTIFICATE_REVOKED;

override val nameEvent: String = name
}
enum class EventError : EventValue {
//error
AUTHENTICATION_ERROR,
GENERAL_ERROR,
ON_NO_INTERNET_CONNECTION,
PIN_INPUT_ERROR;
override val nameEvent: String = name
}

class Event {

var attempts: Int;
private val eventValue: EventValue

constructor (event: EventValue, case: Int = 0) {
this.attempts = case
this.eventValue = event
}

override fun toString(): String {
return eventValue.nameEvent
}
}


interface Callback {

fun onSuccess(url: String)
Expand Down Expand Up @@ -192,7 +141,6 @@ object CieIDSdk : NfcAdapter.ReaderCallback {
isoDep.timeout = isoDepTimeout
isoDep.connect()
ias = Ias(isoDep)

ias!!.getIdServizi()
ias!!.startSecureChannel(ciePin)
val certificate = ias!!.readCertCie()
Expand Down
33 changes: 33 additions & 0 deletions cieidsdk/src/main/java/it/ipzs/cieidsdk/event/CieIDEvent.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package it.ipzs.cieidsdk.event


interface EventEnum

enum class EventTag : EventEnum {
//tag
ON_TAG_DISCOVERED_NOT_CIE,
ON_TAG_DISCOVERED,
ON_TAG_LOST;

}
enum class EventCard: EventEnum {
//card
ON_CARD_PIN_LOCKED,
ON_PIN_ERROR;

}
enum class EventCertificate : EventEnum {
//certificate
CERTIFICATE_EXPIRED,
CERTIFICATE_REVOKED;

}
enum class EventError : EventEnum {
//error
AUTHENTICATION_ERROR,
GENERAL_ERROR,
PIN_INPUT_ERROR,
ON_NO_INTERNET_CONNECTION;
}

data class Event(var event : EventEnum,var attempts : Int? = null,var url : String? = null)
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ internal class NoCieException : CieException()

internal class PinNotValidException(val tentativi: Int) : CieException()

internal class PinInputNotValidException : CieException()
internal class PinInputNotValidException : CieException()
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package it.ipzs.cieidsdk.native_bridge
import com.facebook.react.bridge.*
import it.ipzs.cieidsdk.common.Callback
import it.ipzs.cieidsdk.common.CieIDSdk
import it.ipzs.cieidsdk.common.Event
import com.facebook.react.modules.core.RCTNativeAppEventEmitter
import com.facebook.react.bridge.Arguments.createMap
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.NativeModule.NativeMethod
import it.ipzs.cieidsdk.event.Event


class CieModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext),
Expand Down Expand Up @@ -34,8 +36,8 @@ class CieModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
* onEvent is called if an event occurs
*/
override fun onEvent(event: Event) {
cieInvalidPinAttempts = event.attempts;
this.sendEvent(eventChannel, event.toString())
cieInvalidPinAttempts = event.attempts!!
this.sendEvent(eventChannel,event.toString())
}

override fun getName(): String {
Expand Down Expand Up @@ -119,7 +121,7 @@ class CieModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod

@ReactMethod
fun openNFCSettings(callback: com.facebook.react.bridge.Callback) {
val currentActivity = getCurrentActivity()
val currentActivity = currentActivity
if (currentActivity == null) {
callback.invoke("fail to get current activity");
} else {
Expand Down

0 comments on commit 72ce38d

Please sign in to comment.