[APIv2/Vulcan] Temporary fix for signing requests

This commit is contained in:
Kacper Ziubryniewicz 2019-10-22 10:30:19 +02:00
parent 25744037f5
commit 3540b09623

View File

@ -4,6 +4,7 @@
package pl.szczodrzynski.edziennik.api.v2.vulcan.data package pl.szczodrzynski.edziennik.api.v2.vulcan.data
import android.util.Base64
import com.google.gson.JsonObject import com.google.gson.JsonObject
import im.wangchao.mhttp.Request import im.wangchao.mhttp.Request
import im.wangchao.mhttp.Response 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
import pl.szczodrzynski.edziennik.utils.Utils.d import pl.szczodrzynski.edziennik.utils.Utils.d
import pl.szczodrzynski.edziennik.utils.models.Date import pl.szczodrzynski.edziennik.utils.models.Date
import java.io.ByteArrayInputStream
import java.net.HttpURLConnection import java.net.HttpURLConnection
import java.util.* import java.util.*
@ -112,7 +114,9 @@ open class VulcanApi(open val data: DataVulcan) {
.userAgent(VULCAN_API_USER_AGENT) .userAgent(VULCAN_API_USER_AGENT)
.addHeader("RequestCertificateKey", data.apiCertificateKey) .addHeader("RequestCertificateKey", data.apiCertificateKey)
.addHeader("RequestSignatureValue", .addHeader("RequestSignatureValue",
signContent(VULCAN_API_PASSWORD, data.apiCertificatePfx, finalPayload.toString())) Utils.VulcanRequestEncryptionUtils.signContent(
finalPayload.toString().toByteArray(),
ByteArrayInputStream(Base64.decode(data.apiCertificatePfx, Base64.DEFAULT))))
.apply { .apply {
when (method) { when (method) {
GET -> get() GET -> get()