From 3540b09623df0453704d0353bc5222e69ef0bf78 Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Tue, 22 Oct 2019 10:30:19 +0200 Subject: [PATCH] [APIv2/Vulcan] Temporary fix for signing requests --- .../edziennik/api/v2/vulcan/data/VulcanApi.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/VulcanApi.kt b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/VulcanApi.kt index de9574c4..b0c66a66 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/VulcanApi.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/api/v2/vulcan/data/VulcanApi.kt @@ -4,6 +4,7 @@ package pl.szczodrzynski.edziennik.api.v2.vulcan.data +import android.util.Base64 import com.google.gson.JsonObject import im.wangchao.mhttp.Request import im.wangchao.mhttp.Response @@ -16,6 +17,7 @@ import pl.szczodrzynski.edziennik.data.db.modules.teams.Team import pl.szczodrzynski.edziennik.utils.Utils import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.models.Date +import java.io.ByteArrayInputStream import java.net.HttpURLConnection import java.util.* @@ -52,7 +54,7 @@ open class VulcanApi(open val data: DataVulcan) { } } - val startDate = when(profile?.empty) { + val startDate = when (profile?.empty) { true -> profile?.getSemesterStart(profile?.currentSemester ?: 1)?.stringY_m_d else -> Date.getToday().stepForward(0, -1, 0).stringY_m_d } @@ -112,7 +114,9 @@ open class VulcanApi(open val data: DataVulcan) { .userAgent(VULCAN_API_USER_AGENT) .addHeader("RequestCertificateKey", data.apiCertificateKey) .addHeader("RequestSignatureValue", - signContent(VULCAN_API_PASSWORD, data.apiCertificatePfx, finalPayload.toString())) + Utils.VulcanRequestEncryptionUtils.signContent( + finalPayload.toString().toByteArray(), + ByteArrayInputStream(Base64.decode(data.apiCertificatePfx, Base64.DEFAULT)))) .apply { when (method) { GET -> get()