temporary commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package net.woggioni.gbcs
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.security.KeyStore
|
||||
import java.security.cert.CertPathValidator
|
||||
import java.security.cert.CertificateFactory
|
||||
import java.security.cert.PKIXParameters
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class CertificateValidationTest {
|
||||
|
||||
@Test
|
||||
fun test() {
|
||||
val keystore = KeyStore.getInstance("PKCS12")
|
||||
val keystorePath = Path.of("/home/woggioni/ssl/woggioni@f6aa5663ef26.pfx")
|
||||
Files.newInputStream(keystorePath).use {
|
||||
keystore.load(it, System.getenv("KEYPASS").toCharArray())
|
||||
}
|
||||
val pkix = CertPathValidator.getInstance("PKIX")
|
||||
val trustStore = KeyStore.getInstance("PKCS12")
|
||||
val trustStorePath = Path.of("/home/woggioni/ssl/truststore.pfx")
|
||||
|
||||
Files.newInputStream(trustStorePath).use {
|
||||
trustStore.load(it, "123456".toCharArray())
|
||||
}
|
||||
|
||||
val certificateFactory = CertificateFactory.getInstance("X.509")
|
||||
val cert = keystore.getCertificateChain("woggioni@f6aa5663ef26").toList()
|
||||
.let(certificateFactory::generateCertPath)
|
||||
val params = PKIXParameters(trustStore)
|
||||
params.isRevocationEnabled = false
|
||||
pkix.validate(cert, params)
|
||||
}
|
||||
}
|
22
src/test/kotlin/net/woggioni/gbcs/ConfigurationTest.kt
Normal file
22
src/test/kotlin/net/woggioni/gbcs/ConfigurationTest.kt
Normal file
@@ -0,0 +1,22 @@
|
||||
package net.woggioni.gbcs
|
||||
|
||||
import java.net.URI
|
||||
import java.net.URL
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
class ConfigurationTest {
|
||||
|
||||
@Test
|
||||
fun test() {
|
||||
GradleBuildCacheServer.registerUrlProtocolHandler()
|
||||
val schemaUrl = this::class.java.getResource("/net/woggioni/gbcs/gbcs.xsd")
|
||||
val dbf = Xml.newDocumentBuilderFactory()
|
||||
dbf.schema = Xml.getSchema(schemaUrl)
|
||||
val db = dbf.newDocumentBuilder().apply {
|
||||
setErrorHandler(Xml.ErrorHandler(schemaUrl))
|
||||
}
|
||||
val configurationUrl = this::class.java.getResource("/net/woggioni/gbcs/gbcs-default.xml")
|
||||
val doc = configurationUrl.openStream().use(db::parse)
|
||||
Configuration.parse(doc.documentElement)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user