All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.binaryfoo.crypto.CaPublicKeyTable.kt Maven / Gradle / Ivy

There is a newer version: 0.1.8
Show newest version
package io.github.binaryfoo.crypto

import io.github.binaryfoo.res.ClasspathIO
import org.apache.commons.io.IOUtils

import java.io.IOException
import java.io.InputStream
import java.util.ArrayList
import kotlin.platform.platformStatic

public class CaPublicKeyTable {
    class object {

        public val keys: List = ClasspathIO.readLines("ca-public-keys.txt").map { line ->
            try {
                val fields = line.split("\\t")
                val exponent = fields[1]
                val index = fields[2]
                val rid = fields[3]
                val modulus = fields[4]
                CaPublicKey(rid, index, exponent, modulus)
            } catch(e: Exception) {
                throw RuntimeException("Failed reading CA public key: ${line}", e)
            }
        }

        platformStatic public fun getEntry(aid: String, index: String): CaPublicKey? = keys.firstOrNull { it.rid == aid && it.index == index }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy