package com.betriebsratkanzlei.legalconsenthub_middleware.smartcard

import com.betriebsratkanzlei.legalconsenthub_middleware_api.api.SmartCardApi
import com.betriebsratkanzlei.legalconsenthub_middleware_api.model.CertificateDto
import com.betriebsratkanzlei.legalconsenthub_middleware_api.model.SmartCardInfoDto
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.RestController
import java.time.LocalDateTime

@RestController
@ConditionalOnProperty(name = ["dummy.mode.enabled"], havingValue = "true")
class DummySmartCardController : SmartCardApi {
    
    override fun getSmartCardInfo(): ResponseEntity<SmartCardInfoDto> {
        // Always return successful smart card info
        val dummySmartCardInfo = SmartCardInfoDto(
            isPresent = true,
            label = "DUMMY Smart Card",
            serialNumber = "12345678",
            manufacturer = "Dummy Corp",
            model = "DummyCard 2024"
        )
        return ResponseEntity.ok(dummySmartCardInfo)
    }
    
    override fun getSmartCardCertificates(): ResponseEntity<List<CertificateDto>> {
        // Always return successful list of dummy certificates
        val dummyCertificates = listOf(
            CertificateDto(
                id = "01",
                subject = "CN=John Doe, O=Example Company, L=Berlin, C=DE",
                issuer = "CN=Dummy CA, O=Dummy Corp, C=DE",
                validFrom = LocalDateTime.now().minusYears(1),
                validTo = LocalDateTime.now().plusYears(2),
                keyUsage = listOf("digitalSignature", "keyEncipherment", "nonRepudiation"),
                fingerprint = "AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD"
            ),
            CertificateDto(
                id = "02", 
                subject = "CN=Jane Smith, O=Test Organization, L=Munich, C=DE",
                issuer = "CN=Test CA, O=Test Corp, C=DE",
                validFrom = LocalDateTime.now().minusMonths(6),
                validTo = LocalDateTime.now().plusYears(3),
                keyUsage = listOf("digitalSignature", "nonRepudiation"),
                fingerprint = "11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33:44"
            )
        )
        return ResponseEntity.ok(dummyCertificates)
    }
} 