Shared .NET library for Aerospace, Intelligence, and Cyber solutions.
$ dotnet add package AIC.Core.Messaging.Services.InMemoryTransforming Industry Through Technology
AIC — Aerospace, Intelligence & Cyber — provides cutting-edge, mission-ready software components powering secure, data-driven systems for the UK defence and national security sector.
This repository contains the comprehensive enterprise .NET 10 library ecosystem developed by AIC (Aerospace Intelligence Cyber) for high-assurance environments spanning Defence, Government, and critical national infrastructure.
The solution provides 50+ modular packages implementing:
All packages follow SOLID principles, enforce deterministic builds, include SourceLink tracing, and are published automatically via Azure DevOps CI/CD pipelines.
IRepository<TEntity, TId>, IDataService<TModel>) to reduce boilerplateAll packages provide extension methods for seamless DI registration:
services
.AddIdentityDataServices()
.AddCachingServices()
.AddCryptographyServices()
.AddDataServices();
Purpose: Unified abstractions and implementations for persistent storage across multiple database engines.
AIC.Core.Data
IRepository<TEntity, TId> — Generic repository interface supporting create, read, update, delete, and complex queriesIEntity, IVectorisedEntity — Base entity contracts with ID and metadata supportIHasDisplayName, IHasId — Composable capability interfacesSortDirection enum for query orderingEntity Framework Core
AIC.Core.Data.EntityFramework
BaseEntityFrameworkCoreRepository<TEntity, TId> — Full LINQ support with lazy loading, eager loading, and expression treesMongoDB
AIC.Core.Data.MongoDb
BaseMongoDbRepository<TModel> — MongoDB-native repository with BSON serializationAIC.Core.Data.MongoDb.Realm
BaseMongoDbRealmRepository<TModel> — MongoDB Realm-specific implementation for offline-first mobile scenariosVector Search & Embeddings
AIC.Core.Data.MongoDb + Vector Extensions
BaseVectorisedMongoDbRepository<TModel> — Advanced vector search via MongoDB Atlas Vector SearchSearchVectorAsync() — Cosine similarity search over embeddings with configurable topK resultsSearchVectorWithScoreAsync() — Returns both documents and relevance scoresSearchOrganisationVectorAsync() — Scoped vector search per organisation (multi-tenant aware)Azure Cosmos DB
AIC.Core.Data.CosmosDb
BaseCosmosDbRepository<TEntity, TId> — Cosmos DB SDK integrationAIC.Core.Data.Services
BaseDataService<TModel, TId> — Generic CRUD service wrapping repositoriesGetByIdAsync(), GetAllAsync(), CreateAsync(), UpdateAsync(), DeleteByIdAsync()AIC.Core.Data.Extensions.Expressions — Expression tree utilities for composable query buildingAIC.Core.Data.Models.References — Shared model references across solutionsPurpose: Enterprise-grade user, organisation, tenant, and permission management with audit trails and multi-factor access control.
AIC.Core.Identity.Models
IIdentityService — Primary identity contract (user provisioning, attribute management, lock/unlock operations)IGetUserRequest, IGetUserResponse — Request/response envelopes with organisation scopingQuotaExceededException, ApiKeyInvalidException, RateLimitExceededException, etc.AIC.Core.Identity.Data.Services
IIdentityService + IdentityService — Full user lifecycle (create, retrieve, update, lock, unlock, provision)IVaultService + VaultService — Secure credential storage, key derivation, and secrets managementIUserService + UserService — User-specific operations with organisational scopingIAuditService + AuditService — Comprehensive audit logging for all identity operationsAIC.Core.Identity.Data.Services
BaseRbacDataService<TModel, TId> — Role-Based Access Control base service with resource-level permissionsBaseRbacTenantDataService — Tenant-specific RBAC (all operations scoped to tenant)BaseRbacTenantOrganisationDataService — Organisation-wide RBAC with cross-tenant boundariesAIC.Core.Identity.Subscriptions.Models — Subscription domain modelsAIC.Core.Identity.Subscriptions.Models.MongoDb — MongoDB-specific subscription persistenceAIC.Core.Identity.Subscriptions.Services — Subscription lifecycle and entitlement logicAIC.Core.Identity.Subscriptions.Models.References — Reference data for subscription typesAIC.Core.Identity.Tenants.Models — Tenant domain modelsAIC.Core.Identity.Tenants.Models.MongoDb — MongoDB tenant persistenceAIC.Core.Identity.Tenants.Models.References — Reference data and lookup tablesAIC.Core.Identity.Data.Services
AuditService — Tracks all identity operations with user IDs, timestamps, actions, and resultsAIC.Core.Identity.Extensions — Helper methods for identity operations, token generation, and claim extractionAIC.Core.Identity.Data.Services.Jwt
IAccessTokenService + JwtAccessTokenService — Issues short-lived access tokensIRefreshTokenService + JwtRefreshTokenService — Manages token refresh flowsIJwtKeyMaterialService + RsaJwtKeyMaterialService — RSA-based key material provisioningISigningCredentialsProvisionService + RsaSigningCredentialsProvisionService — Signing credential managementAIC.Core.Identity.Extensions.Jwt
JwtAuthServiceCollectionExtensions — DI registration for JWT authenticationJwtAuthenticationServiceCollectionExtensions — Full JWT pipeline configurationApiKeyMetadata as claims
AIC.Core.Identity.Data.Services.Middleware
AuthenticationServiceContextMiddleware — Extracts and validates auth tokens, populates user contextTokenValidationErrorMiddleware — Handles JWT validation failures with detailed error responsesAuthorizationAuditMiddleware — Logs all authenticated requests with action, resource, outcome, and timingIpGeoPolicyMiddleware — Validates IP address geolocation against API key restrictionsIGeoResolver + DefaultGeoResolver — Geolocation lookup (extensible for custom providers)IIpMatcher + CidrIpMatcher — CIDR block matching for IP validationQuotaMiddleware — Enforces per-user and per-API-key rate limitsRateLimitExceededException for backpressure signalingAIC.Core.Identity.Extensions.WebApi
WebApiExtensions — Comprehensive ASP.NET Core integrationAIC.Core.Identity.Data.Controllers.Authentication
AuthenticationController — RESTful endpoints for login, token refresh, logoutPurpose: Enterprise cryptographic primitives supporting post-quantum algorithms, certificate management, and secure key operations.
AIC.Core.Security.Cryptography
IAsymmetricCryptographyProvider<TAlgorithm> — RSA, ECDSA, post-quantum algorithm abstractionISymmetricCryptographyProvider<TAlgorithm> — AES and other symmetric cipher abstractionIHashProvider — Cryptographic hash function abstraction (SHA-256, SHA-3, BLAKE2, etc.)ICryptographicAsyncStream — Stream-based encryption/decryption for large payloadsRSA Support
AIC.Core.Security.Cryptography.Asymmetric.RSA
Post-Quantum Algorithms
AIC.Core.Security.Cryptography.Asymmetric.QuantumAIC.Core.Security.Cryptography.Asymmetric.Quantum.BouncyCastle
X.509 Certificates
AIC.Core.Security.Cryptography.Asymmetric.Certificates
AIC.Core.Security.Cryptography.Asymmetric.Certificates.Quantum
AIC.Core.Security.Cryptography.Asymmetric.Certificates.Quantum.BouncyCastle
AES Support
AIC.Core.Security.Cryptography.Symmetric.AES
AIC.Core.Security.Cryptography.Hashing
AIC.Core.Security.Cryptography.Hashing.BouncyCastle
AIC.Core.Security.Cryptography.Asymmetric.Extensions — Helper methods for key generation, encoding, format conversionAIC.Core.Security.Cryptography.Hashing.Extensions — Hash computation shortcuts and verification helpersPurpose: Flexible caching abstractions supporting in-memory and distributed cache implementations.
AIC.Core.Caching
ICache — Generic cache interface with Get, Set, Remove, Clear operationsITypedCache<T> — Strongly-typed cache for specific model typesIn-Memory
AIC.Core.Caching.InMemory
InMemoryCache — .NET MemoryCache wrapperMicrosoft Memory Cache Adapter
AIC.Core.Caching.MicrosoftMemoryCache
Microsoft.Extensions.Caching.Memory.IMemoryCacheAIC.Core.Caching Extensions
CacheExtensions — Convenience methods for cache-aside pattern, lazy loading, bulk operationsAIC.Core.Logging
Microsoft.Extensions.LoggingAIC.Core.Logging.Serilog
SerilogLoggingPolicyMiddleware — Middleware for structured request/response loggingAIC.Core.Logging.Extensions — Helper methods for common logging patternsAIC.Core.Extensions — General-purpose extension methods for strings, collections, reflection, and domain operationsEvery data service includes built-in organisational and tenant scoping:
public class TenantDataService : BaseRbacTenantDataService<Model>
{
public async Task GetAsync(Guid tenantId)
{
// Automatically scoped to tenantId; cross-tenant access rejected
return await GetByIdAsync(modelId);
}
}
API keys carry quota metadata:
// Automatically enforced by middleware
services.AddRateLimiter(options => { /* configured per API key */ });
Every identity operation is logged:
MongoDB Atlas vector search enables semantic queries:
var results = await repository.SearchVectorAsync(embeddingVector, topK: 10);
var withScores = await repository.SearchVectorWithScoreAsync(embeddingVector);
Suitable for:
TargetType.Any quotas act as wildcards:
// This quota applies to all request types
var catchAllQuota = quotas.Where(q => q.TargetType == TargetType.Any || q.TargetType == targetType);
Enables org-level policies with user-level overrides.
VaultService for secure credential storageEach package is available via NuGet with the AIC.Core.* prefix:
# Identity & Access
dotnet add package AIC.Core.Identity.Data.Services
dotnet add package AIC.Core.Identity.Extensions.Jwt
dotnet add package AIC.Core.Identity.Extensions.WebApi
# Data Persistence
dotnet add package AIC.Core.Data.Services
dotnet add package AIC.Core.Data.MongoDb
dotnet add package AIC.Core.Data.EntityFramework
# Security & Cryptography
dotnet add package AIC.Core.Security.Cryptography.Asymmetric.RSA
dotnet add package AIC.Core.Security.Cryptography.Asymmetric.Quantum.BouncyCastle
dotnet add package AIC.Core.Security.Cryptography.Symmetric.AES
# Caching
dotnet add package AIC.Core.Caching.MicrosoftMemoryCache
# Logging
dotnet add package AIC.Core.Logging.Serilog
using AIC.Core.Identity.Extensions;
using AIC.Core.Identity.Extensions.Jwt;
using AIC.Core.Identity.Extensions.WebApi;
using AIC.Core.Data.Services;
using AIC.Core.Caching;
using Microsoft.Extensions.DependencyInjection;
// Build service collection
var services = new ServiceCollection();
// Register all AIC services
services
.AddIdentityDataServices()
.AddIdentityJwtServices(Configuration)
.RegisterWebApiDependencies(Configuration)
.AddDataServices()
.AddCachingServices()
.AddLoggingServices();
var provider = services.BuildServiceProvider();
// Use services
var identityService = provider.GetRequiredService<IIdentityService>();
var userResponse = await identityService.GetUserAsync(getUserRequest);
var userService = provider.GetRequiredService<IUserService>();
var user = await userService.GetByIdAsync(userId);
var cache = provider.GetRequiredService<ICache>();
await cache.SetAsync("key", "value", TimeSpan.FromMinutes(5));
# Restore dependencies
dotnet restore
# Build the solution
dotnet build -c Release
# Run all tests
dotnet test
# Generate NuGet packages locally
dotnet pack -c Release
Build output:
bin/Release/net10.0/artifacts/packages/*.snupkgartifacts/packages/*.nupkgMyApplication/
├── MyApplication.Web/ # ASP.NET Core / Blazor app
│ ├── Program.cs # DI & middleware registration
│ └── Controllers/ # API controllers
├── MyApplication.Services/ # Business logic layer
│ ├── UserService.cs # Orchestrates identity operations
│ └── DataService.cs # Data access wrapper
└── MyApplication.Models/ # Domain models
├── User.cs
└── Tenant.cs
// Program.cs registration
services
.AddIdentityDataServices()
.AddIdentityExtensions()
.AddDataServices()
.AddCachingServices();
app.UseWebApi(); // Registers middleware pipeline
All data access flows through IRepository<TEntity, TId>:
public interface IRepository<TEntity, in TId> where TEntity : class where TId : struct
{
Task<TEntity> GetModelAsync(TId id);
Task<IEnumerable<TEntity>> GetModelsAsync();
Task<TEntity> CreateOrUpdateAsync(TEntity entity);
Task<bool> DeleteAsync(TId id);
}
Implementations:
BaseEntityFrameworkCoreRepository — EF Core with LINQ supportBaseMongoDbRepository — MongoDB with document queriesBaseCosmosDbRepository — Cosmos DB with partition-aware queriesBaseVectorisedMongoDbRepository — Vector search extensionGeneric BaseDataService<TModel, TId> wraps repositories:
public class BaseDataService<TModel, TId> where TModel : class where TId : struct
{
public async ValueTask<TModel> GetByIdAsync(TId id) { /* delegates to repository */ }
public async ValueTask<IEnumerable<TModel>> GetAllAsync(Expression<Func<TModel, bool>>? predicate = null) { }
public async ValueTask<TModel> CreateAsync(TModel model) { }
public async ValueTask<TModel> UpdateAsync(TModel model) { }
public async ValueTask<bool> DeleteByIdAsync(TId id) { }
}
Provides:
Get*Async, Create*Async, Delete*Async)BaseRbacDataService<TModel, TId> enforces permissions:
public class BaseRbacDataService<TModel, TId> : BaseDataService<TModel, TId>
{
// All operations respect user roles and resource permissions
public async Task<TModel> GetByIdAsync(TId id)
{
var model = await base.GetByIdAsync(id);
// Check user has read permission on model
await authorizationService.AuthorizeAsync(user, model, "Read");
return model;
}
}
Authentication and authorization are applied via middleware:
→ AuthenticationServiceContextMiddleware (Extract JWT, populate HttpContext.User)
→ AuthorizationAuditMiddleware (Log authenticated action)
→ IpGeoPolicyMiddleware (Validate geo restrictions)
→ QuotaMiddleware (Rate limiting)
→ TokenValidationErrorMiddleware (Error mapping)
→ Application Logic (Controllers, Services)
The solution includes comprehensive test suites:
Test Projects:
AIC.Core.Data.MongoDb.Tests — Repository and query testsAIC.Core.Data.CosmosDb.Tests — Cosmos DB integration testsAIC.Core.Security.Cryptography.*.Tests — Cryptography algorithm testsAIC.Core.Identity.Data.Services.Middleware.Tests — Middleware pipeline testsAIC.Core.Identity.Data.Services.Jwt.Tests — JWT token testsTest Framework: xUnit (with Fluent Assertions, Moq, NUnit conventions)
Coverage:
Versions follow CalVer (Calendar Versioning):
YYYY.MM.DD.patch2025.11.20.3 (November 20, 2025, patch 3)<!-- Directory.Build.props -->
<Deterministic>true</Deterministic>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Ensures:
Each project auto-generates NuGet packages:
.nupkg (DLL + dependencies).snupkg (debugging support)dotnet pack -c Release
# Outputs to ./artifacts/packages/
src/
├── Data/ # Data layer abstractions & implementations
│ ├── AIC.Core.Data/ # Core interfaces (IRepository, IEntity)
│ ├── AIC.Core.Data.Services/ # Generic CRUD services
│ ├── AIC.Core.Data.EntityFramework/ # EF Core repository
│ ├── AIC.Core.Data.MongoDb/ # MongoDB repository
│ ├── AIC.Core.Data.MongoDb.Realm/ # MongoDB Realm offline support
│ ├── AIC.Core.Data.CosmosDb/ # Azure Cosmos DB repository
│ ├── AIC.Core.Data.Models.References/ # Shared model references
│ └── AIC.Core.Data.Extensions.Expressions/ # Expression tree utilities
│
├── Caching/ # Caching abstractions & implementations
│ ├── AIC.Core.Caching/ # Core cache interfaces
│ ├── AIC.Core.Caching.InMemory/ # In-memory implementation
│ └── AIC.Core.Caching.MicrosoftMemoryCache/ # MS.Extensions.Caching adapter
│
├── Security/ # Cryptography & security
│ └── Cryptography/
│ ├── AIC.Core.Security.Cryptography/ # Core crypto abstractions
│ ├── AIC.Core.Security.Cryptography.Streams/ # Stream-based encryption
│ ├── Asymmetric/
│ │ ├── AIC.Core.Security.Cryptography.Asymmetric/ # RSA, ECDSA abstractions
│ │ ├── AIC.Core.Security.Cryptography.Asymmetric.RSA/ # RSA implementation
│ │ ├── AIC.Core.Security.Cryptography.Asymmetric.Extensions/ # RSA helpers
│ │ ├── AIC.Core.Security.Cryptography.Asymmetric.Quantum/ # Post-quantum base
│ │ ├── AIC.Core.Security.Cryptography.Asymmetric.Quantum.BouncyCastle/ # PQ implementations
│ │ ├── AIC.Core.Security.Cryptography.Asymmetric.NBitcoin/ # Bitcoin crypto support
│ │ ├── Certificates/
│ │ │ ├── AIC.Core.Security.Cryptography.Asymmetric.Certificates/ # X.509 support
│ │ │ ├── AIC.Core.Security.Cryptography.Asymmetric.Certificates.Models/
│ │ │ ├── AIC.Core.Security.Cryptography.Asymmetric.Certificates.Quantum/ # PQ certificates
│ │ │ └── AIC.Core.Security.Cryptography.Asymmetric.Certificates.Quantum.BouncyCastle/
│ ├── Symmetric/
│ │ ├── AIC.Core.Security.Cryptography.Symmetric/ # Symmetric abstractions
│ │ └── AIC.Core.Security.Cryptography.Symmetric.AES/ # AES implementation
│ ├── Hashing/
│ │ ├── AIC.Core.Security.Cryptography.Hashing/ # Hash abstractions
│ │ ├── AIC.Core.Security.Cryptography.Hashing.BouncyCastle/ # BC implementations
│ │ └── AIC.Core.Security.Cryptography.Hashing.Extensions/ # Hash helpers
│ └── FIDO2/
│ └── AIC.Core.Security.Cryptography.Fido2/ # WebAuthn/FIDO2 support
│
├── Identity/ # Identity & access management
│ ├── AIC.Core.Identity.Models/ # Core identity domain models & exceptions
│ ├── AIC.Core.Identity.Models.Jwt/ # JWT models (AccessToken, RefreshToken, etc.)
│ ├── AIC.Core.Identity.Models.MongoDb/ # MongoDB-persisted identity models
│ ├── AIC.Core.Identity.Data/ # Identity repositories
│ ├── AIC.Core.Identity.Data.Services/ # Identity business logic (User, Vault, Audit)
│ ├── AIC.Core.Identity.Data.Services.Jwt/ # JWT token generation & validation
│ ├── AIC.Core.Identity.Data.Services.Middleware/ # Auth middleware (context, audit, geo-ip, quota)
│ ├── AIC.Core.Identity.Data.Controllers.Authentication/ # REST controllers
│ ├── AIC.Core.Identity.Extensions/ # Identity extension methods
│ ├── AIC.Core.Identity.Extensions.Jwt/ # JWT DI extensions
│ ├── AIC.Core.Identity.Extensions.WebApi/ # WebApi integration
│ ├── AIC.Core.Identity.Services.Web/ # Web-specific services (GeoResolver, IpMatcher)
│ ├── AIC.Core.Identity.Extensions.Web/ # Web extension methods
│ ├── Subscriptions/
│ │ ├── AIC.Core.Identity.Subscriptions.Models/
│ │ ├── AIC.Core.Identity.Subscriptions.Models.MongoDb/
│ │ ├── AIC.Core.Identity.Subscriptions.Models.References/
│ │ └── AIC.Core.Identity.Subscriptions.Services/
│ └── Tenants/
│ ├── AIC.Core.Identity.Tenants.Models/
│ ├── AIC.Core.Identity.Tenants.Models.MongoDb/
│ └── AIC.Core.Identity.Tenants.Models.References/
│
├── Logging/ # Logging & observability
│ ├── AIC.Core.Logging/ # Core logging abstractions
│ ├── AIC.Core.Logging.Extensions/ # Logging extension methods
│ └── AIC.Core.Logging.Serilog/ # Serilog structured logging
│
├── Extensions/ # Utilities & extensions
│ └── AIC.Core.Extensions/ # General-purpose extension methods
│
└── Encoding/ # Future: Text encoding & compression utilities
This repository is managed internally by AIC.
External contributions are not currently accepted.
For collaboration opportunities, contact the AIC engineering team via https://aicuk.ltd#contact.
All packages are produced within a clean cloud build environment with:
Security vulnerabilities can be reported privately through official AIC channels only. Do not disclose security issues in public GitHub issues or discussions.
Licensed under the MIT License.
See the LICENSE file for full terms.
Copyright © 2025 AIC Professional Services UK Ltd
All rights reserved. This software and its associated artefacts are proprietary to AIC. No part of this material may be used, reproduced, or distributed without explicit written authorisation from AIC.
Last Updated: January 2026
Framework Version: .NET 10
Status: Production Ready