[jvm] Make commpatible with java 6
This commit is contained in:
parent
14383956b7
commit
331bf6a053
2 changed files with 7 additions and 6 deletions
|
@ -7,7 +7,7 @@ plugins {
|
|||
group 'io.github.wulkanowy'
|
||||
version '0.1.0-SNAPSHOT'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
sourceCompatibility = 1.6
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -15,14 +15,15 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
implementation "commons-codec:commons-codec:1.13"
|
||||
testImplementation "junit:junit:4.12"
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
kotlinOptions.jvmTarget = "1.6"
|
||||
}
|
||||
compileTestKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
kotlinOptions.jvmTarget = "1.6"
|
||||
}
|
||||
|
||||
jacocoTestReport {
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package io.github.wulkanowy.signer
|
||||
|
||||
import org.apache.commons.codec.binary.Base64
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.security.KeyStore
|
||||
import java.security.PrivateKey
|
||||
import java.security.Signature
|
||||
import java.util.*
|
||||
|
||||
fun signContent(password: String, certificate: String?, content: String): String {
|
||||
val keystore = KeyStore.getInstance("pkcs12").apply {
|
||||
load(ByteArrayInputStream(Base64.getDecoder().decode(certificate)), password.toCharArray())
|
||||
load(ByteArrayInputStream(Base64.decodeBase64(certificate)), password.toCharArray())
|
||||
}
|
||||
val signature = Signature.getInstance("SHA1WithRSA").apply {
|
||||
initSign(keystore.getKey("LoginCert", password.toCharArray()) as PrivateKey)
|
||||
update(content.toByteArray())
|
||||
}
|
||||
return Base64.getEncoder().encodeToString(signature.sign())
|
||||
return Base64.encodeBase64String(signature.sign())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue