JanssenProject / JanssenProject/jans
Janssen OpenID Federation Implementation
- Dominant language
- Java
- Stars
- 648
- Forks
- 174
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 110
Description
# OpenID Federation Provider Server Requirements
## Introduction
This document defines the requirements for a Java-based OpenID Federation Provider Server that implements the OpenID Federation 1.0 specification. The server serves as a trust anchor in a federation ecosystem, enabling entities to publish and manage entity statements, establish trust chains, and participate in federated identity networks.
The system supports both root trust anchors and intermediate trust anchors, providing a hierarchical trust model where intermediate trust anchors can be authorized by root trust anchors to manage subordinate entities within their domain. The server integrates with an RDBMS for persistent storage and provides comprehensive APIs for federation management, entity lifecycle operations, and telemetry data collection.
Key capabilities include:
- Entity statement publication and management
- Trust chain resolution and validation
- Trust mark issuance and validation
- Federation endpoint implementation per OpenID Federation 1.0
- Multi-tenant support for intermediate trust anchors
- Comprehensive telemetry and monitoring
- OAuth 2.0 protected administrative APIs
## Requirements
### Requirement 1: Federation Entity Configuration Endpoint
**User Story:** As a federation participant, I want to discover the federation entity configuration, so that I can obtain the entity statement and understand the federation's capabilities.
#### Acceptance Criteria
1. WHEN a client requests the federation entity configuration THEN the system SHALL provide the `/.well-known/openid_federation` endpoint that returns the federation entity's statement as a signed JWT
2. WHEN the entity statement is returned THEN it SHALL contain the `iss`, `sub`, `iat`, `exp`, `jwks`, `metadata`, `authority_hints`, and `trust_marks` claims as specified in OpenID Federation 1.0
3. WHEN the entity statement is signed THEN it SHALL use RS256, ES256, or PS256 algorithms with a valid key from the entity's JWK Set
4. WHEN the entity statement is published THEN it SHALL be accessible via HTTPS with proper caching headers (Cache-Control: max-age=3600)
5. WHEN the entity statement is requested THEN the system SHALL return the `application/entity-statement+jwt` content type
### Requirement 2: Subordinate Entity Statement Management
**User Story:** As a federation administrator, I want to publish and manage entity statements for subordinate entities, so that they can participate in the federation with proper authorization.
#### Acceptance Criteria
1. WHEN a subordinate entity statement is requested THEN the system SHALL provide the `/federation/fetch` endpoint to serve entity statements for subordinate entities
2. WHEN publishing a subordinate entity statement THEN the system SHALL sign it with the federation's private key and include the subordinate's metadata, constraints, and trust marks
3. WHEN a subordinate entity statement is created THEN it SHALL include proper `iss` (federation entity), `sub` (subordinate entity), and `aud` claims
4. WHEN managing subordinate entities THEN the system SHALL support entity types: `federation_entity`, `openid_relying_party`, `openid_provider`, `oauth_authorization_server`, `oauth_client`, and `oauth_protected_resource`
5. WHEN a subordinate entity statement is updated THEN the system SHALL invalidate cached versions and publish the new statement immediately
### Requirement 3: Subordinate Entity Listing
**User Story:** As a federation participant, I want to discover all subordinate entities managed by a federation, so that I can understand the federation's scope and capabilities.
#### Acceptance Criteria
1. WHEN subordinate entities are requested THEN the system SHALL provide the `/federation/list` endpoint to return a paginated list of subordinate entities
2. WHEN listing subordinate entities THEN the system SHALL support filtering by entity type, trust mark, and status
3. WHEN pagination is requested THEN the system SHALL support `page` and `per_page` parameters with a maximum of 100 entities per page
4. WHEN listing subordinate entities THEN the system SHALL return entity identifiers, types, and basic metadata for each entity
5. WHEN the listing response is returned THEN it SHALL include pagination metadata (total count, current page, total pages)
### Requirement 4: Entity Resolution and Trust Chain Validation
**User Story:** As a federation participant, I want to resolve entity statements and validate trust chains, so that I can verify the authenticity and authorization of other entities.
#### Acceptance Criteria
1. WHEN entity resolution is requested THEN the system SHALL provide the `/federation/resolve` endpoint to resolve trust chains and return resolved entity statements
2. WHEN resolving an entity THEN the system SHALL fetch and validate the complete trust chain from the requesting entity to the root trust anchor
3. WHEN validating a trust chain THEN the system SHALL verify all signatures, expiration times, and trust relationships in the chain
4. WHEN trust chain validation fails THEN the system SHALL return appropriate error codes and descriptions
5. WHEN resolving an entity THEN the system SHALL return the resolved metadata with all applicable policies and constraints applied
### Requirement 5: Trust Mark Management
**User Story:** As a federation administrator, I want to issue and manage trust marks, so that I can certify entities with specific capabilities or compliance requirements.
#### Acceptance Criteria
1. WHEN trust marks are requested THEN the system SHALL provide the `/federation/trust_mark` endpoint to issue trust marks as signed JWTs
2. WHEN issuing a trust mark THEN the system SHALL include the `iss`, `sub`, `iat`, `exp`, `id`, `mark`, and `ref` claims
3. WHEN trust mark status is queried THEN the system SHALL provide the `/federation/trust_mark_status` endpoint to check validity and status
4. WHEN trust marks are issued THEN the system SHALL support delegation through the `delegation` claim for intermediate trust anchors
5. WHEN trust marks are revoked THEN the system SHALL maintain a revocation list and update trust mark status accordingly
### Requirement 6: Trust Marked Entities Listing
**User Story:** As a federation participant, I want to discover entities that possess specific trust marks, so that I can identify entities with particular capabilities or certifications.
#### Acceptance Criteria
1. WHEN trust marked entities are requested THEN the system SHALL provide the `/federation/trust_marked_entities` endpoint to list entities with specific trust marks
2. WHEN listing trust marked entities THEN the system SHALL support filtering by trust mark ID, entity type, and status
3. WHEN trust marked entities are listed THEN the system SHALL return entity identifiers, trust mark details, and validity periods
4. WHEN pagination is requested THEN the system SHALL support the same pagination parameters as subordinate entity listing
5. WHEN trust marked entities are returned THEN the system SHALL include trust mark delegation information if applicable
### Requirement 7: Federation Historical Keys Management
**User Story:** As a federation administrator, I want to manage historical keys for key rollover scenarios, so that entities can validate signatures from previous key periods.
#### Acceptance Criteria
1. WHEN historical keys are requested THEN the system SHALL provide the `/federation/historical_keys` endpoint to serve historical JWK Sets
2. WHEN serving historical keys THEN the system SHALL include keys that were valid during the specified time period
3. WHEN historical keys are published THEN the system SHALL include key metadata such as `kid`, `use`, `alg`, and `exp` claims
4. WHEN key rollover occurs THEN the system SHALL maintain historical keys for a configurable period (default 30 days)
5. WHEN historical keys are returned THEN the system SHALL include revocation reasons for keys that were revoked
### Requirement 8: Database Integration and Configuration
**User Story:** As a system administrator, I want to configure the federation server with database connection parameters, so that entity data and federation state can be persisted reliably.
#### Acceptance Criteria
1. WHEN the system starts THEN it SHALL connect to the configured RDBMS using JDBC connection parameters
2. WHEN database configuration is provided THEN the system SHALL support connection pooling with configurable pool size and timeout settings
3. WHEN database operations fail THEN the system SHALL implement retry logic with exponential backoff
4. WHEN the database schema is initialized THEN the system SHALL create tables for entities, trust marks, trust chains, and audit logs
5. WHEN database transactions are performed THEN the system SHALL ensure ACID properties for all federation operations
#### Database Schema Requirements
**Entities Table:**
- `entity_id` (VARCHAR, PRIMARY KEY)
- `entity_type` (VARCHAR, NOT NULL)
- `metadata` (JSON, NOT NULL)
- `jwks` (JSON, NOT NULL)
- `constraints` (JSON)
- `trust_marks` (JSON)
- `created_at` (TIMESTAMP)
- `updated_at` (TIMESTAMP)
- `expires_at` (TIMESTAMP)
- `status` (VARCHAR, NOT NULL)
**Trust_Marks Table:**
- `trust_mark_id` (VARCHAR, PRIMARY KEY)
- `issuer` (VARCHAR, NOT NULL)
- `subject` (VARCHAR, NOT NULL)
- `mark` (VARCHAR)
- `ref` (VARCHAR)
- `delegation` (JSON)
- `issued_at` (TIMESTAMP)
- `expires_at` (TIMESTAMP)
- `status` (VARCHAR, NOT NULL)
**Trust_Chains Table:**
- `chain_id` (VARCHAR, PRIMARY KEY)
- `entity_id` (VARCHAR, NOT NULL)
- `trust_anchor` (VARCHAR, NOT NULL)
- `chain_data` (JSON, NOT NULL)
- `validated_at` (TIMESTAMP)
- `expires_at` (TIMESTAMP)
### Requirement 9: Configuration Management API
**User Story:** As a federation administrator, I want to configure federation settings through a REST API, so that I can manage the federation without direct database access.
#### Acceptance Criteria
1. WHEN federation configuration is requested THEN the system SHALL provide GET `/admin/config` endpoint to retrieve current configuration
2. WHEN federation configuration is updated THEN the system SHALL provide PUT `/admin/config` endpoint to update configuration settings
3. WHEN configuration is updated THEN the system SHALL validate all configuration parameters before applying changes
4. WHEN configuration changes are made THEN the system SHALL log all changes with timestamps and administrator identity
5. WHEN configuration is retrieved THEN the system SHALL return configuration in JSON format with proper structure
#### Configuration Parameters
**Federation Settings:**
- `federation_name` (String): Human-readable federation name
- `federation_identifier` (String): Unique federation identifier (HTTPS URL)
- `trust_anchor_type` (Enum): ROOT or INTERMEDIATE
- `parent_federation` (String): Parent federation identifier (for intermediate trust anchors)
- `signing_algorithm` (String): Default signing algorithm (RS256, ES256, PS256)
- `key_rotation_period` (Integer): Key rotation period in days
- `entity_statement_ttl` (Integer): Entity statement TTL in seconds
- `trust_mark_ttl` (Integer): Trust mark TTL in seconds
**Database Settings:**
- `database_url` (String): JDBC connection URL
- `database_username` (String): Database username
- `database_password` (String): Database password (encrypted)
- `connection_pool_size` (Integer): Connection pool size
- `connection_timeout` (Integer): Connection timeout in seconds
**Security Settings:**
- `jwt_issuer` (String): JWT issuer identifier
- `jwt_audience` (String): JWT audience identifier
- `admin_oauth_scopes` (Array): OAuth scopes for admin operations
- `entity_oauth_scopes` (Array): OAuth scopes for entity operations
### Requirement 10: Entity Lifecycle Management API
**User Story:** As a federation administrator, I want to manage entity lifecycle operations through a REST API, so that I can add, update, and remove entities from the federation.
#### Acceptance Criteria
1. WHEN an entity is created THEN the system SHALL provide POST `/admin/entities` endpoint to register new entities
2. WHEN an entity is updated THEN the system SHALL provide PUT `/admin/entities/{entity_id}` endpoint to update entity metadata
3. WHEN an entity is deleted THEN the system SHALL provide DELETE `/admin/entities/{entity_id}` endpoint to remove entities
4. WHEN entity operations are performed THEN the system SHALL validate entity metadata against federation policies
5. WHEN entity operations succeed THEN the system SHALL update entity statements and notify relevant parties
#### Entity Management Operations
**Create Entity:**
- Validate entity metadata structure
- Generate entity identifier
- Create entity statement
- Store in database
- Publish entity statement
**Update Entity:**
- Validate updated metadata
- Update entity statement
- Store changes in database
- Publish updated entity statement
- Invalidate caches
**Delete Entity:**
- Revoke entity statement
- Remove from database
- Update subordinate listings
- Notify federation participants
### Requirement 11: Trust Mark Management API
**User Story:** As a federation administrator, I want to issue, update, and revoke trust marks through a REST API, so that I can manage entity certifications and capabilities.
#### Acceptance Criteria
1. WHEN a trust mark is issued THEN the system SHALL provide POST `/admin/trust_marks` endpoint to create new trust marks
2. WHEN a trust mark is updated THEN the system SHALL provide PUT `/admin/trust_marks/{trust_mark_id}` endpoint to update trust mark properties
3. WHEN a trust mark is revoked THEN the system SHALL provide DELETE `/admin/trust_marks/{trust_mark_id}` endpoint to revoke trust marks
4. WHEN trust marks are managed THEN the system SHALL validate trust mark claims and delegation rules
5. WHEN trust marks are issued THEN the system SHALL sign them with the federation's private key
### Requirement 12: Intermediate Trust Anchor Support
**User Story:** As a federation administrator, I want to create and manage intermediate trust anchors, so that I can delegate authority to regional or organizational administrators.
#### Acceptance Criteria
1. WHEN an intermediate trust anchor is created THEN the system SHALL provide POST `/admin/intermediate_trust_anchors` endpoint to register intermediate trust anchors
2. WHEN an intermediate trust anchor is authorized THEN the system SHALL issue a trust mark with delegation capabilities
3. WHEN intermediate trust anchors operate THEN they SHALL be able to manage subordinate entities within their authorized scope
4. WHEN intermediate trust anchors are managed THEN the system SHALL track their authorization status and scope
5. WHEN intermediate trust anchors are revoked THEN the system SHALL revoke all subordinate entities and trust marks
#### Intermediate Trust Anchor Operations
**Create Intermediate Trust Anchor:**
- Validate intermediate trust anchor metadata
- Issue delegation trust mark
- Configure authorization scope
- Set up subordinate entity management
- Publish intermediate trust anchor entity statement
**Manage Subordinate Entities:**
- Delegate entity management to intermediate trust anchor
- Validate subordinate entity operations
- Maintain trust chain integrity
- Audit all subordinate operations
### Requirement 13: Telemetry and Monitoring API
**User Story:** As a monitoring service, I want to collect telemetry data from the federation server, so that I can monitor federation health and performance.
#### Acceptance Criteria
1. WHEN telemetry data is requested THEN the system SHALL provide GET `/telemetry/metrics` endpoint to return federation metrics
2. WHEN telemetry data is collected THEN the system SHALL include entity counts, request volumes, error rates, and performance metrics
3. WHEN telemetry data is exported THEN the system SHALL support multiple formats (JSON, Prometheus, OpenTelemetry)
4. WHEN telemetry data is accessed THEN the system SHALL require proper authentication and authorization
5. WHEN telemetry data is collected THEN the system SHALL include both real-time and historical metrics
#### Telemetry Data Points
**Federation Metrics:**
- Total entities by type
- Active trust chains
- Trust mark issuances and revocations
- Entity statement requests per endpoint
- Trust chain resolution success/failure rates
- Average response times per endpoint
**System Metrics:**
- Database connection pool utilization
- JVM memory and CPU usage
- Request throughput and latency
- Error rates by endpoint and error type
- Cache hit/miss ratios
**Security Metrics:**
- Failed authentication attempts
- Invalid signature validations
- Trust chain validation failures
- Suspicious activity patterns
- Key rotation events
### Requirement 14: OAuth 2.0 Protection for Administrative APIs
**User Story:** As a federation administrator, I want administrative APIs to be protected by OAuth 2.0, so that only authorized administrators can manage the federation.
#### Acceptance Criteria
1. WHEN administrative APIs are accessed THEN the system SHALL require valid OAuth 2.0 access tokens
2. WHEN access tokens are validated THEN the system SHALL verify token signature, expiration, and required scopes
3. WHEN administrative operations are performed THEN the system SHALL check for appropriate administrative scopes
4. WHEN token validation fails THEN the system SHALL return 401 Unauthorized with proper error details
5. WHEN scope validation fails THEN the system SHALL return 403 Forbidden with required scope information
#### OAuth Scopes
**Administrative Scopes:**
- `federation:admin` - Full administrative access
- `federation:entities:manage` - Entity lifecycle management
- `federation:trust_marks:manage` - Trust mark management
- `federation:config:manage` - Configuration management
- `federation:telemetry:read` - Telemetry data access
**Entity Scopes:**
- `federation:entity:read` - Read entity statements
- `federation:trust_chain:resolve` - Resolve trust chains
- `federation:trust_marks:read` - Read trust mark status
### Requirement 15: Key Material Management and Rotation
**User Story:** As a federation administrator, I want to manage cryptographic keys and implement key rotation, so that the federation can maintain security over time.
#### Acceptance Criteria
1. WHEN keys are generated THEN the system SHALL support RSA, EC, and EdDSA key types with appropriate key sizes
2. WHEN keys are stored THEN the system SHALL encrypt private keys using AES-256-GCM with a master key
3. WHEN key rotation occurs THEN the system SHALL support both manual and automatic key rotation
4. WHEN keys are rotated THEN the system SHALL maintain historical keys for a configurable period
5. WHEN keys are published THEN the system SHALL include proper key metadata (kid, use, alg, exp)
#### Key Management Operations
**Key Generation:**
- Generate new key pairs with appropriate algorithms
- Assign unique key identifiers (kid)
- Set key usage and algorithm parameters
- Encrypt and store private keys securely
**Key Rotation:**
- Generate new key pairs before expiration
- Update entity statements with new public keys
- Maintain historical keys for signature validation
- Notify federation participants of key changes
**Key Revocation:**
- Mark keys as revoked in the system
- Update revocation lists and status endpoints
- Remove keys from active JWK Sets
- Maintain revocation audit trail
### Requirement 16: Error Handling and Logging
**User Story:** As a federation administrator, I want comprehensive error handling and logging, so that I can troubleshoot issues and maintain federation health.
#### Acceptance Criteria
1. WHEN errors occur THEN the system SHALL return appropriate HTTP status codes and error messages
2. WHEN errors are logged THEN the system SHALL include request context, error details, and stack traces
3. WHEN federation errors occur THEN the system SHALL return OpenID Federation compliant error responses
4. WHEN errors are handled THEN the system SHALL not expose sensitive information in error messages
5. WHEN errors are logged THEN the system SHALL support structured logging with configurable log levels
#### Error Response Format
**Standard Error Response:**
```json
{
"error": "error_code",
"error_description": "Human readable error description",
"error_uri": "https://federation.example.com/errors/error_code",
"timestamp": "2024-01-01T00:00:00Z",
"trace_id": "unique-trace-identifier"
}
```
**Federation-Specific Errors:**
- `invalid_entity_statement` - Entity statement validation failed
- `trust_chain_invalid` - Trust chain validation failed
- `trust_mark_invalid` - Trust mark validation failed
- `entity_not_found` - Requested entity not found
- `insufficient_scope` - OAuth scope insufficient for operation
### Requirement 17: Performance and Scalability
**User Story:** As a federation administrator, I want the federation server to handle high loads and scale appropriately, so that it can serve large federations reliably.
#### Acceptance Criteria
1. WHEN the system is under load THEN it SHALL maintain response times under 500ms for 95% of requests
2. WHEN the system scales THEN it SHALL support horizontal scaling with load balancers
3. WHEN caching is implemented THEN the system SHALL cache entity statements and trust chains appropriately
4. WHEN the database is under load THEN the system SHALL implement connection pooling and query optimization
5. WHEN the system is monitored THEN it SHALL provide performance metrics and alerting capabilities
#### Performance Requirements
**Response Time Targets:**
- Entity statement requests: < 100ms (95th percentile)
- Trust chain resolution: < 500ms (95th percentile)
- Administrative operations: < 1s (95th percentile)
- Telemetry data collection: < 50ms (95th percentile)
**Scalability Targets:**
- Support 10,000+ entities per federation
- Handle 1,000+ requests per second
- Support 100+ concurrent administrative sessions
- Maintain 99.9% uptime
### Requirement 18: Security and Compliance
**User Story:** As a federation administrator, I want the federation server to implement security best practices and compliance requirements, so that the federation can be trusted by participants.
#### Acceptance Criteria
1. WHEN the system is deployed THEN it SHALL use TLS 1.3 for all communications
2. WHEN data is stored THEN the system SHALL encrypt sensitive data at rest
3. WHEN authentication occurs THEN the system SHALL implement proper session management
4. WHEN the system is audited THEN it SHALL maintain comprehensive audit logs
5. WHEN security incidents occur THEN the system SHALL implement incident response procedures
#### Security Requirements
**Transport Security:**
- TLS 1.3 with perfect forward secrecy
- HSTS headers for all endpoints
- Certificate pinning for critical operations
- Secure cipher suites only
**Data Protection:**
- AES-256-GCM encryption for sensitive data
- Secure key derivation functions
- Regular key rotation
- Secure deletion of revoked data
**Access Control:**
- OAuth 2.0 with PKCE for all APIs
- Role-based access control (RBAC)
- Principle of least privilege
- Regular access reviews
**Audit and Compliance:**
- Comprehensive audit logging
- Immutable audit trails
- Regular security assessments
- Compliance with relevant standards (SOC 2, ISO 27001)
## Implementation Notes
### Technology Stack Recommendations
- **Framework**: Spring Boot 3.x with Spring Security
- **Database**: PostgreSQL with connection pooling
- **Caching**: Redis for entity statement caching
- **Monitoring**: Micrometer with Prometheus/Grafana
- **Logging**: Logback with structured logging
- **Testing**: JUnit 5 with TestContainers for integration tests
### Deployment Considerations
- Container-based deployment with Docker/Kubernetes
- Health checks and readiness probes
- Graceful shutdown handling
- Blue-green deployment support
- Horizontal pod autoscaling
### Configuration Management
- Externalized configuration with Spring Cloud Config
- Environment-specific profiles
- Secret management with HashiCorp Vault
- Configuration validation on startup
- Hot reloading for non-critical settings
# OpenID Federation Provider Server Design
## Overview
The OpenID Federation Provider Server is a Java-based microservice that implements the OpenID Federation 1.0 specification, serving as a trust anchor in federated identity ecosystems. The system enables entities to publish and manage entity statements, establish trust chains, and participate in federated identity networks through a comprehensive set of REST APIs.
The architecture supports both root trust anchors and intermediate trust anchors, providing a hierarchical trust model where intermediate trust anchors can be authorized by root trust anchors to manage subordinate entities within their domain. The system integrates with PostgreSQL for persistent storage, Redis for caching, and provides comprehensive telemetry and monitoring capabilities.
### Key Design Principles
1. **Security First**: All communications use TLS 1.3, sensitive data is encrypted at rest, and comprehensive audit logging is maintained
2. **Scalability**: Horizontal scaling support with load balancers, connection pooling, and efficient caching strategies
3. **Reliability**: ACID database transactions, retry logic with exponential backoff, and graceful error handling
4. **Observability**: Comprehensive telemetry, structured logging, and performance monitoring
5. **Standards Compliance**: Full implementation of OpenID Federation 1.0 specification with proper error handling
## High-Level Architecture
```mermaid
graph TB
subgraph "External Clients"
FC[Federation Clients]
FA[Federation Administrators]
MS[Monitoring Services]
end
subgraph "Load Balancer"
LB[NGINX/HAProxy]
end
subgraph "Application Layer"
subgraph "Federation Server Instances"
FS1[Federation Server 1]
FS2[Federation Server 2]
FSN[Federation Server N]
end
subgraph "Core Services"
ES[Entity Service]
TMS[Trust Mark Service]
TCS[Trust Chain Service]
KS[Key Management Service]
CS[Configuration Service]
TS[Telemetry Service]
end
end
subgraph "Caching Layer"
RC[Redis Cluster]
end
subgraph "Data Layer"
PG[(PostgreSQL)]
VH[HashiCorp Vault]
end
subgraph "Monitoring"
PM[Prometheus]
GF[Grafana]
ELK[ELK Stack]
end
FC --> LB
FA --> LB
MS --> LB
LB --> FS1
LB --> FS2
LB --> FSN
FS1 --> ES
FS1 --> TMS
FS1 --> TCS
FS1 --> KS
FS1 --> CS
FS1 --> TS
ES --> RC
TMS --> RC
TCS --> RC
ES --> PG
TMS --> PG
TCS --> PG
KS --> VH
TS --> PM
PM --> GF
TS --> ELK
```
## Core Components
### 1. Federation Entity Configuration Service
**Purpose**: Serves the federation entity's own configuration and entity statement
**Key Responsibilities**:
- Publish federation entity statement at `/.well-known/openid_federation`
- Manage federation metadata and JWK Sets
- Handle entity statement signing and validation
- Implement proper caching headers
**Key Classes**:
- `FederationEntityRestWebService`: JAX-RS REST web service for entity configuration endpoints
- `EntityStatementService`: CDI `@ApplicationScoped` service for entity statement generation
- `JwtSigningService`: CDI `@ApplicationScoped` service for JWT signing and validation operations
- `FederationMetadataService`: CDI `@ApplicationScoped` service for federation metadata and configuration
### 2. Entity Management Service
**Purpose**: Manages subordinate entities and their entity statements
**Key Responsibilities**:
- CRUD operations for subordinate entities
- Entity statement generation and signing
- Entity metadata validation against federation policies
- Entity lifecycle management (create, update, delete, revoke)
**Key Classes**:
- `EntityRestWebService`: JAX-RS REST web service for entity management endpoints
- `EntityService`: CDI `@ApplicationScoped` service for entity operations
- `EntityValidatorService`: CDI `@ApplicationScoped` service for entity metadata validation
- `EntityStatementGeneratorService`: CDI `@ApplicationScoped` service for generating signed entity statements
- `EntityPersistenceService`: CDI `@ApplicationScoped` service for entity persistence
### 3. Trust Chain Resolution Service
**Purpose**: Resolves and validates trust chains between entities
**Key Responsibilities**:
- Fetch and validate complete trust chains
- Verify signatures and expiration times
- Apply federation policies and constraints
- Cache validated trust chains for performance
**Key Classes**:
- `TrustChainRestWebService`: JAX-RS REST web service for trust chain endpoints
- `TrustChainService`: CDI `@ApplicationScoped` service for trust chain resolution
- `TrustChainValidatorService`: CDI `@ApplicationScoped` service for trust chain integrity validation
- `TrustChainCacheService`: CDI `@ApplicationScoped` service for caching validated trust chains
- `TrustChainPersistenceService`: CDI `@ApplicationScoped` service for trust chain persistence
### 4. Trust Mark Management Service
**Purpose**: Issues, validates, and manages trust marks
**Key Responsibilities**:
- Issue trust marks as signed JWTs
- Validate trust mark signatures and claims
- Manage trust mark delegation for intermediate trust anchors
- Maintain trust mark revocation lists
**Key Classes**:
- `TrustMarkRestWebService`: JAX-RS REST web service for trust mark endpoints
- `TrustMarkService`: CDI `@ApplicationScoped` service for trust mark operations
- `TrustMarkIssuerService`: CDI `@ApplicationScoped` service for issuing and signing trust marks
- `TrustMarkValidatorService`: CDI `@ApplicationScoped` service for trust mark signature and claim validation
- `TrustMarkPersistenceService`: CDI `@ApplicationScoped` service for trust mark persistence
### 5. Key Management Service
**Purpose**: Manages cryptographic keys and implements key rotation
**Key Responsibilities**:
- Generate RSA, EC, and EdDSA key pairs
- Encrypt and securely store private keys
- Implement automatic and manual key rotation
- Maintain historical keys for signature validation
- Publish JWK Sets with proper metadata
**Key Classes**:
- `KeyManagementService`: CDI `@ApplicationScoped` service for core key management operations
- `KeyGeneratorService`: CDI `@ApplicationScoped` service for generating cryptographic key pairs
- `KeyEncryptionService`: CDI `@ApplicationScoped` service for encrypting/decrypting private keys
- `KeyRotationService`: CDI `@ApplicationScoped` service with scheduled tasks for automatic key rotation
- `JwkSetPublisherService`: CDI `@ApplicationScoped` service for publishing JWK Sets
### 6. Configuration Management Service
**Purpose**: Manages federation configuration and settings
**Key Responsibilities**:
- Provide REST API for configuration management
- Validate configuration parameters
- Support hot reloading for non-critical settings
- Integrate with external configuration services
**Key Classes**:
- `ConfigurationRestWebService`: JAX-RS REST web service for configuration endpoints
- `ConfigurationService`: CDI `@ApplicationScoped` service for configuration management
- `ConfigurationValidatorService`: CDI `@ApplicationScoped` service for configuration parameter validation
- `ConfigurationPersistenceService`: CDI `@ApplicationScoped` service for configuration persistence
### 7. Telemetry and Monitoring Service
**Purpose**: Collects and exports telemetry data for monitoring
**Key Responsibilities**:
- Collect federation and system metrics
- Export metrics in multiple formats (JSON, Prometheus, OpenTelemetry)
- Provide real-time and historical metrics
- Support alerting and monitoring integrations
**Key Classes**:
- `TelemetryRestWebService`: JAX-RS REST web service for telemetry endpoints
- `MetricsCollectorService`: CDI `@ApplicationScoped` service for collecting various metrics
- `MetricsExporterService`: CDI `@ApplicationScoped` service for exporting metrics in different formats
- `TelemetryPersistenceService`: CDI `@ApplicationScoped` service for telemetry data persistence
### 8. OAuth 2.0 Security Service
**Purpose**: Handles OAuth 2.0 authentication and authorization
**Key Responsibilities**:
- Validate OAuth 2.0 access tokens
- Enforce scope-based authorization
- Handle token introspection and validation
- Manage administrative and entity scopes
**Key Classes**:
- `SecurityConfiguration`: Jakarta Security configuration
- `TokenValidationService`: CDI `@ApplicationScoped` service for OAuth 2.0 token validation
- `ScopeAuthorizationService`: CDI `@ApplicationScoped` service for scope-based authorization
- `OAuth2AuthenticationFilter`: JAX-RS `ContainerRequestFilter` for authentication
## Jakarta EE and Weld Architecture Patterns (Jans Style)
### Package Structure (Following Jans Conventions)
**Base Package**: `io.jans.federation`
**Module Structure**:
- `model/` - Domain models and DTOs
- `persistence-model/` - JPA entities and persistence models
- `server/` - REST web services, services, and business logic
- `ws/rs/` - JAX-RS REST web services
- `service/` - Business logic services
- `auth/` - Authentication and authorization
- `audit/` - Audit logging
- `util/` - Utility classes
### CDI (Contexts and Dependency Injection) Patterns
**Service Layer Pattern (Jans Style)**:
- All business logic implemented as CDI services with `@ApplicationScoped` (default) or `@RequestScoped`
- Services named with "Service" suffix (e.g., `EntityStatementService`, `TrustChainService`)
- Services are injected using `@Inject` annotation
- Lifecycle management handled by CDI container
- Use `@PostConstruct` for initialization logic
**REST Web Service Layer Pattern (Jans Style)**:
- JAX-RS web services named with "RestWebService" suffix
- Web services handle HTTP requests and responses
- Web services delegate to CDI services for business logic
- Use `@Path`, `@GET`, `@POST`, `@PUT`, `@DELETE` annotations
- Use `@Produces` and `@Consumes` for content negotiation
**Persistence Service Pattern (Jans Style)**:
- Persistence services named with "PersistenceService" suffix
- Use `@PersistenceContext` for EntityManager injection
- Transaction management with `@Transactional`
- Separate persistence logic from business logic
### MicroProfile Integration
**Configuration Management**:
- Use `@ConfigProperty` for configuration injection
- Support for multiple configuration sources (properties files, environment variables, external services)
- Configuration validation and hot reloading
**Health and Metrics**:
- `@Health` annotations for health check endpoints
- `@Counted`, `@Timed`, `@Gauge` for metrics collection
- Automatic exposure of health and metrics endpoints
**Security Integration**:
- Jakarta Security for authentication and authorization
- OAuth 2.0 Resource Server configuration
- JWT token validation and scope-based authorization
### CDI Qualifiers and Events
**Qualifiers for Service Selection**:
- Use custom qualifiers to distinguish between different implementations
- Example: `@FederationEntity`, `@SubordinateEntity` for different entity types
**Event-Driven Architecture**:
- Use CDI events for loose coupling between components
- Entity lifecycle events (created, updated, deleted)
- Trust mark events (issued, revoked, expired)
## Data Model
### Core Entities
```mermaid
erDiagram
FEDERATION_ENTITY ||--o{ SUBORDINATE_ENTITY : manages
FEDERATION_ENTITY ||--o{ TRUST_MARK : issues
FEDERATION_ENTITY ||--o{ TRUST_CHAIN : anchors
SUBORDINATE_ENTITY ||--o{ TRUST_MARK : possesses
SUBORDINATE_ENTITY ||--o{ TRUST_CHAIN : participates_in
TRUST_MARK ||--o{ TRUST_MARK_DELEGATION : delegates
FEDERATION_ENTITY {
string entity_id PK
string entity_type
json metadata
json jwks
json constraints
json trust_marks
timestamp created_at
timestamp updated_at
timestamp expires_at
string status
}
SUBORDINATE_ENTITY {
string entity_id PK
string entity_type
json metadata
json jwks
json constraints
json trust_marks
string parent_federation
timestamp created_at
timestamp updated_at
timestamp expires_at
string status
}
TRUST_MARK {
string trust_mark_id PK
string issuer
string subject
string mark
string ref
json delegation
timestamp issued_at
timestamp expires_at
string status
}
TRUST_CHAIN {
string chain_id PK
string entity_id
string trust_anchor
json chain_data
timestamp validated_at
timestamp expires_at
}
TRUST_MARK_DELEGATION {
string delegation_id PK
string trust_mark_id
string delegator
string delegatee
json scope
timestamp created_at
timestamp expires_at
}
```
### Database Schema
**Federation_Entities Table**:
```sql
CREATE TABLE federation_entities (
entity_id VARCHAR(255) PRIMARY KEY,
entity_type VARCHAR(50) NOT NULL,
metadata JSONB NOT NULL,
jwks JSONB NOT NULL,
constraints JSONB,
trust_marks JSONB,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
expires_at TIMESTAMP,
status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE',
INDEX idx_entity_type (entity_type),
INDEX idx_status (status),
INDEX idx_expires_at (expires_at)
);
```
**Subordinate_Entities Table**:
```sql
CREATE TABLE subordinate_entities (
entity_id VARCHAR(255) PRIMARY KEY,
entity_type VARCHAR(50) NOT NULL,
metadata JSONB NOT NULL,
jwks JSONB NOT NULL,
constraints JSONB,
trust_marks JSONB,
parent_federation VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
expires_at TIMESTAMP,
status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE',
FOREIGN KEY (parent_federation) REFERENCES federation_entities(entity_id),
INDEX idx_entity_type (entity_type),
INDEX idx_parent_federation (parent_federation),
INDEX idx_status (status)
);
```
**Trust_Marks Table**:
```sql
CREATE TABLE trust_marks (
trust_mark_id VARCHAR(255) PRIMARY KEY,
issuer VARCHAR(255) NOT NULL,
subject VARCHAR(255) NOT NULL,
mark VARCHAR(255),
ref VARCHAR(255),
delegation JSONB,
issued_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
expires_at TIMESTAMP,
status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE',
INDEX idx_issuer (issuer),
INDEX idx_subject (subject),
INDEX idx_status (status),
INDEX idx_expires_at (expires_at)
);
```
**Trust_Chains Table**:
```sql
CREATE TABLE trust_chains (
chain_id VARCHAR(255) PRIMARY KEY,
entity_id VARCHAR(255) NOT NULL,
trust_anchor VARCHAR(255) NOT NULL,
chain_data JSONB NOT NULL,
validated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
expires_at TIMESTAMP,
INDEX idx_entity_id (entity_id),
INDEX idx_trust_anchor (trust_anchor),
INDEX idx_expires_at (expires_at)
);
```
## API Design
### Federation Endpoints (OpenID Federation 1.0)
**Entity Configuration**:
- `GET /.well-known/openid_federation` - Federation entity configuration
**Subordinate Entity Management**:
- `GET /federation/fetch` - Fetch subordinate entity statement
- `GET /federation/list` - List subordinate entities
**Trust Chain Resolution**:
- `GET /federation/resolve` - Resolve entity and trust chain
**Trust Mark Management**:
- `GET /federation/trust_mark` - Get trust mark
- `GET /federation/trust_mark_status` - Check trust mark status
- `GET /federation/trust_marked_entities` - List trust marked entities
**Historical Keys**:
- `GET /federation/historical_keys` - Get historical JWK Sets
### Administrative Endpoints (OAuth 2.0 Protected)
**Configuration Management**:
- `GET /admin/config` - Get federation configuration
- `PUT /admin/config` - Update federation configuration
**Entity Management**:
- `POST /admin/entities` - Create entity
- `GET /admin/entities/{entity_id}` - Get entity details
- `PUT /admin/entities/{entity_id}` - Update entity
- `DELETE /admin/entities/{entity_id}` - Delete entity
**Trust Mark Management**:
- `POST /admin/trust_marks` - Issue trust mark
- `GET /admin/trust_marks/{trust_mark_id}` - Get trust mark details
- `PUT /admin/trust_marks/{trust_mark_id}` - Update trust mark
- `DELETE /admin/trust_marks/{trust_mark_id}` - Revoke trust mark
**Intermediate Trust Anchor Management**:
- `POST /admin/intermediate_trust_anchors` - Create intermediate trust anchor
- `GET /admin/intermediate_trust_anchors` - List intermediate trust anchors
- `PUT /admin/intermediate_trust_anchors/{entity_id}` - Update intermediate trust anchor
- `DELETE /admin/intermediate_trust_anchors/{entity_id}` - Revoke intermediate trust anchor
### Telemetry Endpoints (OAuth 2.0 Protected)
**Metrics**:
- `GET /telemetry/metrics` - Get federation metrics
- `GET /telemetry/metrics/prometheus` - Get Prometheus format metrics
- `GET /telemetry/metrics/opentelemetry` - Get OpenTelemetry format metrics
## Security Architecture
### Authentication and Authorization
**OAuth 2.0 Scopes**:
- `federation:admin` - Full administrative access
- `federation:entities:manage` - Entity lifecycle management
- `federation:trust_marks:manage` - Trust mark management
- `federation:config:manage` - Configuration management
- `federation:telemetry:read` - Telemetry data access
- `federation:entity:read` - Read entity statements
- `federation:trust_chain:resolve` - Resolve trust chains
- `federation:trust_marks:read` - Read trust mark status
**Security Layers**:
1. **Transport Security**: TLS 1.3 with perfect forward secrecy
2. **Authentication**: OAuth 2.0 with PKCE
3. **Authorization**: Scope-based access control
4. **Data Protection**: AES-256-GCM encryption for sensitive data
5. **Audit Logging**: Comprehensive audit trails
### Key Management
**Key Types Supported**:
- RSA (2048, 3072, 4096 bits)
- EC (P-256, P-384, P-521)
- EdDSA (Ed25519, Ed448)
**Key Storage**:
- Private keys encrypted with AES-256-GCM
- Master key stored in HashiCorp Vault
- Key metadata stored in database
**Key Rotation**:
- Automatic rotation based on configurable period
- Manual rotation via administrative API
- Historical key maintenance for signature validation
- Graceful transition with overlapping key periods
## Performance and Scalability
### Caching Strategy
**Redis Caching**:
- Entity statements (TTL: 1 hour)
- Trust chains (TTL: 30 minutes)
- Trust mark status (TTL: 15 minutes)
- JWK Sets (TTL: 1 hour)
**Cache Invalidation**:
- Event-driven cache invalidation
- TTL-based expiration
- Manual cache clearing via admin API
### Database Optimization
**Connection Pooling**:
- HikariCP connection pool
- Configurable pool size and timeouts
- Connection health checks
**Query Optimization**:
- Proper indexing on frequently queried columns
- JSONB indexes for metadata queries
- Prepared statements for security and performance
**Partitioning**:
- Time-based partitioning for audit logs
- Entity type partitioning for large federations
### Horizontal Scaling
**Load Balancing**:
- Stateless application design
- Session affinity not required
- Health check endpoints for load balancer
**Database Scaling**:
- Read replicas for query distribution
- Connection pooling per instance
- Database connection routing
## Monitoring and Observability
### Metrics Collection
**Federation Metrics**:
- Entity counts by type
- Trust chain resolution success/failure rates
- Trust mark issuance and revocation counts
- Request volumes per endpoint
**System Metrics**:
- JVM memory and CPU usage
- Database connection pool utilization
- Cache hit/miss ratios
- Request latency percentiles
**Security Metrics**:
- Failed authentication attempts
- Invalid signature validations
- Trust chain validation failures
- Key rotation events
### Logging Strategy
**Structured Logging**:
- JSON format for machine parsing
- Correlation IDs for request tracing
- Log levels: ERROR, WARN, INFO, DEBUG, TRACE
**Log Aggregation**:
- ELK Stack (Elasticsearch, Logstash, Kibana)
- Centralized log collection
- Log retention policies
### Alerting
**Critical Alerts**:
- Service availability < 99.9%
- Database connection failures
- Key rotation failures
- Authentication failures > threshold
**Warning Alerts**:
- High memory usage
- Slow query performance
- Cache miss rate > threshold
- Trust chain validation failures
## Deployment Architecture
### Container Strategy
**Base Image**:
- OpenJDK 17 Alpine Linux
- Multi-stage Docker build
- Minimal attack surface
**Container Configuration**:
- Non-root user execution
- Resource limits and requests
- Health check probes
- Graceful shutdown handling
### Kubernetes Deployment
**Deployment Manifests**:
- Deployment with replica count
- Service for internal communication
- Ingress for external access
- ConfigMap for configuration
- Secret for sensitive data
**Scaling Configuration**:
- Horizontal Pod Autoscaler (HPA)
- Vertical Pod Autoscaler (VPA)
- Custom metrics for scaling
### Configuration Management
**External Configuration**:
- MicroProfile Config integration
- Environment-specific profiles
- Secret management with HashiCorp Vault
- Configuration validation on startup
**Configuration Sources**:
1. Application properties
2. Environment variables
3. External configuration service
4. Kubernetes ConfigMaps and Secrets
## Implementation Phases
### Phase 1: Core Federation Services (Weeks 1-4)
- Federation entity configuration endpoint
- Basic entity management
- Trust chain resolution
- Database schema and basic persistence
- OAuth 2.0 security implementation
### Phase 2: Trust Mark Management (Weeks 5-6)
- Trust mark issuance and validation
- Trust mark delegation support
- Trust mark status endpoints
- Trust marked entities listing
### Phase 3: Advanced Features (Weeks 7-8)
- Intermediate trust anchor support
- Key management and rotation
- Historical keys management
- Configuration management API
### Phase 4: Monitoring and Operations (Weeks 9-10)
- Telemetry and metrics collection
- Comprehensive logging
- Performance optimization
- Monitoring and alerting setup
### Phase 5: Testing and Deployment (Weeks 11-12)
- Integration testing
- Performance testing
- Security testing
- Production deployment preparation
## Technology Stack
### Core Framework
- **Jakarta EE 10**: Application framework
- **Weld (CDI)**: Dependency injection and context management
- **MicroProfile**: Microservices and cloud-native features
- **Jakarta Security**: OAuth 2.0 and security
- **Jakarta Persistence (JPA)**: Database access
- **Jakarta Caching**: Caching abstraction
### Database and Caching
- **PostgreSQL**: Primary database
- **Redis**: Caching layer
- **HikariCP**: Connection pooling
### Security and Key Management
- **JWT**: Entity statements and trust marks
- **HashiCorp Vault**: Secret management
- **Bouncy Castle**: Cryptographic operations
### Monitoring and Observability
- **MicroProfile Metrics**: Metrics collection
- **MicroProfile Health**: Health checks
- **MicroProfile OpenTracing**: Distributed tracing
- **Prometheus**: Metrics storage
- **Grafana**: Metrics visualization
- **ELK Stack**: Log aggregation
### Testing
- **TestNG**: Unit and integration testing
- **TestContainers**: Integration testing
- **Mockito**: Mocking framework
- **WireMock**: API mocking
### Build and Deployment
- **Maven**: Build tool
- **Docker**: Containerization
- **Kubernetes**: Orchestration
- **Helm**: Package management
## Risk Mitigation
### Security Risks
- **Key Compromise**: Regular key rotation, secure key storage
- **Data Breach**: Encryption at rest, access controls, audit logging
- **DDoS Attacks**: Rate limiting, load balancing, caching
### Operational Risks
- **Database Failures**: Connection pooling, retry logic, read replicas
- **Cache Failures**: Graceful degradation, cache warming
- **Service Outages**: Health checks, auto-scaling, redundancy
### Performance Risks
- **High Load**: Horizontal scaling, caching, database optimization
- **Slow Queries**: Query optimization, indexing, connection pooling
- **Memory Issues**: JVM tuning, garbage collection optimization
## Success Criteria
### Functional Requirements
- ✅ All OpenID Federation 1.0 endpoints implemented
- ✅ Complete entity lifecycle management
- ✅ Trust chain resolution and validation
- ✅ Trust mark issuance and management
- ✅ Intermediate trust anchor support
### Non-Functional Requirements
- ✅ Response times < 500ms for 95% of requests
- ✅ Support for 10,000+ entities per federation
- ✅ 99.9% uptime target
- ✅ Comprehensive security controls
- ✅ Full observability and monitoring
### Quality Requirements
- ✅ 90%+ test coverage
- ✅ Security vulnerability scanning
- ✅ Performance testing validation
- ✅ Documentation completeness
- ✅ Code quality standards compliance
Contributor guide
Assessment
This issue has not been assessed yet.