Initial commit
This commit is contained in:
42
core/certificates/build.gradle.kts
Normal file
42
core/certificates/build.gradle.kts
Normal file
@@ -0,0 +1,42 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
id("kotlin-kapt")
|
||||
id("dagger.hilt.android.plugin")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.smoa.core.certificates"
|
||||
compileSdk = AppConfig.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AppConfig.minSdk
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":core:common"))
|
||||
implementation(project(":core:security"))
|
||||
|
||||
implementation(Dependencies.androidxCoreKtx)
|
||||
|
||||
// Cryptography
|
||||
implementation(Dependencies.bouncycastle)
|
||||
implementation(Dependencies.bouncycastlePkix)
|
||||
|
||||
implementation(Dependencies.hiltAndroid)
|
||||
kapt(Dependencies.hiltAndroidCompiler)
|
||||
|
||||
implementation(Dependencies.coroutinesCore)
|
||||
implementation(Dependencies.coroutinesAndroid)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.smoa.core.certificates
|
||||
|
||||
import com.smoa.core.certificates.domain.CertificateManager as DomainCertificateManager
|
||||
import java.security.cert.X509Certificate
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Certificate Manager - Main entry point for certificate management.
|
||||
*/
|
||||
class CertificateManager @Inject constructor(
|
||||
private val domainManager: DomainCertificateManager
|
||||
) {
|
||||
fun storeCertificate(certificateId: String, certificate: X509Certificate, metadata: com.smoa.core.certificates.domain.CertificateMetadata) =
|
||||
domainManager.storeCertificate(certificateId, certificate, metadata)
|
||||
|
||||
fun getCertificate(certificateId: String) = domainManager.getCertificate(certificateId)
|
||||
|
||||
fun isCertificateValid(certificate: X509Certificate) = domainManager.isCertificateValid(certificate)
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.smoa.core.certificates.domain
|
||||
|
||||
import java.security.cert.X509Certificate
|
||||
import java.util.Date
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* Certificate management system.
|
||||
*/
|
||||
@Singleton
|
||||
class CertificateManager @Inject constructor() {
|
||||
|
||||
private val certificates = mutableMapOf<String, CertificateInfo>()
|
||||
|
||||
/**
|
||||
* Store certificate.
|
||||
*/
|
||||
fun storeCertificate(certificateId: String, certificate: X509Certificate, metadata: CertificateMetadata) {
|
||||
certificates[certificateId] = CertificateInfo(
|
||||
certificateId = certificateId,
|
||||
certificate = certificate,
|
||||
metadata = metadata,
|
||||
storedDate = Date()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get certificate.
|
||||
*/
|
||||
fun getCertificate(certificateId: String): CertificateInfo? {
|
||||
return certificates[certificateId]
|
||||
}
|
||||
|
||||
/**
|
||||
* Check certificate validity.
|
||||
*/
|
||||
fun isCertificateValid(certificate: X509Certificate): Boolean {
|
||||
return try {
|
||||
certificate.checkValidity()
|
||||
true
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check certificate revocation status via OCSP/CRL.
|
||||
* TODO: Implement actual OCSP/CRL checking
|
||||
*/
|
||||
suspend fun checkRevocationStatus(certificate: X509Certificate): RevocationStatus {
|
||||
// Placeholder - actual implementation will query OCSP responder or CRL
|
||||
return RevocationStatus.UNKNOWN
|
||||
}
|
||||
}
|
||||
|
||||
data class CertificateInfo(
|
||||
val certificateId: String,
|
||||
val certificate: X509Certificate,
|
||||
val metadata: CertificateMetadata,
|
||||
val storedDate: Date
|
||||
)
|
||||
|
||||
data class CertificateMetadata(
|
||||
val issuer: String,
|
||||
val subject: String,
|
||||
val purpose: CertificatePurpose,
|
||||
val isQualified: Boolean // eIDAS qualified certificate
|
||||
)
|
||||
|
||||
enum class CertificatePurpose {
|
||||
SIGNING,
|
||||
ENCRYPTION,
|
||||
AUTHENTICATION
|
||||
}
|
||||
|
||||
enum class RevocationStatus {
|
||||
VALID,
|
||||
REVOKED,
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user