A Java 21 web application for digital signature operations and certificate management according to Kazakhstani NCA standards (GOST 34.10-2015 512-bit algorithms).
The application provides:
- Certificate Authority (CA), user, and legal entity certificate generation
- XML digital signature creation and verification
- REST API endpoints for certificate operations
- Vert.x-based asynchronous web server
The backend is built using:
- Vert.x: Asynchronous, event-driven web framework
- Java 21: Modern Java with latest language features
- Gradle: Build automation and dependency management
- MVEL: High-performance expression language for optimized method dispatching
- Kalkan Integration: Cryptographic operations via MVEL-powered reflection proxies
App.java: Main Vert.x verticle with HTTP server setupCertificateHandler.java: REST endpoints for certificate operationsSigningHandler.java: XML signing and verification endpointskalkan/package: Reflection-based Kalkan cryptography library integration
- Vert.x Core/Web: 4.4.6 - Web framework and server
- Jackson: 2.15.2 - JSON processing
- JavaTime Jackson Module: Date/time serialization
- Lombok: 1.18.30 - Code generation annotations
- SLF4J/Simple: Logging framework
- JUnit 5/Jupiter: 5.10.0 - Unit testing
- Vert.x JUnit 5: 4.4.6 - Vert.x testing utilities
- Mockito: 5.5.0 - Mocking framework
Due to license restrictions, we cannot use the Kalkan cryptography library directly through standard imports and linkage. Instead, the application uses runtime reflection with high-performance MVEL expression evaluation to create transparent proxies for Kalkan classes, providing optimized method dispatching without direct commercial licensing.
MVEL-Powered Proxy Architecture:
- High-Performance Method Dispatching: MVEL expressions provide fast, interpreted method invocation
- Compiled Script Caching: Frequently used method calls are cached as compiled expressions for optimal performance
- Simple Wrapper Proxies: Lightweight proxy implementation without complex bytecode manipulation
- Type-Safe Reflection: Safe method invocation with automatic proxy wrapping/unwrapping
Performance Benefits:
- Eliminated Reflection Overhead: MVEL provides significant performance improvements over traditional Java reflection
- Startup Optimization: No dynamic bytecode generation at runtime reduces application startup time
- Memory Efficiency: Simpler proxy structure uses less memory compared to full bytecode-generated proxies
Reflection Helper:
- Dynamic classpath scanning for Kalkan JARs
- Type-safe method invocation via MVEL expressions
- Exception handling and wrapping
The project depends on the Kalkan cryptography library for Kazakhstani digital signature operations. However, due to licensing restrictions:
- Kalkan JARs are NOT included in the repository
- Direct imports are prohibited due to commercial licensing
- Runtime reflection + MVEL-powered proxies are used instead
- Suitable for development/testing without Kalkan JARs (will throw exceptions when cryptographic operations are attempted)
To enable full functionality:
- Obtain Kalkan JAR files separately:
kalkancrypt-0.7.5.jarkalkancrypt_xmldsig-0.4.jarknca_provider_util-0.8.6.jar
- Place them in
backend/lib/directory - The build system will auto-detect and include them
Make sure Java 21 and Gradle are installed on your system.
- Java 21 (JDK)
- Gradle 7.0+ (or use included
./gradlew) - (Optional) Kalkan JARs in
backend/lib/
# Build the application
./gradlew build
# Run tests
./gradlew test
# Run the application
./gradlew run# Clean build artifacts
./gradlew clean
# Build without Kalkan (default)
./gradlew build
# Build with Kalkan support (auto-detected from lib/ directory)
./gradlew build
# Run integration tests
./gradlew test --tests "*IT"
# Create distribution archives
./gradlew distTar
./gradlew distZip
# Generate Gradle wrapper (if needed)
./gradlew wrapperThis project is configured for IntelliJ IDEA:
- Import Project: Open
backend/directory in IDEA - Gradle Sync: IDE will auto-detect Gradle configuration
- JDK 21: Ensure project SDK is set to Java 21
- Run Configurations: Use built-in Gradle tasks or create Run/Debug for
App.main()
The server starts on the configured port (default: 8080):
# Direct execution
./gradlew run
# Or run from JAR
java -jar build/libs/backend.jarDefault Configuration:
- HTTP Port: 8080
- Static Files: Served from
src/main/resources/static/
Run certificate generation example:
./gradlew runGeneratorRun signature validation example:
./gradlew runValidatorAll certificate endpoints return JSON responses.
# Get CA certificate
GET /api/certificates/ca
# Get user certificates
GET /api/certificates/user?caId=default
# Get legal entity certificates
GET /api/certificates/legal?caId=default
# Get certificates from filesystem storage
GET /api/certificates/filesystem
# Generate CA certificate
POST /api/certificates/generate/ca?alias=my-ca
# Generate user certificate
POST /api/certificates/generate/user
Content-Type: application/json
{
"caId": "default"
}
# Generate legal entity certificate
POST /api/certificates/generate/legal
Content-Type: application/json
{
"caId": "default"
}# Sign XML data
POST /api/sign
Content-Type: application/json
{
"data": "<xml>...</xml>",
"certificate": "...",
"key": "..."
}
# Verify signature
POST /api/verify
Content-Type: application/json
{
"signature": "...",
"data": "...",
"certificate": "..."
}
# Validate XML signature
POST /api/validate/xml
Content-Type: application/json
{
"xml": "<xml>...</xml>"
}# Application health status
GET /health./gradlew test --tests "*Test"./gradlew test --tests "*IT"Tests use JUnit 5 and require real Kalkan provider for full functionality.
Example classes for testing operations:
Generator.java: Certificate generation exampleReader.java: Certificate reading exampleValidator.java: Signature validation example
Run examples:
./gradlew runGenerator
./gradlew runReader
./gradlew runValidatorThis project is licensed under the MIT License. Note that the Kalkan cryptography library has separate licensing terms that may require commercial licensing for production use. This application avoids direct Kalkan linkage through reflection and proxy techniques to enable development and testing without licensing restrictions.