Initial commit

This commit is contained in:
defiQUG
2025-12-26 10:48:33 -08:00
commit 97f75e144f
270 changed files with 35886 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
id("dagger.hilt.android.plugin")
}
android {
namespace = "com.smoa.modules.intelligence"
compileSdk = AppConfig.compileSdk
defaultConfig {
minSdk = AppConfig.minSdk
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.4"
}
}
dependencies {
implementation(project(":core:common"))
implementation(project(":core:auth"))
implementation(project(":core:security"))
implementation(platform(Dependencies.composeBom))
implementation(Dependencies.composeUi)
implementation(Dependencies.composeMaterial3)
implementation(Dependencies.androidxCoreKtx)
implementation(Dependencies.hiltAndroid)
kapt(Dependencies.hiltAndroidCompiler)
implementation(Dependencies.coroutinesCore)
implementation(Dependencies.coroutinesAndroid)
}

View File

@@ -0,0 +1,25 @@
package com.smoa.modules.intelligence
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
@Composable
fun IntelligenceModule(modifier: Modifier = Modifier) {
Column(
modifier = modifier
.fillMaxSize()
.padding(16.dp)
) {
Text(
text = "Intelligence Operations",
style = MaterialTheme.typography.headlineMedium
)
}
}

View File

@@ -0,0 +1,34 @@
package com.smoa.modules.intelligence.domain
/**
* Compartmented access control framework for intelligence operations.
*/
data class Compartment(
val compartmentId: String,
val name: String,
val description: String,
val accessLevel: AccessLevel,
val controllingAgency: String,
val authorizedPersonnel: List<String>
)
enum class AccessLevel {
UNCLASSIFIED,
CONFIDENTIAL,
SECRET,
TOP_SECRET,
TS_SCI // Top Secret - Sensitive Compartmented Information
}
/**
* Need-to-know enforcement.
*/
data class NeedToKnow(
val compartmentId: String,
val userId: String,
val justification: String,
val authorizedBy: String,
val authorizationDate: java.util.Date,
val expirationDate: java.util.Date?
)

View File

@@ -0,0 +1,59 @@
package com.smoa.modules.intelligence.domain
import javax.inject.Inject
import javax.inject.Singleton
/**
* Compartment manager for multi-level security (MLS) system.
*/
@Singleton
class CompartmentManager @Inject constructor() {
private val compartments = mutableMapOf<String, Compartment>()
private val userCompartments = mutableMapOf<String, Set<String>>()
private val needToKnowRecords = mutableMapOf<String, List<NeedToKnow>>()
/**
* Register a compartment.
*/
fun registerCompartment(compartment: Compartment) {
compartments[compartment.compartmentId] = compartment
}
/**
* Check if user has access to compartment.
*/
fun hasAccess(userId: String, compartmentId: String): Boolean {
val userComps = userCompartments[userId] ?: return false
return userComps.contains(compartmentId)
}
/**
* Check need-to-know for compartment access.
*/
fun hasNeedToKnow(userId: String, compartmentId: String): Boolean {
val records = needToKnowRecords[userId] ?: return false
val now = java.util.Date()
return records.any {
it.compartmentId == compartmentId &&
it.expirationDate?.after(now) != false
}
}
/**
* Grant compartment access to user.
*/
fun grantAccess(userId: String, compartmentId: String) {
val current = userCompartments[userId] ?: emptySet()
userCompartments[userId] = current + compartmentId
}
/**
* Add need-to-know authorization.
*/
fun addNeedToKnow(needToKnow: NeedToKnow) {
val current = needToKnowRecords[needToKnow.userId] ?: emptyList()
needToKnowRecords[needToKnow.userId] = current + needToKnow
}
}

View File

@@ -0,0 +1,75 @@
package com.smoa.modules.intelligence.domain
import com.smoa.core.security.AuditLogger
import com.smoa.core.security.AuditEventType
import java.util.Date
import java.util.UUID
import javax.inject.Inject
import javax.inject.Singleton
/**
* Intelligence operations service.
*/
@Singleton
class IntelligenceService @Inject constructor(
private val compartmentManager: CompartmentManager,
private val auditLogger: AuditLogger
) {
/**
* Register compartment.
*/
suspend fun registerCompartment(compartment: Compartment) {
compartmentManager.registerCompartment(compartment)
auditLogger.logEvent(
AuditEventType.POLICY_UPDATE,
userId = compartment.controllingAgency,
module = "intelligence",
details = "Compartment registered: ${compartment.compartmentId}"
)
}
/**
* Check compartment access.
*/
fun checkCompartmentAccess(userId: String, compartmentId: String): Boolean {
return compartmentManager.hasAccess(userId, compartmentId) &&
compartmentManager.hasNeedToKnow(userId, compartmentId)
}
/**
* Create protected source.
*/
suspend fun createProtectedSource(
sourceType: SourceType,
codename: String?,
description: String,
protectionLevel: ProtectionLevel,
authorizedHandlers: List<String>
): Result<ProtectedSource> {
return try {
val source = ProtectedSource(
sourceId = UUID.randomUUID().toString(),
sourceType = sourceType,
codename = codename,
description = description,
protectionLevel = protectionLevel,
authorizedHandlers = authorizedHandlers,
creationDate = Date(),
lastAccessDate = null
)
auditLogger.logEvent(
AuditEventType.CREDENTIAL_ACCESS,
userId = authorizedHandlers.firstOrNull() ?: "system",
module = "intelligence",
details = "Protected source created: ${source.sourceId}"
)
Result.success(source)
} catch (e: Exception) {
Result.failure(e)
}
}
}

View File

@@ -0,0 +1,50 @@
package com.smoa.modules.intelligence.domain
import java.util.Date
/**
* Source protection framework for intelligence operations.
*/
data class ProtectedSource(
val sourceId: String,
val sourceType: SourceType,
val codename: String?,
val description: String,
val protectionLevel: ProtectionLevel,
val authorizedHandlers: List<String>,
val creationDate: Date,
val lastAccessDate: Date?
)
enum class SourceType {
HUMAN_INTELLIGENCE,
SIGNALS_INTELLIGENCE,
IMAGERY_INTELLIGENCE,
OPEN_SOURCE,
OTHER
}
enum class ProtectionLevel {
ROUTINE,
SENSITIVE,
HIGHLY_SENSITIVE,
CRITICAL
}
data class SourceHandlingRecord(
val recordId: String,
val sourceId: String,
val handlerId: String,
val action: HandlingAction,
val timestamp: Date,
val notes: String?
)
enum class HandlingAction {
ACCESSED,
MODIFIED,
SHARED,
ARCHIVED,
DESTROYED
}