6.4 KiB
6.4 KiB
TMS Framework
Single-process TMS monolith scaffold built with:
- JDK 17
- Spring Boot 3.5.x
- MyBatis-Plus
- TiDB (MySQL driver)
- Swagger (springdoc-openapi)
Quick Start
cd tms-framework
mvn spring-boot:run
Runtime recommendation:
- Use JDK 17 for local build/test to match project and CI runtime.
Open:
- Swagger UI: http://localhost:8080/swagger-ui.html
- Internal health API:
GET /api/v1/device/status - Internal sign preview API:
POST /api/v1/sign/preview - External sign API:
POST /openapi/v1/sign/signature - Init template API:
GET /api/v1/init/template - Init preview API:
POST /api/v1/init/preview - Auth login API:
POST /api/v1/auth/login - Device info API:
GET /api/v1/device/info - PCIe crypto count API:
GET /api/v1/device/crypto/device-count - PCIe crypto HMAC API:
POST /api/v1/device/crypto/hmac
Architecture (Monolith + Modular)
- One deployable Spring Boot application.
- Module-first packaging under
modules/*. - Default module layout:
controller/internal + service + repository + entity + dto. signmodule has extracontroller/openapi,dto/openapi, andsupport.- Cross-cutting concerns moved to top-level
securityandintegration.
Project Structure
src/main/java/com/cisd/tms
├── TmsApplication.java
├── common
│ ├── api
│ ├── config
│ │ └── properties
│ ├── constant
│ ├── enums
│ ├── exception
│ └── util
├── infrastructure
│ └── persistence
│ ├── entity
│ ├── mapper
│ └── mybatis
├── integration
│ ├── cips
│ ├── mq
│ ├── crypto
│ └── file
├── security
│ ├── internal
│ └── openapi
└── modules
├── system
│ ├── controller/internal
│ ├── service
│ └── dto
├── sign
│ ├── controller/internal
│ ├── controller/openapi
│ ├── service
│ ├── dto/internal
│ ├── dto/openapi
│ ├── support
│ ├── repository
│ └── entity
├── init
├── auth
├── device
├── upgrade
├── cert
├── key
├── audit
├── backup
└── activation
src/main/resources
├── application.yml
├── application-dev.yml
├── application-prod.yml
├── mapper
│ ├── init/InitTaskMapper.xml
│ ├── auth/AuthUserMapper.xml
│ └── device/DeviceNodeMapper.xml
└── db/migration
└── V1__init_auth_device_tables.sql
API Boundary Rules
- Internal API controllers only in
*/controller/internal, path prefix/api/**. - External API controllers only in
*/controller/openapi, path prefix/openapi/**. - Internal and external DTOs are separated.
- Cross-module calls must go through
service, notrepository. - Internal token interceptor exclusions:
/api/v1/device/status,/api/v1/auth/login.
Auth Configuration
tms:
security:
internal-token: ${TMS_INTERNAL_TOKEN:change-me-internal-token}
openapi:
timestamp-skew-seconds: 300
clients:
demo-app: ${TMS_OPENAPI_DEMO_SECRET:change-me-openapi-secret}
Crypto Card Configuration
tms:
crypto-card:
enabled: ${TMS_CRYPTO_CARD_ENABLED:false}
mode: ${TMS_CRYPTO_CARD_MODE:MOCK} # MOCK / JNA
vendor-lib-path: ${TMS_CRYPTO_VENDOR_LIB_PATH:}
vendor-lib-name: ${TMS_CRYPTO_VENDOR_LIB_NAME:swsdsdf}
- Internal PCIe debug APIs (strong-typed service):
GET /api/v1/device/crypto/device-countGET /api/v1/device/crypto/device-confGET /api/v1/device/crypto/device-infoGET /api/v1/device/crypto/random?length=16POST /api/v1/device/crypto/self-testPOST /api/v1/device/crypto/hmacPOST /api/v1/device/crypto/digestPOST /api/v1/device/crypto/encrypt/plainPOST /api/v1/device/crypto/decrypt/plainPOST /api/v1/device/crypto/encrypt/kekPOST /api/v1/device/crypto/decrypt/kekPOST /api/v1/device/crypto/mac/plainPOST /api/v1/device/crypto/file/createPOST /api/v1/device/crypto/file/writePOST /api/v1/device/crypto/file/readPOST /api/v1/device/crypto/file/deletePOST /api/v1/device/crypto/kek/generateGET /api/v1/device/crypto/kek/status?keyIndex=1GET /api/v1/device/crypto/lmk/seed-macPOST /api/v1/device/crypto/std/keypair/rsaPOST /api/v1/device/crypto/std/keypair/eccPOST /api/v1/device/crypto/envelope/exchange/rsaPOST /api/v1/device/crypto/envelope/exchange/eccPOST /api/v1/device/crypto/agreement/data-key/eccPOST /api/v1/device/crypto/agreement/session-key/ecc
PCIe Crypto Unified Wrapper (JNA)
The project keeps JNA native mappings for PCIe card SDF/SDFE interfaces from
PCIE密码卡应用接口说明书 V1.02, and provides strong-typed service APIs via
com.cisd.tms.integration.crypto.pcie.service.PcieCryptoService.
tms:
crypto-card:
enabled: ${TMS_CRYPTO_CARD_ENABLED:false}
mode: ${TMS_CRYPTO_CARD_MODE:JNA} # MOCK / JNA
vendor-lib-path: ${TMS_CRYPTO_VENDOR_LIB_PATH:}
vendor-lib-name: ${TMS_CRYPTO_VENDOR_LIB_NAME:swsdsdf}
- JNA native mapping:
com.cisd.tms.integration.crypto.pcie.jna.PcieNativeLibrary - JNA implementation:
com.cisd.tms.integration.crypto.pcie.service.JnaPcieCryptoService - Mock fallback:
com.cisd.tms.integration.crypto.pcie.service.MockPcieCryptoService
OpenAPI Signature Rules
- Headers:
X-App-Id,X-Timestamp,X-Nonce,X-Signature - Canonical string:
appId + "\\n" + timestamp + "\\n" + nonce - Signature algorithm:
HMAC-SHA256with app secret, lowercase hex - Replay protection: nonce one-time in time window
Build And Test
mvn -q -DskipTests compile
mvn -q test
- CI is pinned to JDK 17 via
.github/workflows/ci.yml. - Maven Surefire preloads Mockito javaagent to avoid dynamic self-attach failures on newer JDKs.
Current Status
- Structure refactored to lightweight monolith modules.
- Internal and external API entry points separated.
- Basic auth interceptors for internal/openapi are in place.
init/auth/device/sign/systemmodules have runnable skeleton controllers and services.init/auth/devicemodules include mapper+xml+repository-impl+DDL skeleton for TiDB.
aeb6a4d (初始化项目)