Skip to content

Commit

Permalink
fix: Plug&Charge nested Authorize idToken
Browse files Browse the repository at this point in the history
original author @tnn Troels Nørgaard
  • Loading branch information
BrianEstrada committed Sep 6, 2024
1 parent aeb7e63 commit cee4e7d
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 37 deletions.
17 changes: 16 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@ plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
id("org.jetbrains.kotlin.jvm") apply false
// Linter
id("org.jlleitschuh.gradle.ktlint") version "12.1.1" apply false
id("org.jlleitschuh.gradle.ktlint") version "12.1.1"
// Apply the java-library plugin for API and implementation separation.
`java-library`
}

allprojects {
repositories {
mavenLocal()
mavenCentral()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/monta-app/library-micronaut")
credentials {
username = System.getenv("GHL_USERNAME") ?: project.findProperty("gpr.user") as String?
password = System.getenv("GHL_PASSWORD") ?: project.findProperty("gpr.key") as String?
}
}
}
}
5 changes: 0 additions & 5 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ val libraryArtifactId = "core"
group = "$libraryGroupId:$libraryArtifactId"
version = libraryVersion

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
// Main
implementation(platform(kotlinlibs.platform))
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kotlinVersion=2.0.20
javaToolChainVersion=17
libraryVersion=1.0.2
libraryVersion=1.0.3
org.gradle.jvmargs=-Xmx4096m
org.gradle.warning.mode=all
17 changes: 2 additions & 15 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@ plugins {
version = "1.0.0"
group = "com.monta.ocpp"

repositories {
mavenLocal()
mavenCentral()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/monta-app/library-micronaut")
credentials {
username = System.getenv("GHL_USERNAME") ?: project.findProperty("gpr.user") as String?
password = System.getenv("GHL_PASSWORD") ?: project.findProperty("gpr.key") as String?
}
}
}

dependencies {

implementation(project(":core"))
Expand Down Expand Up @@ -54,13 +41,13 @@ dependencies {
implementation(jackson.bundles.implementation)

// Database Libraries
implementation(platform("org.jetbrains.exposed:exposed-bom:0.52.0"))
implementation(platform("org.jetbrains.exposed:exposed-bom:0.54.0"))
implementation("org.jetbrains.exposed:exposed-core")
implementation("org.jetbrains.exposed:exposed-dao")
implementation("org.jetbrains.exposed:exposed-jdbc")
implementation("org.jetbrains.exposed:exposed-java-time")
implementation("com.zaxxer:HikariCP:5.1.0")
runtimeOnly("com.h2database:h2:2.2.224")
runtimeOnly("com.h2database:h2:2.3.232")

// Logging
implementation("io.ktor:ktor-server-call-logging-jvm")
Expand Down
5 changes: 0 additions & 5 deletions v16/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ val libraryArtifactId = "v16"
group = "$libraryGroupId:$libraryArtifactId"
version = libraryVersion

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
// Internal Libs
implementation(project(":core"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ data class PncAuthorizeRequest(
// string[0..5500] Optional
// The X.509 certificated presented by EV and encoded in PEM format
val certificate: String?,
// identifierString[0..20] Required
// This contains the identifier that needs to be authorized
val idToken: String,
val idToken: IdToken,
// Optional
// Contains the information needed to verify the EV Contract Certificate via OCSP.
// A list of up to 4 certificates
Expand All @@ -35,6 +33,14 @@ data class PncAuthorizeRequest(
val evX509Cert: X509Certificate? by lazy {
CertificateUtil.stringToX509Cert(certificate)
}

data class IdToken(
// identifierString[0..20] Required
// This contains the identifier that needs to be authorized
val idToken: String,
// Optional, non-standard field from OCPP 2.0.1 (Kempower)
val type: String? = null
)
}

data class PncAuthorizeConfirmation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class PlugAndChargeExtensionServerProfileTest : StringSpec() {
data = messageSerializer.toPayloadString(
PncAuthorizeRequest(
certificate = acceptedVehicleCertificatePem(),
idToken = "eMAID Accept",
idToken = PncAuthorizeRequest.IdToken("DEICECMONTAQA5"),
iso15118CertificateHashData = listOf(ocspRequest())
)
)
Expand Down Expand Up @@ -263,7 +263,7 @@ class PlugAndChargeExtensionServerProfileTest : StringSpec() {
confOfdtRequest(
GetCertificateStatusConfirmation(
status = GetCertificateStatusConfirmation.Status.Accepted,
ocspResult = "base64 encoded raw OSCP"
ocspResult = "base64 encoded raw OCSP"
)
)
}.errorCode shouldBe MessageErrorCodeV16.FormationViolation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import com.monta.library.ocpp.common.serialization.SerializationMode
import com.monta.library.ocpp.v16.core.DataTransferConfirmation
import com.monta.library.ocpp.v16.core.DataTransferRequest
import com.monta.library.ocpp.v16.error.OcppErrorResponderV16
import com.monta.library.ocpp.v16.extension.plugandcharge.features.Get15118EVCertificateRequest
import com.monta.library.ocpp.v16.extension.plugandcharge.features.GetInstalledCertificateIdsConfirmation
import com.monta.library.ocpp.v16.extension.plugandcharge.features.GetInstalledCertificateIdsRequest
import com.monta.library.ocpp.v16.extension.plugandcharge.features.PncAuthorizeRequest
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.should
import io.kotest.matchers.shouldNotBe
Expand Down Expand Up @@ -64,4 +66,28 @@ class PlugAndChargeSerializationTest : StringSpec({
)
conf shouldNotBe null
}

"Authorize request should parse with extra type tag" {
val conf = dtReq(
"kempower-Authorize.req.json",
PncAuthorizeRequest::class.java
)
conf shouldNotBe null
}

"Kempower Get15118EVCertificate request should be deserialized" {
val conf = dtReq(
"kempower-Get15118EVCertificate.req.json",
Get15118EVCertificateRequest::class.java
)
conf shouldNotBe null
}

"Kempower GetInstalledCertificateIds response should be deserialized" {
val conf = dtConf(
"kempower-GetInstalledCertificateIds.conf.json",
GetInstalledCertificateIdsConfirmation::class.java
)
conf shouldNotBe null
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[2,"67fd6bcd-98ab-4c88-9d8f-86c7e18a13b5","DataTransfer",{"messageId":"Authorize","data":"{\"idToken\":{\"idToken\":\"DEICECMONTAQA5\",\"type\":\"eMAID\"},\"iso15118CertificateHashData\":[{\"hashAlgorithm\":\"SHA256\",\"issuerNameHash\":\"5D9AA3B240912700F8621901B1FD95C73E2BDBAA00CCE071ADE233CD74A21DDC\",\"issuerKeyHash\":\"41D1DE817DDFA5EDD6D2AC64F98C70D25EC7B3842034D73F5E76A06839D0866A\",\"serialNumber\":\"6CC631AEDA073E6DAA723FF22E2FECC7\",\"responderURL\":\"http://ocsp-qa.hubject.com:8080\"},{\"hashAlgorithm\":\"SHA256\",\"issuerNameHash\":\"115C803CDCB2CBA1CC7D1EB3B20B069586FBC7F74EDA930347358E304C40355D\",\"issuerKeyHash\":\"7A9194FEF27EC5E8D95D3A668DE2E7686F3E92B1ADD28818CA02AF7408C57269\",\"serialNumber\":\"5DDF42CD0CBCF95C6942DF48C0DACE11\",\"responderURL\":\"http://ocsp-qa.hubject.com:8080\"},{\"hashAlgorithm\":\"SHA256\",\"issuerNameHash\":\"F53488037C9A84BBEBCE74C3BB5D175A36B6A41FF9F12E41A1C50A2FB7303159\",\"issuerKeyHash\":\"811B8014E48BA314127C5A54E79F841166C82ACD3CE2EB190EF7E25922F986DE\",\"serialNumber\":\"20EBA4FBC7C06F25D08B3055A52239E7\",\"responderURL\":\"http://ocsp-qa.hubject.com:8080\"}]}","vendorId":"org.openchargealliance.iso15118pnc"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[2,"ca1f4d8f-0744-481e-8862-c1ef957c89d5","DataTransfer",{"messageId":"Get15118EVCertificate","data":"{\"action\":\"Install\",\"exiRequest\":\"gJgCPOUdVt2xWhMKiVodHRwOi8vd3d3LnczLm9yZy9UUi9jYW5vbmljYWwtZXhpL0NWh0dHA6Ly93d3cudzMub3JnLzIwMDE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dCBDQSBRQSBHMSxPPUh1YmplY3QgR21iSA7cuzmK3TlMDOhf3em8u0gKvTARAA=\",\"iso15118SchemaVersion\":\"urn:iso:15118:2:2013:MsgDef\"}","vendorId":"org.openchargealliance.iso15118pnc"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[3,"4ec35e1f-a4e9-42f4-93bf-cd2c62597c93",{"status":"Accepted","data":"{\"status\":\"Accepted\",\"certificateHashDataChain\":[{\"certificateType\":\"V2GCertificateChain\",\"certificateHashData\":{\"hashAlgorithm\":\"SHA256\",\"issuerKeyHash\":\"EB5637201C0080C6190376CF086A7D09D95A5BC941B67DC86A4CEEBA8BCF3C25\",\"issuerNameHash\":\"42A718F14103FABAFE0F34A16A1E05679465C84FEE470C15CE005F7896D3DC06\",\"serialNumber\":\"542D502CB1105602E387161AFE579036\"}}]}"}]
5 changes: 0 additions & 5 deletions v201/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ val libraryArtifactId = "v201"
group = "$libraryGroupId:$libraryArtifactId"
version = libraryVersion

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
// Internal Libs
implementation(project(":core"))
Expand Down

0 comments on commit cee4e7d

Please sign in to comment.