Compare commits

...

28 commits

Author SHA1 Message Date
98e0b032d0 Regenerate launcher icons 2023-11-27 21:21:04 -05:00
58bd80556a core: TelephonyManagerApduInterface: convert to UByte first
Otherwise, the integer representation will be negative when the byte
value is greater than 127.
2023-11-27 20:20:38 -05:00
7413c86dba core: Fixup TelephonyManagerApduInterface channel management 2023-11-27 20:02:08 -05:00
05334d15bd lpac-jni: Android.bp: Move liblpac-jni.so to system_ext 2023-11-27 20:01:15 -05:00
e0c7c83032 Android.bp: Disable proguard optimizations for JNI interfaces 2023-11-27 20:00:55 -05:00
7c21cda40c Implement Android.bp building with AOSP for lpac_jni 2023-11-27 16:54:49 -05:00
b5a63f3de3 lpac-jni: Update HTTP interface 2023-11-26 20:49:04 -05:00
51357d945b ProfileDownloadFragment: Hide all inputs except SM-DP+ address as passwords 2023-11-26 09:56:28 -05:00
434a173cb1 ProfileDownloadFragment: Allow customizing IMEI sent to the server 2023-11-26 09:55:16 -05:00
3ae1e0015f lpac-jni: Make most argumengts to downloadProfile optional 2023-11-26 09:33:28 -05:00
936cd0150e core: Commonize close() between EuiccChannel's 2023-11-25 22:01:26 -05:00
c62e8bcecd core: Implement TelephonyManagerApduInterface
Untested; need to build on AOSP and test on real eSIM device.
2023-11-25 21:58:08 -05:00
1c2ca55d51 app: build.gradle: Set versionCode to timestamp for debug builds 2023-11-25 21:56:11 -05:00
bea5aa0dcf lpac-jni: Implement confirmation code support 2023-11-25 18:33:10 -05:00
98e4c6d94d .idea: Sync 2023-11-25 18:33:00 -05:00
25da3671c7 refactor: [13/n] Nuke Truphone LPAd implementation 2023-11-25 14:39:26 -05:00
b305e1a2d6 refactor: [12/n] Remove hack for IMEI filler character 2023-11-25 14:31:43 -05:00
f5f146d8ee refactor: [11/n] Implement es9p/es10b profile downloading 2023-11-25 11:05:23 -05:00
37a7d332ef refactor: [10/n] Reimplement profile renaming and deletion 2023-11-24 17:28:10 -05:00
0e43f392ab refactor: [9/n] Reimplement profile enabling / disabling 2023-11-23 20:29:49 -05:00
987eff8111 refactor: [8/n] Ensure local references are deleted 2023-11-23 18:07:52 -05:00
4d2084b3d3 refactor: [7/n] Don't mind me, I am stupid 2023-11-23 18:05:25 -05:00
d19109d62b refactor: [6/n] Implement getProfiles() 2023-11-23 17:47:02 -05:00
d59e05279d refactor: [5/n] Catch and clear exceptions properly in interface adapter 2023-11-22 21:46:33 -05:00
92bc390ee5 refactor: [4/n] Kill Truphone LPAd dependency
nothing is re-implemented just yet
2023-11-22 20:52:04 -05:00
2707a5f1f8 refactor: [3/n] Use userdata member in euicc_ctx 2023-11-18 20:21:00 -05:00
013fe157eb refactor: [2/n] LpacJni should be an object 2023-11-14 21:00:42 -05:00
85af3bcfc0 refactor: [1/n] Introduce the lpac project and lpac_jni 2023-11-14 20:59:27 -05:00
417 changed files with 1219 additions and 50671 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "libs/lpac-jni/src/main/jni/lpac"]
path = libs/lpac-jni/src/main/jni/lpac
url = https://github.com/estkme/lpac

7
.idea/compiler.xml generated
View file

@ -4,9 +4,10 @@
<bytecodeTargetLevel target="1.7"> <bytecodeTargetLevel target="1.7">
<module name="OpenEUICC.app" target="17" /> <module name="OpenEUICC.app" target="17" />
<module name="OpenEUICC.libs.hidden-apis-shim" target="17" /> <module name="OpenEUICC.libs.hidden-apis-shim" target="17" />
<module name="OpenEUICC.libs.lpad-sm-dp-plus-connector" target="1.8" /> <module name="OpenEUICC.libs.lpac-jni" target="17" />
<module name="OpenEUICC.libs.lpad-sm-dp-plus-connector.main" target="1.8" /> <module name="OpenEUICC.libs.lpad-sm-dp-plus-connector" target="17" />
<module name="OpenEUICC.libs.lpad-sm-dp-plus-connector.test" target="1.8" /> <module name="OpenEUICC.libs.lpad-sm-dp-plus-connector.main" target="17" />
<module name="OpenEUICC.libs.lpad-sm-dp-plus-connector.test" target="17" />
</bytecodeTargetLevel> </bytecodeTargetLevel>
</component> </component>
</project> </project>

2
.idea/gradle.xml generated
View file

@ -16,7 +16,7 @@
<option value="$PROJECT_DIR$/libs" /> <option value="$PROJECT_DIR$/libs" />
<option value="$PROJECT_DIR$/libs/hidden-apis-shim" /> <option value="$PROJECT_DIR$/libs/hidden-apis-shim" />
<option value="$PROJECT_DIR$/libs/hidden-apis-stub" /> <option value="$PROJECT_DIR$/libs/hidden-apis-stub" />
<option value="$PROJECT_DIR$/libs/lpad-sm-dp-plus-connector" /> <option value="$PROJECT_DIR$/libs/lpac-jni" />
</set> </set>
</option> </option>
</GradleProjectSettings> </GradleProjectSettings>

2
.idea/kotlinc.xml generated
View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="KotlinJpsPluginSettings"> <component name="KotlinJpsPluginSettings">
<option name="version" value="1.6.21" /> <option name="version" value="1.9.20" />
</component> </component>
</project> </project>

1
.idea/vcs.xml generated
View file

@ -2,5 +2,6 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/libs/lpac-jni/src/main/jni/lpac" vcs="Git" />
</component> </component>
</project> </project>

View file

@ -1,8 +1,7 @@
android_app { android_app {
name: "OpenEUICC", name: "OpenEUICC",
static_libs: [ static_libs: [
// Dependencies that must be pulled from maven // Dependencies that must be pulled from maven,
"asn1bean-prebuilt-jar",
"zxing-core-prebuilt-jar", "zxing-core-prebuilt-jar",
"zxing-android-embedded-prebuilt-aar", "zxing-android-embedded-prebuilt-aar",
@ -14,18 +13,22 @@ android_app {
"androidx.lifecycle_lifecycle-runtime-ktx", "androidx.lifecycle_lifecycle-runtime-ktx",
"androidx.swiperefreshlayout_swiperefreshlayout", "androidx.swiperefreshlayout_swiperefreshlayout",
"com.google.android.material_material", "com.google.android.material_material",
"gson-prebuilt-jar", "gson",
"kotlinx_coroutines", "kotlinx_coroutines",
], ],
jni_libs: [
"liblpac-jni",
],
srcs: [ srcs: [
// Main app // Main app
"app/src/main/**/*.kt", "app/src/main/**/*.kt",
// TruPhone LPAd library // lpac-jni interface
"libs/lpad-sm-dp-plus-connector/src/generated/**/*.java", "libs/lpac-jni/src/main/**/*.kt",
"libs/lpad-sm-dp-plus-connector/src/main/**/*.java",
"libs/lpad-sm-dp-plus-connector/src/main/**/*.kt",
], ],
optimize: {
enabled: false,
},
resource_dirs: [ resource_dirs: [
"app/src/main/res", "app/src/main/res",
], ],

0
Android.mk Normal file
View file

View file

@ -37,7 +37,7 @@ def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android { android {
compileSdk 31 compileSdk 34
defaultConfig { defaultConfig {
applicationId "im.angry.openeuicc" applicationId "im.angry.openeuicc"
@ -67,6 +67,11 @@ android {
signingConfig signingConfigs.config signingConfig signingConfigs.config
} }
} }
applicationVariants.all { variant ->
if (variant.name == "debug") {
variant.outputs.each { o -> o.versionCodeOverride = System.currentTimeSeconds() }
}
}
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
@ -80,12 +85,12 @@ android {
dependencies { dependencies {
compileOnly project(':libs:hidden-apis-stub') compileOnly project(':libs:hidden-apis-stub')
implementation project(':libs:hidden-apis-shim') implementation project(':libs:hidden-apis-shim')
implementation project(":libs:lpad-sm-dp-plus-connector") implementation project(":libs:lpac-jni")
implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.4.1' implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.6.0' implementation 'com.google.android.material:material:1.10.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3' implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1' implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation "androidx.cardview:cardview:1.0.0" implementation "androidx.cardview:cardview:1.0.0"
implementation 'com.journeyapps:zxing-android-embedded:4.3.0' implementation 'com.journeyapps:zxing-android-embedded:4.3.0'

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
tools:ignore="ProtectedPermissions"> tools:ignore="ProtectedPermissions"
package="im.angry.openeuicc">
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" /> <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />

View file

@ -1,6 +1,6 @@
package im.angry.openeuicc.core package im.angry.openeuicc.core
import com.truphone.lpa.LocalProfileAssistant import net.typeblog.lpac_jni.LocalProfileAssistant
// A custom type to avoid compatibility issues with UiccCardInfo / UiccPortInfo // A custom type to avoid compatibility issues with UiccCardInfo / UiccPortInfo
data class EuiccChannelInfo( data class EuiccChannelInfo(
@ -21,7 +21,16 @@ abstract class EuiccChannel(
val removable = info.removable val removable = info.removable
abstract val lpa: LocalProfileAssistant abstract val lpa: LocalProfileAssistant
abstract val valid: Boolean val valid: Boolean
get() {
abstract fun close() try {
// Try to ping the eUICC card by reading the EID
lpa.eID
} catch (e: Exception) {
return false
}
return true
}
fun close() = lpa.close()
} }

View file

@ -14,6 +14,7 @@ import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import java.lang.Exception import java.lang.Exception
import java.lang.IllegalArgumentException
import kotlin.coroutines.resume import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine import kotlin.coroutines.suspendCoroutine
@ -75,11 +76,19 @@ class EuiccChannelManager(private val context: Context) {
if (uiccInfo.isEuicc && !uiccInfo.isRemovable) { if (uiccInfo.isEuicc && !uiccInfo.isRemovable) {
Log.d(TAG, "Using TelephonyManager for slot ${uiccInfo.slotIndex}") Log.d(TAG, "Using TelephonyManager for slot ${uiccInfo.slotIndex}")
// TODO: On Tiramisu, we should also connect all available "ports" for MEP support // TODO: On Tiramisu, we should also connect all available "ports" for MEP support
euiccChannel = TelephonyManagerChannel.tryConnect(tm, channelInfo) try {
euiccChannel = TelephonyManagerChannel(channelInfo, tm)
} catch (e: IllegalArgumentException) {
// Failed
}
} }
if (euiccChannel == null) { if (euiccChannel == null) {
euiccChannel = OmapiChannel.tryConnect(seService!!, channelInfo) try {
euiccChannel = OmapiChannel(seService!!, channelInfo)
} catch (e: IllegalArgumentException) {
// Failed
}
} }
if (euiccChannel != null) { if (euiccChannel != null) {

View file

@ -1,29 +0,0 @@
package im.angry.openeuicc.core
import android.se.omapi.Channel
import com.truphone.lpa.ApduChannel
import com.truphone.lpa.ApduTransmittedListener
import im.angry.openeuicc.util.byteArrayToHex
import im.angry.openeuicc.util.hexStringToByteArray
class OmapiApduChannel(private val channel: Channel) : ApduChannel {
override fun transmitAPDU(apdu: String): String =
byteArrayToHex(channel.transmit(hexStringToByteArray(apdu)))
override fun transmitAPDUS(apdus: MutableList<String>): String {
var res = ""
for (pdu in apdus) {
res = transmitAPDU(pdu)
}
return res
}
override fun sendStatus() {
}
override fun setApduTransmittedListener(apduTransmittedListener: ApduTransmittedListener?) {
}
override fun removeApduTransmittedListener(apduTransmittedListener: ApduTransmittedListener?) {
}
}

View file

@ -0,0 +1,58 @@
package im.angry.openeuicc.core
import android.se.omapi.Channel
import android.se.omapi.SEService
import android.se.omapi.Session
import net.typeblog.lpac_jni.ApduInterface
import net.typeblog.lpac_jni.LocalProfileAssistant
import net.typeblog.lpac_jni.impl.HttpInterfaceImpl
import net.typeblog.lpac_jni.impl.LocalProfileAssistantImpl
class OmapiApduInterface(
private val service: SEService,
private val info: EuiccChannelInfo
): ApduInterface {
private lateinit var session: Session
private lateinit var lastChannel: Channel
override fun connect() {
session = service.getUiccReader(info.slotId + 1).openSession()
}
override fun disconnect() {
session.close()
}
override fun logicalChannelOpen(aid: ByteArray): Int {
check(!this::lastChannel.isInitialized) {
"Can only open one channel"
}
lastChannel = session.openLogicalChannel(aid)!!;
return 0;
}
override fun logicalChannelClose(handle: Int) {
check(handle == 0 && !this::lastChannel.isInitialized) {
"Unknown channel"
}
lastChannel.close()
}
override fun transmit(tx: ByteArray): ByteArray {
check(this::lastChannel.isInitialized) {
"Unknown channel"
}
return lastChannel.transmit(tx)
}
}
class OmapiChannel(
service: SEService,
info: EuiccChannelInfo,
) : EuiccChannel(info) {
override val lpa: LocalProfileAssistant = LocalProfileAssistantImpl(
OmapiApduInterface(service, info),
HttpInterfaceImpl())
}

View file

@ -1,39 +0,0 @@
package im.angry.openeuicc.core
import android.se.omapi.Channel
import android.se.omapi.SEService
import android.util.Log
import com.truphone.lpa.LocalProfileAssistant
import com.truphone.lpa.impl.LocalProfileAssistantImpl
import java.lang.Exception
class OmapiChannel private constructor(
info: EuiccChannelInfo,
private val channel: Channel
) : EuiccChannel(info) {
companion object {
private const val TAG = "OmapiChannel"
private val APPLET_ID = byteArrayOf(-96, 0, 0, 5, 89, 16, 16, -1, -1, -1, -1, -119, 0, 0, 1, 0)
fun tryConnect(service: SEService, info: EuiccChannelInfo): OmapiChannel? {
try {
val reader = service.getUiccReader(info.slotId + 1) // slotId from telephony starts from 0
val session = reader.openSession()
val channel = session.openLogicalChannel(APPLET_ID) ?: return null
return OmapiChannel(info, channel)
} catch (e: Exception) {
Log.e(TAG, "Unable to open eUICC channel for slot ${info.slotId}, skipping")
Log.e(TAG, Log.getStackTraceString(e))
return null
}
}
}
override val lpa: LocalProfileAssistant by lazy {
LocalProfileAssistantImpl(OmapiApduChannel(channel))
}
override val valid: Boolean
get() = channel.isOpen // TODO: This has to be implemented properly
override fun close() = channel.close()
}

View file

@ -1,42 +0,0 @@
package im.angry.openeuicc.core
import android.telephony.TelephonyManager
import com.truphone.lpa.ApduChannel
import com.truphone.lpa.ApduTransmittedListener
import im.angry.openeuicc.util.*
class TelephonyManagerApduChannel(
private val tm: TelephonyManager,
private val slotId: Int,
private val channelId: Int) : ApduChannel {
override fun transmitAPDU(apdu: String): String? {
val cla = Integer.parseInt(apdu.substring(0, 2), 16)
val instruction = Integer.parseInt(apdu.substring(2, 4), 16)
val p1 = Integer.parseInt(apdu.substring(4, 6), 16)
val p2 = Integer.parseInt(apdu.substring(6, 8), 16)
val p3 = Integer.parseInt(apdu.substring(8, 10), 16)
val p4 = apdu.substring(10)
return tm.iccTransmitApduLogicalChannelBySlot(
slotId, channelId,
cla, instruction, p1, p2, p3, p4)
}
override fun transmitAPDUS(apdus: MutableList<String>): String? {
var res: String? = ""
for (pdu in apdus) {
res = transmitAPDU(pdu)
}
return res
}
override fun sendStatus() {
}
override fun setApduTransmittedListener(apduTransmittedListener: ApduTransmittedListener?) {
}
override fun removeApduTransmittedListener(apduTransmittedListener: ApduTransmittedListener?) {
}
}

View file

@ -0,0 +1,66 @@
package im.angry.openeuicc.core
import android.telephony.IccOpenLogicalChannelResponse
import android.telephony.TelephonyManager
import im.angry.openeuicc.util.*
import net.typeblog.lpac_jni.LocalProfileAssistant
import net.typeblog.lpac_jni.ApduInterface
import net.typeblog.lpac_jni.impl.HttpInterfaceImpl
import net.typeblog.lpac_jni.impl.LocalProfileAssistantImpl
class TelephonyManagerApduInterface(
private val info: EuiccChannelInfo,
private val tm: TelephonyManager
): ApduInterface {
private var lastChannel: Int = -1
override fun connect() {
// Do nothing
}
override fun disconnect() {
// Do nothing
}
override fun logicalChannelOpen(aid: ByteArray): Int {
check(lastChannel == -1) { "Already initialized" }
val hex = aid.encodeHex()
val channel = tm.iccOpenLogicalChannelBySlot(info.slotId, hex, 0)
if (channel.status != IccOpenLogicalChannelResponse.STATUS_NO_ERROR || channel.channel == IccOpenLogicalChannelResponse.INVALID_CHANNEL) {
throw IllegalArgumentException("Cannot open logical channel " + hex + " via TelephonManager on slot " + info.slotId);
}
lastChannel = channel.channel
return lastChannel
}
override fun logicalChannelClose(handle: Int) {
check(handle == lastChannel) { "Invalid channel handle " }
tm.iccCloseLogicalChannelBySlot(info.slotId, handle)
lastChannel = -1
}
override fun transmit(tx: ByteArray): ByteArray {
check(lastChannel != -1) { "Uninitialized" }
val cla = tx[0].toUByte().toInt()
val instruction = tx[1].toUByte().toInt()
val p1 = tx[2].toUByte().toInt()
val p2 = tx[3].toUByte().toInt()
val p3 = tx[4].toUByte().toInt()
val p4 = tx.drop(5).toByteArray().encodeHex()
return tm.iccTransmitApduLogicalChannelBySlot(info.slotId, lastChannel,
cla, instruction, p1, p2, p3, p4)?.decodeHex() ?: byteArrayOf()
}
}
class TelephonyManagerChannel(
info: EuiccChannelInfo,
private val tm: TelephonyManager
) : EuiccChannel(info) {
override val lpa: LocalProfileAssistant = LocalProfileAssistantImpl(
TelephonyManagerApduInterface(info, tm),
HttpInterfaceImpl()
)
}

View file

@ -1,49 +0,0 @@
package im.angry.openeuicc.core
import android.telephony.IccOpenLogicalChannelResponse
import android.telephony.TelephonyManager
import android.util.Log
import com.truphone.lpa.LocalProfileAssistant
import com.truphone.lpa.impl.LocalProfileAssistantImpl
import im.angry.openeuicc.util.*
import java.lang.Exception
class TelephonyManagerChannel private constructor(
info: EuiccChannelInfo,
private val tm: TelephonyManager,
private val channelId: Int
) : EuiccChannel(info) {
companion object {
private const val TAG = "TelephonyManagerApduChannel"
private const val EUICC_APP_ID = "A0000005591010FFFFFFFF8900000100"
// TODO: On Tiramisu, we need to specify the portId also if we want MEP support
fun tryConnect(tm: TelephonyManager, info: EuiccChannelInfo): TelephonyManagerChannel? {
try {
val channel = tm.iccOpenLogicalChannelBySlot(info.slotId, EUICC_APP_ID, 0)
if (channel.status != IccOpenLogicalChannelResponse.STATUS_NO_ERROR || channel.channel == IccOpenLogicalChannelResponse.INVALID_CHANNEL) {
Log.e(TAG, "Unable to open eUICC channel for slot ${info.slotId} via TelephonyManager: ${channel.status}")
return null
}
Log.d(TAG, "channel: ${channel.channel}")
return TelephonyManagerChannel(info, tm, channel.channel)
} catch (e: Exception) {
Log.e(TAG, "Unable to open eUICC channel for slot ${info.slotId} via TelephonyManager")
Log.e(TAG, Log.getStackTraceString(e))
return null
}
}
}
override val lpa: LocalProfileAssistant by lazy {
LocalProfileAssistantImpl(TelephonyManagerApduChannel(tm, slotId, channelId))
}
override val valid: Boolean
get() = true // TODO: Fix this
override fun close() {
tm.iccCloseLogicalChannelBySlot(slotId, channelId)
}
}

View file

@ -3,8 +3,7 @@ package im.angry.openeuicc.service
import android.service.euicc.* import android.service.euicc.*
import android.telephony.euicc.DownloadableSubscription import android.telephony.euicc.DownloadableSubscription
import android.telephony.euicc.EuiccInfo import android.telephony.euicc.EuiccInfo
import com.truphone.lpa.LocalProfileInfo import net.typeblog.lpac_jni.LocalProfileInfo
import com.truphone.lpad.progress.Progress
import im.angry.openeuicc.OpenEuiccApplication import im.angry.openeuicc.OpenEuiccApplication
import im.angry.openeuicc.core.EuiccChannel import im.angry.openeuicc.core.EuiccChannel
import im.angry.openeuicc.util.* import im.angry.openeuicc.util.*
@ -18,7 +17,7 @@ class OpenEuiccService : EuiccService() {
.findEuiccChannelBySlotBlocking(slotId) .findEuiccChannelBySlotBlocking(slotId)
override fun onGetEid(slotId: Int): String? = override fun onGetEid(slotId: Int): String? =
findChannel(slotId)?.lpa?.eid findChannel(slotId)?.lpa?.eID
// When two eSIM cards are present on one device, the Android settings UI // When two eSIM cards are present on one device, the Android settings UI
// gets confused and sets the incorrect slotId for profiles from one of // gets confused and sets the incorrect slotId for profiles from one of
@ -103,7 +102,7 @@ class OpenEuiccService : EuiccService() {
return RESULT_FIRST_USER return RESULT_FIRST_USER
} }
return if (channel.lpa.deleteProfile(iccid, Progress())) { return if (channel.lpa.deleteProfile(iccid)) {
RESULT_OK RESULT_OK
} else { } else {
RESULT_FIRST_USER RESULT_FIRST_USER
@ -135,13 +134,13 @@ class OpenEuiccService : EuiccService() {
it.state == LocalProfileInfo.State.Enabled it.state == LocalProfileInfo.State.Enabled
} ?: return RESULT_OK } ?: return RESULT_OK
return if (channel.lpa.disableProfile(activeProfile.iccid, Progress())) { return if (channel.lpa.disableProfile(activeProfile.iccid)) {
RESULT_OK RESULT_OK
} else { } else {
RESULT_FIRST_USER RESULT_FIRST_USER
} }
} else { } else {
return if (channel.lpa.enableProfile(iccid, Progress())) { return if (channel.lpa.enableProfile(iccid)) {
RESULT_OK RESULT_OK
} else { } else {
RESULT_FIRST_USER RESULT_FIRST_USER
@ -160,7 +159,7 @@ class OpenEuiccService : EuiccService() {
return RESULT_FIRST_USER return RESULT_FIRST_USER
} }
val success = channel.lpa val success = channel.lpa
.setNickname(iccid, nickname) .setNickname(iccid, nickname!!)
openEuiccApplication.subscriptionManager.tryRefreshCachedEuiccInfo(channel.cardId) openEuiccApplication.subscriptionManager.tryRefreshCachedEuiccInfo(channel.cardId)
return if (success) { return if (success) {
RESULT_OK RESULT_OK

View file

@ -18,8 +18,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.truphone.lpa.LocalProfileInfo import net.typeblog.lpac_jni.LocalProfileInfo
import com.truphone.lpad.progress.Progress
import im.angry.openeuicc.R import im.angry.openeuicc.R
import im.angry.openeuicc.util.* import im.angry.openeuicc.util.*
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@ -123,12 +122,12 @@ class EuiccManagementFragment : Fragment(), EuiccFragmentMarker, EuiccProfilesCh
private suspend fun doEnableProfile(iccid: String) = private suspend fun doEnableProfile(iccid: String) =
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
channel.lpa.enableProfile(iccid, Progress()) channel.lpa.enableProfile(iccid)
} }
private suspend fun doDisableProfile(iccid: String) = private suspend fun doDisableProfile(iccid: String) =
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
channel.lpa.disableProfile(iccid, Progress()) channel.lpa.disableProfile(iccid)
} }
inner class ViewHolder(private val root: View) : RecyclerView.ViewHolder(root) { inner class ViewHolder(private val root: View) : RecyclerView.ViewHolder(root) {

View file

@ -95,7 +95,7 @@ class MainActivity : AppCompatActivity() {
manager.enumerateEuiccChannels() manager.enumerateEuiccChannels()
manager.knownChannels.forEach { manager.knownChannels.forEach {
Log.d(TAG, it.name) Log.d(TAG, it.name)
Log.d(TAG, it.lpa.eid) Log.d(TAG, it.lpa.eID)
openEuiccApplication.subscriptionManager.tryRefreshCachedEuiccInfo(it.cardId) openEuiccApplication.subscriptionManager.tryRefreshCachedEuiccInfo(it.cardId)
} }
} }

View file

@ -6,7 +6,6 @@ import android.util.Log
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.truphone.lpad.progress.Progress
import im.angry.openeuicc.R import im.angry.openeuicc.R
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -72,6 +71,6 @@ class ProfileDeleteFragment : DialogFragment(), EuiccFragmentMarker {
} }
private suspend fun doDelete() = withContext(Dispatchers.IO) { private suspend fun doDelete() = withContext(Dispatchers.IO) {
channel.lpa.deleteProfile(requireArguments().getString("iccid"), Progress()) channel.lpa.deleteProfile(requireArguments().getString("iccid")!!)
} }
} }

View file

@ -2,6 +2,7 @@ package im.angry.openeuicc.ui
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.text.Editable
import android.util.Log import android.util.Log
import android.view.* import android.view.*
import android.widget.ProgressBar import android.widget.ProgressBar
@ -12,12 +13,12 @@ import androidx.lifecycle.lifecycleScope
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
import com.journeyapps.barcodescanner.ScanContract import com.journeyapps.barcodescanner.ScanContract
import com.journeyapps.barcodescanner.ScanOptions import com.journeyapps.barcodescanner.ScanOptions
import com.truphone.lpa.progress.DownloadProgress
import im.angry.openeuicc.R import im.angry.openeuicc.R
import im.angry.openeuicc.util.setWidthPercent import im.angry.openeuicc.util.setWidthPercent
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import net.typeblog.lpac_jni.ProfileDownloadCallback
import java.lang.Exception import java.lang.Exception
class ProfileDownloadFragment : DialogFragment(), EuiccFragmentMarker, Toolbar.OnMenuItemClickListener { class ProfileDownloadFragment : DialogFragment(), EuiccFragmentMarker, Toolbar.OnMenuItemClickListener {
@ -31,6 +32,8 @@ class ProfileDownloadFragment : DialogFragment(), EuiccFragmentMarker, Toolbar.O
private lateinit var toolbar: Toolbar private lateinit var toolbar: Toolbar
private lateinit var profileDownloadServer: TextInputLayout private lateinit var profileDownloadServer: TextInputLayout
private lateinit var profileDownloadCode: TextInputLayout private lateinit var profileDownloadCode: TextInputLayout
private lateinit var profileDownloadConfirmationCode: TextInputLayout
private lateinit var profileDownloadIMEI: TextInputLayout
private lateinit var progress: ProgressBar private lateinit var progress: ProgressBar
private var downloading = false private var downloading = false
@ -55,6 +58,8 @@ class ProfileDownloadFragment : DialogFragment(), EuiccFragmentMarker, Toolbar.O
toolbar = view.findViewById(R.id.toolbar) toolbar = view.findViewById(R.id.toolbar)
profileDownloadServer = view.findViewById(R.id.profile_download_server) profileDownloadServer = view.findViewById(R.id.profile_download_server)
profileDownloadCode = view.findViewById(R.id.profile_download_code) profileDownloadCode = view.findViewById(R.id.profile_download_code)
profileDownloadConfirmationCode = view.findViewById(R.id.profile_download_confirmation_code)
profileDownloadIMEI = view.findViewById(R.id.profile_download_imei)
progress = view.findViewById(R.id.progress) progress = view.findViewById(R.id.progress)
toolbar.inflateMenu(R.menu.fragment_profile_download) toolbar.inflateMenu(R.menu.fragment_profile_download)
@ -94,6 +99,11 @@ class ProfileDownloadFragment : DialogFragment(), EuiccFragmentMarker, Toolbar.O
setWidthPercent(95) setWidthPercent(95)
} }
override fun onStart() {
super.onStart()
profileDownloadIMEI.editText!!.text = Editable.Factory.getInstance().newEditable(channel.imei)
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return super.onCreateDialog(savedInstanceState).also { return super.onCreateDialog(savedInstanceState).also {
it.window?.requestFeature(Window.FEATURE_NO_TITLE) it.window?.requestFeature(Window.FEATURE_NO_TITLE)
@ -112,6 +122,11 @@ class ProfileDownloadFragment : DialogFragment(), EuiccFragmentMarker, Toolbar.O
} }
val code = profileDownloadCode.editText!!.text.toString().trim() val code = profileDownloadCode.editText!!.text.toString().trim()
.ifBlank { null }
val confirmationCode = profileDownloadConfirmationCode.editText!!.text.toString().trim()
.ifBlank { null }
val imei = profileDownloadIMEI.editText!!.text.toString().trim()
.ifBlank { null }
downloading = true downloading = true
@ -123,7 +138,7 @@ class ProfileDownloadFragment : DialogFragment(), EuiccFragmentMarker, Toolbar.O
lifecycleScope.launch { lifecycleScope.launch {
try { try {
doDownloadProfile(server, code) doDownloadProfile(server, code, confirmationCode, imei)
} catch (e: Exception) { } catch (e: Exception) {
Log.d(TAG, "Error downloading profile") Log.d(TAG, "Error downloading profile")
Log.d(TAG, Log.getStackTraceString(e)) Log.d(TAG, Log.getStackTraceString(e))
@ -137,11 +152,13 @@ class ProfileDownloadFragment : DialogFragment(), EuiccFragmentMarker, Toolbar.O
} }
} }
private suspend fun doDownloadProfile(server: String, code: String) = withContext(Dispatchers.IO) { private suspend fun doDownloadProfile(server: String, code: String?, confirmationCode: String?, imei: String?) = withContext(Dispatchers.IO) {
channel.lpa.downloadProfile("1\$${server}\$${code}", channel.imei, DownloadProgress().apply { channel.lpa.downloadProfile(server, code, imei, confirmationCode, object : ProfileDownloadCallback {
setProgressListener { _, _, percentage, _ -> override fun onStateUpdate(state: ProfileDownloadCallback.DownloadState) {
lifecycleScope.launch(Dispatchers.Main) {
progress.isIndeterminate = false progress.isIndeterminate = false
progress.progress = (percentage * 100).toInt() progress.progress = state.progress
}
} }
}) })
} }

View file

@ -115,7 +115,7 @@ class ProfileRenameFragment : DialogFragment(), EuiccFragmentMarker {
} }
private suspend fun doRename(name: String) = withContext(Dispatchers.IO) { private suspend fun doRename(name: String) = withContext(Dispatchers.IO) {
if (!channel.lpa.setNickname(requireArguments().getString("iccid"), name)) { if (!channel.lpa.setNickname(requireArguments().getString("iccid")!!, name)) {
throw RuntimeException("Profile nickname not changed") throw RuntimeException("Profile nickname not changed")
} }
} }

View file

@ -1,19 +1,22 @@
package im.angry.openeuicc.util package im.angry.openeuicc.util
fun hexStringToByteArray(str: String): ByteArray { fun String.decodeHex(): ByteArray {
val length = str.length / 2 check(length % 2 == 0) { "Must have an even length" }
val out = ByteArray(length)
for (i in 0 until length) { val decodedLength = length / 2
val out = ByteArray(decodedLength)
for (i in 0 until decodedLength) {
val i2 = i * 2 val i2 = i * 2
out[i] = str.substring(i2, i2 + 2).toInt(16).toByte() out[i] = substring(i2, i2 + 2).toInt(16).toByte()
} }
return out return out
} }
fun byteArrayToHex(arr: ByteArray): String {
fun ByteArray.encodeHex(): String {
val sb = StringBuilder() val sb = StringBuilder()
val length = arr.size val length = size
for (i in 0 until length) { for (i in 0 until length) {
sb.append(String.format("%02X", arr[i])) sb.append(String.format("%02X", this[i]))
} }
return sb.toString() return sb.toString()
} }

View file

@ -2,7 +2,7 @@ package im.angry.openeuicc.util
import android.telephony.SubscriptionManager import android.telephony.SubscriptionManager
import android.telephony.TelephonyManager import android.telephony.TelephonyManager
import com.truphone.lpa.LocalProfileInfo import net.typeblog.lpac_jni.LocalProfileInfo
import java.lang.Exception import java.lang.Exception
val TelephonyManager.supportsDSDS: Boolean val TelephonyManager.supportsDSDS: Boolean

View file

@ -1,30 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View file

@ -5,7 +5,7 @@
android:viewportWidth="108" android:viewportWidth="108"
android:viewportHeight="108"> android:viewportHeight="108">
<path <path
android:fillColor="#3DDC84" android:fillColor="#D81B60"
android:pathData="M0,0h108v108h-108z" /> android:pathData="M0,0h108v108h-108z" />
<path <path
android:fillColor="#00000000" android:fillColor="#00000000"

View file

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF">
<group android:scaleX="0.5162"
android:scaleY="0.5162"
android:translateX="5.8056"
android:translateY="5.8056">
<path
android:fillColor="@android:color/white"
android:pathData="M19.99,4c0,-1.1 -0.89,-2 -1.99,-2h-8L4,8v12c0,1.1 0.9,2 2,2h12.01c1.1,0 1.99,-0.9 1.99,-2l-0.01,-16zM9,19L7,19v-2h2v2zM17,19h-2v-2h2v2zM9,15L7,15v-4h2v4zM13,19h-2v-4h2v4zM13,13h-2v-2h2v2zM17,15h-2v-4h2v4z"/>
</group>
</vector>

View file

@ -66,12 +66,56 @@
app:layout_constraintTop_toBottomOf="@id/profile_download_server" app:layout_constraintTop_toBottomOf="@id/profile_download_server"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintWidth_percent=".8"
app:layout_constraintWidth_percent=".8"> app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:inputType="textPassword"
android:theme="@style/Theme.OpenEUICC.Input.Cursor"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/profile_download_confirmation_code"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginVertical="15dp"
android:hint="@string/profile_download_confirmation_code"
style="@style/Widget.OpenEUICC.Input"
app:layout_constraintTop_toBottomOf="@id/profile_download_code"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintWidth_percent=".8"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textPassword"
android:theme="@style/Theme.OpenEUICC.Input.Cursor"/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/profile_download_imei"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginVertical="15dp"
android:hint="@string/profile_download_imei"
style="@style/Widget.OpenEUICC.Input"
app:layout_constraintTop_toBottomOf="@id/profile_download_confirmation_code"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintWidth_percent=".8"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textPassword"
android:theme="@style/Theme.OpenEUICC.Input.Cursor"/> android:theme="@style/Theme.OpenEUICC.Input.Cursor"/>
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 982 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View file

@ -23,6 +23,8 @@
<string name="profile_download">New eSIM</string> <string name="profile_download">New eSIM</string>
<string name="profile_download_server">Server (RSP / SM-DP+)</string> <string name="profile_download_server">Server (RSP / SM-DP+)</string>
<string name="profile_download_code">Activation Code</string> <string name="profile_download_code">Activation Code</string>
<string name="profile_download_confirmation_code">Confirmation Code (Optional)</string>
<string name="profile_download_imei">IMEI (Optional)</string>
<string name="profile_download_scan">Scan QR Code</string> <string name="profile_download_scan">Scan QR Code</string>
<string name="profile_download_ok">Download</string> <string name="profile_download_ok">Download</string>
<string name="profile_download_failed">Failed to download eSIM. Check your activation / QR code.</string> <string name="profile_download_failed">Failed to download eSIM. Check your activation / QR code.</string>

View file

@ -2,8 +2,8 @@
plugins { plugins {
id 'com.android.application' version '8.1.2' apply false id 'com.android.application' version '8.1.2' apply false
id 'com.android.library' version '8.1.2' apply false id 'com.android.library' version '8.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false id 'org.jetbrains.kotlin.android' version '1.9.20' apply false
id 'org.jetbrains.kotlin.multiplatform' version '1.6.21' apply false id 'org.jetbrains.kotlin.multiplatform' version '1.9.20' apply false
} }
task clean(type: Delete) { task clean(type: Delete) {

View file

@ -0,0 +1,46 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'net.typeblog.lpac_jni'
compileSdk 33
defaultConfig {
minSdk 27
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
ndkBuild {
path "src/main/jni/Android.mk"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.12.0'
implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.10.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

View file

21
libs/lpac-jni/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -0,0 +1,24 @@
package net.typeblog.lpac_jni
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("net.typeblog.lpac_jni.test", appContext.packageName)
}
}

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

View file

@ -0,0 +1,12 @@
package net.typeblog.lpac_jni
/*
* Should reflect euicc_apdu_interface in lpac/euicc/interface.h
*/
interface ApduInterface {
fun connect()
fun disconnect()
fun logicalChannelOpen(aid: ByteArray): Int
fun logicalChannelClose(handle: Int)
fun transmit(tx: ByteArray): ByteArray
}

View file

@ -0,0 +1,28 @@
package net.typeblog.lpac_jni
/*
* Should reflect euicc_http_interface in lpac/euicc/interface.h
*/
interface HttpInterface {
data class HttpResponse(val rcode: Int, val data: ByteArray) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as HttpResponse
if (rcode != other.rcode) return false
if (!data.contentEquals(other.data)) return false
return true
}
override fun hashCode(): Int {
var result = rcode
result = 31 * result + data.contentHashCode()
return result
}
}
fun transmit(url: String, tx: ByteArray, headers: Array<String>): HttpResponse
}

View file

@ -0,0 +1,19 @@
package net.typeblog.lpac_jni
interface LocalProfileAssistant {
val profiles: List<LocalProfileInfo>
val eID: String
fun enableProfile(iccid: String): Boolean
fun disableProfile(iccid: String): Boolean
fun deleteProfile(iccid: String): Boolean
fun downloadProfile(smdp: String, matchingId: String?, imei: String?,
confirmationCode: String?, callback: ProfileDownloadCallback): Boolean
fun setNickname(
iccid: String, nickname: String
): Boolean
fun close()
}

View file

@ -1,18 +1,4 @@
/* package net.typeblog.lpac_jni
* Copyright 2022 Peter Cai & Pierre-Hugues Husson
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
package com.truphone.lpa
import java.lang.IllegalArgumentException import java.lang.IllegalArgumentException

View file

@ -0,0 +1,28 @@
package net.typeblog.lpac_jni
internal object LpacJni {
init {
System.loadLibrary("lpac-jni")
}
external fun createContext(apduInterface: ApduInterface, httpInterface: HttpInterface): Long
external fun destroyContext(handle: Long)
// es10x
external fun es10xInit(handle: Long): Int
external fun es10xFini(handle: Long)
// es10c
// null returns signify errors
external fun es10cGetEid(handle: Long): String?
external fun es10cGetProfilesInfo(handle: Long): Array<LocalProfileInfo>?
external fun es10cEnableProfile(handle: Long, iccid: String): Int
external fun es10cDisableProfile(handle: Long, iccid: String): Int
external fun es10cDeleteProfile(handle: Long, iccid: String): Int
external fun es10cSetNickname(handle: Long, iccid: String, nick: String): Int
// es9p + es10b
// We do not expose all of the functions because of tediousness :)
external fun downloadProfile(handle: Long, smdp: String, matchingId: String?, imei: String?,
confirmationCode: String?, callback: ProfileDownloadCallback): Int
}

View file

@ -0,0 +1,13 @@
package net.typeblog.lpac_jni
interface ProfileDownloadCallback {
enum class DownloadState(val progress: Int) {
Preparing(0),
Connecting(20), // Before {server,client} authentication
Authenticating(40), // {server,client} authentication
Downloading(60), // prepare download, get bpp from es9p
Finalizing(80), // load bpp
}
fun onStateUpdate(state: DownloadState)
}

View file

@ -0,0 +1,29 @@
package net.typeblog.lpac_jni.impl
import net.typeblog.lpac_jni.HttpInterface
import java.net.HttpURLConnection
import java.net.URL
class HttpInterfaceImpl: HttpInterface {
override fun transmit(
url: String,
tx: ByteArray,
headers: Array<String>
): HttpInterface.HttpResponse {
val conn = URL(url).openConnection() as HttpURLConnection
conn.requestMethod = "POST"
conn.doInput = true
conn.doOutput = true
for (h in headers) {
val s = h.split(":", limit = 2)
conn.setRequestProperty(s[0], s[1])
}
conn.outputStream.write(tx)
conn.outputStream.flush()
conn.outputStream.close()
return HttpInterface.HttpResponse(conn.responseCode, conn.inputStream.readBytes())
}
}

View file

@ -0,0 +1,53 @@
package net.typeblog.lpac_jni.impl
import net.typeblog.lpac_jni.LpacJni
import net.typeblog.lpac_jni.ApduInterface
import net.typeblog.lpac_jni.HttpInterface
import net.typeblog.lpac_jni.LocalProfileAssistant
import net.typeblog.lpac_jni.LocalProfileInfo
import net.typeblog.lpac_jni.ProfileDownloadCallback
class LocalProfileAssistantImpl(
apduInterface: ApduInterface,
httpInterface: HttpInterface
): LocalProfileAssistant {
private val contextHandle: Long = LpacJni.createContext(apduInterface, httpInterface)
init {
if (LpacJni.es10xInit(contextHandle) < 0) {
throw IllegalArgumentException("Failed to initialize LPA")
}
}
override val profiles: List<LocalProfileInfo>
get() = LpacJni.es10cGetProfilesInfo(contextHandle)!!.asList() // TODO: Maybe we need better error handling
override val eID: String by lazy {
LpacJni.es10cGetEid(contextHandle)!!
}
override fun enableProfile(iccid: String): Boolean {
return LpacJni.es10cEnableProfile(contextHandle, iccid) == 0
}
override fun disableProfile(iccid: String): Boolean {
return LpacJni.es10cDisableProfile(contextHandle, iccid) == 0
}
override fun deleteProfile(iccid: String): Boolean {
return LpacJni.es10cDeleteProfile(contextHandle, iccid) == 0
}
override fun downloadProfile(smdp: String, matchingId: String?, imei: String?,
confirmationCode: String?, callback: ProfileDownloadCallback): Boolean {
return LpacJni.downloadProfile(contextHandle, smdp, matchingId, imei, confirmationCode, callback) == 0
}
override fun setNickname(iccid: String, nickname: String): Boolean {
return LpacJni.es10cSetNickname(contextHandle, iccid, nickname) == 0
}
override fun close() {
LpacJni.es10xFini(contextHandle)
LpacJni.destroyContext(contextHandle)
}
}

View file

@ -0,0 +1,52 @@
cc_defaults {
name: "lpac-jni-defaults",
local_include_dirs: ["lpac"],
sdk_version: "current",
cflags: ["-Wno-error"],
}
cc_library_static {
name: "liblpac-cjson",
defaults: ["lpac-jni-defaults"],
srcs: [
"lpac/cjson/*.c",
],
}
cc_library_static {
name: "liblpac-asn1c",
defaults: ["lpac-jni-defaults"],
local_include_dirs: ["lpac/euicc/asn1c"],
cflags: ["-DHAVE_CONFIG_H"],
srcs: [
"lpac/euicc/asn1c/asn1/*.c",
],
}
cc_library_static {
name: "liblpac-euicc",
defaults: ["lpac-jni-defaults"],
srcs: [
"lpac/euicc/*.c",
],
static_libs: [
"liblpac-asn1c",
"liblpac-cjson",
],
}
cc_library_shared {
name: "liblpac-jni",
defaults: ["lpac-jni-defaults"],
header_libs: ["jni_headers"],
srcs: [
"lpac-jni/*.c",
],
static_libs: [
"liblpac-euicc",
"liblpac-asn1c",
"liblpac-cjson",
],
shared_libs: ["liblog"],
system_ext_specific: true,
}

View file

@ -0,0 +1,47 @@
LOCAL_PATH := $(call my-dir)
# function to find all *.c files under a directory
define all-c-files-under
$(patsubst ./%,%, \
$(shell cd $(LOCAL_PATH) ; \
find $(1) -name "*.c" -and -not -name ".*" -maxdepth 1) \
)
endef
include $(CLEAR_VARS)
# libcjson
LOCAL_MODULE := lpac-cjson
LOCAL_SRC_FILES := \
$(call all-c-files-under, lpac/cjson)
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
# libasn1c, the ASN parser component from lpac
LOCAL_MODULE := lpac-asn1c
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/lpac/euicc/asn1c
LOCAL_SRC_FILES := \
$(call all-c-files-under, lpac/euicc/asn1c/asn1)
LOCAL_CFLAGS := -DHAVE_CONFIG_H
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
# libeuicc component from lpac, which contains the actual implementation
LOCAL_MODULE := lpac-euicc
LOCAL_STATIC_LIBRARIES := lpac-asn1c lpac-cjson
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/lpac
LOCAL_SRC_FILES := \
$(call all-c-files-under, lpac/euicc)
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := lpac-jni
LOCAL_STATIC_LIBRARIES := lpac-euicc
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/lpac
LOCAL_SRC_FILES := \
lpac-jni/lpac-jni.c \
lpac-jni/lpac-download.c \
lpac-jni/interface-wrapper.c
include $(BUILD_SHARED_LIBRARY)

View file

@ -0,0 +1 @@
APP_ABI := all

@ -0,0 +1 @@
Subproject commit 29984b34220581ec3779876d964b41bb566851f5

View file

@ -0,0 +1,116 @@
#include <string.h>
#include <malloc.h>
#include "interface-wrapper.h"
jmethodID method_apdu_connect;
jmethodID method_apdu_disconnect;
jmethodID method_apdu_logical_channel_open;
jmethodID method_apdu_logical_channel_close;
jmethodID method_apdu_transmit;
jmethodID method_http_transmit;
jfieldID field_resp_rcode;
jfieldID field_resp_data;
void interface_wrapper_init() {
LPAC_JNI_SETUP_ENV;
jclass apdu_class = (*env)->FindClass(env, "net/typeblog/lpac_jni/ApduInterface");
method_apdu_connect = (*env)->GetMethodID(env, apdu_class, "connect", "()V");
method_apdu_disconnect = (*env)->GetMethodID(env, apdu_class, "disconnect", "()V");
method_apdu_logical_channel_open = (*env)->GetMethodID(env, apdu_class, "logicalChannelOpen", "([B)I");
method_apdu_logical_channel_close = (*env)->GetMethodID(env, apdu_class, "logicalChannelClose", "(I)V");
method_apdu_transmit = (*env)->GetMethodID(env, apdu_class, "transmit", "([B)[B");
jclass http_class = (*env)->FindClass(env, "net/typeblog/lpac_jni/HttpInterface");
method_http_transmit = (*env)->GetMethodID(env, http_class, "transmit",
"(Ljava/lang/String;[B[Ljava/lang/String;)Lnet/typeblog/lpac_jni/HttpInterface$HttpResponse;");
jclass resp_class = (*env)->FindClass(env, "net/typeblog/lpac_jni/HttpInterface$HttpResponse");
field_resp_rcode = (*env)->GetFieldID(env, resp_class, "rcode", "I");
field_resp_data = (*env)->GetFieldID(env, resp_class, "data", "[B");
}
static int apdu_interface_connect(struct euicc_ctx *ctx) {
LPAC_JNI_SETUP_ENV;
(*env)->CallVoidMethod(env, LPAC_JNI_CTX(ctx)->apdu_interface, method_apdu_connect);
LPAC_JNI_EXCEPTION_RETURN;
return 0;
}
static void apdu_interface_disconnect(struct euicc_ctx *ctx) {
LPAC_JNI_SETUP_ENV;
(*env)->CallVoidMethod(env, LPAC_JNI_CTX(ctx)->apdu_interface, method_apdu_disconnect);
}
static int apdu_interface_logical_channel_open(struct euicc_ctx *ctx, const uint8_t *aid, uint8_t aid_len) {
LPAC_JNI_SETUP_ENV;
jbyteArray jbarr = (*env)->NewByteArray(env, aid_len);
(*env)->SetByteArrayRegion(env, jbarr, 0, aid_len, (const jbyte *) aid);
jint ret = (*env)->CallIntMethod(env, LPAC_JNI_CTX(ctx)->apdu_interface, method_apdu_logical_channel_open, jbarr);
LPAC_JNI_EXCEPTION_RETURN;
return ret;
}
static void apdu_interface_logical_channel_close(struct euicc_ctx *ctx, uint8_t channel) {
LPAC_JNI_SETUP_ENV;
(*env)->CallVoidMethod(env, LPAC_JNI_CTX(ctx)->apdu_interface, method_apdu_logical_channel_close, channel);
(*env)->ExceptionClear(env);
}
static int apdu_interface_transmit(struct euicc_ctx *ctx, uint8_t **rx, uint32_t *rx_len, const uint8_t *tx, uint32_t tx_len) {
LPAC_JNI_SETUP_ENV;
jbyteArray txArr = (*env)->NewByteArray(env, tx_len);
(*env)->SetByteArrayRegion(env, txArr, 0, tx_len, (const jbyte *) tx);
jbyteArray ret = (jbyteArray) (*env)->CallObjectMethod(env, LPAC_JNI_CTX(ctx)->apdu_interface, method_apdu_transmit, txArr);
LPAC_JNI_EXCEPTION_RETURN;
*rx_len = (*env)->GetArrayLength(env, ret);
*rx = malloc(*rx_len * sizeof(uint8_t));
(*env)->GetByteArrayRegion(env, ret, 0, *rx_len, *rx);
(*env)->DeleteLocalRef(env, txArr);
(*env)->DeleteLocalRef(env, ret);
return 0;
}
static int http_interface_transmit(struct euicc_ctx *ctx, const char *url, uint32_t *rcode, uint8_t **rx, uint32_t *rx_len, const uint8_t *tx, uint32_t tx_len, const char **headers) {
LPAC_JNI_SETUP_ENV;
jstring jurl = toJString(env, url);
jbyteArray txArr = (*env)->NewByteArray(env, tx_len);
(*env)->SetByteArrayRegion(env, txArr, 0, tx_len, (const jbyte *) tx);
int num_headers = 0;
while (headers[num_headers] != NULL) {
num_headers++;
}
jobjectArray headersArr = (*env)->NewObjectArray(env, num_headers, string_class, NULL);
for (int i = 0; i < num_headers; i++) {
jstring header = toJString(env, headers[i]);
(*env)->SetObjectArrayElement(env, headersArr, i, header);
(*env)->DeleteLocalRef(env, header);
}
jobject ret = (*env)->CallObjectMethod(env, LPAC_JNI_CTX(ctx)->http_interface, method_http_transmit, jurl, txArr, headersArr);
LPAC_JNI_EXCEPTION_RETURN;
*rcode = (*env)->GetIntField(env, ret, field_resp_rcode);
jbyteArray rxArr = (jbyteArray) (*env)->GetObjectField(env, ret, field_resp_data);
*rx_len = (*env)->GetArrayLength(env, rxArr);
*rx = malloc(*rx_len * sizeof(uint8_t));
(*env)->GetByteArrayRegion(env, rxArr, 0, *rx_len, *rx);
(*env)->DeleteLocalRef(env, txArr);
(*env)->DeleteLocalRef(env, rxArr);
(*env)->DeleteLocalRef(env, headersArr);
(*env)->DeleteLocalRef(env, ret);
return 0;
}
struct euicc_apdu_interface lpac_jni_apdu_interface = {
.connect = &apdu_interface_connect,
.disconnect = &apdu_interface_disconnect,
.logic_channel_open = &apdu_interface_logical_channel_open,
.logic_channel_close = &apdu_interface_logical_channel_close,
.transmit = &apdu_interface_transmit
};
struct euicc_http_interface lpac_jni_http_interface = {
.transmit = &http_interface_transmit
};

View file

@ -0,0 +1,16 @@
#pragma once
#undef NDEBUG
#include <assert.h>
#include <euicc/interface.h>
#include "lpac-jni.h"
void interface_wrapper_init();
extern struct euicc_apdu_interface lpac_jni_apdu_interface;
extern struct euicc_http_interface lpac_jni_http_interface;
#define LPAC_JNI_EXCEPTION_RETURN \
if ((*env)->ExceptionCheck(env) == JNI_TRUE) { \
(*env)->ExceptionClear(env); \
return -1; \
}

View file

@ -0,0 +1,133 @@
#include <euicc/es9p.h>
#include <euicc/es10b.h>
#include <stdlib.h>
#include <string.h>
#include "lpac-download.h"
jobject download_state_preparing;
jobject download_state_connecting;
jobject download_state_authenticating;
jobject download_state_downloading;
jobject download_state_finalizing;
jmethodID on_state_update;
void lpac_download_init() {
LPAC_JNI_SETUP_ENV;
jclass download_state_class = (*env)->FindClass(env, "net/typeblog/lpac_jni/ProfileDownloadCallback$DownloadState");
jfieldID download_state_preparing_field = (*env)->GetStaticFieldID(env, download_state_class, "Preparing", "Lnet/typeblog/lpac_jni/ProfileDownloadCallback$DownloadState;");
download_state_preparing = (*env)->GetStaticObjectField(env, download_state_class, download_state_preparing_field);
download_state_preparing = (*env)->NewGlobalRef(env, download_state_preparing);
jfieldID download_state_connecting_field = (*env)->GetStaticFieldID(env, download_state_class, "Connecting", "Lnet/typeblog/lpac_jni/ProfileDownloadCallback$DownloadState;");
download_state_connecting = (*env)->GetStaticObjectField(env, download_state_class, download_state_connecting_field);
download_state_connecting = (*env)->NewGlobalRef(env, download_state_connecting);
jfieldID download_state_authenticating_field = (*env)->GetStaticFieldID(env, download_state_class, "Authenticating", "Lnet/typeblog/lpac_jni/ProfileDownloadCallback$DownloadState;");
download_state_authenticating = (*env)->GetStaticObjectField(env, download_state_class, download_state_authenticating_field);
download_state_authenticating = (*env)->NewGlobalRef(env, download_state_authenticating);
jfieldID download_state_downloading_field = (*env)->GetStaticFieldID(env, download_state_class, "Downloading", "Lnet/typeblog/lpac_jni/ProfileDownloadCallback$DownloadState;");
download_state_downloading = (*env)->GetStaticObjectField(env, download_state_class, download_state_downloading_field);
download_state_downloading = (*env)->NewGlobalRef(env, download_state_downloading);
jfieldID download_state_finalizng_field = (*env)->GetStaticFieldID(env, download_state_class, "Finalizing", "Lnet/typeblog/lpac_jni/ProfileDownloadCallback$DownloadState;");
download_state_finalizing = (*env)->GetStaticObjectField(env, download_state_class, download_state_finalizng_field);
download_state_finalizing = (*env)->NewGlobalRef(env, download_state_finalizing);
jclass download_callback_class = (*env)->FindClass(env, "net/typeblog/lpac_jni/ProfileDownloadCallback");
on_state_update = (*env)->GetMethodID(env, download_callback_class, "onStateUpdate", "(Lnet/typeblog/lpac_jni/ProfileDownloadCallback$DownloadState;)V");
}
JNIEXPORT jint JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_downloadProfile(JNIEnv *env, jobject thiz, jlong handle,
jstring smdp, jstring matching_id,
jstring imei, jstring confirmation_code,
jobject callback) {
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
struct es9p_get_bound_profile_package_resp es9p_get_bound_profile_package_resp;
struct es9p_initiate_authentication_resp es9p_initiate_authentication_resp;
struct es10b_authenticate_server_param es10b_authenticate_server_param;
struct es9p_authenticate_client_resp es9p_authenticate_client_resp;
struct es10b_prepare_download_param es10b_prepare_download_param;
char *b64_authenticate_server_response = NULL;
char *b64_prepare_download_response = NULL;
char *b64_euicc_challenge = NULL;
char *b64_euicc_info_1 = NULL;
char *transaction_id = NULL;
const char *_confirmation_code = NULL;
const char *_matching_id = NULL;
const char *_smdp = NULL;
const char *_imei = NULL;
int ret;
if (confirmation_code != NULL)
_confirmation_code = (*env)->GetStringUTFChars(env, confirmation_code, NULL);
if (matching_id != NULL)
_matching_id = (*env)->GetStringUTFChars(env, matching_id, NULL);
_smdp = (*env)->GetStringUTFChars(env, smdp, NULL);
if (imei != NULL)
_imei = (*env)->GetStringUTFChars(env, imei, NULL);
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_preparing);
ret = es10b_get_euicc_challenge(ctx, &b64_euicc_challenge);
if (ret < 0)
goto out;
ret = es10b_get_euicc_info(ctx, &b64_euicc_info_1);
if (ret < 0)
goto out;
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_connecting);
ret = es9p_initiate_authentication(ctx, _smdp, b64_euicc_challenge, b64_euicc_info_1, &es9p_initiate_authentication_resp);
if (ret < 0)
goto out;
transaction_id = strdup(es9p_initiate_authentication_resp.transaction_id);
es10b_authenticate_server_param.b64_server_signed_1 = es9p_initiate_authentication_resp.b64_server_signed_1;
es10b_authenticate_server_param.b64_server_signature_1 = es9p_initiate_authentication_resp.b64_server_signature_1;
es10b_authenticate_server_param.b64_euicc_ci_pkid_to_be_used = es9p_initiate_authentication_resp.b64_euicc_ci_pkid_to_be_used;
es10b_authenticate_server_param.b64_server_certificate = es9p_initiate_authentication_resp.b64_server_certificate;
es10b_authenticate_server_param.matchingId = _matching_id;
es10b_authenticate_server_param.imei = _imei;
es10b_authenticate_server_param.tac = NULL;
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_authenticating);
ret = es10b_authenticate_server(ctx, &b64_authenticate_server_response, &es10b_authenticate_server_param);
if (ret < 0)
goto out;
ret = es9p_authenticate_client(ctx, _smdp, transaction_id, b64_authenticate_server_response, &es9p_authenticate_client_resp);
if (ret < 0)
goto out;
es10b_prepare_download_param.b64_smdp_signed_2 = es9p_authenticate_client_resp.b64_smdp_signed_2;
es10b_prepare_download_param.b64_smdp_signature_2 = es9p_authenticate_client_resp.b64_smdp_signature_2;
es10b_prepare_download_param.b64_smdp_certificate = es9p_authenticate_client_resp.b64_smdp_certificate;
es10b_prepare_download_param.hexstr_transcation_id = transaction_id;
es10b_prepare_download_param.str_checkcode = _confirmation_code;
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_downloading);
ret = es10b_prepare_download(ctx, &b64_prepare_download_response, &es10b_prepare_download_param);
if (ret < 0)
goto out;
ret = es9p_get_bound_profile_package(ctx, _smdp, transaction_id, b64_prepare_download_response, &es9p_get_bound_profile_package_resp);
if (ret < 0)
goto out;
(*env)->CallVoidMethod(env, callback, on_state_update, download_state_finalizing);
ret = es10b_load_bound_profile_package(ctx, es9p_get_bound_profile_package_resp.b64_bpp);
out:
free(b64_authenticate_server_response);
free(b64_prepare_download_response);
free(b64_euicc_info_1);
free(b64_euicc_challenge);
free(transaction_id);
if (_confirmation_code != NULL)
(*env)->ReleaseStringUTFChars(env, confirmation_code, _confirmation_code);
if (_matching_id != NULL)
(*env)->ReleaseStringUTFChars(env, matching_id, _matching_id);
(*env)->ReleaseStringUTFChars(env, smdp, _smdp);
if (_imei != NULL)
(*env)->ReleaseStringUTFChars(env, imei, _imei);
return ret;
}

View file

@ -0,0 +1,5 @@
#pragma once
#include <jni.h>
#include "lpac-jni.h"
void lpac_download_init();

View file

@ -0,0 +1,232 @@
#include <euicc/es10x.h>
#include <euicc/interface.h>
#include <malloc.h>
#include <string.h>
#include <syslog.h>
#include "lpac-jni.h"
#include "lpac-download.h"
#include "interface-wrapper.h"
JavaVM *jvm = NULL;
jclass local_profile_info_class;
jmethodID local_profile_info_constructor;
jobject local_profile_state_enabled;
jobject local_profile_state_disabled;
jobject local_profile_class_testing;
jobject local_profile_class_provisioning;
jobject local_profile_class_operational;
jstring empty_string;
jclass string_class;
jmethodID string_constructor;
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
jvm = vm;
interface_wrapper_init();
lpac_download_init();
LPAC_JNI_SETUP_ENV;
string_class = (*env)->FindClass(env, "java/lang/String");
string_class = (*env)->NewGlobalRef(env, string_class);
string_constructor = (*env)->GetMethodID(env, string_class, "<init>", "([BLjava/lang/String;)V");
local_profile_info_class = (*env)->FindClass(env, "net/typeblog/lpac_jni/LocalProfileInfo");
local_profile_info_class = (*env)->NewGlobalRef(env, local_profile_info_class);
local_profile_info_constructor = (*env)->GetMethodID(env, local_profile_info_class, "<init>",
"(Ljava/lang/String;Lnet/typeblog/lpac_jni/LocalProfileInfo$State;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lnet/typeblog/lpac_jni/LocalProfileInfo$Clazz;)V");
jclass local_profile_state_class = (*env)->FindClass(env, "net/typeblog/lpac_jni/LocalProfileInfo$State");
jfieldID field_enabled = (*env)->GetStaticFieldID(env, local_profile_state_class, "Enabled", "Lnet/typeblog/lpac_jni/LocalProfileInfo$State;");
local_profile_state_enabled = (*env)->GetStaticObjectField(env, local_profile_state_class, field_enabled);
local_profile_state_enabled = (*env)->NewGlobalRef(env, local_profile_state_enabled);
jfieldID field_disabled = (*env)->GetStaticFieldID(env, local_profile_state_class, "Disabled", "Lnet/typeblog/lpac_jni/LocalProfileInfo$State;");
local_profile_state_disabled = (*env)->GetStaticObjectField(env, local_profile_state_class, field_disabled);
local_profile_state_disabled = (*env)->NewGlobalRef(env, local_profile_state_disabled);
jclass local_profile_class_class = (*env)->FindClass(env, "net/typeblog/lpac_jni/LocalProfileInfo$Clazz");
jfieldID field_testing = (*env)->GetStaticFieldID(env, local_profile_class_class, "Testing", "Lnet/typeblog/lpac_jni/LocalProfileInfo$Clazz;");
local_profile_class_testing = (*env)->GetStaticObjectField(env, local_profile_class_class, field_testing);
local_profile_class_testing = (*env)->NewGlobalRef(env, local_profile_class_testing);
jfieldID field_provisioning = (*env)->GetStaticFieldID(env, local_profile_class_class, "Provisioning", "Lnet/typeblog/lpac_jni/LocalProfileInfo$Clazz;");
local_profile_class_provisioning = (*env)->GetStaticObjectField(env, local_profile_class_class, field_provisioning);
local_profile_class_provisioning = (*env)->NewGlobalRef(env, local_profile_class_provisioning);
jfieldID field_operational = (*env)->GetStaticFieldID(env, local_profile_class_class, "Operational", "Lnet/typeblog/lpac_jni/LocalProfileInfo$Clazz;");
local_profile_class_operational = (*env)->GetStaticObjectField(env, local_profile_class_class, field_operational);
local_profile_class_operational = (*env)->NewGlobalRef(env, local_profile_class_operational);
const char _unused[1];
empty_string = (*env)->NewString(env, _unused, 0);
empty_string = (*env)->NewGlobalRef(env, empty_string);
return JNI_VERSION_1_6;
}
JNIEXPORT jlong JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_createContext(JNIEnv *env, jobject thiz,
jobject apdu_interface,
jobject http_interface) {
struct euicc_ctx *ctx = malloc(sizeof(struct euicc_ctx));
struct lpac_jni_ctx *_ctx = malloc(sizeof(struct lpac_jni_ctx));
memset(ctx, 0, sizeof(struct lpac_jni_ctx));
memset(_ctx, 0, sizeof(struct lpac_jni_ctx));
ctx->interface.apdu = &lpac_jni_apdu_interface;
ctx->interface.http = &lpac_jni_http_interface;
_ctx->apdu_interface = (*env)->NewGlobalRef(env, apdu_interface);
_ctx->http_interface = (*env)->NewGlobalRef(env, http_interface);
ctx->userdata = (void *) _ctx;
return (jlong) ctx;
}
JNIEXPORT void JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_destroyContext(JNIEnv *env, jobject thiz, jlong handle) {
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
struct lpac_jni_ctx *_ctx = LPAC_JNI_CTX(ctx);
(*env)->DeleteGlobalRef(env, _ctx->apdu_interface);
(*env)->DeleteGlobalRef(env, _ctx->http_interface);
free(_ctx);
free(ctx);
}
JNIEXPORT jint JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_es10xInit(JNIEnv *env, jobject thiz, jlong handle) {
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
return es10x_init(ctx);
}
JNIEXPORT void JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_es10xFini(JNIEnv *env, jobject thiz, jlong handle) {
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
es10x_fini(ctx);
}
jstring toJString(JNIEnv *env, const char *pat) {
int len = strlen(pat);
jbyteArray bytes = (*env)->NewByteArray(env, len);
(*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte *) pat);
jstring encoding = (*env)->NewStringUTF(env, "utf-8");
jstring jstr = (jstring) (*env)->NewObject(env, string_class,
string_constructor, bytes, encoding);
(*env)->DeleteLocalRef(env, encoding);
(*env)->DeleteLocalRef(env, bytes);
return jstr;
}
JNIEXPORT jstring JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_es10cGetEid(JNIEnv *env, jobject thiz, jlong handle) {
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
char *buf;
if (es10c_get_eid(ctx, &buf) < 0) {
return NULL;
}
jstring ret = toJString(env, buf);
free(buf);
return ret;
}
JNIEXPORT jobjectArray JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_es10cGetProfilesInfo(JNIEnv *env, jobject thiz, jlong handle) {
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
struct es10c_profile_info *info;
int count;
if (es10c_get_profiles_info(ctx, &info, &count) < 0) {
return NULL;
}
jobjectArray ret = (*env)->NewObjectArray(env, count, local_profile_info_class, NULL);
// Convert the native info array to Java
for (int i = 0; i < count; i++) {
jstring iccid = toJString(env, info[i].iccid);
jstring isdpAid = toJString(env, info[i].isdpAid);
jstring name = toJString(env, info[i].profileName);
jstring nickName = info[i].profileNickname ? toJString(env, info[i].profileNickname) : (*env)->NewLocalRef(env, empty_string);
jstring serviceProvider = info[i].serviceProviderName ? toJString(env, info[i].serviceProviderName) : (*env)->NewLocalRef(env, empty_string);
jobject state;
switch (info[i].profileState) {
case ES10C_PROFILE_INFO_STATE_ENABLED:
state = local_profile_state_enabled;
break;
case ES10C_PROFILE_INFO_STATE_DISABLED:
state = local_profile_state_disabled;
break;
}
state = (*env)->NewLocalRef(env, state);
jobject class;
switch (info[i].profileClass) {
case ES10C_PROFILE_INFO_CLASS_TEST:
class = local_profile_class_testing;
break;
case ES10C_PROFILE_INFO_CLASS_PROVISIONING:
class = local_profile_class_provisioning;
break;
case ES10C_PROFILE_INFO_CLASS_OPERATIONAL:
class = local_profile_class_operational;
break;
}
class = (*env)->NewLocalRef(env, class);
jobject jinfo = (*env)->NewObject(env, local_profile_info_class, local_profile_info_constructor,
iccid, state, name, nickName, serviceProvider, isdpAid, class);
(*env)->SetObjectArrayElement(env, ret, i, jinfo);
(*env)->DeleteLocalRef(env, jinfo);
(*env)->DeleteLocalRef(env, class);
(*env)->DeleteLocalRef(env, state);
(*env)->DeleteLocalRef(env, serviceProvider);
(*env)->DeleteLocalRef(env, nickName);
(*env)->DeleteLocalRef(env, name);
(*env)->DeleteLocalRef(env, isdpAid);
(*env)->DeleteLocalRef(env, iccid);
}
es10c_profile_info_free_all(info, count);
return ret;
}
JNIEXPORT jint JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_es10cEnableProfile(JNIEnv *env, jobject thiz, jlong handle,
jstring iccid) {
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
const char *_iccid = (*env)->GetStringUTFChars(env, iccid, NULL);
int ret = es10c_enable_profile_iccid(ctx, _iccid, 1);
(*env)->ReleaseStringUTFChars(env, iccid, _iccid);
return ret;
}
JNIEXPORT jint JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_es10cDisableProfile(JNIEnv *env, jobject thiz, jlong handle,
jstring iccid) {
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
const char *_iccid = (*env)->GetStringUTFChars(env, iccid, NULL);
int ret = es10c_disable_profile_iccid(ctx, _iccid, 1);
(*env)->ReleaseStringUTFChars(env, iccid, _iccid);
return ret;
}
JNIEXPORT jint JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_es10cSetNickname(JNIEnv *env, jobject thiz, jlong handle,
jstring iccid, jstring nick) {
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
const char *_iccid = (*env)->GetStringUTFChars(env, iccid, NULL);
const char *_nick = (*env)->GetStringUTFChars(env, nick, NULL);
int ret = es10c_set_nickname(ctx, _iccid, _nick);
(*env)->ReleaseStringUTFChars(env, nick, _nick);
(*env)->ReleaseStringUTFChars(env, iccid, _iccid);
return ret;
}
JNIEXPORT jint JNICALL
Java_net_typeblog_lpac_1jni_LpacJni_es10cDeleteProfile(JNIEnv *env, jobject thiz, jlong handle,
jstring iccid) {
struct euicc_ctx *ctx = (struct euicc_ctx *) handle;
const char *_iccid = (*env)->GetStringUTFChars(env, iccid, NULL);
int ret = es10c_delete_profile_iccid(ctx, _iccid);
(*env)->ReleaseStringUTFChars(env, iccid, _iccid);
return ret;
}

View file

@ -0,0 +1,19 @@
#pragma once
#include <euicc/euicc.h>
#include <pthread.h>
#include <jni.h>
struct lpac_jni_ctx {
jobject apdu_interface;
jobject http_interface;
};
#define LPAC_JNI_CTX(ctx) ((struct lpac_jni_ctx *) ctx->userdata)
#define LPAC_JNI_SETUP_ENV \
JNIEnv *env; \
(*jvm)->AttachCurrentThread(jvm, &env, NULL)
extern JavaVM *jvm;
extern jclass string_class;
jstring toJString(JNIEnv *env, const char *pat);

View file

@ -0,0 +1,17 @@
package net.typeblog.lpac_jni
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

View file

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="target/generated-sources/asn1">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>lpad-sm-dp-plus-connector</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View file

@ -1,6 +0,0 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//target/generated-sources/asn1=UTF-8
encoding/<project>=UTF-8

View file

@ -1,2 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false

View file

@ -1,9 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=11

View file

@ -1,4 +0,0 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

View file

@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -1,34 +0,0 @@
apply plugin: 'java'
apply plugin: 'kotlin'
configurations {
tool
}
dependencies {
tool 'javax.xml.bind:jaxb-api:2.3.0'
tool 'com.beanit:asn1bean-compiler:1.13.0'
implementation 'com.beanit:asn1bean:1.13.0'
implementation 'com.google.code.gson:gson:2.8.4'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-all:1.10.19'
testImplementation 'com.github.tomakehurst:wiremock:2.17.0'
}
sourceSets.main.java.srcDirs = ['src/generated/asn1','src/main/java']
task genAsn1(type: JavaExec) {
mainClass = 'com.beanit.asn1bean.compiler.Compiler'
args "-o", "$projectDir/src/generated/asn1", "-p", "com.truphone.rsp.dto.asn1", "-f", "$projectDir/src/main/resources/PKIXExplicit88.asn", "$projectDir/src/main/resources/PKIXImplicit88.asn", "$projectDir/src/main/resources/rsp.asn"
classpath configurations.tool
}
compileJava.dependsOn genAsn1
compileKotlin.dependsOn genAsn1
description = 'LPAd SM-DP+ Connector'
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

View file

@ -1,170 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>lpad-sm-dp-plus-parent</artifactId>
<groupId>com.truphone.lpad</groupId>
<version>1.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lpad-sm-dp-plus-connector</artifactId>
<name>LPAd SM-DP+ Connector</name>
<dependencies>
<dependency>
<groupId>org.openmuc</groupId>
<artifactId>jasn1-compiler</artifactId>
</dependency>
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>${java.version}</compilerVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<mainClass>org.openmuc.jasn1.compiler.Compiler</mainClass>
<arguments>
<argument>-o</argument>
<argument>${project.basedir}/target/generated-sources/asn1/</argument>
<argument>-p</argument>
<argument>com.truphone.rsp.dto.asn1</argument>
<argument>-f</argument>
<argument>${project.basedir}/src/main/resources/PKIXExplicit88.asn</argument>
<argument>${project.basedir}/src/main/resources/PKIXImplicit88.asn</argument>
<argument>${project.basedir}/src/main/resources/rsp.asn</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.basedir}/target/generated-sources/asn1/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.truphone.lpa.ProfileAssistant</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<configuration>
<archive>
<manifest>
<mainClass>com.truphone.lpa.ProfileAssistant</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -1,153 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class AdministrationDomainName implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 2);
private BerNumericString numeric = null;
private BerPrintableString printable = null;
public AdministrationDomainName() {
}
public AdministrationDomainName(byte[] code) {
this.code = code;
}
public void setNumeric(BerNumericString numeric) {
this.numeric = numeric;
}
public BerNumericString getNumeric() {
return numeric;
}
public void setPrintable(BerPrintableString printable) {
this.printable = printable;
}
public BerPrintableString getPrintable() {
return printable;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
if (printable != null) {
codeLength += printable.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
if (numeric != null) {
codeLength += numeric.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlvByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlvByteCount += tag.decodeAndCheck(is);
}
BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
tlvByteCount += berTag.decode(is);
if (berTag.equals(BerNumericString.tag)) {
numeric = new BerNumericString();
tlvByteCount += numeric.decode(is, false);
tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
}
if (berTag.equals(BerPrintableString.tag)) {
printable = new BerPrintableString();
tlvByteCount += printable.decode(is, false);
tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
}
throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item.");
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
if (numeric != null) {
sb.append("numeric: ").append(numeric);
return;
}
if (printable != null) {
sb.append("printable: ").append(printable);
return;
}
sb.append("<none>");
}
}

View file

@ -1,184 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class AlgorithmIdentifier implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private BerObjectIdentifier algorithm = null;
private BerAny parameters = null;
public AlgorithmIdentifier() {
}
public AlgorithmIdentifier(byte[] code) {
this.code = code;
}
public void setAlgorithm(BerObjectIdentifier algorithm) {
this.algorithm = algorithm;
}
public BerObjectIdentifier getAlgorithm() {
return algorithm;
}
public void setParameters(BerAny parameters) {
this.parameters = parameters;
}
public BerAny getParameters() {
return parameters;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
if (parameters != null) {
codeLength += parameters.encode(reverseOS);
}
codeLength += algorithm.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
if (berTag.equals(BerObjectIdentifier.tag)) {
algorithm = new BerObjectIdentifier();
vByteCount += algorithm.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
parameters = new BerAny();
numDecodedBytes = parameters.decode(is, berTag);
if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
else {
parameters = null;
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException("Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{");
sb.append("\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (algorithm != null) {
sb.append("algorithm: ").append(algorithm);
}
else {
sb.append("algorithm: <empty-required-field>");
}
if (parameters != null) {
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("parameters: ").append(parameters);
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,317 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class Attribute implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static class Values implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 17);
private byte[] code = null;
private List<AttributeValue> seqOf = null;
public Values() {
seqOf = new ArrayList<>();
}
public Values(byte[] code) {
this.code = code;
}
public List<AttributeValue> getAttributeValue() {
if (seqOf == null) {
seqOf = new ArrayList<>();
}
return seqOf;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
for (int i = (seqOf.size() - 1); i >= 0; i--) {
codeLength += seqOf.get(i).encode(reverseOS);
}
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
AttributeValue element = new AttributeValue();
numDecodedBytes = element.decode(is, berTag);
if (numDecodedBytes == 0) {
throw new IOException("Tag did not match");
}
vByteCount += numDecodedBytes;
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + lengthVal + " but has " + vByteCount);
}
return tlByteCount + vByteCount;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (seqOf == null) {
sb.append("null");
}
else {
Iterator<AttributeValue> it = seqOf.iterator();
if (it.hasNext()) {
sb.append(it.next());
while (it.hasNext()) {
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append(it.next());
}
}
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private AttributeType type = null;
private Values values = null;
public Attribute() {
}
public Attribute(byte[] code) {
this.code = code;
}
public void setType(AttributeType type) {
this.type = type;
}
public AttributeType getType() {
return type;
}
public void setValues(Values values) {
this.values = values;
}
public Values getValues() {
return values;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
codeLength += values.encode(reverseOS, true);
codeLength += type.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
if (berTag.equals(AttributeType.tag)) {
type = new AttributeType();
vByteCount += type.decode(is, false);
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(Values.tag)) {
values = new Values();
vByteCount += values.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException("Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{");
sb.append("\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (type != null) {
sb.append("type: ").append(type);
}
else {
sb.append("type: <empty-required-field>");
}
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (values != null) {
sb.append("values: ");
values.appendAsString(sb, indentLevel + 1);
}
else {
sb.append("values: <empty-required-field>");
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,38 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class AttributeType extends BerObjectIdentifier {
private static final long serialVersionUID = 1L;
public AttributeType() {
}
public AttributeType(byte[] code) {
super(code);
}
public AttributeType(int[] value) {
super(value);
}
}

View file

@ -1,182 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class AttributeTypeAndValue implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private AttributeType type = null;
private AttributeValue value = null;
public AttributeTypeAndValue() {
}
public AttributeTypeAndValue(byte[] code) {
this.code = code;
}
public void setType(AttributeType type) {
this.type = type;
}
public AttributeType getType() {
return type;
}
public void setValue(AttributeValue value) {
this.value = value;
}
public AttributeValue getValue() {
return value;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
codeLength += value.encode(reverseOS);
codeLength += type.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
int numDecodedBytes;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
if (berTag.equals(AttributeType.tag)) {
type = new AttributeType();
vByteCount += type.decode(is, false);
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
value = new AttributeValue();
numDecodedBytes = value.decode(is, berTag);
if (numDecodedBytes != 0) {
vByteCount += numDecodedBytes;
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException("Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{");
sb.append("\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (type != null) {
sb.append("type: ").append(type);
}
else {
sb.append("type: <empty-required-field>");
}
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (value != null) {
sb.append("value: ").append(value);
}
else {
sb.append("value: <empty-required-field>");
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,34 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class AttributeValue extends BerAny {
private static final long serialVersionUID = 1L;
public AttributeValue() {
}
public AttributeValue(byte[] value) {
super(value);
}
}

View file

@ -1,181 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class BuiltInDomainDefinedAttribute implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private BerPrintableString type = null;
private BerPrintableString value = null;
public BuiltInDomainDefinedAttribute() {
}
public BuiltInDomainDefinedAttribute(byte[] code) {
this.code = code;
}
public void setType(BerPrintableString type) {
this.type = type;
}
public BerPrintableString getType() {
return type;
}
public void setValue(BerPrintableString value) {
this.value = value;
}
public BerPrintableString getValue() {
return value;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
codeLength += value.encode(reverseOS, true);
codeLength += type.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
if (berTag.equals(BerPrintableString.tag)) {
type = new BerPrintableString();
vByteCount += type.decode(is, false);
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(BerPrintableString.tag)) {
value = new BerPrintableString();
vByteCount += value.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException("Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{");
sb.append("\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (type != null) {
sb.append("type: ").append(type);
}
else {
sb.append("type: <empty-required-field>");
}
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (value != null) {
sb.append("value: ").append(value);
}
else {
sb.append("value: <empty-required-field>");
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,155 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class BuiltInDomainDefinedAttributes implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private List<BuiltInDomainDefinedAttribute> seqOf = null;
public BuiltInDomainDefinedAttributes() {
seqOf = new ArrayList<>();
}
public BuiltInDomainDefinedAttributes(byte[] code) {
this.code = code;
}
public List<BuiltInDomainDefinedAttribute> getBuiltInDomainDefinedAttribute() {
if (seqOf == null) {
seqOf = new ArrayList<>();
}
return seqOf;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
for (int i = (seqOf.size() - 1); i >= 0; i--) {
codeLength += seqOf.get(i).encode(reverseOS, true);
}
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(BuiltInDomainDefinedAttribute.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
BuiltInDomainDefinedAttribute element = new BuiltInDomainDefinedAttribute();
vByteCount += element.decode(is, false);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + lengthVal + " but has " + vByteCount);
}
return tlByteCount + vByteCount;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (seqOf == null) {
sb.append("null");
}
else {
Iterator<BuiltInDomainDefinedAttribute> it = seqOf.iterator();
if (it.hasNext()) {
it.next().appendAsString(sb, indentLevel + 1);
while (it.hasNext()) {
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
it.next().appendAsString(sb, indentLevel + 1);
}
}
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,446 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class BuiltInStandardAttributes implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private CountryName countryName = null;
private AdministrationDomainName administrationDomainName = null;
private NetworkAddress networkAddress = null;
private TerminalIdentifier terminalIdentifier = null;
private PrivateDomainName privateDomainName = null;
private OrganizationName organizationName = null;
private NumericUserIdentifier numericUserIdentifier = null;
private PersonalName personalName = null;
private OrganizationalUnitNames organizationalUnitNames = null;
public BuiltInStandardAttributes() {
}
public BuiltInStandardAttributes(byte[] code) {
this.code = code;
}
public void setCountryName(CountryName countryName) {
this.countryName = countryName;
}
public CountryName getCountryName() {
return countryName;
}
public void setAdministrationDomainName(AdministrationDomainName administrationDomainName) {
this.administrationDomainName = administrationDomainName;
}
public AdministrationDomainName getAdministrationDomainName() {
return administrationDomainName;
}
public void setNetworkAddress(NetworkAddress networkAddress) {
this.networkAddress = networkAddress;
}
public NetworkAddress getNetworkAddress() {
return networkAddress;
}
public void setTerminalIdentifier(TerminalIdentifier terminalIdentifier) {
this.terminalIdentifier = terminalIdentifier;
}
public TerminalIdentifier getTerminalIdentifier() {
return terminalIdentifier;
}
public void setPrivateDomainName(PrivateDomainName privateDomainName) {
this.privateDomainName = privateDomainName;
}
public PrivateDomainName getPrivateDomainName() {
return privateDomainName;
}
public void setOrganizationName(OrganizationName organizationName) {
this.organizationName = organizationName;
}
public OrganizationName getOrganizationName() {
return organizationName;
}
public void setNumericUserIdentifier(NumericUserIdentifier numericUserIdentifier) {
this.numericUserIdentifier = numericUserIdentifier;
}
public NumericUserIdentifier getNumericUserIdentifier() {
return numericUserIdentifier;
}
public void setPersonalName(PersonalName personalName) {
this.personalName = personalName;
}
public PersonalName getPersonalName() {
return personalName;
}
public void setOrganizationalUnitNames(OrganizationalUnitNames organizationalUnitNames) {
this.organizationalUnitNames = organizationalUnitNames;
}
public OrganizationalUnitNames getOrganizationalUnitNames() {
return organizationalUnitNames;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
int sublength;
if (organizationalUnitNames != null) {
codeLength += organizationalUnitNames.encode(reverseOS, false);
// write tag: CONTEXT_CLASS, CONSTRUCTED, 6
reverseOS.write(0xA6);
codeLength += 1;
}
if (personalName != null) {
codeLength += personalName.encode(reverseOS, false);
// write tag: CONTEXT_CLASS, CONSTRUCTED, 5
reverseOS.write(0xA5);
codeLength += 1;
}
if (numericUserIdentifier != null) {
codeLength += numericUserIdentifier.encode(reverseOS, false);
// write tag: CONTEXT_CLASS, PRIMITIVE, 4
reverseOS.write(0x84);
codeLength += 1;
}
if (organizationName != null) {
codeLength += organizationName.encode(reverseOS, false);
// write tag: CONTEXT_CLASS, PRIMITIVE, 3
reverseOS.write(0x83);
codeLength += 1;
}
if (privateDomainName != null) {
sublength = privateDomainName.encode(reverseOS);
codeLength += sublength;
codeLength += BerLength.encodeLength(reverseOS, sublength);
// write tag: CONTEXT_CLASS, CONSTRUCTED, 2
reverseOS.write(0xA2);
codeLength += 1;
}
if (terminalIdentifier != null) {
codeLength += terminalIdentifier.encode(reverseOS, false);
// write tag: CONTEXT_CLASS, PRIMITIVE, 1
reverseOS.write(0x81);
codeLength += 1;
}
if (networkAddress != null) {
codeLength += networkAddress.encode(reverseOS, false);
// write tag: CONTEXT_CLASS, PRIMITIVE, 0
reverseOS.write(0x80);
codeLength += 1;
}
if (administrationDomainName != null) {
codeLength += administrationDomainName.encode(reverseOS, true);
}
if (countryName != null) {
codeLength += countryName.encode(reverseOS, true);
}
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
if (lengthVal == 0) {
return tlByteCount;
}
vByteCount += berTag.decode(is);
if (berTag.equals(CountryName.tag)) {
countryName = new CountryName();
vByteCount += countryName.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (berTag.equals(AdministrationDomainName.tag)) {
administrationDomainName = new AdministrationDomainName();
vByteCount += administrationDomainName.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
networkAddress = new NetworkAddress();
vByteCount += networkAddress.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
terminalIdentifier = new TerminalIdentifier();
vByteCount += terminalIdentifier.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) {
vByteCount += length.decode(is);
privateDomainName = new PrivateDomainName();
vByteCount += privateDomainName.decode(is, null);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 3)) {
organizationName = new OrganizationName();
vByteCount += organizationName.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 4)) {
numericUserIdentifier = new NumericUserIdentifier();
vByteCount += numericUserIdentifier.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
personalName = new PersonalName();
vByteCount += personalName.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 6)) {
organizationalUnitNames = new OrganizationalUnitNames();
vByteCount += organizationalUnitNames.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException("Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{");
boolean firstSelectedElement = true;
if (countryName != null) {
sb.append("\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("countryName: ");
countryName.appendAsString(sb, indentLevel + 1);
firstSelectedElement = false;
}
if (administrationDomainName != null) {
if (!firstSelectedElement) {
sb.append(",\n");
}
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("administrationDomainName: ");
administrationDomainName.appendAsString(sb, indentLevel + 1);
firstSelectedElement = false;
}
if (networkAddress != null) {
if (!firstSelectedElement) {
sb.append(",\n");
}
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("networkAddress: ").append(networkAddress);
firstSelectedElement = false;
}
if (terminalIdentifier != null) {
if (!firstSelectedElement) {
sb.append(",\n");
}
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("terminalIdentifier: ").append(terminalIdentifier);
firstSelectedElement = false;
}
if (privateDomainName != null) {
if (!firstSelectedElement) {
sb.append(",\n");
}
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("privateDomainName: ");
privateDomainName.appendAsString(sb, indentLevel + 1);
firstSelectedElement = false;
}
if (organizationName != null) {
if (!firstSelectedElement) {
sb.append(",\n");
}
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("organizationName: ").append(organizationName);
firstSelectedElement = false;
}
if (numericUserIdentifier != null) {
if (!firstSelectedElement) {
sb.append(",\n");
}
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("numericUserIdentifier: ").append(numericUserIdentifier);
firstSelectedElement = false;
}
if (personalName != null) {
if (!firstSelectedElement) {
sb.append(",\n");
}
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("personalName: ");
personalName.appendAsString(sb, indentLevel + 1);
firstSelectedElement = false;
}
if (organizationalUnitNames != null) {
if (!firstSelectedElement) {
sb.append(",\n");
}
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("organizationalUnitNames: ");
organizationalUnitNames.appendAsString(sb, indentLevel + 1);
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,214 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class Certificate implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private TBSCertificate tbsCertificate = null;
private AlgorithmIdentifier signatureAlgorithm = null;
private BerBitString signature = null;
public Certificate() {
}
public Certificate(byte[] code) {
this.code = code;
}
public void setTbsCertificate(TBSCertificate tbsCertificate) {
this.tbsCertificate = tbsCertificate;
}
public TBSCertificate getTbsCertificate() {
return tbsCertificate;
}
public void setSignatureAlgorithm(AlgorithmIdentifier signatureAlgorithm) {
this.signatureAlgorithm = signatureAlgorithm;
}
public AlgorithmIdentifier getSignatureAlgorithm() {
return signatureAlgorithm;
}
public void setSignature(BerBitString signature) {
this.signature = signature;
}
public BerBitString getSignature() {
return signature;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
codeLength += signature.encode(reverseOS, true);
codeLength += signatureAlgorithm.encode(reverseOS, true);
codeLength += tbsCertificate.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
if (berTag.equals(TBSCertificate.tag)) {
tbsCertificate = new TBSCertificate();
vByteCount += tbsCertificate.decode(is, false);
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(AlgorithmIdentifier.tag)) {
signatureAlgorithm = new AlgorithmIdentifier();
vByteCount += signatureAlgorithm.decode(is, false);
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(BerBitString.tag)) {
signature = new BerBitString();
vByteCount += signature.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException("Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{");
sb.append("\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (tbsCertificate != null) {
sb.append("tbsCertificate: ");
tbsCertificate.appendAsString(sb, indentLevel + 1);
}
else {
sb.append("tbsCertificate: <empty-required-field>");
}
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (signatureAlgorithm != null) {
sb.append("signatureAlgorithm: ");
signatureAlgorithm.appendAsString(sb, indentLevel + 1);
}
else {
sb.append("signatureAlgorithm: <empty-required-field>");
}
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (signature != null) {
sb.append("signature: ").append(signature);
}
else {
sb.append("signature: <empty-required-field>");
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,214 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class CertificateList implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private TBSCertList tbsCertList = null;
private AlgorithmIdentifier signatureAlgorithm = null;
private BerBitString signature = null;
public CertificateList() {
}
public CertificateList(byte[] code) {
this.code = code;
}
public void setTbsCertList(TBSCertList tbsCertList) {
this.tbsCertList = tbsCertList;
}
public TBSCertList getTbsCertList() {
return tbsCertList;
}
public void setSignatureAlgorithm(AlgorithmIdentifier signatureAlgorithm) {
this.signatureAlgorithm = signatureAlgorithm;
}
public AlgorithmIdentifier getSignatureAlgorithm() {
return signatureAlgorithm;
}
public void setSignature(BerBitString signature) {
this.signature = signature;
}
public BerBitString getSignature() {
return signature;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
codeLength += signature.encode(reverseOS, true);
codeLength += signatureAlgorithm.encode(reverseOS, true);
codeLength += tbsCertList.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
if (berTag.equals(TBSCertList.tag)) {
tbsCertList = new TBSCertList();
vByteCount += tbsCertList.decode(is, false);
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(AlgorithmIdentifier.tag)) {
signatureAlgorithm = new AlgorithmIdentifier();
vByteCount += signatureAlgorithm.decode(is, false);
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(BerBitString.tag)) {
signature = new BerBitString();
vByteCount += signature.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException("Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{");
sb.append("\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (tbsCertList != null) {
sb.append("tbsCertList: ");
tbsCertList.appendAsString(sb, indentLevel + 1);
}
else {
sb.append("tbsCertList: <empty-required-field>");
}
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (signatureAlgorithm != null) {
sb.append("signatureAlgorithm: ");
signatureAlgorithm.appendAsString(sb, indentLevel + 1);
}
else {
sb.append("signatureAlgorithm: <empty-required-field>");
}
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (signature != null) {
sb.append("signature: ").append(signature);
}
else {
sb.append("signature: <empty-required-field>");
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,42 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class CertificateSerialNumber extends BerInteger {
private static final long serialVersionUID = 1L;
public CertificateSerialNumber() {
}
public CertificateSerialNumber(byte[] code) {
super(code);
}
public CertificateSerialNumber(BigInteger value) {
super(value);
}
public CertificateSerialNumber(long value) {
super(value);
}
}

View file

@ -1,34 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class CommonName extends BerPrintableString {
private static final long serialVersionUID = 1L;
public CommonName() {
}
public CommonName(byte[] value) {
super(value);
}
}

View file

@ -1,153 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class CountryName implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public static final BerTag tag = new BerTag(BerTag.APPLICATION_CLASS, BerTag.CONSTRUCTED, 1);
private BerNumericString x121DccCode = null;
private BerPrintableString iso3166Alpha2Code = null;
public CountryName() {
}
public CountryName(byte[] code) {
this.code = code;
}
public void setX121DccCode(BerNumericString x121DccCode) {
this.x121DccCode = x121DccCode;
}
public BerNumericString getX121DccCode() {
return x121DccCode;
}
public void setIso3166Alpha2Code(BerPrintableString iso3166Alpha2Code) {
this.iso3166Alpha2Code = iso3166Alpha2Code;
}
public BerPrintableString getIso3166Alpha2Code() {
return iso3166Alpha2Code;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
if (iso3166Alpha2Code != null) {
codeLength += iso3166Alpha2Code.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
if (x121DccCode != null) {
codeLength += x121DccCode.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlvByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlvByteCount += tag.decodeAndCheck(is);
}
BerLength explicitTagLength = new BerLength();
tlvByteCount += explicitTagLength.decode(is);
tlvByteCount += berTag.decode(is);
if (berTag.equals(BerNumericString.tag)) {
x121DccCode = new BerNumericString();
tlvByteCount += x121DccCode.decode(is, false);
tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
}
if (berTag.equals(BerPrintableString.tag)) {
iso3166Alpha2Code = new BerPrintableString();
tlvByteCount += iso3166Alpha2Code.decode(is, false);
tlvByteCount += explicitTagLength.readEocIfIndefinite(is);
return tlvByteCount;
}
throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item.");
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
if (x121DccCode != null) {
sb.append("x121DccCode: ").append(x121DccCode);
return;
}
if (iso3166Alpha2Code != null) {
sb.append("iso3166Alpha2Code: ").append(iso3166Alpha2Code);
return;
}
sb.append("<none>");
}
}

View file

@ -1,211 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class DirectoryString implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
private BerTeletexString teletexString = null;
private BerPrintableString printableString = null;
private BerUniversalString universalString = null;
private BerUTF8String utf8String = null;
private BerBMPString bmpString = null;
public DirectoryString() {
}
public DirectoryString(byte[] code) {
this.code = code;
}
public void setTeletexString(BerTeletexString teletexString) {
this.teletexString = teletexString;
}
public BerTeletexString getTeletexString() {
return teletexString;
}
public void setPrintableString(BerPrintableString printableString) {
this.printableString = printableString;
}
public BerPrintableString getPrintableString() {
return printableString;
}
public void setUniversalString(BerUniversalString universalString) {
this.universalString = universalString;
}
public BerUniversalString getUniversalString() {
return universalString;
}
public void setUtf8String(BerUTF8String utf8String) {
this.utf8String = utf8String;
}
public BerUTF8String getUtf8String() {
return utf8String;
}
public void setBmpString(BerBMPString bmpString) {
this.bmpString = bmpString;
}
public BerBMPString getBmpString() {
return bmpString;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
return code.length;
}
int codeLength = 0;
if (bmpString != null) {
codeLength += bmpString.encode(reverseOS, true);
return codeLength;
}
if (utf8String != null) {
codeLength += utf8String.encode(reverseOS, true);
return codeLength;
}
if (universalString != null) {
codeLength += universalString.encode(reverseOS, true);
return codeLength;
}
if (printableString != null) {
codeLength += printableString.encode(reverseOS, true);
return codeLength;
}
if (teletexString != null) {
codeLength += teletexString.encode(reverseOS, true);
return codeLength;
}
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
}
if (berTag.equals(BerTeletexString.tag)) {
teletexString = new BerTeletexString();
tlvByteCount += teletexString.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerPrintableString.tag)) {
printableString = new BerPrintableString();
tlvByteCount += printableString.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerUniversalString.tag)) {
universalString = new BerUniversalString();
tlvByteCount += universalString.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerUTF8String.tag)) {
utf8String = new BerUTF8String();
tlvByteCount += utf8String.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerBMPString.tag)) {
bmpString = new BerBMPString();
tlvByteCount += bmpString.decode(is, false);
return tlvByteCount;
}
if (tagWasPassed) {
return 0;
}
throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item.");
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
if (teletexString != null) {
sb.append("teletexString: ").append(teletexString);
return;
}
if (printableString != null) {
sb.append("printableString: ").append(printableString);
return;
}
if (universalString != null) {
sb.append("universalString: ").append(universalString);
return;
}
if (utf8String != null) {
sb.append("utf8String: ").append(utf8String);
return;
}
if (bmpString != null) {
sb.append("bmpString: ").append(bmpString);
return;
}
sb.append("<none>");
}
}

View file

@ -1,34 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class DistinguishedName extends RDNSequence {
private static final long serialVersionUID = 1L;
public DistinguishedName() {
}
public DistinguishedName(byte[] code) {
super(code);
}
}

View file

@ -1,34 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class DomainComponent extends BerIA5String {
private static final long serialVersionUID = 1L;
public DomainComponent() {
}
public DomainComponent(byte[] value) {
super(value);
}
}

View file

@ -1,34 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class EmailAddress extends BerIA5String {
private static final long serialVersionUID = 1L;
public EmailAddress() {
}
public EmailAddress(byte[] value) {
super(value);
}
}

View file

@ -1,305 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class ExtendedNetworkAddress implements BerType, Serializable {
private static final long serialVersionUID = 1L;
private byte[] code = null;
public static class E1634Address implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private BerNumericString number = null;
private BerNumericString subAddress = null;
public E1634Address() {
}
public E1634Address(byte[] code) {
this.code = code;
}
public void setNumber(BerNumericString number) {
this.number = number;
}
public BerNumericString getNumber() {
return number;
}
public void setSubAddress(BerNumericString subAddress) {
this.subAddress = subAddress;
}
public BerNumericString getSubAddress() {
return subAddress;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
if (subAddress != null) {
codeLength += subAddress.encode(reverseOS, false);
// write tag: CONTEXT_CLASS, PRIMITIVE, 1
reverseOS.write(0x81);
codeLength += 1;
}
codeLength += number.encode(reverseOS, false);
// write tag: CONTEXT_CLASS, PRIMITIVE, 0
reverseOS.write(0x80);
codeLength += 1;
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
number = new BerNumericString();
vByteCount += number.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
subAddress = new BerNumericString();
vByteCount += subAddress.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException("Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{");
sb.append("\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (number != null) {
sb.append("number: ").append(number);
}
else {
sb.append("number: <empty-required-field>");
}
if (subAddress != null) {
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("subAddress: ").append(subAddress);
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}
private E1634Address e1634Address = null;
private PresentationAddress psapAddress = null;
public ExtendedNetworkAddress() {
}
public ExtendedNetworkAddress(byte[] code) {
this.code = code;
}
public void setE1634Address(E1634Address e1634Address) {
this.e1634Address = e1634Address;
}
public E1634Address getE1634Address() {
return e1634Address;
}
public void setPsapAddress(PresentationAddress psapAddress) {
this.psapAddress = psapAddress;
}
public PresentationAddress getPsapAddress() {
return psapAddress;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
if (code != null) {
reverseOS.write(code);
return code.length;
}
int codeLength = 0;
if (psapAddress != null) {
codeLength += psapAddress.encode(reverseOS, false);
// write tag: CONTEXT_CLASS, CONSTRUCTED, 0
reverseOS.write(0xA0);
codeLength += 1;
return codeLength;
}
if (e1634Address != null) {
codeLength += e1634Address.encode(reverseOS, true);
return codeLength;
}
throw new IOException("Error encoding CHOICE: No element of CHOICE was selected.");
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, null);
}
public int decode(InputStream is, BerTag berTag) throws IOException {
int tlvByteCount = 0;
boolean tagWasPassed = (berTag != null);
if (berTag == null) {
berTag = new BerTag();
tlvByteCount += berTag.decode(is);
}
if (berTag.equals(E1634Address.tag)) {
e1634Address = new E1634Address();
tlvByteCount += e1634Address.decode(is, false);
return tlvByteCount;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
psapAddress = new PresentationAddress();
tlvByteCount += psapAddress.decode(is, false);
return tlvByteCount;
}
if (tagWasPassed) {
return 0;
}
throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item.");
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
if (e1634Address != null) {
sb.append("e1634Address: ");
e1634Address.appendAsString(sb, indentLevel + 1);
return;
}
if (psapAddress != null) {
sb.append("psapAddress: ");
psapAddress.appendAsString(sb, indentLevel + 1);
return;
}
sb.append("<none>");
}
}

View file

@ -1,208 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class Extension implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private BerObjectIdentifier extnID = null;
private BerBoolean critical = null;
private BerOctetString extnValue = null;
public Extension() {
}
public Extension(byte[] code) {
this.code = code;
}
public void setExtnID(BerObjectIdentifier extnID) {
this.extnID = extnID;
}
public BerObjectIdentifier getExtnID() {
return extnID;
}
public void setCritical(BerBoolean critical) {
this.critical = critical;
}
public BerBoolean getCritical() {
return critical;
}
public void setExtnValue(BerOctetString extnValue) {
this.extnValue = extnValue;
}
public BerOctetString getExtnValue() {
return extnValue;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
codeLength += extnValue.encode(reverseOS, true);
if (critical != null) {
codeLength += critical.encode(reverseOS, true);
}
codeLength += extnID.encode(reverseOS, true);
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
if (berTag.equals(BerObjectIdentifier.tag)) {
extnID = new BerObjectIdentifier();
vByteCount += extnID.decode(is, false);
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(BerBoolean.tag)) {
critical = new BerBoolean();
vByteCount += critical.decode(is, false);
vByteCount += berTag.decode(is);
}
if (berTag.equals(BerOctetString.tag)) {
extnValue = new BerOctetString();
vByteCount += extnValue.decode(is, false);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException("Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{");
sb.append("\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (extnID != null) {
sb.append("extnID: ").append(extnID);
}
else {
sb.append("extnID: <empty-required-field>");
}
if (critical != null) {
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
sb.append("critical: ").append(critical);
}
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (extnValue != null) {
sb.append("extnValue: ").append(extnValue);
}
else {
sb.append("extnValue: <empty-required-field>");
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,193 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class ExtensionAttribute implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private BerInteger extensionAttributeType = null;
private BerAny extensionAttributeValue = null;
public ExtensionAttribute() {
}
public ExtensionAttribute(byte[] code) {
this.code = code;
}
public void setExtensionAttributeType(BerInteger extensionAttributeType) {
this.extensionAttributeType = extensionAttributeType;
}
public BerInteger getExtensionAttributeType() {
return extensionAttributeType;
}
public void setExtensionAttributeValue(BerAny extensionAttributeValue) {
this.extensionAttributeValue = extensionAttributeValue;
}
public BerAny getExtensionAttributeValue() {
return extensionAttributeValue;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
int sublength;
sublength = extensionAttributeValue.encode(reverseOS);
codeLength += sublength;
codeLength += BerLength.encodeLength(reverseOS, sublength);
// write tag: CONTEXT_CLASS, CONSTRUCTED, 1
reverseOS.write(0xA1);
codeLength += 1;
codeLength += extensionAttributeType.encode(reverseOS, false);
// write tag: CONTEXT_CLASS, PRIMITIVE, 0
reverseOS.write(0x80);
codeLength += 1;
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
vByteCount += berTag.decode(is);
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) {
extensionAttributeType = new BerInteger();
vByteCount += extensionAttributeType.decode(is, false);
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 1)) {
vByteCount += length.decode(is);
extensionAttributeValue = new BerAny();
vByteCount += extensionAttributeValue.decode(is, null);
vByteCount += length.readEocIfIndefinite(is);
if (lengthVal >= 0 && vByteCount == lengthVal) {
return tlByteCount + vByteCount;
}
vByteCount += berTag.decode(is);
}
else {
throw new IOException("Tag does not match mandatory sequence component.");
}
if (lengthVal < 0) {
if (!berTag.equals(0, 0, 0)) {
throw new IOException("Decoded sequence has wrong end of contents octets");
}
vByteCount += BerLength.readEocByte(is);
return tlByteCount + vByteCount;
}
throw new IOException("Unexpected end of sequence, length tag: " + lengthVal + ", bytes decoded: " + vByteCount);
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{");
sb.append("\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (extensionAttributeType != null) {
sb.append("extensionAttributeType: ").append(extensionAttributeType);
}
else {
sb.append("extensionAttributeType: <empty-required-field>");
}
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (extensionAttributeValue != null) {
sb.append("extensionAttributeValue: ").append(extensionAttributeValue);
}
else {
sb.append("extensionAttributeValue: <empty-required-field>");
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,155 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class ExtensionAttributes implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 17);
private byte[] code = null;
private List<ExtensionAttribute> seqOf = null;
public ExtensionAttributes() {
seqOf = new ArrayList<>();
}
public ExtensionAttributes(byte[] code) {
this.code = code;
}
public List<ExtensionAttribute> getExtensionAttribute() {
if (seqOf == null) {
seqOf = new ArrayList<>();
}
return seqOf;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
for (int i = (seqOf.size() - 1); i >= 0; i--) {
codeLength += seqOf.get(i).encode(reverseOS, true);
}
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(ExtensionAttribute.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
ExtensionAttribute element = new ExtensionAttribute();
vByteCount += element.decode(is, false);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + lengthVal + " but has " + vByteCount);
}
return tlByteCount + vByteCount;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (seqOf == null) {
sb.append("null");
}
else {
Iterator<ExtensionAttribute> it = seqOf.iterator();
if (it.hasNext()) {
it.next().appendAsString(sb, indentLevel + 1);
while (it.hasNext()) {
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
it.next().appendAsString(sb, indentLevel + 1);
}
}
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,34 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class ExtensionORAddressComponents extends PDSParameter {
private static final long serialVersionUID = 1L;
public ExtensionORAddressComponents() {
}
public ExtensionORAddressComponents(byte[] code) {
super(code);
}
}

View file

@ -1,34 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class ExtensionPhysicalDeliveryAddressComponents extends PDSParameter {
private static final long serialVersionUID = 1L;
public ExtensionPhysicalDeliveryAddressComponents() {
}
public ExtensionPhysicalDeliveryAddressComponents(byte[] code) {
super(code);
}
}

View file

@ -1,155 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class Extensions implements BerType, Serializable {
private static final long serialVersionUID = 1L;
public static final BerTag tag = new BerTag(BerTag.UNIVERSAL_CLASS, BerTag.CONSTRUCTED, 16);
private byte[] code = null;
private List<Extension> seqOf = null;
public Extensions() {
seqOf = new ArrayList<>();
}
public Extensions(byte[] code) {
this.code = code;
}
public List<Extension> getExtension() {
if (seqOf == null) {
seqOf = new ArrayList<>();
}
return seqOf;
}
@Override public int encode(OutputStream reverseOS) throws IOException {
return encode(reverseOS, true);
}
public int encode(OutputStream reverseOS, boolean withTag) throws IOException {
if (code != null) {
reverseOS.write(code);
if (withTag) {
return tag.encode(reverseOS) + code.length;
}
return code.length;
}
int codeLength = 0;
for (int i = (seqOf.size() - 1); i >= 0; i--) {
codeLength += seqOf.get(i).encode(reverseOS, true);
}
codeLength += BerLength.encodeLength(reverseOS, codeLength);
if (withTag) {
codeLength += tag.encode(reverseOS);
}
return codeLength;
}
@Override public int decode(InputStream is) throws IOException {
return decode(is, true);
}
public int decode(InputStream is, boolean withTag) throws IOException {
int tlByteCount = 0;
int vByteCount = 0;
BerTag berTag = new BerTag();
if (withTag) {
tlByteCount += tag.decodeAndCheck(is);
}
BerLength length = new BerLength();
tlByteCount += length.decode(is);
int lengthVal = length.val;
while (vByteCount < lengthVal || lengthVal < 0) {
vByteCount += berTag.decode(is);
if (lengthVal < 0 && berTag.equals(0, 0, 0)) {
vByteCount += BerLength.readEocByte(is);
break;
}
if (!berTag.equals(Extension.tag)) {
throw new IOException("Tag does not match mandatory sequence of/set of component.");
}
Extension element = new Extension();
vByteCount += element.decode(is, false);
seqOf.add(element);
}
if (lengthVal >= 0 && vByteCount != lengthVal) {
throw new IOException("Decoded SequenceOf or SetOf has wrong length. Expected " + lengthVal + " but has " + vByteCount);
}
return tlByteCount + vByteCount;
}
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
@Override public String toString() {
StringBuilder sb = new StringBuilder();
appendAsString(sb, 0);
return sb.toString();
}
public void appendAsString(StringBuilder sb, int indentLevel) {
sb.append("{\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
if (seqOf == null) {
sb.append("null");
}
else {
Iterator<Extension> it = seqOf.iterator();
if (it.hasNext()) {
it.next().appendAsString(sb, indentLevel + 1);
while (it.hasNext()) {
sb.append(",\n");
for (int i = 0; i < indentLevel + 1; i++) {
sb.append("\t");
}
it.next().appendAsString(sb, indentLevel + 1);
}
}
}
sb.append("\n");
for (int i = 0; i < indentLevel; i++) {
sb.append("\t");
}
sb.append("}");
}
}

View file

@ -1,34 +0,0 @@
/*
* This class file was automatically generated by ASN1bean v1.13.0 (http://www.beanit.com)
*/
package com.truphone.rsp.dto.asn1.pkix1explicit88;
import java.io.IOException;
import java.io.EOFException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.io.Serializable;
import com.beanit.asn1bean.ber.*;
import com.beanit.asn1bean.ber.types.*;
import com.beanit.asn1bean.ber.types.string.*;
public class LocalPostalAttributes extends PDSParameter {
private static final long serialVersionUID = 1L;
public LocalPostalAttributes() {
}
public LocalPostalAttributes(byte[] code) {
super(code);
}
}

Some files were not shown because too many files have changed in this diff Show more