Compare commits
139 Commits
feat/serve
...
04cea1ca4b
| Author | SHA1 | Date | |
|---|---|---|---|
| 04cea1ca4b | |||
| 29108594d9 | |||
| 51c0f51738 | |||
| 816bbce9c6 | |||
| 5194d638ac | |||
| 6b3622b366 | |||
| 4f8fa9afd8 | |||
| 7a36316b7e | |||
| 68d9dbdcdf | |||
| 7f3d1afcb9 | |||
| 955ac57a1a | |||
| b8a96330c0 | |||
| 8f2744afc7 | |||
| c8ddfac8d0 | |||
| 1942d78155 | |||
| f361898ba4 | |||
| 7766e2ea25 | |||
| 63c60a91b2 | |||
| a5d2c477f6 | |||
| 3a71d57619 | |||
| 73b6c2712c | |||
| 200972c370 | |||
| 9f7519941a | |||
| 66e58b4a1a | |||
| de9d8c6f37 | |||
| 47f48ba12a | |||
| 60241c9c6d | |||
| 2a939b4cad | |||
| e89d471c6f | |||
| ece676fbcf | |||
| fac4ec28a4 | |||
| a3b11ed63f | |||
| 5627483589 | |||
| bf23e88cf8 | |||
| 9435561e78 | |||
| db1e91a3f6 | |||
| 0c664c0995 | |||
| 5db2f6f1e3 | |||
| a535e20b0e | |||
| bb35a68b1f | |||
| 715add7f51 | |||
| 621e22701a | |||
| 5ef32a2b0c | |||
| 54d16eb3b8 | |||
| ae3264253d | |||
| 4cbfe52d5b | |||
| 27c6b017cd | |||
| 8378c33465 | |||
| c7c4e1194d | |||
| 3b367eff7f | |||
| d0c3d79fbc | |||
| e81c7896a1 | |||
| 127e2b253e | |||
| 6d0b78072e | |||
| 3721ea9a1f | |||
| f86588551c | |||
| 0eaa9ff08f | |||
| ec79d7622e | |||
| f558d03bdf | |||
| db79053c62 | |||
| 85dd85aa92 | |||
| c7bc9fbcca | |||
| 1e8e5c96c4 | |||
| 61d04ca51a | |||
| af674a811d | |||
| 123889451f | |||
| 3b5075fe44 | |||
| 48302a374f | |||
| b2c245d6bd | |||
| e9c0ec139a | |||
| 819bdcfcfb | |||
| ad7686b7c2 | |||
| ade542ded0 | |||
| 01c1283622 | |||
| d969dbe843 | |||
| 41779a4f58 | |||
| bf739c1360 | |||
| 0f167d731e | |||
| 021d7cfe29 | |||
| e2322b41cd | |||
| 618451f0c1 | |||
| 96c7cd6e8a | |||
| 4047ba7c6b | |||
| 8386b85592 | |||
| 640f0b95fe | |||
| 181f7f4dec | |||
| 95961a296f | |||
| db613358d5 | |||
| 7a126050cf | |||
| 7081c5f64e | |||
| 12ec5b28fa | |||
| 925e60a45c | |||
| 897860b2bf | |||
| 8933cff558 | |||
| b0b9ba7212 | |||
| 33c75ea7e1 | |||
| 513efa0833 | |||
| 0c81d79a9b | |||
| 696cd1b623 | |||
| 2434f67627 | |||
| 776700b247 | |||
| 7a114f47a6 | |||
| ed44d841e7 | |||
| 4bd0cc2e94 | |||
| 8a4963472c | |||
| 4d3f72a3ed | |||
| 1ebd43e3b0 | |||
| 19aeda5aef | |||
| 940d129c11 | |||
| 44bbdbb835 | |||
| 223017006b | |||
| ad9250c7b1 | |||
| 5cc47ca9c7 | |||
| 156988403a | |||
| e960c02cd4 | |||
| a0e2492757 | |||
| 28f8b829e3 | |||
| d00c459124 | |||
| 287c14e114 | |||
| 212ba9d569 | |||
| 735f072dd1 | |||
| 48cfd3f416 | |||
| 0d2e43b2d6 | |||
| 5aaa37b8ec | |||
| 051a8ce211 | |||
| 519a8bf3f9 | |||
| a7d0b40e39 | |||
| 3dc9a180d3 | |||
| 4dba965c75 | |||
| 4d2538cc2c | |||
| d201eacc97 | |||
| 9daa671655 | |||
| 3fbf011fe3 | |||
| a815705fa4 | |||
| 6e44d0d4b5 | |||
| 42a853cb0d | |||
| b46c3c8ebe | |||
| 9f712a6b8c | |||
| 4449743105 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -370,3 +370,4 @@ FodyWeavers.xsd
|
|||||||
/EnvelopeGenerator.Server/EnvelopeGenerator.Server/publish-output
|
/EnvelopeGenerator.Server/EnvelopeGenerator.Server/publish-output
|
||||||
/EnvelopeGenerator.Server/EnvelopeGenerator.Server/tekh_softHSM_test.md
|
/EnvelopeGenerator.Server/EnvelopeGenerator.Server/tekh_softHSM_test.md
|
||||||
/ignore/EnvelopeGenerator.Form
|
/ignore/EnvelopeGenerator.Form
|
||||||
|
/EnvelopeGenerator.Server/EnvelopeGenerator.Server/appsettings.Secrets.json
|
||||||
|
|||||||
87
AGENTS.md
87
AGENTS.md
@@ -63,15 +63,45 @@ This section explains every markdown file in the repo: what it contains, why it
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Markdown Audit Snapshot (2026-10-05)
|
||||||
|
|
||||||
|
The following table summarizes repository markdown files by practical status: completed, partially complete, or removable candidates.
|
||||||
|
|
||||||
|
| File | Type | Status | Missing / Gap | Removal Recommendation |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `AGENTS.md` | Agent onboarding | Partially complete | Route/migration statements can drift from real code over time. | Keep |
|
||||||
|
| `COPILOT_CONTEXT.md` | Architecture reference | Partially complete | Some route/render details may be out of sync with other docs; needs regular reconciliation. | Keep |
|
||||||
|
| `FORM_APPLICATION_CONTEXT.md` | Legacy-to-modern feature spec | Partially complete | Large sections still marked not implemented / needs implementation. | Keep |
|
||||||
|
| `RECEIVER_PDF_VIEWER_CONTEXT.md` | Receiver PDF viewer deep-dive | Partially complete | Long migration plan needs periodic sync with active implementation. | Keep |
|
||||||
|
| `SENDER_SAVE_EDIT_MIGRATION_PLAN.md` | Sender workflow implementation plan | Partially complete | No explicit implementation progress markers per phase. | Keep (until migration closes) |
|
||||||
|
| `SENDER_PDF_TOOLBAR_PLAN_EN.md` | Sender PDF toolbar plan | Incomplete | Explicit pending item remains (`Toolbar visual polish`). | Keep (until done) |
|
||||||
|
| `SENDER_EDITOR_WASM_PDF_EDITOR_IMPLEMENTATION_PLAN_en.md` | Sender editor WASM migration plan | Incomplete | Plan exists but completion/progress tracking is minimal. | Keep (until done) |
|
||||||
|
| `EnvelopeGenerator.Server/EnvelopeGenerator.Server/README.md` | Deployment guide | Complete (operational) | No critical gap identified. | Keep |
|
||||||
|
| `envelope-generator-ui/README.md` | Angular scaffold README | Complete but generic | Template text only; low project-specific value. | Removable or replace with project-specific summary |
|
||||||
|
| `EnvelopeGenerator.Web/wwwroot/lib/typed.js@2.1.0/README.md` | Third-party vendor README | Complete (vendor) | Not project workflow documentation. | Keep with vendor assets |
|
||||||
|
| `EnvelopeGenerator.Web/wwwroot/lib/jquery-validation/LICENSE.md` | Third-party license | Complete (legal) | No gap. | Keep |
|
||||||
|
| `EnvelopeGenerator.Server/EnvelopeGenerator.Server/wwwroot/css/open-iconic/README.md` | Third-party vendor README | Complete (vendor) | Not project-specific guidance. | Keep with vendor assets |
|
||||||
|
| `ignore/EnvelopeGenerator/EnvelopeGenerator.Web/wwwroot/README.md` | Legacy PSPDFKit note | Outdated | Mentions deprecated PSPDFKit-based flow; may mislead if reused. | Removable/archive |
|
||||||
|
| `ignore/EnvelopeGenerator/EnvelopeGenerator.Web/wwwroot/lib/typed.js@2.1.0/README.md` | Duplicate vendor README | Redundant | Duplicate copy under `ignore/`. | Removable/archive |
|
||||||
|
| `ignore/EnvelopeGenerator/EnvelopeGenerator.Web/wwwroot/lib/bootstrap-icons/README.md` | Vendor README in archive area | Secondary | Archive-only utility, not active docs. | Removable/archive |
|
||||||
|
| `ignore/EnvelopeGenerator/EnvelopeGenerator.Web/wwwroot/lib/jquery-validation/LICENSE.md` | Duplicate license in archive area | Redundant | Duplicate copy under `ignore/`. | Removable/archive (if legal policy allows) |
|
||||||
|
| `ignore/EnvelopeGenerator/EnvelopeGenerator.GeneratorAPI/ClientApp/envelope-generator-ui/README.md` | Duplicate Angular scaffold README | Redundant | Generic template + duplicate in archive path. | Removable/archive |
|
||||||
|
|
||||||
|
### Documentation Audit TODO
|
||||||
|
|
||||||
|
- [ ] Validate this markdown audit table against the current codebase and update statuses (`complete`, `partial`, `incomplete`, `removable`) when implementation changes land.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Active Architecture (Post-Migration)
|
## Active Architecture (Post-Migration)
|
||||||
|
|
||||||
**Frontend:** Blazor Auto (Server+WASM hybrid)
|
**Frontend:** Blazor Auto (Server+WASM hybrid)
|
||||||
- **EnvelopeGenerator.Server** (Server): `@rendermode InteractiveServer` - PDF viewers requiring DevExpress backend
|
- **EnvelopeGenerator.Server** (Server): `@rendermode InteractiveServer` - PDF viewers requiring DevExpress backend
|
||||||
- **EnvelopeGenerator.Server.Client** (WASM): `@rendermode InteractiveWebAssembly` - Login, dashboards, business logic
|
- **EnvelopeGenerator.Server.Client** (WASM): `@rendermode InteractiveWebAssembly` - Login, dashboards, business logic
|
||||||
|
|
||||||
**Backend:** EnvelopeGenerator.API (ASP.NET Core 8.0)
|
**Backend + API Host:** `EnvelopeGenerator.Server` (ASP.NET Core 8.0, merged Blazor + Web API host)
|
||||||
|
|
||||||
**Proxy:** YARP in EnvelopeGenerator.Server routes `/api/*` → `localhost:8088` (API)
|
**Proxy:** YARP in `EnvelopeGenerator.Server` is used for external integrations (for example AuthHub forwarding), not for routing app APIs to `EnvelopeGenerator.API`.
|
||||||
|
|
||||||
### Deprecated Projects - DO NOT USE
|
### Deprecated Projects - DO NOT USE
|
||||||
- `EnvelopeGenerator.ReceiverUI` - Pure WASM (migrated to Server)
|
- `EnvelopeGenerator.ReceiverUI` - Pure WASM (migrated to Server)
|
||||||
@@ -80,18 +110,14 @@ This section explains every markdown file in the repo: what it contains, why it
|
|||||||
|
|
||||||
## Development Commands
|
## Development Commands
|
||||||
|
|
||||||
### Run Both Projects (Required)
|
### Run Active Host
|
||||||
```powershell
|
```powershell
|
||||||
# Terminal 1 - API Backend
|
# Terminal - Blazor + Web API host
|
||||||
cd EnvelopeGenerator.API
|
|
||||||
dotnet run
|
|
||||||
|
|
||||||
# Terminal 2 - Blazor Frontend
|
|
||||||
cd EnvelopeGenerator.Server\EnvelopeGenerator.Server
|
cd EnvelopeGenerator.Server\EnvelopeGenerator.Server
|
||||||
dotnet run
|
dotnet run
|
||||||
```
|
```
|
||||||
|
|
||||||
**Critical:** Both must run simultaneously. EnvelopeGenerator.Server proxy forwards `/api/*` to API.
|
**Critical:** `EnvelopeGenerator.Server` is the active runtime host for both UI and API controllers.
|
||||||
|
|
||||||
### Build
|
### Build
|
||||||
```powershell
|
```powershell
|
||||||
@@ -104,10 +130,10 @@ dotnet build EnvelopeGenerator.sln
|
|||||||
EnvelopeGenerator.Domain/ # Entities (Envelope, Receiver, Document, etc.)
|
EnvelopeGenerator.Domain/ # Entities (Envelope, Receiver, Document, etc.)
|
||||||
EnvelopeGenerator.Application/ # MediatR CQRS (Commands, Queries, Handlers)
|
EnvelopeGenerator.Application/ # MediatR CQRS (Commands, Queries, Handlers)
|
||||||
EnvelopeGenerator.Infrastructure/ # EF Core, SQL executors, repositories
|
EnvelopeGenerator.Infrastructure/ # EF Core, SQL executors, repositories
|
||||||
EnvelopeGenerator.API/ # Controllers, endpoints
|
|
||||||
EnvelopeGenerator.Server/
|
EnvelopeGenerator.Server/
|
||||||
EnvelopeGenerator.Server/ # Server-side Blazor components
|
EnvelopeGenerator.Server/ # Server-side Blazor + API controllers
|
||||||
├─ Components/Pages/ # @rendermode InteractiveServer
|
├─ Components/Pages/ # @rendermode InteractiveServer
|
||||||
|
├─ Controllers/ # Active Web API endpoints
|
||||||
EnvelopeGenerator.Server.Client/ # Client-side WASM components
|
EnvelopeGenerator.Server.Client/ # Client-side WASM components
|
||||||
├─ Pages/ # @rendermode InteractiveWebAssembly
|
├─ Pages/ # @rendermode InteractiveWebAssembly
|
||||||
├─ Services/ # HTTP API clients
|
├─ Services/ # HTTP API clients
|
||||||
@@ -156,15 +182,13 @@ float inches = (pixelX / canvasWidth) * pageWidthInches;
|
|||||||
- **Use case:** External API consumers
|
- **Use case:** External API consumers
|
||||||
- **Not suitable for:** Step-by-step UI workflow (no draft support, no partial updates)
|
- **Not suitable for:** Step-by-step UI workflow (no draft support, no partial updates)
|
||||||
|
|
||||||
### Missing Granular Endpoints (Need to Create)
|
### Sender Workflow Endpoint
|
||||||
```
|
```
|
||||||
POST /api/Envelope/draft # Create draft envelope
|
POST /api/Envelope # Create/update/save/send envelope workflow payload
|
||||||
PUT /api/Envelope/{id} # Update metadata
|
|
||||||
DELETE /api/Envelope/{id} # Delete with reason
|
DELETE /api/Envelope/{id} # Delete with reason
|
||||||
POST /api/Envelope/{id}/document # Upload PDF
|
POST /api/Envelope/{id}/document # Upload PDF
|
||||||
POST /api/Envelope/{id}/receivers # Add receiver
|
POST /api/Envelope/{id}/receivers # Add receiver
|
||||||
POST /api/Envelope/{id}/signature-fields # Place signature field
|
POST /api/Envelope/{id}/signature-fields # Place signature field
|
||||||
POST /api/Envelope/{id}/send # Send to receivers
|
|
||||||
```
|
```
|
||||||
|
|
||||||
See `FORM_APPLICATION_CONTEXT.md` for detailed workflow requirements.
|
See `FORM_APPLICATION_CONTEXT.md` for detailed workflow requirements.
|
||||||
@@ -199,7 +223,7 @@ Routes `/api/*`, `/swagger/*`, `/openapi/*`, `/scalar/*` → `https://localhost:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### API Config (`API/appsettings.json`)
|
### Server Host Config (`EnvelopeGenerator.Server/EnvelopeGenerator.Server/appsettings.json`)
|
||||||
- `ConnectionStrings:Default` - SQL Server DB
|
- `ConnectionStrings:Default` - SQL Server DB
|
||||||
- `AllowedOrigins` - CORS (includes `http://localhost:5131`, `http://localhost:7192`)
|
- `AllowedOrigins` - CORS (includes `http://localhost:5131`, `http://localhost:7192`)
|
||||||
- `Cache:SignatureCacheExpiration` - Signature persistence timeout
|
- `Cache:SignatureCacheExpiration` - Signature persistence timeout
|
||||||
@@ -237,16 +261,32 @@ Routes `/api/*`, `/swagger/*`, `/openapi/*`, `/scalar/*` → `https://localhost:
|
|||||||
**No automated tests exist yet.**
|
**No automated tests exist yet.**
|
||||||
|
|
||||||
Manual testing workflow:
|
Manual testing workflow:
|
||||||
1. Start API (`dotnet run` in `EnvelopeGenerator.API`)
|
1. Start EnvelopeGenerator.Server (`dotnet run` in `EnvelopeGenerator.Server\EnvelopeGenerator.Server`)
|
||||||
2. Start EnvelopeGenerator.Server (`dotnet run` in `EnvelopeGenerator.Server\EnvelopeGenerator.Server`)
|
2. Navigate to `https://localhost:5131` (or check console output for port)
|
||||||
3. Navigate to `https://localhost:5131` (or check console output for port)
|
3. Test sender login at `/sender/login`
|
||||||
4. Test sender login at `/sender/login`
|
4. Test receiver flow at `/envelope/login/{envelopeKey}`
|
||||||
5. Test receiver flow at `/envelope/login/{envelopeKey}`
|
|
||||||
|
## Technical Debt TODOs
|
||||||
|
|
||||||
|
- Refactor `EnvelopeGenerator.Server/EnvelopeGenerator.Server/Components/Pages/EnvelopeSenderPage.razor` to reduce complexity.
|
||||||
|
- Move sender dashboard business/status logic into dedicated services and extension methods (for example effective status resolution, tab classification, receiver signed/rejected detection, and grid-layout filter sanitation).
|
||||||
|
- Keep `EnvelopeSenderPage.razor` focused on UI composition/state orchestration; avoid embedding heavy domain logic directly in the Razor component.
|
||||||
|
- Apply a modular page architecture across Server pages (starting with `EnvelopeGenerator.Server/EnvelopeGenerator.Server/Components/Pages/EnvelopeSenderPage.razor`): split large pages into smaller subcomponents/partial modules, eliminate duplicated code paths, and centralize shared UI/domain logic for maintainability.
|
||||||
|
- Perform a senior-level page performance review across sender/receiver flows before further UX changes: verify route transitions, component mount/unmount behavior, loading-state correctness, duplicate API calls, and perceived latency (first meaningful paint and return-navigation responsiveness). Treat loading logic defects as architecture/performance issues first, not styling problems.
|
||||||
|
- Audit `EnvelopeGenerator.Server/EnvelopeGenerator.Server.Client/Services/` for unnecessary request/payload remapping and remove redundant mappings where direct request DTO usage is safe; review client HTTP methods end-to-end for similar avoidable transformation layers.
|
||||||
|
- Centralize dependency injection registrations into dedicated extension methods/modules (especially server + client service registrations in `Program.cs`) to reduce startup composition sprawl and improve maintainability.
|
||||||
|
- Refactor `EnvelopeGenerator.Server/EnvelopeGenerator.Server/Controllers/PdfRenderController.cs` + matching client service contract to remove JSON/base64 `byte[]` transport for PDF rendering; prefer binary streaming (`application/octet-stream` or multipart), avoid `data:` URL bloat where possible, and validate end-to-end memory/latency behavior with large PDFs.
|
||||||
|
- Establish a DevExpress toast-based notification architecture using `DxToastProvider` + `IToastNotificationService` (tab/page-scoped provider strategy, standardized `ToastOptions` factory, and severity-to-style mapping) so sender/receiver flows show consistent, non-duplicated, actionable feedback.
|
||||||
|
- Eliminate manual property-by-property request→domain mapping drift (example: `CreateEnvelopeCommandHandler`) by introducing a standardized mapping policy (AutoMapper/profile conventions or reflection/source-generator based mapper) and enforcing it across envelope workflows; this needs to be solved in the shared company Core library level so all services get the same guardrails by default.
|
||||||
|
- P1 security workstream: remove dynamic SQL string composition/interpolation from active save/create/update paths (`string.Format`, `$"...{input}..."`, `ToSqlParam`) and migrate to parameterized queries only; treat this as a potential SQL injection vulnerability (stability + security risk), execute repo-wide audit, and add CI guardrails to block reintroduction.
|
||||||
|
- Alternative UX design (Server component): in `EnvelopeGenerator.Server/EnvelopeGenerator.Server/Components/Pages/EnvelopeSenderPage.razor`, enforce deterministic row double-click behavior as exactly one action (preview OR edit), and keep row action buttons/tooltips aligned with the same rule to eliminate ambiguous navigation.
|
||||||
|
- Implement SPA-style language switching so the UI culture updates immediately without a full page reload.
|
||||||
|
- Implement sender-scoped caching for "recent receiver suggestions" used during envelope creation (wizard/editor flows): cache key should include sender identity, support short TTL + invalidation hooks after successful envelope receiver writes, and prevent cross-sender suggestion leakage.
|
||||||
|
|
||||||
## Database
|
## Database
|
||||||
|
|
||||||
**SQL Server** (DD_ECM)
|
**SQL Server** (DD_ECM)
|
||||||
- Connection string in `API/appsettings.json`
|
- Connection string in `EnvelopeGenerator.Server/EnvelopeGenerator.Server/appsettings.json`
|
||||||
- EF Core migrations NOT used (manual SQL scripts)
|
- EF Core migrations NOT used (manual SQL scripts)
|
||||||
- Stored procedures: `PRSIG_*` prefix
|
- Stored procedures: `PRSIG_*` prefix
|
||||||
|
|
||||||
@@ -320,5 +360,4 @@ Each envelope maintains independent authentication state.
|
|||||||
None required. All config in `appsettings.json`.
|
None required. All config in `appsettings.json`.
|
||||||
|
|
||||||
**Local dev ports:**
|
**Local dev ports:**
|
||||||
- API: `https://localhost:8088`
|
- App host (UI + API): `https://localhost:5131` or `http://localhost:7192`
|
||||||
- WebUI: `https://localhost:5131` or `http://localhost:7192`
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ This project contains:
|
|||||||
- `EnvelopeGenerator.Domain` — domain models, constants, shared abstractions
|
- `EnvelopeGenerator.Domain` — domain models, constants, shared abstractions
|
||||||
- `EnvelopeGenerator.Infrastructure` — EF Core and infrastructure services
|
- `EnvelopeGenerator.Infrastructure` — EF Core and infrastructure services
|
||||||
- `EnvelopeGenerator.PdfEditor` — PDF-related backend utilities
|
- `EnvelopeGenerator.PdfEditor` — PDF-related backend utilities
|
||||||
- `EnvelopeGenerator.API` — still exists in the solution, but the current merged app host is `EnvelopeGenerator.Server`
|
- `EnvelopeGenerator.API` — deprecated project (no longer part of the active solution/runtime path)
|
||||||
|
|
||||||
### Legacy / Do Not Touch
|
### Legacy / Do Not Touch
|
||||||
- `EnvelopeGenerator.Service`
|
- `EnvelopeGenerator.Service`
|
||||||
@@ -121,7 +121,7 @@ Current controller set includes:
|
|||||||
- `SignatureController`
|
- `SignatureController`
|
||||||
- `TfaRegistrationController`
|
- `TfaRegistrationController`
|
||||||
|
|
||||||
Do not assume API behavior lives only in `EnvelopeGenerator.API`; the active merged host contains controller endpoints directly.
|
Do not assume API behavior lives in `EnvelopeGenerator.API`; the active merged host contains controller endpoints directly.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
using DigitalData.Core.Exceptions;
|
||||||
|
using FluentValidation;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Common.Behaviors;
|
||||||
|
|
||||||
|
public class ValidationBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
|
||||||
|
where TRequest : notnull
|
||||||
|
{
|
||||||
|
private readonly IEnumerable<IValidator<TRequest>> _validators;
|
||||||
|
|
||||||
|
public ValidationBehavior(IEnumerable<IValidator<TRequest>> validators)
|
||||||
|
{
|
||||||
|
_validators = validators;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TResponse> Handle(
|
||||||
|
TRequest request,
|
||||||
|
RequestHandlerDelegate<TResponse> next,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (_validators.Any())
|
||||||
|
{
|
||||||
|
var context = new ValidationContext<TRequest>(request);
|
||||||
|
var failures = _validators
|
||||||
|
.Select(v => v.Validate(context))
|
||||||
|
.SelectMany(r => r.Errors)
|
||||||
|
.Where(f => f is not null)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (failures.Count > 0)
|
||||||
|
{
|
||||||
|
var message = string.Join("; ", failures.Select(f => f.ErrorMessage).Distinct());
|
||||||
|
throw new BadRequestException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return await next();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Enums;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Common.Configurations;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents PKCS#11 signing configuration for PDF signing workflows.
|
||||||
|
/// This options model maps to the <c>Crypt:Pkcs11</c> configuration section.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Pkcs11Options
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration section path used for binding PKCS#11 options.
|
||||||
|
/// </summary>
|
||||||
|
public const string SectionName = "Crypt:Pkcs11";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional base directory that contains the <c>pkcs11</c> folder.
|
||||||
|
/// If null/empty, runtime uses the application base directory.
|
||||||
|
/// </summary>
|
||||||
|
public string? AssetsRootPath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional numeric slot identifier used to directly select the target token slot.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? SlotId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional token label used as a fallback token selector when <see cref="SlotId"/> is not provided.
|
||||||
|
/// </summary>
|
||||||
|
public string? TokenLabel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional PKCS#11 proxy endpoint (for example <c>tcp://host:port</c>).
|
||||||
|
/// </summary>
|
||||||
|
public string? ProxySocket { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolved absolute PKCS#11 proxy module path used at runtime.
|
||||||
|
/// Computed from <see cref="AssetsRootPath"/> and runtime defaults.
|
||||||
|
/// </summary>
|
||||||
|
public string ResolvedLibraryPath { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolved absolute pkcs11-tool path used at runtime.
|
||||||
|
/// Computed from <see cref="AssetsRootPath"/> and runtime defaults.
|
||||||
|
/// Can be null when tool fallback is not available.
|
||||||
|
/// </summary>
|
||||||
|
public string? ResolvedToolPath { get; private set; }
|
||||||
|
|
||||||
|
public void SetResolvedPaths(string resolvedLibraryPath, string? resolvedToolPath)
|
||||||
|
{
|
||||||
|
ResolvedLibraryPath = resolvedLibraryPath;
|
||||||
|
ResolvedToolPath = resolvedToolPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User PIN used to authenticate to the PKCS#11 token session.
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
[MinLength(1)]
|
||||||
|
public required string UserPin { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Label of the private key object used to create digital signatures.
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
[MinLength(1)]
|
||||||
|
public required string PrivateKeyLabel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Label of the certificate object returned/embedded with the signature.
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
[MinLength(1)]
|
||||||
|
public required string CertificateLabel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional global default signing reason used when request-level options do not specify a value.
|
||||||
|
/// </summary>
|
||||||
|
public string? DefaultReason { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Application name embedded into PDF signature metadata.
|
||||||
|
/// This value is controlled via app settings and is not client-overridable.
|
||||||
|
/// </summary>
|
||||||
|
public string? ApplicationName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controls how fallback signing time is created when request-level options do not specify a value.
|
||||||
|
/// <c>true</c> uses <see cref="DateTimeOffset.UtcNow"/>, <c>false</c> uses <see cref="DateTimeOffset.Now"/>.
|
||||||
|
/// </summary>
|
||||||
|
public bool UseUtcSigningTime { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optional global default certification level used when request-level options do not specify a value.
|
||||||
|
/// </summary>
|
||||||
|
public PdfSignatureCertificationLevel? DefaultCertificationLevel { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data Transfer Object representing document metadata and elements without binary payload.
|
||||||
|
/// </summary>
|
||||||
|
public record DocumentDetailsDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the unique identifier of the document.
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the envelope ID to which the document belongs.
|
||||||
|
/// </summary>
|
||||||
|
public int EnvelopeId { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the date and time when the document was added.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime AddedWhen { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the collection of elements associated with the document for receiver interactions, if any.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<DocReceiverElementDto>? Elements { get; init; }
|
||||||
|
}
|
||||||
@@ -3,30 +3,25 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Data Transfer Object representing a document within an envelope, including optional binary data and form elements.
|
/// Data Transfer Object representing a document within an envelope, including optional binary data and form elements.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DocumentDto
|
public record DocumentDto : DocumentDetailsDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the unique identifier of the document.
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public DocumentDto() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the envelope ID to which the document belongs.
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int EnvelopeId { get; set; }
|
/// <param name="byteData"></param>
|
||||||
|
/// <param name="details"></param>
|
||||||
/// <summary>
|
public DocumentDto(byte[] byteData, DocumentDetailsDto details) : base(details)
|
||||||
/// Gets or sets the date and time when the document was added.
|
{
|
||||||
/// </summary>
|
ByteData = byteData;
|
||||||
public DateTime AddedWhen { get; set; }
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the binary data of the document, if available.
|
/// Gets or sets the binary data of the document, if available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte[]? ByteData { get; set; }
|
public byte[]? ByteData { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the collection of elements associated with the document for receiver interactions, if any.
|
|
||||||
/// </summary>
|
|
||||||
public IEnumerable<DocReceiverElementDto>? Elements { get; set; }
|
|
||||||
}
|
}
|
||||||
@@ -86,6 +86,41 @@ public record EnvelopeDto : IEnvelope
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int? CertificationType { get; set; }
|
public int? CertificationType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int? FinalEmailToCreator { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int? FinalEmailToReceivers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public bool? SendReminderEmails { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int? FirstReminderDays { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int? ReminderIntervalDays { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int? ExpiresWhenDays { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int? ExpiresWarningWhenDays { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -60,6 +60,11 @@ public record EnvelopeReceiverDto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? PrivateMessage { get; init; }
|
public string? PrivateMessage { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string? AccessCode { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
16
EnvelopeGenerator.Application/Common/Dto/PdfPageImageDto.cs
Normal file
16
EnvelopeGenerator.Application/Common/Dto/PdfPageImageDto.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
|
public sealed class PdfPageImageDto
|
||||||
|
{
|
||||||
|
public int PageNumber { get; init; }
|
||||||
|
|
||||||
|
public double WidthPt { get; init; }
|
||||||
|
|
||||||
|
public double HeightPt { get; init; }
|
||||||
|
|
||||||
|
public int WidthPx { get; init; }
|
||||||
|
|
||||||
|
public int HeightPx { get; init; }
|
||||||
|
|
||||||
|
public string ImageDataUrl { get; init; } = string.Empty;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
|
public sealed class PdfRenderRequestDto
|
||||||
|
{
|
||||||
|
public byte[]? PdfBytes { get; init; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Enums;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
|
public sealed record PdfSignOptionsDto
|
||||||
|
{
|
||||||
|
public string? UUID { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? Reason { get; set; }
|
||||||
|
public string? Location { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public string? Phone { get; set; }
|
||||||
|
public string? ApplicationName { get; set; }
|
||||||
|
public PdfSignatureCertificationLevel? CertificationLevel { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
|
public sealed record PdfSignaturePrincipalDto(
|
||||||
|
string? CommonName,
|
||||||
|
string? Organization,
|
||||||
|
string? Country,
|
||||||
|
string? Full);
|
||||||
|
|
||||||
|
public sealed record PdfSignatureCertificateInfoDto(
|
||||||
|
PdfSignaturePrincipalDto IssuedTo,
|
||||||
|
PdfSignaturePrincipalDto IssuedBy,
|
||||||
|
string? SerialNumber,
|
||||||
|
DateTimeOffset? ValidFrom,
|
||||||
|
DateTimeOffset? ValidTo,
|
||||||
|
bool SelfSigned,
|
||||||
|
bool Expired,
|
||||||
|
bool NotYetValid,
|
||||||
|
bool IsSigner,
|
||||||
|
int? Version,
|
||||||
|
string? KeyAlgorithm,
|
||||||
|
string? SignatureAlgorithm,
|
||||||
|
string? Pem,
|
||||||
|
int? KeySizeBits);
|
||||||
|
|
||||||
|
public sealed record PdfSignatureCheckItemDto(
|
||||||
|
bool CoversWholeDoc,
|
||||||
|
string? Reason,
|
||||||
|
string? BusinessReason,
|
||||||
|
string? Location,
|
||||||
|
string? DeclaredName,
|
||||||
|
string? ContactInfo,
|
||||||
|
string? Email,
|
||||||
|
string? Phone,
|
||||||
|
string? DigestAlgorithm,
|
||||||
|
string? SignatureAlgorithm,
|
||||||
|
string? SignerName,
|
||||||
|
string? Issuer,
|
||||||
|
string? SerialNumber,
|
||||||
|
DateTimeOffset? ValidFrom,
|
||||||
|
DateTimeOffset? ValidTo,
|
||||||
|
string ExpiryCheckedAgainst,
|
||||||
|
IReadOnlyList<PdfSignatureCertificateInfoDto> Certificates,
|
||||||
|
bool Unchanged,
|
||||||
|
string? FieldName,
|
||||||
|
bool IsCryptographicallyValid,
|
||||||
|
string? SigningTime,
|
||||||
|
string? Filter,
|
||||||
|
string? SubFilter,
|
||||||
|
string? ApplicationName,
|
||||||
|
string? UUID,
|
||||||
|
string? OriginalDocumentSha256,
|
||||||
|
string? MessageDigestHex,
|
||||||
|
string? Error);
|
||||||
|
|
||||||
|
public sealed record PdfSignatureCheckResultDto(
|
||||||
|
bool Signed,
|
||||||
|
IReadOnlyList<PdfSignatureCheckItemDto> Signatures);
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
|
public sealed record Pkcs11SelfTestStatusDto(
|
||||||
|
bool Completed,
|
||||||
|
bool Success,
|
||||||
|
string Mode,
|
||||||
|
string Summary,
|
||||||
|
DateTimeOffset? CheckedAtUtc,
|
||||||
|
string? InteropError,
|
||||||
|
string? ToolError);
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Common.Dto.Receiver;
|
||||||
|
|
||||||
|
public class RecentReceiverSuggestionDto
|
||||||
|
{
|
||||||
|
public required string FullName { get; init; }
|
||||||
|
|
||||||
|
public required string EmailAddress { get; init; }
|
||||||
|
|
||||||
|
public required DateTime LastUsedAt { get; init; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace EnvelopeGenerator.Application.Common.Enums;
|
||||||
|
|
||||||
|
public enum PdfSignatureCertificationLevel
|
||||||
|
{
|
||||||
|
NoCertification = 0,
|
||||||
|
NoChangesAllowed = 1,
|
||||||
|
FormFillingAndSigning = 2,
|
||||||
|
FormFillingAndAnnotations = 3
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Common.Interfaces.Doc;
|
||||||
|
|
||||||
|
public interface IPdfPageImageRenderer
|
||||||
|
{
|
||||||
|
Task<IReadOnlyList<PdfPageImageDto>> RenderPagesAsImagesAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Common.Interfaces.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines PDF digital-signing operations for the application boundary.
|
||||||
|
/// </summary>
|
||||||
|
public interface IPdfDigitalSignatureService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a digital signature for the provided PDF bytes and returns
|
||||||
|
/// a new signed PDF document.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inputPdf">Source PDF content stream.</param>
|
||||||
|
/// <param name="outputPdf">Destination stream for signed PDF output.</param>
|
||||||
|
/// <param name="options">Optional signing options that map to PDF signature metadata fields.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token for cooperative cancellation.</param>
|
||||||
|
Task SignPdfAsync(Stream inputPdf, Stream outputPdf, PdfSignOptionsDto? options = null, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies multiple signatures to the provided PDF in sequence and returns
|
||||||
|
/// the final signed PDF document.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inputPdf">Source PDF content stream.</param>
|
||||||
|
/// <param name="outputPdf">Destination stream for signed PDF output.</param>
|
||||||
|
/// <param name="optionsList">Ordered signing options; one signature is applied per item.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token for cooperative cancellation.</param>
|
||||||
|
Task SignPdfAsync(Stream inputPdf, Stream outputPdf, IReadOnlyList<PdfSignOptionsDto> optionsList, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks whether the provided PDF contains signature field(s) and whether
|
||||||
|
/// those signatures are cryptographically valid.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inputPdf">PDF content stream to inspect.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token for cooperative cancellation.</param>
|
||||||
|
/// <returns>A structured result containing signature presence and per-signature details.</returns>
|
||||||
|
Task<PdfSignatureCheckResultDto> CheckPdfSignatureAsync(Stream inputPdf, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extracts the original signed revision from a signed PDF.
|
||||||
|
/// For multi-revision files this returns the first signed revision bytes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inputPdf">Signed PDF content stream.</param>
|
||||||
|
/// <param name="outputPdf">Destination stream for original revision output.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token for cooperative cancellation.</param>
|
||||||
|
Task ExtractOriginalPdfAsync(Stream inputPdf, Stream outputPdf, CancellationToken cancellationToken = default);
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Common.Interfaces.Services;
|
||||||
|
|
||||||
|
public interface IPkcs11SelfTestStatusProvider
|
||||||
|
{
|
||||||
|
Pkcs11SelfTestStatusDto GetStatus();
|
||||||
|
}
|
||||||
@@ -32,6 +32,7 @@ public class MappingProfile : Profile
|
|||||||
.ForMember(dest => dest.EnvelopeTypeTitle,
|
.ForMember(dest => dest.EnvelopeTypeTitle,
|
||||||
opt => opt.MapFrom(src => src.Type != null ? src.Type.Title : null));
|
opt => opt.MapFrom(src => src.Type != null ? src.Type.Title : null));
|
||||||
CreateMap<Document, DocumentDto>();
|
CreateMap<Document, DocumentDto>();
|
||||||
|
CreateMap<Document, DocumentDetailsDto>();
|
||||||
CreateMap<History, HistoryDto>().ForMember(dest => dest.ActionDate, opt => opt.MapFrom(src => src.ChangedWhen));
|
CreateMap<History, HistoryDto>().ForMember(dest => dest.ActionDate, opt => opt.MapFrom(src => src.ChangedWhen));
|
||||||
CreateMap<History, HistoryCreateDto>().ForMember(dest => dest.ActionDate, opt => opt.MapFrom(src => src.ChangedWhen));
|
CreateMap<History, HistoryCreateDto>().ForMember(dest => dest.ActionDate, opt => opt.MapFrom(src => src.ChangedWhen));
|
||||||
CreateMap<EnvelopeReceiver, EnvelopeReceiverDto>();
|
CreateMap<EnvelopeReceiver, EnvelopeReceiverDto>();
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Common.Notifications.EnvelopeDeleted;
|
||||||
|
|
||||||
|
public record EnvelopeDeletedNotification : INotification, ISendMailNotification
|
||||||
|
{
|
||||||
|
public required Envelope Envelope { get; init; }
|
||||||
|
|
||||||
|
public required EnvelopeReceiver EnvelopeReceiver { get; init; }
|
||||||
|
|
||||||
|
public required string Reason { get; init; }
|
||||||
|
|
||||||
|
public required string SenderReference { get; init; }
|
||||||
|
|
||||||
|
public EmailTemplateType TemplateType => EmailTemplateType.DocumentDeleted;
|
||||||
|
|
||||||
|
public string EmailAddress => EnvelopeReceiver.Receiver?.EmailAddress
|
||||||
|
?? throw new InvalidOperationException("Receiver email is missing for EnvelopeDeletedNotification.");
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
|
using DigitalData.EmailProfilerDispatcher.Abstraction.Entities;
|
||||||
|
using EnvelopeGenerator.Application.Common.Configurations;
|
||||||
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Common.Notifications.EnvelopeDeleted.Handlers;
|
||||||
|
|
||||||
|
public class SendDeletedMailHandler : SendMailHandler<EnvelopeDeletedNotification>
|
||||||
|
{
|
||||||
|
public SendDeletedMailHandler(
|
||||||
|
IRepository<EmailTemplate> tempRepo,
|
||||||
|
IRepository<EmailOut> emailOutRepo,
|
||||||
|
IOptions<MailParams> mailParamsOptions,
|
||||||
|
IOptions<DispatcherParams> dispatcherParamsOptions)
|
||||||
|
: base(tempRepo, emailOutRepo, mailParamsOptions, dispatcherParamsOptions)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ConfigureEmailOut(EnvelopeDeletedNotification notification, EmailOut emailOut)
|
||||||
|
{
|
||||||
|
emailOut.ReferenceString = notification.EmailAddress;
|
||||||
|
emailOut.ReferenceId = notification.EnvelopeReceiver.ReceiverId;
|
||||||
|
emailOut.WfId = (int)EnvelopeStatus.MessageDeletionSent;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Dictionary<string, string> CreatePlaceHolders(EnvelopeDeletedNotification notification)
|
||||||
|
{
|
||||||
|
var senderName = notification.Envelope.User?.Email;
|
||||||
|
if (string.IsNullOrWhiteSpace(senderName))
|
||||||
|
senderName = notification.SenderReference;
|
||||||
|
|
||||||
|
return new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
["[NAME_RECEIVER]"] = notification.EnvelopeReceiver.Name ?? string.Empty,
|
||||||
|
["[NAME_SENDER]"] = senderName ?? string.Empty,
|
||||||
|
["[DOCUMENT_TITLE]"] = notification.Envelope.Title ?? string.Empty,
|
||||||
|
["[REASON]"] = notification.Reason
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ using System.Reflection;
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using EnvelopeGenerator.Application.DocReceiverElements.Commands;
|
using EnvelopeGenerator.Application.DocReceiverElements.Commands;
|
||||||
using EnvelopeGenerator.Application.DocReceiverElements.Behaviors;
|
using EnvelopeGenerator.Application.DocReceiverElements.Behaviors;
|
||||||
|
using EnvelopeGenerator.Application.Common.Behaviors;
|
||||||
|
using FluentValidation;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application;
|
namespace EnvelopeGenerator.Application;
|
||||||
|
|
||||||
@@ -60,6 +62,9 @@ public static class DependencyInjection
|
|||||||
{
|
{
|
||||||
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
|
cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
|
|
||||||
|
// Generic request validation
|
||||||
|
cfg.AddOpenBehavior(typeof(ValidationBehavior<,>));
|
||||||
|
|
||||||
// Register SignCommand pipeline behaviors in execution order
|
// Register SignCommand pipeline behaviors in execution order
|
||||||
// 0. EnvelopeReceiverResolutionBehavior - Resolves EnvelopeReceiver from query parameters (executes FIRST)
|
// 0. EnvelopeReceiverResolutionBehavior - Resolves EnvelopeReceiver from query parameters (executes FIRST)
|
||||||
cfg.AddBehavior<IPipelineBehavior<SigningCommand, Unit>, EnvelopeReceiverResolutionBehavior>();
|
cfg.AddBehavior<IPipelineBehavior<SigningCommand, Unit>, EnvelopeReceiverResolutionBehavior>();
|
||||||
@@ -80,6 +85,8 @@ public static class DependencyInjection
|
|||||||
cfg.AddBehavior<IPipelineBehavior<SigningCommand, Unit>, SendSignedMailBehavior>();
|
cfg.AddBehavior<IPipelineBehavior<SigningCommand, Unit>, SendSignedMailBehavior>();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using AutoMapper.QueryableExtensions;
|
||||||
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Documents.Queries;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a query to read document metadata/details without binary payload.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="EnvelopeId">The identifier of the envelope associated with the document.</param>
|
||||||
|
/// <param name="UserId">The unique identifier of the sending user. Optional.</param>
|
||||||
|
public record ReadDocumentDetailsQuery(int EnvelopeId, int? UserId = null) : IRequest<DocumentDetailsDto?>;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles queries for reading document details without loading BYTE_DATA.
|
||||||
|
/// </summary>
|
||||||
|
public class ReadDocumentDetailsQueryHandler : IRequestHandler<ReadDocumentDetailsQuery, DocumentDetailsDto?>
|
||||||
|
{
|
||||||
|
private readonly IRepository<Document> _repo;
|
||||||
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
|
public ReadDocumentDetailsQueryHandler(IRepository<Document> repo, IMapper mapper)
|
||||||
|
{
|
||||||
|
_repo = repo;
|
||||||
|
_mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<DocumentDetailsDto?> Handle(ReadDocumentDetailsQuery query, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
var docQuery = _repo.Query.AsNoTracking();
|
||||||
|
|
||||||
|
if (query.UserId is int userId)
|
||||||
|
docQuery = docQuery.Where(doc => doc.Envelope.UserId == userId);
|
||||||
|
|
||||||
|
return await docQuery
|
||||||
|
.Where(d => d.EnvelopeId == query.EnvelopeId)
|
||||||
|
.ProjectTo<DocumentDetailsDto>(_mapper.ConfigurationProvider)
|
||||||
|
.FirstOrDefaultAsync(cancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Documents.Queries;
|
||||||
|
|
||||||
|
public class ReadDocumentDetailsQueryValidator : AbstractValidator<ReadDocumentDetailsQuery>
|
||||||
|
{
|
||||||
|
public ReadDocumentDetailsQueryValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x.EnvelopeId)
|
||||||
|
.GreaterThan(0)
|
||||||
|
.WithMessage("EnvelopeId is required.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using FluentValidation;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Documents.Queries;
|
||||||
|
|
||||||
|
public class ReadDocumentQueryValidator : AbstractValidator<ReadDocumentQuery>
|
||||||
|
{
|
||||||
|
public ReadDocumentQueryValidator()
|
||||||
|
{
|
||||||
|
RuleFor(x => x)
|
||||||
|
.Must(x => (x.Id ?? 0) > 0 || (x.EnvelopeId ?? 0) > 0)
|
||||||
|
.WithMessage("Id or EnvelopeId is required.");
|
||||||
|
|
||||||
|
RuleFor(x => x.Id)
|
||||||
|
.GreaterThan(0)
|
||||||
|
.When(x => x.Id.HasValue)
|
||||||
|
.WithMessage("Id must be greater than 0.");
|
||||||
|
|
||||||
|
RuleFor(x => x.EnvelopeId)
|
||||||
|
.GreaterThan(0)
|
||||||
|
.When(x => x.EnvelopeId.HasValue)
|
||||||
|
.WithMessage("EnvelopeId must be greater than 0.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
|
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -19,6 +20,8 @@
|
|||||||
<PackageReference Include="DigitalData.Core.Client" Version="2.1.0" />
|
<PackageReference Include="DigitalData.Core.Client" Version="2.1.0" />
|
||||||
<PackageReference Include="DigitalData.Core.Exceptions" Version="1.1.0" />
|
<PackageReference Include="DigitalData.Core.Exceptions" Version="1.1.0" />
|
||||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.1.1" />
|
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.1.1" />
|
||||||
|
<PackageReference Include="FluentValidation" Version="11.11.0" />
|
||||||
|
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.11.0" />
|
||||||
<PackageReference Include="HtmlSanitizer" Version="9.0.892" />
|
<PackageReference Include="HtmlSanitizer" Version="9.0.892" />
|
||||||
<PackageReference Include="MediatR" Version="12.5.0" />
|
<PackageReference Include="MediatR" Version="12.5.0" />
|
||||||
<PackageReference Include="Microsoft.Identity.Client" Version="4.82.1" />
|
<PackageReference Include="Microsoft.Identity.Client" Version="4.82.1" />
|
||||||
|
|||||||
@@ -16,5 +16,9 @@ public class MappingProfile : Profile
|
|||||||
public MappingProfile()
|
public MappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<Receiver, ReceiverDto>();
|
CreateMap<Receiver, ReceiverDto>();
|
||||||
|
|
||||||
|
CreateMap<EnvelopeReceiver, RecentReceiverSuggestionDto>()
|
||||||
|
.ForMember(dest => dest.FullName, opt => opt.MapFrom(src => src.Name))
|
||||||
|
.ForMember(dest => dest.EmailAddress, opt => opt.MapFrom(src => src.Receiver.EmailAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
|
using EnvelopeGenerator.Application.Common.Dto.Receiver;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads recent receiver suggestions for envelope creation.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Sender scope is assigned via chain method to avoid exposing username mutation from API query binding.
|
||||||
|
/// </remarks>
|
||||||
|
public record ReadRecentReceiverSuggestionsQuery : IRequest<IReadOnlyList<RecentReceiverSuggestionDto>>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Sender username used for scoping suggestion results.
|
||||||
|
/// </summary>
|
||||||
|
internal string? Username { get; private init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desired number of results.
|
||||||
|
/// </summary>
|
||||||
|
public int? Take { get; init; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a new query instance scoped to the specified sender username.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username">Sender username from authenticated claims.</param>
|
||||||
|
/// <returns>Scoped query instance.</returns>
|
||||||
|
public ReadRecentReceiverSuggestionsQuery ForSender(string username)
|
||||||
|
{
|
||||||
|
return this with { Username = username };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles <see cref="ReadRecentReceiverSuggestionsQuery"/>.
|
||||||
|
/// </summary>
|
||||||
|
public class ReadRecentReceiverSuggestionsQueryHandler(IRepository<EnvelopeReceiver> repository)
|
||||||
|
: IRequestHandler<ReadRecentReceiverSuggestionsQuery, IReadOnlyList<RecentReceiverSuggestionDto>>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves distinct recent receiver suggestions grouped by receiver email.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">Suggestion query.</param>
|
||||||
|
/// <param name="cancel">Cancellation token.</param>
|
||||||
|
/// <returns>Ordered list of recent receiver suggestions.</returns>
|
||||||
|
public async Task<IReadOnlyList<RecentReceiverSuggestionDto>> Handle(ReadRecentReceiverSuggestionsQuery request, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
var query = repository.Query
|
||||||
|
.AsNoTracking()
|
||||||
|
.Where(er => er.Receiver != null);
|
||||||
|
|
||||||
|
if (request.Username is not null)
|
||||||
|
query = query.Where(er => er.Envelope != null && er.Envelope.User.Username == request.Username);
|
||||||
|
|
||||||
|
// 1) For each email, compute the latest usage timestamp.
|
||||||
|
var latestPerEmail = query
|
||||||
|
.GroupBy(er => er.Receiver!.EmailAddress)
|
||||||
|
.Select(g => new
|
||||||
|
{
|
||||||
|
EmailAddress = g.Key,
|
||||||
|
LastUsedAt = g.Max(er => er.AddedWhen),
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2) Join back to rows that match the latest timestamp per email.
|
||||||
|
var latestRows =
|
||||||
|
from er in query
|
||||||
|
join latest in latestPerEmail
|
||||||
|
on new { EmailAddress = er.Receiver!.EmailAddress, LastUsedAt = er.AddedWhen }
|
||||||
|
equals new { latest.EmailAddress, latest.LastUsedAt }
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
EmailAddress = er.Receiver!.EmailAddress,
|
||||||
|
FullName = er.Name,
|
||||||
|
LastUsedAt = er.AddedWhen,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 3) Tie-break: if multiple rows share the same latest timestamp for an email,
|
||||||
|
// pick a deterministic name via Max(FullName), then order by most recent usage.
|
||||||
|
var suggestions = latestRows
|
||||||
|
.GroupBy(x => new { x.EmailAddress, x.LastUsedAt })
|
||||||
|
.Select(g => new RecentReceiverSuggestionDto
|
||||||
|
{
|
||||||
|
EmailAddress = g.Key.EmailAddress,
|
||||||
|
FullName = g.Max(x => x.FullName) ?? string.Empty,
|
||||||
|
LastUsedAt = g.Key.LastUsedAt,
|
||||||
|
})
|
||||||
|
.OrderByDescending(x => x.LastUsedAt)
|
||||||
|
.ThenBy(x => x.EmailAddress);
|
||||||
|
|
||||||
|
return request.Take is int take
|
||||||
|
? await suggestions.Take(take).ToListAsync(cancel)
|
||||||
|
: await suggestions.ToListAsync(cancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using EnvelopeGenerator.Application.Common.Dto;
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using AutoMapper;
|
|
||||||
using DigitalData.Core.Abstraction.Application.Repository;
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@@ -18,17 +17,14 @@ public record ReadEnvelopeTypesQuery : IRequest<IEnumerable<EnvelopeTypeDto>>;
|
|||||||
public class ReadEnvelopeTypesQueryHandler : IRequestHandler<ReadEnvelopeTypesQuery, IEnumerable<EnvelopeTypeDto>>
|
public class ReadEnvelopeTypesQueryHandler : IRequestHandler<ReadEnvelopeTypesQuery, IEnumerable<EnvelopeTypeDto>>
|
||||||
{
|
{
|
||||||
private readonly IRepository<EnvelopeType> _repository;
|
private readonly IRepository<EnvelopeType> _repository;
|
||||||
private readonly IMapper _mapper;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="repository"></param>
|
/// <param name="repository"></param>
|
||||||
/// <param name="mapper"></param>
|
public ReadEnvelopeTypesQueryHandler(IRepository<EnvelopeType> repository)
|
||||||
public ReadEnvelopeTypesQueryHandler(IRepository<EnvelopeType> repository, IMapper mapper)
|
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_mapper = mapper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -39,7 +35,28 @@ public class ReadEnvelopeTypesQueryHandler : IRequestHandler<ReadEnvelopeTypesQu
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<IEnumerable<EnvelopeTypeDto>> Handle(ReadEnvelopeTypesQuery request, CancellationToken cancellationToken)
|
public async Task<IEnumerable<EnvelopeTypeDto>> Handle(ReadEnvelopeTypesQuery request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var types = await _repository.Query.ToListAsync(cancellationToken);
|
// TODO: Temporary manual projection to avoid null-materialization crashes from legacy nullable DB columns in EnvelopeType.
|
||||||
return _mapper.Map<IEnumerable<EnvelopeTypeDto>>(types);
|
// Revisit and switch to AutoMapper query projection (ProjectTo) after schema nullability and mapping contracts are stabilized.
|
||||||
|
return await _repository.Query
|
||||||
|
.AsNoTracking()
|
||||||
|
.Select(t => new EnvelopeTypeDto
|
||||||
|
{
|
||||||
|
Id = t.Id,
|
||||||
|
Title = t.Title ?? string.Empty,
|
||||||
|
Language = string.IsNullOrWhiteSpace(t.Language) ? "de-DE" : t.Language,
|
||||||
|
ExpiresDays = t.ExpiresDays,
|
||||||
|
CertificationType = (int?)t.CertificationType,
|
||||||
|
UseAccessCode = t.UseAccessCode,
|
||||||
|
FinalEmailToCreator = (int?)t.FinalEmailToCreator,
|
||||||
|
FinalEmailToReceivers = (int?)t.FinalEmailToReceivers,
|
||||||
|
AddedWhen = t.AddedWhen,
|
||||||
|
ChangedWhen = t.ChangedWhen,
|
||||||
|
ExpiresWarningDays = t.ExpiresWarningDays,
|
||||||
|
SendReminderEmails = t.SendReminderEmails,
|
||||||
|
FirstReminderDays = t.FirstReminderDays,
|
||||||
|
ReminderIntervalDays = t.ReminderIntervalDays,
|
||||||
|
ContractType = t.ContractType
|
||||||
|
})
|
||||||
|
.ToListAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using DigitalData.Core.Abstraction.Application.Repository;
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
using EnvelopeGenerator.Application.Common.Dto;
|
|
||||||
using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
|
using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
@@ -13,23 +12,96 @@ namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public record CreateEnvelopeCommand : IRequest<EnvelopeDto?>
|
public record CreateEnvelopeCommand : IRequest<EnvelopeDto?>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Optionale Umschlag-ID fuer Aktualisierungsvorgaenge.
|
||||||
|
/// </summary>
|
||||||
|
public int? EnvelopeId { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Kennung des ausgewaehlten Umschlagtyps (Vorlage).
|
||||||
|
/// </summary>
|
||||||
|
public int? EnvelopeTypeId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sprachcode fuer Umschlaginhalt und Benachrichtigungen.
|
||||||
|
/// </summary>
|
||||||
|
public string? Language { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gibt an, ob der Zugriffscode fuer Empfaenger aktiviert ist.
|
||||||
|
/// </summary>
|
||||||
|
public bool? UseAccessCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Zertifizierungstyp fuer den Signaturprozess.
|
||||||
|
/// </summary>
|
||||||
|
public int? CertificationType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Finale E-Mail-Einstellung fuer den Ersteller.
|
||||||
|
/// </summary>
|
||||||
|
public int? FinalEmailToCreator { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Finale E-Mail-Einstellung fuer die Empfaenger.
|
||||||
|
/// </summary>
|
||||||
|
public int? FinalEmailToReceivers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gibt an, ob Erinnerungs-E-Mails aktiviert sind.
|
||||||
|
/// </summary>
|
||||||
|
public bool? SendReminderEmails { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Anzahl der Tage bis zur ersten Erinnerung.
|
||||||
|
/// </summary>
|
||||||
|
public int? FirstReminderDays { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Intervall in Tagen zwischen Erinnerungs-E-Mails.
|
||||||
|
/// </summary>
|
||||||
|
public int? ReminderIntervalDays { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Anzahl der Tage bis zum Ablauf des Umschlags.
|
||||||
|
/// </summary>
|
||||||
|
public int? ExpiresWhenDays { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Anzahl der Tage vor Ablauf, ab denen gewarnt wird.
|
||||||
|
/// </summary>
|
||||||
|
public int? ExpiresWarningWhenDays { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Der Titel des Umschlags. Dies ist ein Pflichtfeld.
|
/// Der Titel des Umschlags. Dies ist ein Pflichtfeld.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required]
|
public string? Title { get; set; }
|
||||||
public required string Title { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Die Nachricht, die im Umschlag enthalten sein soll. Dies ist ein Pflichtfeld.
|
/// Die Nachricht, die im Umschlag enthalten sein soll. Dies ist ein Pflichtfeld.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required]
|
public string? Message { get; set; }
|
||||||
public required string Message { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gibt an, ob die Zwei-Faktor-Authentifizierung für den Umschlag aktiviert ist. Standardmäßig false.
|
/// Gibt an, ob die Zwei-Faktor-Authentifizierung für den Umschlag aktiviert ist. Standardmäßig false.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool TFAEnabled { get; set; } = false;
|
public bool TFAEnabled { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gibt an, ob der Umschlag nach dem Speichern sofort versendet werden soll.
|
||||||
|
/// </summary>
|
||||||
|
public bool Send { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Optionaler PDF-Dokumentinhalt als Base64.
|
||||||
|
/// </summary>
|
||||||
|
public CreateEnvelopeDocumentDto? Document { get; init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Empfaengerliste inklusive optionaler Signaturfeld-Koordinaten.
|
||||||
|
/// </summary>
|
||||||
|
public List<CreateEnvelopeReceiverDto> Receivers { get; init; } = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ID des Absenders
|
/// ID des Absenders
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -56,3 +128,13 @@ public record CreateEnvelopeCommand : IRequest<EnvelopeDto?>
|
|||||||
[NotMapped]
|
[NotMapped]
|
||||||
public bool UseSQLExecutor { get; set; } = true;
|
public bool UseSQLExecutor { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public record CreateEnvelopeDocumentDto(string DataAsBase64);
|
||||||
|
|
||||||
|
public record CreateEnvelopeFieldDto(double X, double Y, int Page);
|
||||||
|
|
||||||
|
public record CreateEnvelopeReceiverDto(
|
||||||
|
string EmailAddress,
|
||||||
|
string? Name,
|
||||||
|
string? PhoneNumber,
|
||||||
|
List<CreateEnvelopeFieldDto> Fields);
|
||||||
|
|||||||
@@ -1,10 +1,20 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
using DigitalData.Core.Abstraction.Application.Repository;
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
|
using DigitalData.EmailProfilerDispatcher.Abstraction.Entities;
|
||||||
|
using DigitalData.Core.Exceptions;
|
||||||
using EnvelopeGenerator.Domain.Entities;
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
using EnvelopeGenerator.Application.Common.Dto;
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
using EnvelopeGenerator.Application.Common.Configurations;
|
||||||
|
using EnvelopeGenerator.Application.Common.Extensions;
|
||||||
|
using EnvelopeGenerator.Application.Common.Interfaces.Services;
|
||||||
using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
|
using EnvelopeGenerator.Application.Common.Interfaces.SQLExecutor;
|
||||||
|
using EnvelopeGenerator.Application.Histories.Commands;
|
||||||
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
|
using EnvelopeGenerator.Domain;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||||
|
|
||||||
@@ -19,6 +29,28 @@ public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeComman
|
|||||||
|
|
||||||
private IRepository<Envelope> Repository => _provider.GetRequiredService<IRepository<Envelope>>();
|
private IRepository<Envelope> Repository => _provider.GetRequiredService<IRepository<Envelope>>();
|
||||||
|
|
||||||
|
private IRepository<Document> DocumentRepository => _provider.GetRequiredService<IRepository<Document>>();
|
||||||
|
|
||||||
|
private IRepository<EnvelopeReceiver> EnvelopeReceiverRepository => _provider.GetRequiredService<IRepository<EnvelopeReceiver>>();
|
||||||
|
|
||||||
|
private IRepository<EnvelopeType> EnvelopeTypeRepository => _provider.GetRequiredService<IRepository<EnvelopeType>>();
|
||||||
|
|
||||||
|
private IRepository<Receiver> ReceiverRepository => _provider.GetRequiredService<IRepository<Receiver>>();
|
||||||
|
|
||||||
|
private IRepository<DocReceiverElement> DocReceiverElementRepository => _provider.GetRequiredService<IRepository<DocReceiverElement>>();
|
||||||
|
|
||||||
|
private IRepository<EmailTemplate> EmailTemplateRepository => _provider.GetRequiredService<IRepository<EmailTemplate>>();
|
||||||
|
|
||||||
|
private IRepository<EmailOut> EmailOutRepository => _provider.GetRequiredService<IRepository<EmailOut>>();
|
||||||
|
|
||||||
|
private MailParams MailParams => _provider.GetRequiredService<IOptions<MailParams>>().Value;
|
||||||
|
|
||||||
|
private DispatcherParams DispatcherParams => _provider.GetRequiredService<IOptions<DispatcherParams>>().Value;
|
||||||
|
|
||||||
|
private IConfigService ConfigService => _provider.GetRequiredService<IConfigService>();
|
||||||
|
|
||||||
|
private IMediator Mediator => _provider.GetRequiredService<IMediator>();
|
||||||
|
|
||||||
private readonly IMapper _mapper;
|
private readonly IMapper _mapper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -40,10 +72,572 @@ public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeComman
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<EnvelopeDto?> Handle(CreateEnvelopeCommand request, CancellationToken cancel)
|
public async Task<EnvelopeDto?> Handle(CreateEnvelopeCommand request, CancellationToken cancel)
|
||||||
{
|
{
|
||||||
var envelope = request.UseSQLExecutor
|
var now = DateTime.Now;
|
||||||
? await Executor.CreateEnvelopeAsync(request.UserId, request.Title, request.Message, request.TFAEnabled, cancel)
|
var title = request.Title?.Trim() ?? string.Empty;
|
||||||
: await Repository.CreateAsync(request, cancel);
|
var message = request.Message?.Trim() ?? string.Empty;
|
||||||
|
var settings = await ResolveEnvelopeSettingsAsync(request, existing: null, cancel);
|
||||||
|
|
||||||
|
Envelope envelope;
|
||||||
|
if (request.EnvelopeId is int envelopeId)
|
||||||
|
{
|
||||||
|
envelope = await Repository.Query
|
||||||
|
.Include(e => e.User)
|
||||||
|
.FirstOrDefaultAsync(e => e.Id == envelopeId, cancel)
|
||||||
|
?? throw new BadRequestException($"Envelope {envelopeId} not found.");
|
||||||
|
|
||||||
|
if (envelope.UserId != request.UserId)
|
||||||
|
throw new ForbiddenException();
|
||||||
|
|
||||||
|
settings = await ResolveEnvelopeSettingsAsync(request, envelope, cancel);
|
||||||
|
|
||||||
|
await Repository.UpdateAsync(e =>
|
||||||
|
{
|
||||||
|
e.Title = title;
|
||||||
|
e.Message = message;
|
||||||
|
e.TfaEnabled = request.TFAEnabled;
|
||||||
|
e.EnvelopeTypeId = settings.EnvelopeTypeId;
|
||||||
|
e.Language = settings.Language;
|
||||||
|
e.UseAccessCode = settings.UseAccessCode;
|
||||||
|
e.CertificationType = settings.CertificationType;
|
||||||
|
e.FinalEmailToCreator = settings.FinalEmailToCreator;
|
||||||
|
e.FinalEmailToReceivers = settings.FinalEmailToReceivers;
|
||||||
|
e.SendReminderEmails = settings.SendReminderEmails;
|
||||||
|
e.FirstReminderDays = settings.FirstReminderDays;
|
||||||
|
e.ReminderIntervalDays = settings.ReminderIntervalDays;
|
||||||
|
e.ExpiresWhenDays = settings.ExpiresWhenDays;
|
||||||
|
e.ExpiresWarningWhenDays = settings.ExpiresWarningWhenDays;
|
||||||
|
e.ContractType = settings.ContractType;
|
||||||
|
e.ExpiresWhen = settings.ExpiresWhen;
|
||||||
|
e.ExpiresWarningWhen = settings.ExpiresWarningWhen;
|
||||||
|
e.Status = EnvelopeStatus.EnvelopeSaved;
|
||||||
|
e.ChangedWhen = now;
|
||||||
|
}, e => e.Id == envelopeId, cancel);
|
||||||
|
|
||||||
|
envelope.Title = title;
|
||||||
|
envelope.Message = message;
|
||||||
|
envelope.TfaEnabled = request.TFAEnabled;
|
||||||
|
envelope.EnvelopeTypeId = settings.EnvelopeTypeId;
|
||||||
|
envelope.Language = settings.Language;
|
||||||
|
envelope.UseAccessCode = settings.UseAccessCode;
|
||||||
|
envelope.CertificationType = settings.CertificationType;
|
||||||
|
envelope.FinalEmailToCreator = settings.FinalEmailToCreator;
|
||||||
|
envelope.FinalEmailToReceivers = settings.FinalEmailToReceivers;
|
||||||
|
envelope.SendReminderEmails = settings.SendReminderEmails;
|
||||||
|
envelope.FirstReminderDays = settings.FirstReminderDays;
|
||||||
|
envelope.ReminderIntervalDays = settings.ReminderIntervalDays;
|
||||||
|
envelope.ExpiresWhenDays = settings.ExpiresWhenDays;
|
||||||
|
envelope.ExpiresWarningWhenDays = settings.ExpiresWarningWhenDays;
|
||||||
|
envelope.ContractType = settings.ContractType;
|
||||||
|
envelope.ExpiresWhen = settings.ExpiresWhen;
|
||||||
|
envelope.ExpiresWarningWhen = settings.ExpiresWarningWhen;
|
||||||
|
envelope.Status = EnvelopeStatus.EnvelopeSaved;
|
||||||
|
envelope.ChangedWhen = now;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
envelope = request.UseSQLExecutor
|
||||||
|
? await Executor.CreateEnvelopeAsync(request.UserId, title, message, request.TFAEnabled, cancel)
|
||||||
|
: await Repository.CreateAsync(new Envelope
|
||||||
|
{
|
||||||
|
UserId = request.UserId,
|
||||||
|
Status = EnvelopeStatus.EnvelopeCreated,
|
||||||
|
Uuid = Guid.NewGuid().ToString(),
|
||||||
|
Title = title,
|
||||||
|
Message = message,
|
||||||
|
AddedWhen = now,
|
||||||
|
ChangedWhen = now,
|
||||||
|
Comment = string.Empty,
|
||||||
|
EnvelopeTypeId = settings.EnvelopeTypeId,
|
||||||
|
Language = settings.Language,
|
||||||
|
TfaEnabled = request.TFAEnabled,
|
||||||
|
UseAccessCode = settings.UseAccessCode,
|
||||||
|
CertificationType = settings.CertificationType,
|
||||||
|
FinalEmailToCreator = settings.FinalEmailToCreator,
|
||||||
|
FinalEmailToReceivers = settings.FinalEmailToReceivers,
|
||||||
|
SendReminderEmails = settings.SendReminderEmails,
|
||||||
|
FirstReminderDays = settings.FirstReminderDays,
|
||||||
|
ReminderIntervalDays = settings.ReminderIntervalDays,
|
||||||
|
ExpiresWhenDays = settings.ExpiresWhenDays,
|
||||||
|
ExpiresWarningWhenDays = settings.ExpiresWarningWhenDays,
|
||||||
|
ExpiresWhen = settings.ExpiresWhen,
|
||||||
|
ExpiresWarningWhen = settings.ExpiresWarningWhen,
|
||||||
|
ContractType = settings.ContractType
|
||||||
|
}, cancel);
|
||||||
|
|
||||||
|
if (request.UseSQLExecutor)
|
||||||
|
{
|
||||||
|
await Repository.UpdateAsync(e =>
|
||||||
|
{
|
||||||
|
e.Title = title;
|
||||||
|
e.Message = message;
|
||||||
|
e.TfaEnabled = request.TFAEnabled;
|
||||||
|
e.EnvelopeTypeId = settings.EnvelopeTypeId;
|
||||||
|
e.Language = settings.Language;
|
||||||
|
e.UseAccessCode = settings.UseAccessCode;
|
||||||
|
e.CertificationType = settings.CertificationType;
|
||||||
|
e.FinalEmailToCreator = settings.FinalEmailToCreator;
|
||||||
|
e.FinalEmailToReceivers = settings.FinalEmailToReceivers;
|
||||||
|
e.SendReminderEmails = settings.SendReminderEmails;
|
||||||
|
e.FirstReminderDays = settings.FirstReminderDays;
|
||||||
|
e.ReminderIntervalDays = settings.ReminderIntervalDays;
|
||||||
|
e.ExpiresWhenDays = settings.ExpiresWhenDays;
|
||||||
|
e.ExpiresWarningWhenDays = settings.ExpiresWarningWhenDays;
|
||||||
|
e.ExpiresWhen = settings.ExpiresWhen;
|
||||||
|
e.ExpiresWarningWhen = settings.ExpiresWarningWhen;
|
||||||
|
e.ContractType = settings.ContractType;
|
||||||
|
e.Status = EnvelopeStatus.EnvelopeSaved;
|
||||||
|
e.ChangedWhen = now;
|
||||||
|
}, e => e.Id == envelope.Id, cancel);
|
||||||
|
|
||||||
|
envelope.Title = title;
|
||||||
|
envelope.Message = message;
|
||||||
|
envelope.TfaEnabled = request.TFAEnabled;
|
||||||
|
envelope.EnvelopeTypeId = settings.EnvelopeTypeId;
|
||||||
|
envelope.Language = settings.Language;
|
||||||
|
envelope.UseAccessCode = settings.UseAccessCode;
|
||||||
|
envelope.CertificationType = settings.CertificationType;
|
||||||
|
envelope.FinalEmailToCreator = settings.FinalEmailToCreator;
|
||||||
|
envelope.FinalEmailToReceivers = settings.FinalEmailToReceivers;
|
||||||
|
envelope.SendReminderEmails = settings.SendReminderEmails;
|
||||||
|
envelope.FirstReminderDays = settings.FirstReminderDays;
|
||||||
|
envelope.ReminderIntervalDays = settings.ReminderIntervalDays;
|
||||||
|
envelope.ExpiresWhenDays = settings.ExpiresWhenDays;
|
||||||
|
envelope.ExpiresWarningWhenDays = settings.ExpiresWarningWhenDays;
|
||||||
|
envelope.ExpiresWhen = settings.ExpiresWhen;
|
||||||
|
envelope.ExpiresWarningWhen = settings.ExpiresWarningWhen;
|
||||||
|
envelope.ContractType = settings.ContractType;
|
||||||
|
envelope.Status = EnvelopeStatus.EnvelopeSaved;
|
||||||
|
envelope.ChangedWhen = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Mediator.Send(new CreateHistoryCommand
|
||||||
|
{
|
||||||
|
EnvelopeId = envelope.Id,
|
||||||
|
UserReference = await ResolveSenderReferenceAsync(envelope, cancel),
|
||||||
|
Status = EnvelopeStatus.EnvelopeCreated
|
||||||
|
}, cancel);
|
||||||
|
}
|
||||||
|
|
||||||
|
await UpsertDocumentAsync(envelope.Id, request.Document, now, cancel);
|
||||||
|
await UpsertReceiversAndFieldsAsync(envelope.Id, request.Receivers, now, cancel);
|
||||||
|
|
||||||
|
if (request.Send)
|
||||||
|
await SendEnvelopeAsync(envelope, cancel);
|
||||||
|
|
||||||
|
envelope = await Repository.Query
|
||||||
|
.Include(e => e.User)
|
||||||
|
.Include(e => e.EnvelopeReceivers)
|
||||||
|
.ThenInclude(er => er.Receiver)
|
||||||
|
.FirstAsync(e => e.Id == envelope.Id, cancel);
|
||||||
|
|
||||||
return _mapper.Map<EnvelopeDto>(envelope);
|
return _mapper.Map<EnvelopeDto>(envelope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<EnvelopeSettings> ResolveEnvelopeSettingsAsync(CreateEnvelopeCommand request, Envelope? existing, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
EnvelopeType? selectedType = null;
|
||||||
|
if (request.EnvelopeTypeId is int envelopeTypeId && envelopeTypeId > 0)
|
||||||
|
{
|
||||||
|
selectedType = await EnvelopeTypeRepository.Query
|
||||||
|
.FirstOrDefaultAsync(t => t.Id == envelopeTypeId, cancel)
|
||||||
|
?? throw new BadRequestException($"Envelope type {envelopeTypeId} not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var expiresWhenDays = Math.Max(0,
|
||||||
|
request.ExpiresWhenDays
|
||||||
|
?? selectedType?.ExpiresWhenDays
|
||||||
|
?? existing?.ExpiresWhenDays
|
||||||
|
?? 0);
|
||||||
|
|
||||||
|
var expiresWarningWhenDays = Math.Max(0,
|
||||||
|
request.ExpiresWarningWhenDays
|
||||||
|
?? selectedType?.ExpiresWarningWhenDays
|
||||||
|
?? existing?.ExpiresWarningWhenDays
|
||||||
|
?? 0);
|
||||||
|
|
||||||
|
var useAccessCode = request.UseAccessCode
|
||||||
|
?? selectedType?.UseAccessCode
|
||||||
|
?? existing?.UseAccessCode
|
||||||
|
?? false;
|
||||||
|
|
||||||
|
if (request.TFAEnabled)
|
||||||
|
useAccessCode = true;
|
||||||
|
|
||||||
|
return new EnvelopeSettings(
|
||||||
|
EnvelopeTypeId: request.EnvelopeTypeId ?? existing?.EnvelopeTypeId,
|
||||||
|
Language: ResolveLanguage(request.Language, selectedType?.Language, existing?.Language),
|
||||||
|
UseAccessCode: useAccessCode,
|
||||||
|
CertificationType: request.CertificationType
|
||||||
|
?? (int?)selectedType?.CertificationType
|
||||||
|
?? existing?.CertificationType
|
||||||
|
?? (int)CertificationType.AdvancedElectronicSignature,
|
||||||
|
FinalEmailToCreator: request.FinalEmailToCreator
|
||||||
|
?? (int?)selectedType?.FinalEmailToCreator
|
||||||
|
?? existing?.FinalEmailToCreator
|
||||||
|
?? (int)FinalEmailType.No,
|
||||||
|
FinalEmailToReceivers: request.FinalEmailToReceivers
|
||||||
|
?? (int?)selectedType?.FinalEmailToReceivers
|
||||||
|
?? existing?.FinalEmailToReceivers
|
||||||
|
?? (int)FinalEmailType.No,
|
||||||
|
SendReminderEmails: request.SendReminderEmails
|
||||||
|
?? selectedType?.SendReminderEmails
|
||||||
|
?? existing?.SendReminderEmails
|
||||||
|
?? false,
|
||||||
|
FirstReminderDays: Math.Max(0,
|
||||||
|
request.FirstReminderDays
|
||||||
|
?? selectedType?.FirstReminderDays
|
||||||
|
?? existing?.FirstReminderDays
|
||||||
|
?? 0),
|
||||||
|
ReminderIntervalDays: Math.Max(0,
|
||||||
|
request.ReminderIntervalDays
|
||||||
|
?? selectedType?.ReminderIntervalDays
|
||||||
|
?? existing?.ReminderIntervalDays
|
||||||
|
?? 0),
|
||||||
|
ExpiresWhenDays: expiresWhenDays,
|
||||||
|
ExpiresWarningWhenDays: expiresWarningWhenDays,
|
||||||
|
ExpiresWhen: expiresWhenDays > 0 ? DateTime.Now.AddDays(expiresWhenDays) : null,
|
||||||
|
ExpiresWarningWhen: expiresWarningWhenDays > 0 ? DateTime.Now.AddDays(expiresWarningWhenDays) : null,
|
||||||
|
ContractType: existing?.ContractType
|
||||||
|
?? selectedType?.ContractType
|
||||||
|
?? (int)ContractType.Contract);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ResolveLanguage(string? preferred, string? fallback1, string? fallback2)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(preferred))
|
||||||
|
return preferred.Trim();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(fallback1))
|
||||||
|
return fallback1.Trim();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(fallback2))
|
||||||
|
return fallback2.Trim();
|
||||||
|
|
||||||
|
return "de-DE";
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed record EnvelopeSettings(
|
||||||
|
int? EnvelopeTypeId,
|
||||||
|
string Language,
|
||||||
|
bool UseAccessCode,
|
||||||
|
int CertificationType,
|
||||||
|
int FinalEmailToCreator,
|
||||||
|
int FinalEmailToReceivers,
|
||||||
|
bool SendReminderEmails,
|
||||||
|
int FirstReminderDays,
|
||||||
|
int ReminderIntervalDays,
|
||||||
|
int ExpiresWhenDays,
|
||||||
|
int ExpiresWarningWhenDays,
|
||||||
|
DateTime? ExpiresWhen,
|
||||||
|
DateTime? ExpiresWarningWhen,
|
||||||
|
int ContractType);
|
||||||
|
|
||||||
|
private async Task<string> ResolveSenderReferenceAsync(Envelope envelope, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(envelope.User?.Email))
|
||||||
|
return envelope.User.Email;
|
||||||
|
|
||||||
|
var senderEmail = await Repository.Query
|
||||||
|
.Where(e => e.Id == envelope.Id)
|
||||||
|
.Select(e => e.User.Email)
|
||||||
|
.FirstOrDefaultAsync(cancel);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(senderEmail))
|
||||||
|
throw new BadRequestException("Envelope sender email is missing.");
|
||||||
|
|
||||||
|
return senderEmail;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpsertDocumentAsync(int envelopeId, CreateEnvelopeDocumentDto? document, DateTime now, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
if (document is null || string.IsNullOrWhiteSpace(document.DataAsBase64))
|
||||||
|
return;
|
||||||
|
|
||||||
|
byte[] bytes;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bytes = Convert.FromBase64String(document.DataAsBase64);
|
||||||
|
}
|
||||||
|
catch (FormatException)
|
||||||
|
{
|
||||||
|
throw new BadRequestException("Document payload is not valid base64.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var existingDocumentId = await DocumentRepository.Query
|
||||||
|
.Where(d => d.EnvelopeId == envelopeId)
|
||||||
|
.Select(d => (int?)d.Id)
|
||||||
|
.FirstOrDefaultAsync(cancel);
|
||||||
|
|
||||||
|
if (existingDocumentId is null)
|
||||||
|
{
|
||||||
|
await DocumentRepository.CreateAsync(new Document
|
||||||
|
{
|
||||||
|
EnvelopeId = envelopeId,
|
||||||
|
AddedWhen = now,
|
||||||
|
ByteData = bytes,
|
||||||
|
Filename = string.Empty,
|
||||||
|
Filepath = string.Empty,
|
||||||
|
FileNameOriginal = string.Empty
|
||||||
|
}, cancel);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await DocumentRepository.UpdateAsync(d =>
|
||||||
|
{
|
||||||
|
d.ByteData = bytes;
|
||||||
|
}, d => d.Id == existingDocumentId.Value, cancel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpsertReceiversAndFieldsAsync(int envelopeId, IReadOnlyCollection<CreateEnvelopeReceiverDto> receivers, DateTime now, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
var filteredReceivers = receivers
|
||||||
|
.Where(r => !string.IsNullOrWhiteSpace(r.EmailAddress))
|
||||||
|
.Select(r => r with
|
||||||
|
{
|
||||||
|
EmailAddress = r.EmailAddress.Trim().ToLowerInvariant(),
|
||||||
|
Name = r.Name?.Trim(),
|
||||||
|
PhoneNumber = string.IsNullOrWhiteSpace(r.PhoneNumber) ? null : r.PhoneNumber.Trim(),
|
||||||
|
Fields = r.Fields ?? new List<CreateEnvelopeFieldDto>()
|
||||||
|
})
|
||||||
|
.GroupBy(r => r.EmailAddress, StringComparer.OrdinalIgnoreCase)
|
||||||
|
.Select(g => g.First())
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (filteredReceivers.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var document = await DocumentRepository.Query
|
||||||
|
.FirstOrDefaultAsync(d => d.EnvelopeId == envelopeId, cancel);
|
||||||
|
|
||||||
|
if (document is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var currentLinks = await EnvelopeReceiverRepository.Query
|
||||||
|
.Include(er => er.Receiver)
|
||||||
|
.Where(er => er.EnvelopeId == envelopeId)
|
||||||
|
.ToListAsync(cancel);
|
||||||
|
|
||||||
|
var linksByEmail = currentLinks
|
||||||
|
.Where(er => !string.IsNullOrWhiteSpace(er.Receiver?.EmailAddress))
|
||||||
|
.GroupBy(er => er.Receiver!.EmailAddress, StringComparer.OrdinalIgnoreCase)
|
||||||
|
.ToDictionary(g => g.Key.ToLowerInvariant(), g => g.First(), StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
var sequence = currentLinks.Count > 0 ? currentLinks.Max(er => er.Sequence) : 0;
|
||||||
|
|
||||||
|
foreach (var receiverDraft in filteredReceivers)
|
||||||
|
{
|
||||||
|
var linkResult = await GetOrCreateEnvelopeReceiverAsync(envelopeId, receiverDraft, linksByEmail, now, sequence, cancel);
|
||||||
|
var link = linkResult.Link;
|
||||||
|
sequence = linkResult.NextSequence;
|
||||||
|
|
||||||
|
await DocReceiverElementRepository.DeleteAsync(query => query
|
||||||
|
.Where(e => e.DocumentId == document.Id)
|
||||||
|
.Where(e => e.ReceiverId == link.ReceiverId), cancel);
|
||||||
|
|
||||||
|
foreach (var field in receiverDraft.Fields.Where(f => f.Page > 0))
|
||||||
|
{
|
||||||
|
await DocReceiverElementRepository.CreateAsync(new DocReceiverElement
|
||||||
|
{
|
||||||
|
DocumentId = document.Id,
|
||||||
|
ReceiverId = link.ReceiverId,
|
||||||
|
ElementType = 1,
|
||||||
|
X = field.X,
|
||||||
|
Y = field.Y,
|
||||||
|
Width = 1.77,
|
||||||
|
Height = 1.96,
|
||||||
|
Page = field.Page,
|
||||||
|
Required = true,
|
||||||
|
ReadOnly = false,
|
||||||
|
AnnotationIndex = 0,
|
||||||
|
AddedWhen = now,
|
||||||
|
FullName = link.Name,
|
||||||
|
Position = string.Empty,
|
||||||
|
Place = string.Empty,
|
||||||
|
Tooltip = string.Empty
|
||||||
|
}, cancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<(EnvelopeReceiver Link, int NextSequence)> GetOrCreateEnvelopeReceiverAsync(
|
||||||
|
int envelopeId,
|
||||||
|
CreateEnvelopeReceiverDto receiverDraft,
|
||||||
|
IDictionary<string, EnvelopeReceiver> linksByEmail,
|
||||||
|
DateTime now,
|
||||||
|
int sequence,
|
||||||
|
CancellationToken cancel)
|
||||||
|
{
|
||||||
|
if (linksByEmail.TryGetValue(receiverDraft.EmailAddress, out var existingLink))
|
||||||
|
{
|
||||||
|
var nextName = string.IsNullOrWhiteSpace(receiverDraft.Name) ? existingLink.Name : receiverDraft.Name!;
|
||||||
|
var nextPhoneNumber = receiverDraft.PhoneNumber ?? existingLink.PhoneNumber;
|
||||||
|
|
||||||
|
await EnvelopeReceiverRepository.UpdateAsync(er =>
|
||||||
|
{
|
||||||
|
er.Name = nextName;
|
||||||
|
er.PhoneNumber = nextPhoneNumber;
|
||||||
|
er.ChangedWhen = now;
|
||||||
|
}, er => er.EnvelopeId == existingLink.EnvelopeId && er.ReceiverId == existingLink.ReceiverId, cancel);
|
||||||
|
|
||||||
|
existingLink.Name = nextName;
|
||||||
|
existingLink.PhoneNumber = nextPhoneNumber;
|
||||||
|
return (existingLink, sequence);
|
||||||
|
}
|
||||||
|
|
||||||
|
var receiver = await ReceiverRepository.Query
|
||||||
|
.FirstOrDefaultAsync(r => r.EmailAddress != null && r.EmailAddress.ToLower() == receiverDraft.EmailAddress, cancel);
|
||||||
|
|
||||||
|
if (receiver is null)
|
||||||
|
{
|
||||||
|
receiver = await ReceiverRepository.CreateAsync(new Receiver
|
||||||
|
{
|
||||||
|
EmailAddress = receiverDraft.EmailAddress,
|
||||||
|
Signature = receiverDraft.EmailAddress.ToUpperInvariant().GetChecksum(),
|
||||||
|
AddedWhen = now,
|
||||||
|
TotpSecretkey = string.Empty,
|
||||||
|
TfaRegDeadline = null
|
||||||
|
}, cancel);
|
||||||
|
}
|
||||||
|
|
||||||
|
sequence++;
|
||||||
|
var link = await EnvelopeReceiverRepository.CreateAsync(new EnvelopeReceiver
|
||||||
|
{
|
||||||
|
EnvelopeId = envelopeId,
|
||||||
|
ReceiverId = receiver.Id,
|
||||||
|
Sequence = sequence,
|
||||||
|
Name = receiverDraft.Name ?? receiverDraft.EmailAddress,
|
||||||
|
JobTitle = string.Empty,
|
||||||
|
CompanyName = string.Empty,
|
||||||
|
PrivateMessage = string.Empty,
|
||||||
|
AccessCode = string.Empty,
|
||||||
|
AddedWhen = now,
|
||||||
|
ChangedWhen = now,
|
||||||
|
PhoneNumber = receiverDraft.PhoneNumber ?? string.Empty
|
||||||
|
}, cancel);
|
||||||
|
|
||||||
|
link.Receiver = receiver;
|
||||||
|
linksByEmail[receiverDraft.EmailAddress] = link;
|
||||||
|
return (link, sequence);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SendEnvelopeAsync(Envelope envelope, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
var hasDocument = await DocumentRepository.Query
|
||||||
|
.AnyAsync(d => d.EnvelopeId == envelope.Id && d.ByteData != null && d.ByteData.Length > 0, cancel);
|
||||||
|
|
||||||
|
if (!hasDocument)
|
||||||
|
throw new BadRequestException("Cannot send envelope without a document.");
|
||||||
|
|
||||||
|
var links = await EnvelopeReceiverRepository.Query
|
||||||
|
.Include(er => er.Receiver)
|
||||||
|
.Where(er => er.EnvelopeId == envelope.Id)
|
||||||
|
.ToListAsync(cancel);
|
||||||
|
|
||||||
|
if (links.Count == 0)
|
||||||
|
throw new BadRequestException("Cannot send envelope without receivers.");
|
||||||
|
|
||||||
|
var receiverIds = links.Select(l => l.ReceiverId).Distinct().ToList();
|
||||||
|
var documentIds = await DocumentRepository.Query
|
||||||
|
.Where(d => d.EnvelopeId == envelope.Id)
|
||||||
|
.Select(d => d.Id)
|
||||||
|
.ToListAsync(cancel);
|
||||||
|
|
||||||
|
var receiverFieldCounts = await DocReceiverElementRepository.Query
|
||||||
|
.Where(e => documentIds.Contains(e.DocumentId))
|
||||||
|
.Where(e => receiverIds.Contains(e.ReceiverId))
|
||||||
|
.GroupBy(e => e.ReceiverId)
|
||||||
|
.Select(g => new { ReceiverId = g.Key, Count = g.Count() })
|
||||||
|
.ToDictionaryAsync(x => x.ReceiverId, x => x.Count, cancel);
|
||||||
|
|
||||||
|
var receiversWithoutFields = links
|
||||||
|
.Where(link => !receiverFieldCounts.TryGetValue(link.ReceiverId, out var count) || count <= 0)
|
||||||
|
.Select(link => link.Name)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (receiversWithoutFields.Count > 0)
|
||||||
|
throw new BadRequestException("Cannot send envelope because some receivers have no signature fields.");
|
||||||
|
|
||||||
|
var changedWhen = DateTime.Now;
|
||||||
|
await Repository.UpdateAsync(e =>
|
||||||
|
{
|
||||||
|
e.Status = EnvelopeStatus.EnvelopeQueued;
|
||||||
|
e.ChangedWhen = changedWhen;
|
||||||
|
}, e => e.Id == envelope.Id, cancel);
|
||||||
|
|
||||||
|
var userReference = await ResolveSenderReferenceAsync(envelope, cancel);
|
||||||
|
|
||||||
|
await Mediator.Send(new CreateHistoryCommand
|
||||||
|
{
|
||||||
|
EnvelopeId = envelope.Id,
|
||||||
|
UserReference = userReference,
|
||||||
|
Status = EnvelopeStatus.EnvelopeQueued
|
||||||
|
}, cancel);
|
||||||
|
|
||||||
|
await QueueInvitationEmailsAsync(envelope, links, userReference, cancel);
|
||||||
|
|
||||||
|
envelope.Status = EnvelopeStatus.EnvelopeQueued;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task QueueInvitationEmailsAsync(
|
||||||
|
Envelope envelope,
|
||||||
|
IReadOnlyCollection<EnvelopeReceiver> links,
|
||||||
|
string senderReference,
|
||||||
|
CancellationToken cancel)
|
||||||
|
{
|
||||||
|
var template = await EmailTemplateRepository.Query
|
||||||
|
.SingleOrDefaultAsync(x => x.Name == EmailTemplateType.DocumentReceived.ToString(), cancel)
|
||||||
|
?? throw new InvalidOperationException($"Email template not found: {EmailTemplateType.DocumentReceived}");
|
||||||
|
|
||||||
|
var signatureHost = await ConfigService.ReadDefaultSignatureHost();
|
||||||
|
var senderName = senderReference;
|
||||||
|
|
||||||
|
foreach (var link in links)
|
||||||
|
{
|
||||||
|
var receiver = link.Receiver;
|
||||||
|
if (receiver is null || string.IsNullOrWhiteSpace(receiver.EmailAddress) || string.IsNullOrWhiteSpace(receiver.Signature))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var envelopeKey = (envelope.Uuid, receiver.Signature).ToEnvelopeKey();
|
||||||
|
var documentLink = $"{signatureHost.TrimEnd('/')}/envelope/login/{Uri.EscapeDataString(envelopeKey)}";
|
||||||
|
|
||||||
|
var placeholders = new Dictionary<string, string>(MailParams.Placeholders)
|
||||||
|
{
|
||||||
|
["[NAME_RECEIVER]"] = link.Name ?? string.Empty,
|
||||||
|
["[NAME_SENDER]"] = senderName ?? string.Empty,
|
||||||
|
["[DOCUMENT_TITLE]"] = envelope.Title ?? string.Empty,
|
||||||
|
["[MESSAGE]"] = envelope.Message ?? string.Empty,
|
||||||
|
["[LINK_TO_DOCUMENT]"] = documentLink,
|
||||||
|
["[LINK_TO_DOCUMENT_TEXT]"] = documentLink[..Math.Min(40, documentLink.Length)] + ".."
|
||||||
|
};
|
||||||
|
|
||||||
|
var subject = ReplacePlaceHolders(template.Subject, placeholders);
|
||||||
|
var body = ReplacePlaceHolders(template.Body, placeholders);
|
||||||
|
|
||||||
|
var emailOut = new EmailOut
|
||||||
|
{
|
||||||
|
EmailAddress = receiver.EmailAddress,
|
||||||
|
EmailSubj = subject,
|
||||||
|
EmailBody = body,
|
||||||
|
AddedWhen = DateTime.Now,
|
||||||
|
AddedWho = DispatcherParams.AddedWho,
|
||||||
|
SendingProfile = DispatcherParams.SendingProfile,
|
||||||
|
ReminderTypeId = DispatcherParams.ReminderTypeId,
|
||||||
|
EmailAttmt1 = DispatcherParams.EmailAttmt1,
|
||||||
|
WfId = (int)EnvelopeStatus.MessageInvitationSent,
|
||||||
|
ReferenceString = receiver.EmailAddress,
|
||||||
|
ReferenceId = link.ReceiverId
|
||||||
|
};
|
||||||
|
|
||||||
|
await EmailOutRepository.CreateAsync(emailOut, cancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ReplacePlaceHolders(string text, Dictionary<string, string> placeHolders)
|
||||||
|
{
|
||||||
|
foreach (var placeHolder in placeHolders)
|
||||||
|
text = text.Replace(placeHolder.Key, placeHolder.Value);
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||||
|
|
||||||
|
public record DeleteEnvelopeResultDto(int EnvelopeId, EnvelopeStatus AppliedStatus, bool IsNoOp);
|
||||||
|
|
||||||
|
public record DeleteEnvelopeCommand : IRequest<DeleteEnvelopeResultDto>
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public int EnvelopeId { get; init; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[MinLength(1)]
|
||||||
|
public string Reason { get; init; } = string.Empty;
|
||||||
|
|
||||||
|
internal int UserId { get; private set; }
|
||||||
|
|
||||||
|
public DeleteEnvelopeCommand WithAuth(int userId)
|
||||||
|
{
|
||||||
|
UserId = userId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Notifications.EnvelopeDeleted;
|
||||||
|
using DigitalData.Core.Abstraction.Application.Repository;
|
||||||
|
using DigitalData.Core.Exceptions;
|
||||||
|
using EnvelopeGenerator.Application.Histories.Commands;
|
||||||
|
using EnvelopeGenerator.Domain.Constants;
|
||||||
|
using EnvelopeGenerator.Domain.Entities;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||||
|
|
||||||
|
public class DeleteEnvelopeCommandHandler : IRequestHandler<DeleteEnvelopeCommand, DeleteEnvelopeResultDto>
|
||||||
|
{
|
||||||
|
private readonly IRepository<Envelope> _envelopeRepository;
|
||||||
|
private readonly IMediator _mediator;
|
||||||
|
|
||||||
|
public DeleteEnvelopeCommandHandler(
|
||||||
|
IRepository<Envelope> envelopeRepository,
|
||||||
|
IMediator mediator)
|
||||||
|
{
|
||||||
|
_envelopeRepository = envelopeRepository;
|
||||||
|
_mediator = mediator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<DeleteEnvelopeResultDto> Handle(DeleteEnvelopeCommand request, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
var reason = request.Reason?.Trim();
|
||||||
|
if (string.IsNullOrWhiteSpace(reason))
|
||||||
|
throw new BadRequestException("Please provide a reason.");
|
||||||
|
|
||||||
|
var envelope = await _envelopeRepository.Query
|
||||||
|
.Include(e => e.User)
|
||||||
|
.Include(e => e.EnvelopeReceivers)
|
||||||
|
.ThenInclude(er => er.Receiver)
|
||||||
|
.FirstOrDefaultAsync(e => e.Id == request.EnvelopeId, cancel)
|
||||||
|
?? throw new NotFoundException($"Envelope {request.EnvelopeId} not found.");
|
||||||
|
|
||||||
|
if (envelope.UserId != request.UserId)
|
||||||
|
throw new ForbiddenException();
|
||||||
|
|
||||||
|
if (envelope.Status is EnvelopeStatus.EnvelopeDeleted or EnvelopeStatus.EnvelopeWithdrawn)
|
||||||
|
return new DeleteEnvelopeResultDto(envelope.Id, envelope.Status, IsNoOp: true);
|
||||||
|
|
||||||
|
var targetStatus = envelope.Status > EnvelopeStatus.EnvelopeSaved
|
||||||
|
? EnvelopeStatus.EnvelopeWithdrawn
|
||||||
|
: EnvelopeStatus.EnvelopeDeleted;
|
||||||
|
|
||||||
|
var changedWhen = DateTime.Now;
|
||||||
|
envelope.Status = targetStatus;
|
||||||
|
envelope.Comment = reason;
|
||||||
|
envelope.ChangedWhen = changedWhen;
|
||||||
|
|
||||||
|
await _envelopeRepository.UpdateAsync(e =>
|
||||||
|
{
|
||||||
|
e.Status = targetStatus;
|
||||||
|
e.Comment = reason;
|
||||||
|
e.ChangedWhen = changedWhen;
|
||||||
|
}, e => e.Id == envelope.Id, cancel);
|
||||||
|
|
||||||
|
var userReference = envelope.User?.Email;
|
||||||
|
if (string.IsNullOrWhiteSpace(userReference))
|
||||||
|
throw new BadRequestException("Envelope sender email is missing.");
|
||||||
|
|
||||||
|
await _mediator.Send(new CreateHistoryCommand
|
||||||
|
{
|
||||||
|
EnvelopeId = envelope.Id,
|
||||||
|
UserReference = userReference,
|
||||||
|
Status = targetStatus,
|
||||||
|
Comment = reason
|
||||||
|
}, cancel);
|
||||||
|
|
||||||
|
foreach (var envelopeReceiver in envelope.EnvelopeReceivers ?? Enumerable.Empty<EnvelopeReceiver>())
|
||||||
|
{
|
||||||
|
if (envelopeReceiver.Receiver is null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
await _mediator.Publish(new EnvelopeDeletedNotification
|
||||||
|
{
|
||||||
|
Envelope = envelope,
|
||||||
|
EnvelopeReceiver = envelopeReceiver,
|
||||||
|
Reason = reason,
|
||||||
|
SenderReference = userReference
|
||||||
|
}, cancel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DeleteEnvelopeResultDto(envelope.Id, targetStatus, IsNoOp: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -149,7 +149,9 @@ public class ReadEnvelopeQueryHandler : IRequestHandler<ReadEnvelopeQuery, IEnum
|
|||||||
query = query.Where(e => Status.Completed.Contains(e.Status));
|
query = query.Where(e => Status.Completed.Contains(e.Status));
|
||||||
|
|
||||||
var envelopes = await query
|
var envelopes = await query
|
||||||
|
.Include(e => e.Type)
|
||||||
.Include(e => e.EnvelopeReceivers).ThenInclude(er => er.Receiver)
|
.Include(e => e.EnvelopeReceivers).ThenInclude(er => er.Receiver)
|
||||||
|
.Include(e => e.Histories)
|
||||||
.ToListAsync(cancel);
|
.ToListAsync(cancel);
|
||||||
|
|
||||||
return _mapper.Map<IEnumerable<EnvelopeDto>>(envelopes);
|
return _mapper.Map<IEnumerable<EnvelopeDto>>(envelopes);
|
||||||
|
|||||||
@@ -123,6 +123,9 @@
|
|||||||
<data name="Back" xml:space="preserve">
|
<data name="Back" xml:space="preserve">
|
||||||
<value>Zurück</value>
|
<value>Zurück</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Next" xml:space="preserve">
|
||||||
|
<value>Weiter</value>
|
||||||
|
</data>
|
||||||
<data name="AuthenticatorSetup_Prefix" xml:space="preserve">
|
<data name="AuthenticatorSetup_Prefix" xml:space="preserve">
|
||||||
<value>Klicken Sie auf den</value>
|
<value>Klicken Sie auf den</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -564,6 +567,12 @@
|
|||||||
<data name="AddReceiver" xml:space="preserve">
|
<data name="AddReceiver" xml:space="preserve">
|
||||||
<value>Empfänger hinzufügen</value>
|
<value>Empfänger hinzufügen</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="SenderWizard_RecentReceivers" xml:space="preserve">
|
||||||
|
<value>Zuletzt verwendete Empfänger</value>
|
||||||
|
</data>
|
||||||
|
<data name="Skip" xml:space="preserve">
|
||||||
|
<value>Überspringen</value>
|
||||||
|
</data>
|
||||||
<data name="DeleteReceiver" xml:space="preserve">
|
<data name="DeleteReceiver" xml:space="preserve">
|
||||||
<value>Empfänger löschen</value>
|
<value>Empfänger löschen</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -651,4 +660,125 @@
|
|||||||
<data name="Status" xml:space="preserve">
|
<data name="Status" xml:space="preserve">
|
||||||
<value>Status</value>
|
<value>Status</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ChangedAt" xml:space="preserve"><value>Geändert am</value></data>
|
||||||
|
<data name="Close" xml:space="preserve"><value>Schließen</value></data>
|
||||||
|
<data name="CloseLanguageMenu" xml:space="preserve"><value>Sprachmenü schließen</value></data>
|
||||||
|
<data name="ConfirmSignature" xml:space="preserve"><value>Unterschrift bestätigen</value></data>
|
||||||
|
<data name="Created" xml:space="preserve"><value>Erstellt</value></data>
|
||||||
|
<data name="Delete" xml:space="preserve"><value>Löschen</value></data>
|
||||||
|
<data name="Document" xml:space="preserve"><value>Dokument</value></data>
|
||||||
|
<data name="DocumentCouldNotBeLoaded" xml:space="preserve"><value>Dokument konnte nicht geladen werden</value></data>
|
||||||
|
<data name="DocumentLoading" xml:space="preserve"><value>Dokument wird geladen...</value></data>
|
||||||
|
<data name="EmailAddress" xml:space="preserve"><value>E-Mail-Adresse</value></data>
|
||||||
|
<data name="Envelope" xml:space="preserve"><value>Umschlag</value></data>
|
||||||
|
<data name="Error" xml:space="preserve"><value>Fehler</value></data>
|
||||||
|
<data name="ErrorLoadingDocument_WithReason" xml:space="preserve"><value>Fehler beim Laden des Dokuments: {0}</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode" xml:space="preserve"><value>Entwicklungsmodus</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode_Detail" xml:space="preserve"><value>Dies kann dazu führen, dass vertrauliche Informationen aus Ausnahmen Endbenutzern angezeigt werden. Für lokales Debugging setzen Sie ASPNETCORE_ENVIRONMENT auf Development und starten die App neu.</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode_Info" xml:space="preserve"><value>Im Entwicklungsmodus werden detailliertere Fehlerinformationen angezeigt.</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode_Warning" xml:space="preserve"><value>Der Entwicklungsmodus sollte in bereitgestellten Anwendungen nicht aktiviert sein.</value></data>
|
||||||
|
<data name="ErrorPage_ProcessingRequest" xml:space="preserve"><value>Bei der Verarbeitung Ihrer Anfrage ist ein Fehler aufgetreten.</value></data>
|
||||||
|
<data name="ErrorPage_RequestId" xml:space="preserve"><value>Anfrage-ID</value></data>
|
||||||
|
<data name="ErrorWithReason" xml:space="preserve"><value>Fehler: {0}</value></data>
|
||||||
|
<data name="From" xml:space="preserve"><value>Von</value></data>
|
||||||
|
<data name="FullName" xml:space="preserve"><value>Vor- und Nachname</value></data>
|
||||||
|
<data name="History" xml:space="preserve"><value>Historie</value></data>
|
||||||
|
<data name="Index_DigitalSignature" xml:space="preserve"><value>Digitale Unterschrift</value></data>
|
||||||
|
<data name="Index_PdfExport" xml:space="preserve"><value>PDF-Export</value></data>
|
||||||
|
<data name="Index_SecureAccess" xml:space="preserve"><value>Sicherer Zugang</value></data>
|
||||||
|
<data name="Index_Subtitle" xml:space="preserve"><value>Willkommen im eSign-Portal</value></data>
|
||||||
|
<data name="Index_ToEnvelopeOverview" xml:space="preserve"><value>Zur Umschlag-Übersicht</value></data>
|
||||||
|
<data name="Languages" xml:space="preserve"><value>Sprachen</value></data>
|
||||||
|
<data name="Loading" xml:space="preserve"><value>Lädt...</value></data>
|
||||||
|
<data name="Login" xml:space="preserve"><value>Anmelden</value></data>
|
||||||
|
<data name="LoginInProgress" xml:space="preserve"><value>Anmelden ...</value></data>
|
||||||
|
<data name="NotAuthenticatedPleaseLoginAgain" xml:space="preserve"><value>Nicht authentifiziert. Bitte melden Sie sich erneut an.</value></data>
|
||||||
|
<data name="Only" xml:space="preserve"><value>Nur</value></data>
|
||||||
|
<data name="OpenDocument" xml:space="preserve"><value>Dokument öffnen</value></data>
|
||||||
|
<data name="Optional" xml:space="preserve"><value>optional</value></data>
|
||||||
|
<data name="Pending" xml:space="preserve"><value>Ausstehend</value></data>
|
||||||
|
<data name="Preview" xml:space="preserve"><value>Vorschau</value></data>
|
||||||
|
<data name="PrivacyPolicy" xml:space="preserve"><value>Datenschutz</value></data>
|
||||||
|
<data name="Receiver" xml:space="preserve"><value>Empfänger</value></data>
|
||||||
|
<data name="ReceiverLogin_AccessCode_Placeholder" xml:space="preserve"><value>Zugangscode eingeben</value></data>
|
||||||
|
<data name="ReceiverLogin_Description" xml:space="preserve"><value>Bitte geben Sie den Zugangscode ein, den Sie per E-Mail erhalten haben, um das Dokument sicher zu öffnen.</value></data>
|
||||||
|
<data name="ReceiverLogin_FooterHelp" xml:space="preserve"><value>Bei Problemen wenden Sie sich bitte an den Absender des Dokuments.</value></data>
|
||||||
|
<data name="ReceiverLogin_InvalidCode_Body" xml:space="preserve"><value>Der eingegebene Code ist falsch. Bitte versuchen Sie es erneut.</value></data>
|
||||||
|
<data name="ReceiverLogin_InvalidCode_Title" xml:space="preserve"><value>Ungültiger Zugangscode.</value></data>
|
||||||
|
<data name="ReceiverLogin_NotFound_Body" xml:space="preserve"><value>Der angegebene Zugangscode konnte keinem Dokument zugeordnet werden. Bitte prüfen Sie den Link in Ihrer E-Mail.</value></data>
|
||||||
|
<data name="ReceiverLogin_NotFound_Title" xml:space="preserve"><value>Dokument nicht gefunden.</value></data>
|
||||||
|
<data name="ReceiverLogin_Subtitle" xml:space="preserve"><value>Sicherer Zugang mit Zugangscode</value></data>
|
||||||
|
<data name="ReceiverSigned_ConfirmBody" xml:space="preserve"><value>Diese Aktion kann nicht rückgängig gemacht werden. Mit der Bestätigung erklären Sie, das oben angezeigte Dokument elektronisch unterzeichnet zu haben. Das unterzeichnete Dokument wird anschließend an alle beteiligten Parteien übermittelt.</value></data>
|
||||||
|
<data name="ReceiverSigned_ConfirmQuestion" xml:space="preserve"><value>Möchten Sie das Dokument verbindlich unterschreiben?</value></data>
|
||||||
|
<data name="ReceiverSigned_EnvelopeKeyMissing" xml:space="preserve"><value>Envelope-Schlüssel fehlt.</value></data>
|
||||||
|
<data name="Refresh" xml:space="preserve"><value>Aktualisieren</value></data>
|
||||||
|
<data name="RequiredField" xml:space="preserve"><value>Pflichtfeld</value></data>
|
||||||
|
<data name="Selected" xml:space="preserve"><value>ausgewählte</value></data>
|
||||||
|
<data name="Send" xml:space="preserve"><value>Senden</value></data>
|
||||||
|
<data name="Sender_ActiveEnvelopes" xml:space="preserve"><value>Aktive Umschläge</value></data>
|
||||||
|
<data name="Sender_CompletedEnvelopes" xml:space="preserve"><value>Abgeschlossene Umschläge</value></data>
|
||||||
|
<data name="Sender_CreateEnvelope" xml:space="preserve"><value>Neuer Umschlag</value></data>
|
||||||
|
<data name="Sender_CreateEnvelope_Title" xml:space="preserve"><value>Neuen Umschlag erstellen</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_Header" xml:space="preserve"><value>Umschlag löschen</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_ReasonPlaceholder" xml:space="preserve"><value>Begründung eingeben...</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_ReasonPrompt" xml:space="preserve"><value>Bitte geben Sie einen Grund an, warum der Umschlag gelöscht/zurückgezogen werden soll.</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_ReasonRequired" xml:space="preserve"><value>Bitte geben Sie einen Löschgrund an.</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_Title" xml:space="preserve"><value>Ausgewählten Umschlag löschen</value></data>
|
||||||
|
<data name="Sender_Edit" xml:space="preserve"><value>Bearbeiten</value></data>
|
||||||
|
<data name="Sender_EditEnvelope_Title" xml:space="preserve"><value>Ausgewählten Umschlag bearbeiten</value></data>
|
||||||
|
<data name="Sender_ExportCurrentView_Title" xml:space="preserve"><value>Aktuelle Ansicht exportieren</value></data>
|
||||||
|
<data name="Sender_ExportFormat_Aria" xml:space="preserve"><value>Exportformat auswählen</value></data>
|
||||||
|
<data name="Sender_ExportView_Title" xml:space="preserve"><value>Export der aktuellen Tabellenansicht</value></data>
|
||||||
|
<data name="Sender_LoadError_Title" xml:space="preserve"><value>Fehler beim Laden der Umschläge</value></data>
|
||||||
|
<data name="Sender_LoadingEnvelopes" xml:space="preserve"><value>Umschläge werden geladen...</value></data>
|
||||||
|
<data name="Sender_NoHistory" xml:space="preserve"><value>Keine Historie vorhanden</value></data>
|
||||||
|
<data name="Sender_NoReceivers" xml:space="preserve"><value>Keine Empfänger</value></data>
|
||||||
|
<data name="Sender_Preview_Title" xml:space="preserve"><value>Ausgewählten Umschlag als PDF anzeigen</value></data>
|
||||||
|
<data name="Sender_PreviewDocumentNotFound" xml:space="preserve"><value>Das Dokument für Umschlag #{0} wurde nicht gefunden oder Sie haben keinen Zugriff darauf.</value></data>
|
||||||
|
<data name="SenderEditor_AddSignature" xml:space="preserve"><value>Signatur hinzufügen</value></data>
|
||||||
|
<data name="SenderEditor_ClickDocumentFor" xml:space="preserve"><value>Klicken Sie auf die Stelle im Dokument für</value></data>
|
||||||
|
<data name="SenderEditor_EmailSuggestionsHint" xml:space="preserve"><value>Bereits verwendete E-Mail-Adressen werden bei der Eingabe vorgeschlagen.</value></data>
|
||||||
|
<data name="SenderEditor_EmailSuggestionsLoading" xml:space="preserve"><value>E-Mail-Vorschläge werden geladen...</value></data>
|
||||||
|
<data name="SenderEditor_ErrorCreatingEnvelope" xml:space="preserve"><value>Fehler beim Erstellen des Umschlags</value></data>
|
||||||
|
<data name="SenderEditor_LoadEnvelopeError" xml:space="preserve"><value>Fehler beim Laden des Umschlags #{0}: {1}</value></data>
|
||||||
|
<data name="SenderEditor_LoadFileError" xml:space="preserve"><value>Fehler beim Laden der Datei: {0}</value></data>
|
||||||
|
<data name="SenderEditor_Message_Placeholder" xml:space="preserve"><value>Bitte unterzeichnen Sie das beigefügte Dokument.</value></data>
|
||||||
|
<data name="SenderEditor_NoDocumentLoaded" xml:space="preserve"><value>Kein Dokument geladen</value></data>
|
||||||
|
<data name="SenderEditor_NoPagesToDisplay" xml:space="preserve"><value>Keine Seiten zur Anzeige verfügbar.</value></data>
|
||||||
|
<data name="SenderEditor_NoReceiversAdded" xml:space="preserve"><value>Noch keine Empfänger hinzugefügt.</value></data>
|
||||||
|
<data name="SenderEditor_PageLabel" xml:space="preserve"><value>Seite</value></data>
|
||||||
|
<data name="SenderEditor_PlaceSignatureField" xml:space="preserve"><value>Signaturfeld platzieren</value></data>
|
||||||
|
<data name="SenderEditor_RemoveAllSignatureFields" xml:space="preserve"><value>Alle Signaturfelder entfernen</value></data>
|
||||||
|
<data name="SenderEditor_SelectPdf" xml:space="preserve"><value>Bitte wählen Sie eine PDF-Datei aus.</value></data>
|
||||||
|
<data name="SenderEditor_Sent_Body" xml:space="preserve"><value>Der bestehende Entwurf wurde versendet.</value></data>
|
||||||
|
<data name="SenderEditor_Sent_Header" xml:space="preserve"><value>Umschlag gesendet</value></data>
|
||||||
|
<data name="SenderEditor_Sent_Title" xml:space="preserve"><value>Umschlag wurde erfolgreich gesendet.</value></data>
|
||||||
|
<data name="SenderEditor_SignatureField" xml:space="preserve"><value>Signaturfeld</value></data>
|
||||||
|
<data name="SenderEditor_Title_Placeholder" xml:space="preserve"><value>z.B. Arbeitsvertrag 2025</value></data>
|
||||||
|
<data name="SenderEditor_ToOverview" xml:space="preserve"><value>Zur Übersicht</value></data>
|
||||||
|
<data name="SenderEditor_UploadPdfToPlaceFields" xml:space="preserve"><value>Laden Sie eine PDF-Datei hoch, um Signaturfelder zu platzieren.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_EmailDuplicate" xml:space="preserve"><value>Diese E-Mail-Adresse wurde bereits hinzugefügt.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_EmailInvalid" xml:space="preserve"><value>Bitte geben Sie eine gültige E-Mail-Adresse ein.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_EmailRequired" xml:space="preserve"><value>Bitte geben Sie eine E-Mail-Adresse ein.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_FullNameRequired" xml:space="preserve"><value>Bitte geben Sie einen Vor- und Nachnamen ein.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_ReceiverRequired" xml:space="preserve"><value>Bitte fügen Sie mindestens einen Empfänger hinzu.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_SignatureFieldRequired" xml:space="preserve"><value>Bitte platzieren Sie mindestens ein Signaturfeld.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_TitleRequired" xml:space="preserve"><value>Bitte geben Sie einen Titel ein.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_UploadPdf" xml:space="preserve"><value>Bitte laden Sie zuerst ein PDF-Dokument hoch.</value></data>
|
||||||
|
<data name="SenderLogin_Description" xml:space="preserve"><value>Bitte melden Sie sich mit Ihren Zugangsdaten an, um auf das Sender-Dashboard zuzugreifen.</value></data>
|
||||||
|
<data name="SenderLogin_FooterHelp" xml:space="preserve"><value>Bei Problemen wenden Sie sich bitte an den Administrator.</value></data>
|
||||||
|
<data name="SenderLogin_InvalidCredentials_Body" xml:space="preserve"><value>Benutzername oder Passwort ist falsch. Bitte versuchen Sie es erneut.</value></data>
|
||||||
|
<data name="SenderLogin_InvalidCredentials_Title" xml:space="preserve"><value>Ungültige Anmeldedaten.</value></data>
|
||||||
|
<data name="SenderLogin_Password_Placeholder" xml:space="preserve"><value>Passwort eingeben</value></data>
|
||||||
|
<data name="SenderLogin_Subtitle" xml:space="preserve"><value>Sicherer Zugang zum Sender-Dashboard</value></data>
|
||||||
|
<data name="SenderLogin_Title" xml:space="preserve"><value>Sender Anmeldung</value></data>
|
||||||
|
<data name="SenderLogin_Username_Placeholder" xml:space="preserve"><value>Benutzername eingeben</value></data>
|
||||||
|
<data name="ServerError" xml:space="preserve"><value>Serverfehler.</value></data>
|
||||||
|
<data name="Signed" xml:space="preserve"><value>Unterschrieben</value></data>
|
||||||
|
<data name="SignedDocument" xml:space="preserve"><value>Signiertes Dokument</value></data>
|
||||||
|
<data name="System" xml:space="preserve"><value>System</value></data>
|
||||||
|
<data name="UnexpectedErrorTryAgainLater" xml:space="preserve"><value>Ein unerwarteter Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.</value></data>
|
||||||
|
<data name="UploadPdf" xml:space="preserve"><value>PDF hochladen</value></data>
|
||||||
|
<data name="UserName" xml:space="preserve"><value>Benutzername</value></data>
|
||||||
|
<data name="VerifyInProgress" xml:space="preserve"><value>Überprüfen ...</value></data>
|
||||||
</root>
|
</root>
|
||||||
@@ -123,6 +123,9 @@
|
|||||||
<data name="Back" xml:space="preserve">
|
<data name="Back" xml:space="preserve">
|
||||||
<value>Back</value>
|
<value>Back</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Next" xml:space="preserve">
|
||||||
|
<value>Next</value>
|
||||||
|
</data>
|
||||||
<data name="AuthenticatorSetup_Prefix" xml:space="preserve">
|
<data name="AuthenticatorSetup_Prefix" xml:space="preserve">
|
||||||
<value>Click the</value>
|
<value>Click the</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -564,6 +567,12 @@
|
|||||||
<data name="AddReceiver" xml:space="preserve">
|
<data name="AddReceiver" xml:space="preserve">
|
||||||
<value>Add Receiver</value>
|
<value>Add Receiver</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="SenderWizard_RecentReceivers" xml:space="preserve">
|
||||||
|
<value>Recently used recipients</value>
|
||||||
|
</data>
|
||||||
|
<data name="Skip" xml:space="preserve">
|
||||||
|
<value>Skip</value>
|
||||||
|
</data>
|
||||||
<data name="DeleteReceiver" xml:space="preserve">
|
<data name="DeleteReceiver" xml:space="preserve">
|
||||||
<value>Delete Receiver</value>
|
<value>Delete Receiver</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -651,4 +660,125 @@
|
|||||||
<data name="Status" xml:space="preserve">
|
<data name="Status" xml:space="preserve">
|
||||||
<value>Status</value>
|
<value>Status</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ChangedAt" xml:space="preserve"><value>Changed at</value></data>
|
||||||
|
<data name="Close" xml:space="preserve"><value>Close</value></data>
|
||||||
|
<data name="CloseLanguageMenu" xml:space="preserve"><value>Close language menu</value></data>
|
||||||
|
<data name="ConfirmSignature" xml:space="preserve"><value>Confirm signature</value></data>
|
||||||
|
<data name="Created" xml:space="preserve"><value>Created</value></data>
|
||||||
|
<data name="Delete" xml:space="preserve"><value>Delete</value></data>
|
||||||
|
<data name="Document" xml:space="preserve"><value>Document</value></data>
|
||||||
|
<data name="DocumentCouldNotBeLoaded" xml:space="preserve"><value>Document could not be loaded</value></data>
|
||||||
|
<data name="DocumentLoading" xml:space="preserve"><value>Document is loading...</value></data>
|
||||||
|
<data name="EmailAddress" xml:space="preserve"><value>Email address</value></data>
|
||||||
|
<data name="Envelope" xml:space="preserve"><value>Envelope</value></data>
|
||||||
|
<data name="Error" xml:space="preserve"><value>Error</value></data>
|
||||||
|
<data name="ErrorLoadingDocument_WithReason" xml:space="preserve"><value>Error loading document: {0}</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode" xml:space="preserve"><value>Development Mode</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode_Detail" xml:space="preserve"><value>This can result in sensitive exception information being shown to end users. For local debugging, set ASPNETCORE_ENVIRONMENT to Development and restart the app.</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode_Info" xml:space="preserve"><value>Switching to Development will display more detailed error information.</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode_Warning" xml:space="preserve"><value>The Development environment should not be enabled in deployed applications.</value></data>
|
||||||
|
<data name="ErrorPage_ProcessingRequest" xml:space="preserve"><value>An error occurred while processing your request.</value></data>
|
||||||
|
<data name="ErrorPage_RequestId" xml:space="preserve"><value>Request ID</value></data>
|
||||||
|
<data name="ErrorWithReason" xml:space="preserve"><value>Error: {0}</value></data>
|
||||||
|
<data name="From" xml:space="preserve"><value>From</value></data>
|
||||||
|
<data name="FullName" xml:space="preserve"><value>First and last name</value></data>
|
||||||
|
<data name="History" xml:space="preserve"><value>History</value></data>
|
||||||
|
<data name="Index_DigitalSignature" xml:space="preserve"><value>Digital signature</value></data>
|
||||||
|
<data name="Index_PdfExport" xml:space="preserve"><value>PDF export</value></data>
|
||||||
|
<data name="Index_SecureAccess" xml:space="preserve"><value>Secure access</value></data>
|
||||||
|
<data name="Index_Subtitle" xml:space="preserve"><value>Welcome to the eSign portal</value></data>
|
||||||
|
<data name="Index_ToEnvelopeOverview" xml:space="preserve"><value>Go to envelope overview</value></data>
|
||||||
|
<data name="Languages" xml:space="preserve"><value>Languages</value></data>
|
||||||
|
<data name="Loading" xml:space="preserve"><value>Loading...</value></data>
|
||||||
|
<data name="Login" xml:space="preserve"><value>Sign in</value></data>
|
||||||
|
<data name="LoginInProgress" xml:space="preserve"><value>Signing in ...</value></data>
|
||||||
|
<data name="NotAuthenticatedPleaseLoginAgain" xml:space="preserve"><value>Not authenticated. Please sign in again.</value></data>
|
||||||
|
<data name="Only" xml:space="preserve"><value>Only</value></data>
|
||||||
|
<data name="OpenDocument" xml:space="preserve"><value>Open document</value></data>
|
||||||
|
<data name="Optional" xml:space="preserve"><value>optional</value></data>
|
||||||
|
<data name="Pending" xml:space="preserve"><value>Pending</value></data>
|
||||||
|
<data name="Preview" xml:space="preserve"><value>Preview</value></data>
|
||||||
|
<data name="PrivacyPolicy" xml:space="preserve"><value>Privacy policy</value></data>
|
||||||
|
<data name="Receiver" xml:space="preserve"><value>Receiver</value></data>
|
||||||
|
<data name="ReceiverLogin_AccessCode_Placeholder" xml:space="preserve"><value>Enter access code</value></data>
|
||||||
|
<data name="ReceiverLogin_Description" xml:space="preserve"><value>Please enter the access code you received by email to securely open the document.</value></data>
|
||||||
|
<data name="ReceiverLogin_FooterHelp" xml:space="preserve"><value>If you have issues, please contact the document sender.</value></data>
|
||||||
|
<data name="ReceiverLogin_InvalidCode_Body" xml:space="preserve"><value>The entered code is incorrect. Please try again.</value></data>
|
||||||
|
<data name="ReceiverLogin_InvalidCode_Title" xml:space="preserve"><value>Invalid access code.</value></data>
|
||||||
|
<data name="ReceiverLogin_NotFound_Body" xml:space="preserve"><value>The provided access code could not be matched to a document. Please verify the link in your email.</value></data>
|
||||||
|
<data name="ReceiverLogin_NotFound_Title" xml:space="preserve"><value>Document not found.</value></data>
|
||||||
|
<data name="ReceiverLogin_Subtitle" xml:space="preserve"><value>Secure access with access code</value></data>
|
||||||
|
<data name="ReceiverSigned_ConfirmBody" xml:space="preserve"><value>This action cannot be undone. By confirming, you declare that you have electronically signed the document shown above. The signed document will then be delivered to all involved parties.</value></data>
|
||||||
|
<data name="ReceiverSigned_ConfirmQuestion" xml:space="preserve"><value>Do you want to sign this document as binding?</value></data>
|
||||||
|
<data name="ReceiverSigned_EnvelopeKeyMissing" xml:space="preserve"><value>Envelope key is missing.</value></data>
|
||||||
|
<data name="Refresh" xml:space="preserve"><value>Refresh</value></data>
|
||||||
|
<data name="RequiredField" xml:space="preserve"><value>Required field</value></data>
|
||||||
|
<data name="Selected" xml:space="preserve"><value>selected</value></data>
|
||||||
|
<data name="Send" xml:space="preserve"><value>Send</value></data>
|
||||||
|
<data name="Sender_ActiveEnvelopes" xml:space="preserve"><value>Active envelopes</value></data>
|
||||||
|
<data name="Sender_CompletedEnvelopes" xml:space="preserve"><value>Completed envelopes</value></data>
|
||||||
|
<data name="Sender_CreateEnvelope" xml:space="preserve"><value>New envelope</value></data>
|
||||||
|
<data name="Sender_CreateEnvelope_Title" xml:space="preserve"><value>Create new envelope</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_Header" xml:space="preserve"><value>Delete envelope</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_ReasonPlaceholder" xml:space="preserve"><value>Enter reason...</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_ReasonPrompt" xml:space="preserve"><value>Please provide a reason why the envelope should be deleted/withdrawn.</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_ReasonRequired" xml:space="preserve"><value>Please provide a deletion reason.</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_Title" xml:space="preserve"><value>Delete selected envelope</value></data>
|
||||||
|
<data name="Sender_Edit" xml:space="preserve"><value>Edit</value></data>
|
||||||
|
<data name="Sender_EditEnvelope_Title" xml:space="preserve"><value>Edit selected envelope</value></data>
|
||||||
|
<data name="Sender_ExportCurrentView_Title" xml:space="preserve"><value>Export current view</value></data>
|
||||||
|
<data name="Sender_ExportFormat_Aria" xml:space="preserve"><value>Select export format</value></data>
|
||||||
|
<data name="Sender_ExportView_Title" xml:space="preserve"><value>Export current table view</value></data>
|
||||||
|
<data name="Sender_LoadError_Title" xml:space="preserve"><value>Error loading envelopes</value></data>
|
||||||
|
<data name="Sender_LoadingEnvelopes" xml:space="preserve"><value>Loading envelopes...</value></data>
|
||||||
|
<data name="Sender_NoHistory" xml:space="preserve"><value>No history available</value></data>
|
||||||
|
<data name="Sender_NoReceivers" xml:space="preserve"><value>No receivers</value></data>
|
||||||
|
<data name="Sender_Preview_Title" xml:space="preserve"><value>Show selected envelope as PDF</value></data>
|
||||||
|
<data name="Sender_PreviewDocumentNotFound" xml:space="preserve"><value>The document for envelope #{0} was not found or you do not have access.</value></data>
|
||||||
|
<data name="SenderEditor_AddSignature" xml:space="preserve"><value>Add signature</value></data>
|
||||||
|
<data name="SenderEditor_ClickDocumentFor" xml:space="preserve"><value>Click on the location in the document for</value></data>
|
||||||
|
<data name="SenderEditor_EmailSuggestionsHint" xml:space="preserve"><value>Previously used email addresses are suggested while typing.</value></data>
|
||||||
|
<data name="SenderEditor_EmailSuggestionsLoading" xml:space="preserve"><value>Loading email suggestions...</value></data>
|
||||||
|
<data name="SenderEditor_ErrorCreatingEnvelope" xml:space="preserve"><value>Error creating envelope</value></data>
|
||||||
|
<data name="SenderEditor_LoadEnvelopeError" xml:space="preserve"><value>Error loading envelope #{0}: {1}</value></data>
|
||||||
|
<data name="SenderEditor_LoadFileError" xml:space="preserve"><value>Error loading file: {0}</value></data>
|
||||||
|
<data name="SenderEditor_Message_Placeholder" xml:space="preserve"><value>Please sign the attached document.</value></data>
|
||||||
|
<data name="SenderEditor_NoDocumentLoaded" xml:space="preserve"><value>No document loaded</value></data>
|
||||||
|
<data name="SenderEditor_NoPagesToDisplay" xml:space="preserve"><value>No pages to display.</value></data>
|
||||||
|
<data name="SenderEditor_NoReceiversAdded" xml:space="preserve"><value>No receivers added yet.</value></data>
|
||||||
|
<data name="SenderEditor_PageLabel" xml:space="preserve"><value>Page</value></data>
|
||||||
|
<data name="SenderEditor_PlaceSignatureField" xml:space="preserve"><value>Place signature field</value></data>
|
||||||
|
<data name="SenderEditor_RemoveAllSignatureFields" xml:space="preserve"><value>Remove all signature fields</value></data>
|
||||||
|
<data name="SenderEditor_SelectPdf" xml:space="preserve"><value>Please select a PDF file.</value></data>
|
||||||
|
<data name="SenderEditor_Sent_Body" xml:space="preserve"><value>The existing draft has been sent.</value></data>
|
||||||
|
<data name="SenderEditor_Sent_Header" xml:space="preserve"><value>Envelope sent</value></data>
|
||||||
|
<data name="SenderEditor_Sent_Title" xml:space="preserve"><value>Envelope was sent successfully.</value></data>
|
||||||
|
<data name="SenderEditor_SignatureField" xml:space="preserve"><value>Signature field</value></data>
|
||||||
|
<data name="SenderEditor_Title_Placeholder" xml:space="preserve"><value>e.g. Employment contract 2025</value></data>
|
||||||
|
<data name="SenderEditor_ToOverview" xml:space="preserve"><value>To overview</value></data>
|
||||||
|
<data name="SenderEditor_UploadPdfToPlaceFields" xml:space="preserve"><value>Upload a PDF file to place signature fields.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_EmailDuplicate" xml:space="preserve"><value>This email address has already been added.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_EmailInvalid" xml:space="preserve"><value>Please enter a valid email address.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_EmailRequired" xml:space="preserve"><value>Please enter an email address.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_FullNameRequired" xml:space="preserve"><value>Please enter first and last name.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_ReceiverRequired" xml:space="preserve"><value>Please add at least one receiver.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_SignatureFieldRequired" xml:space="preserve"><value>Please place at least one signature field.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_TitleRequired" xml:space="preserve"><value>Please enter a title.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_UploadPdf" xml:space="preserve"><value>Please upload a PDF document first.</value></data>
|
||||||
|
<data name="SenderLogin_Description" xml:space="preserve"><value>Please sign in with your credentials to access the sender dashboard.</value></data>
|
||||||
|
<data name="SenderLogin_FooterHelp" xml:space="preserve"><value>If you have issues, please contact the administrator.</value></data>
|
||||||
|
<data name="SenderLogin_InvalidCredentials_Body" xml:space="preserve"><value>Username or password is incorrect. Please try again.</value></data>
|
||||||
|
<data name="SenderLogin_InvalidCredentials_Title" xml:space="preserve"><value>Invalid credentials.</value></data>
|
||||||
|
<data name="SenderLogin_Password_Placeholder" xml:space="preserve"><value>Enter password</value></data>
|
||||||
|
<data name="SenderLogin_Subtitle" xml:space="preserve"><value>Secure access to sender dashboard</value></data>
|
||||||
|
<data name="SenderLogin_Title" xml:space="preserve"><value>Sender login</value></data>
|
||||||
|
<data name="SenderLogin_Username_Placeholder" xml:space="preserve"><value>Enter username</value></data>
|
||||||
|
<data name="ServerError" xml:space="preserve"><value>Server error.</value></data>
|
||||||
|
<data name="Signed" xml:space="preserve"><value>Signed</value></data>
|
||||||
|
<data name="SignedDocument" xml:space="preserve"><value>Signed document</value></data>
|
||||||
|
<data name="System" xml:space="preserve"><value>System</value></data>
|
||||||
|
<data name="UnexpectedErrorTryAgainLater" xml:space="preserve"><value>An unexpected error occurred. Please try again later.</value></data>
|
||||||
|
<data name="UploadPdf" xml:space="preserve"><value>Upload PDF</value></data>
|
||||||
|
<data name="UserName" xml:space="preserve"><value>Username</value></data>
|
||||||
|
<data name="VerifyInProgress" xml:space="preserve"><value>Verifying ...</value></data>
|
||||||
</root>
|
</root>
|
||||||
@@ -123,6 +123,9 @@
|
|||||||
<data name="Back" xml:space="preserve">
|
<data name="Back" xml:space="preserve">
|
||||||
<value>Retour</value>
|
<value>Retour</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Next" xml:space="preserve">
|
||||||
|
<value>Suivant</value>
|
||||||
|
</data>
|
||||||
<data name="AuthenticatorSetup_Prefix" xml:space="preserve">
|
<data name="AuthenticatorSetup_Prefix" xml:space="preserve">
|
||||||
<value>Cliquez sur</value>
|
<value>Cliquez sur</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -564,6 +567,12 @@
|
|||||||
<data name="AddReceiver" xml:space="preserve">
|
<data name="AddReceiver" xml:space="preserve">
|
||||||
<value>Ajouter un destinataire</value>
|
<value>Ajouter un destinataire</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="SenderWizard_RecentReceivers" xml:space="preserve">
|
||||||
|
<value>Destinataires recents</value>
|
||||||
|
</data>
|
||||||
|
<data name="Skip" xml:space="preserve">
|
||||||
|
<value>Passer</value>
|
||||||
|
</data>
|
||||||
<data name="DeleteReceiver" xml:space="preserve">
|
<data name="DeleteReceiver" xml:space="preserve">
|
||||||
<value>Supprimer le destinataire</value>
|
<value>Supprimer le destinataire</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -651,4 +660,125 @@
|
|||||||
<data name="Status" xml:space="preserve">
|
<data name="Status" xml:space="preserve">
|
||||||
<value>Statut</value>
|
<value>Statut</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ChangedAt" xml:space="preserve"><value>Modifié le</value></data>
|
||||||
|
<data name="Close" xml:space="preserve"><value>Fermer</value></data>
|
||||||
|
<data name="CloseLanguageMenu" xml:space="preserve"><value>Fermer le menu des langues</value></data>
|
||||||
|
<data name="ConfirmSignature" xml:space="preserve"><value>Confirmer la signature</value></data>
|
||||||
|
<data name="Created" xml:space="preserve"><value>Créé</value></data>
|
||||||
|
<data name="Delete" xml:space="preserve"><value>Supprimer</value></data>
|
||||||
|
<data name="Document" xml:space="preserve"><value>Document</value></data>
|
||||||
|
<data name="DocumentCouldNotBeLoaded" xml:space="preserve"><value>Le document n'a pas pu être chargé</value></data>
|
||||||
|
<data name="DocumentLoading" xml:space="preserve"><value>Chargement du document...</value></data>
|
||||||
|
<data name="EmailAddress" xml:space="preserve"><value>Adresse e-mail</value></data>
|
||||||
|
<data name="Envelope" xml:space="preserve"><value>Enveloppe</value></data>
|
||||||
|
<data name="Error" xml:space="preserve"><value>Erreur</value></data>
|
||||||
|
<data name="ErrorLoadingDocument_WithReason" xml:space="preserve"><value>Erreur lors du chargement du document : {0}</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode" xml:space="preserve"><value>Mode développement</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode_Detail" xml:space="preserve"><value>Cela peut afficher des informations sensibles d'exception aux utilisateurs finaux. Pour le débogage local, définissez ASPNETCORE_ENVIRONMENT sur Development et redémarrez l'application.</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode_Info" xml:space="preserve"><value>Le mode développement affiche des informations d'erreur plus détaillées.</value></data>
|
||||||
|
<data name="ErrorPage_DevelopmentMode_Warning" xml:space="preserve"><value>Le mode développement ne doit pas être activé dans les applications déployées.</value></data>
|
||||||
|
<data name="ErrorPage_ProcessingRequest" xml:space="preserve"><value>Une erreur s'est produite lors du traitement de votre demande.</value></data>
|
||||||
|
<data name="ErrorPage_RequestId" xml:space="preserve"><value>ID de requête</value></data>
|
||||||
|
<data name="ErrorWithReason" xml:space="preserve"><value>Erreur : {0}</value></data>
|
||||||
|
<data name="From" xml:space="preserve"><value>De</value></data>
|
||||||
|
<data name="FullName" xml:space="preserve"><value>Nom et prénom</value></data>
|
||||||
|
<data name="History" xml:space="preserve"><value>Historique</value></data>
|
||||||
|
<data name="Index_DigitalSignature" xml:space="preserve"><value>Signature numérique</value></data>
|
||||||
|
<data name="Index_PdfExport" xml:space="preserve"><value>Export PDF</value></data>
|
||||||
|
<data name="Index_SecureAccess" xml:space="preserve"><value>Accès sécurisé</value></data>
|
||||||
|
<data name="Index_Subtitle" xml:space="preserve"><value>Bienvenue sur le portail eSign</value></data>
|
||||||
|
<data name="Index_ToEnvelopeOverview" xml:space="preserve"><value>Aller à l'aperçu des enveloppes</value></data>
|
||||||
|
<data name="Languages" xml:space="preserve"><value>Langues</value></data>
|
||||||
|
<data name="Loading" xml:space="preserve"><value>Chargement...</value></data>
|
||||||
|
<data name="Login" xml:space="preserve"><value>Connexion</value></data>
|
||||||
|
<data name="LoginInProgress" xml:space="preserve"><value>Connexion ...</value></data>
|
||||||
|
<data name="NotAuthenticatedPleaseLoginAgain" xml:space="preserve"><value>Non authentifié. Veuillez vous reconnecter.</value></data>
|
||||||
|
<data name="Only" xml:space="preserve"><value>Uniquement</value></data>
|
||||||
|
<data name="OpenDocument" xml:space="preserve"><value>Ouvrir le document</value></data>
|
||||||
|
<data name="Optional" xml:space="preserve"><value>optionnel</value></data>
|
||||||
|
<data name="Pending" xml:space="preserve"><value>En attente</value></data>
|
||||||
|
<data name="Preview" xml:space="preserve"><value>Aperçu</value></data>
|
||||||
|
<data name="PrivacyPolicy" xml:space="preserve"><value>Politique de confidentialité</value></data>
|
||||||
|
<data name="Receiver" xml:space="preserve"><value>Destinataire</value></data>
|
||||||
|
<data name="ReceiverLogin_AccessCode_Placeholder" xml:space="preserve"><value>Saisir le code d'accès</value></data>
|
||||||
|
<data name="ReceiverLogin_Description" xml:space="preserve"><value>Veuillez saisir le code d'accès reçu par e-mail pour ouvrir le document en toute sécurité.</value></data>
|
||||||
|
<data name="ReceiverLogin_FooterHelp" xml:space="preserve"><value>En cas de problème, veuillez contacter l'expéditeur du document.</value></data>
|
||||||
|
<data name="ReceiverLogin_InvalidCode_Body" xml:space="preserve"><value>Le code saisi est incorrect. Veuillez réessayer.</value></data>
|
||||||
|
<data name="ReceiverLogin_InvalidCode_Title" xml:space="preserve"><value>Code d'accès invalide.</value></data>
|
||||||
|
<data name="ReceiverLogin_NotFound_Body" xml:space="preserve"><value>Le code d'accès indiqué ne correspond à aucun document. Veuillez vérifier le lien dans votre e-mail.</value></data>
|
||||||
|
<data name="ReceiverLogin_NotFound_Title" xml:space="preserve"><value>Document introuvable.</value></data>
|
||||||
|
<data name="ReceiverLogin_Subtitle" xml:space="preserve"><value>Accès sécurisé avec code d'accès</value></data>
|
||||||
|
<data name="ReceiverSigned_ConfirmBody" xml:space="preserve"><value>Cette action est irréversible. En confirmant, vous déclarez avoir signé électroniquement le document affiché ci-dessus. Le document signé sera ensuite transmis à toutes les parties concernées.</value></data>
|
||||||
|
<data name="ReceiverSigned_ConfirmQuestion" xml:space="preserve"><value>Voulez-vous signer ce document de manière contraignante ?</value></data>
|
||||||
|
<data name="ReceiverSigned_EnvelopeKeyMissing" xml:space="preserve"><value>La clé d'enveloppe est manquante.</value></data>
|
||||||
|
<data name="Refresh" xml:space="preserve"><value>Actualiser</value></data>
|
||||||
|
<data name="RequiredField" xml:space="preserve"><value>Champ obligatoire</value></data>
|
||||||
|
<data name="Selected" xml:space="preserve"><value>sélectionnées</value></data>
|
||||||
|
<data name="Send" xml:space="preserve"><value>Envoyer</value></data>
|
||||||
|
<data name="Sender_ActiveEnvelopes" xml:space="preserve"><value>Enveloppes actives</value></data>
|
||||||
|
<data name="Sender_CompletedEnvelopes" xml:space="preserve"><value>Enveloppes terminées</value></data>
|
||||||
|
<data name="Sender_CreateEnvelope" xml:space="preserve"><value>Nouvelle enveloppe</value></data>
|
||||||
|
<data name="Sender_CreateEnvelope_Title" xml:space="preserve"><value>Créer une nouvelle enveloppe</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_Header" xml:space="preserve"><value>Supprimer l'enveloppe</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_ReasonPlaceholder" xml:space="preserve"><value>Saisir la raison...</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_ReasonPrompt" xml:space="preserve"><value>Veuillez indiquer la raison pour laquelle l'enveloppe doit être supprimée/retirée.</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_ReasonRequired" xml:space="preserve"><value>Veuillez indiquer un motif de suppression.</value></data>
|
||||||
|
<data name="Sender_DeleteEnvelope_Title" xml:space="preserve"><value>Supprimer l'enveloppe sélectionnée</value></data>
|
||||||
|
<data name="Sender_Edit" xml:space="preserve"><value>Modifier</value></data>
|
||||||
|
<data name="Sender_EditEnvelope_Title" xml:space="preserve"><value>Modifier l'enveloppe sélectionnée</value></data>
|
||||||
|
<data name="Sender_ExportCurrentView_Title" xml:space="preserve"><value>Exporter la vue actuelle</value></data>
|
||||||
|
<data name="Sender_ExportFormat_Aria" xml:space="preserve"><value>Sélectionner le format d'export</value></data>
|
||||||
|
<data name="Sender_ExportView_Title" xml:space="preserve"><value>Exporter la vue actuelle du tableau</value></data>
|
||||||
|
<data name="Sender_LoadError_Title" xml:space="preserve"><value>Erreur lors du chargement des enveloppes</value></data>
|
||||||
|
<data name="Sender_LoadingEnvelopes" xml:space="preserve"><value>Chargement des enveloppes...</value></data>
|
||||||
|
<data name="Sender_NoHistory" xml:space="preserve"><value>Aucun historique disponible</value></data>
|
||||||
|
<data name="Sender_NoReceivers" xml:space="preserve"><value>Aucun destinataire</value></data>
|
||||||
|
<data name="Sender_Preview_Title" xml:space="preserve"><value>Afficher l'enveloppe sélectionnée en PDF</value></data>
|
||||||
|
<data name="Sender_PreviewDocumentNotFound" xml:space="preserve"><value>Le document de l'enveloppe #{0} est introuvable ou vous n'avez pas l'autorisation d'y accéder.</value></data>
|
||||||
|
<data name="SenderEditor_AddSignature" xml:space="preserve"><value>Ajouter une signature</value></data>
|
||||||
|
<data name="SenderEditor_ClickDocumentFor" xml:space="preserve"><value>Cliquez sur l'emplacement dans le document pour</value></data>
|
||||||
|
<data name="SenderEditor_EmailSuggestionsHint" xml:space="preserve"><value>Les adresses e-mail déjà utilisées sont proposées pendant la saisie.</value></data>
|
||||||
|
<data name="SenderEditor_EmailSuggestionsLoading" xml:space="preserve"><value>Chargement des suggestions d'e-mail...</value></data>
|
||||||
|
<data name="SenderEditor_ErrorCreatingEnvelope" xml:space="preserve"><value>Erreur lors de la création de l'enveloppe</value></data>
|
||||||
|
<data name="SenderEditor_LoadEnvelopeError" xml:space="preserve"><value>Erreur lors du chargement de l'enveloppe #{0} : {1}</value></data>
|
||||||
|
<data name="SenderEditor_LoadFileError" xml:space="preserve"><value>Erreur lors du chargement du fichier : {0}</value></data>
|
||||||
|
<data name="SenderEditor_Message_Placeholder" xml:space="preserve"><value>Veuillez signer le document ci-joint.</value></data>
|
||||||
|
<data name="SenderEditor_NoDocumentLoaded" xml:space="preserve"><value>Aucun document chargé</value></data>
|
||||||
|
<data name="SenderEditor_NoPagesToDisplay" xml:space="preserve"><value>Aucune page à afficher.</value></data>
|
||||||
|
<data name="SenderEditor_NoReceiversAdded" xml:space="preserve"><value>Aucun destinataire ajouté pour le moment.</value></data>
|
||||||
|
<data name="SenderEditor_PageLabel" xml:space="preserve"><value>Page</value></data>
|
||||||
|
<data name="SenderEditor_PlaceSignatureField" xml:space="preserve"><value>Placer un champ de signature</value></data>
|
||||||
|
<data name="SenderEditor_RemoveAllSignatureFields" xml:space="preserve"><value>Supprimer tous les champs de signature</value></data>
|
||||||
|
<data name="SenderEditor_SelectPdf" xml:space="preserve"><value>Veuillez sélectionner un fichier PDF.</value></data>
|
||||||
|
<data name="SenderEditor_Sent_Body" xml:space="preserve"><value>Le brouillon existant a été envoyé.</value></data>
|
||||||
|
<data name="SenderEditor_Sent_Header" xml:space="preserve"><value>Enveloppe envoyée</value></data>
|
||||||
|
<data name="SenderEditor_Sent_Title" xml:space="preserve"><value>L'enveloppe a été envoyée avec succès.</value></data>
|
||||||
|
<data name="SenderEditor_SignatureField" xml:space="preserve"><value>Champ de signature</value></data>
|
||||||
|
<data name="SenderEditor_Title_Placeholder" xml:space="preserve"><value>p. ex. Contrat de travail 2025</value></data>
|
||||||
|
<data name="SenderEditor_ToOverview" xml:space="preserve"><value>Vers l'aperçu</value></data>
|
||||||
|
<data name="SenderEditor_UploadPdfToPlaceFields" xml:space="preserve"><value>Téléversez un fichier PDF pour placer des champs de signature.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_EmailDuplicate" xml:space="preserve"><value>Cette adresse e-mail a déjà été ajoutée.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_EmailInvalid" xml:space="preserve"><value>Veuillez saisir une adresse e-mail valide.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_EmailRequired" xml:space="preserve"><value>Veuillez saisir une adresse e-mail.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_FullNameRequired" xml:space="preserve"><value>Veuillez saisir le nom et le prénom.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_ReceiverRequired" xml:space="preserve"><value>Veuillez ajouter au moins un destinataire.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_SignatureFieldRequired" xml:space="preserve"><value>Veuillez placer au moins un champ de signature.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_TitleRequired" xml:space="preserve"><value>Veuillez saisir un titre.</value></data>
|
||||||
|
<data name="SenderEditor_Validation_UploadPdf" xml:space="preserve"><value>Veuillez d'abord téléverser un document PDF.</value></data>
|
||||||
|
<data name="SenderLogin_Description" xml:space="preserve"><value>Veuillez vous connecter avec vos identifiants pour accéder au tableau de bord expéditeur.</value></data>
|
||||||
|
<data name="SenderLogin_FooterHelp" xml:space="preserve"><value>En cas de problème, veuillez contacter l'administrateur.</value></data>
|
||||||
|
<data name="SenderLogin_InvalidCredentials_Body" xml:space="preserve"><value>Le nom d'utilisateur ou le mot de passe est incorrect. Veuillez réessayer.</value></data>
|
||||||
|
<data name="SenderLogin_InvalidCredentials_Title" xml:space="preserve"><value>Identifiants invalides.</value></data>
|
||||||
|
<data name="SenderLogin_Password_Placeholder" xml:space="preserve"><value>Saisir le mot de passe</value></data>
|
||||||
|
<data name="SenderLogin_Subtitle" xml:space="preserve"><value>Accès sécurisé au tableau de bord expéditeur</value></data>
|
||||||
|
<data name="SenderLogin_Title" xml:space="preserve"><value>Connexion expéditeur</value></data>
|
||||||
|
<data name="SenderLogin_Username_Placeholder" xml:space="preserve"><value>Saisir le nom d'utilisateur</value></data>
|
||||||
|
<data name="ServerError" xml:space="preserve"><value>Erreur serveur.</value></data>
|
||||||
|
<data name="Signed" xml:space="preserve"><value>Signé</value></data>
|
||||||
|
<data name="SignedDocument" xml:space="preserve"><value>Document signé</value></data>
|
||||||
|
<data name="System" xml:space="preserve"><value>Système</value></data>
|
||||||
|
<data name="UnexpectedErrorTryAgainLater" xml:space="preserve"><value>Une erreur inattendue s'est produite. Veuillez réessayer plus tard.</value></data>
|
||||||
|
<data name="UploadPdf" xml:space="preserve"><value>Téléverser un PDF</value></data>
|
||||||
|
<data name="UserName" xml:space="preserve"><value>Nom d'utilisateur</value></data>
|
||||||
|
<data name="VerifyInProgress" xml:space="preserve"><value>Vérification ...</value></data>
|
||||||
</root>
|
</root>
|
||||||
@@ -22,41 +22,41 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
public string Language { get; set; }
|
public string Language { get; set; }
|
||||||
|
|
||||||
[Column("EXPIRES_DAYS")]
|
[Column("EXPIRES_DAYS")]
|
||||||
public int ExpiresDays { get; set; }
|
public int? ExpiresDays { get; set; }
|
||||||
|
|
||||||
[Column("CERTIFICATION_TYPE")]
|
[Column("CERTIFICATION_TYPE")]
|
||||||
public Constants.CertificationType CertificationType { get; set; } = Constants.CertificationType.AdvancedElectronicSignature;
|
public Constants.CertificationType? CertificationType { get; set; }
|
||||||
|
|
||||||
[Column("USE_ACCESS_CODE")]
|
[Column("USE_ACCESS_CODE")]
|
||||||
public bool UseAccessCode { get; set; }
|
public bool? UseAccessCode { get; set; }
|
||||||
|
|
||||||
[Column("FINAL_EMAIL_TO_CREATOR")]
|
[Column("FINAL_EMAIL_TO_CREATOR")]
|
||||||
public Constants.FinalEmailType FinalEmailToCreator { get; set; }
|
public Constants.FinalEmailType? FinalEmailToCreator { get; set; }
|
||||||
|
|
||||||
[Column("FINAL_EMAIL_TO_RECEIVERS")]
|
[Column("FINAL_EMAIL_TO_RECEIVERS")]
|
||||||
public Constants.FinalEmailType FinalEmailToReceivers { get; set; }
|
public Constants.FinalEmailType? FinalEmailToReceivers { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||||
public DateTime AddedWhen { get; set; }
|
public DateTime AddedWhen { get; set; }
|
||||||
|
|
||||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||||
public DateTime ChangedWhen { get; set; }
|
public DateTime? ChangedWhen { get; set; }
|
||||||
|
|
||||||
[Column("EXPIRES_WARNING_DAYS")]
|
[Column("EXPIRES_WARNING_DAYS")]
|
||||||
public int ExpiresWarningDays { get; set; }
|
public int? ExpiresWarningDays { get; set; }
|
||||||
|
|
||||||
[Column("SEND_REMINDER_EMAILS")]
|
[Column("SEND_REMINDER_EMAILS")]
|
||||||
public bool SendReminderEmails { get; set; } = false;
|
public bool? SendReminderEmails { get; set; }
|
||||||
|
|
||||||
[Column("FIRST_REMINDER_DAYS")]
|
[Column("FIRST_REMINDER_DAYS")]
|
||||||
public int FirstReminderDays { get; set; } = 0;
|
public int? FirstReminderDays { get; set; }
|
||||||
|
|
||||||
[Column("REMINDER_INTERVAL_DAYS")]
|
[Column("REMINDER_INTERVAL_DAYS")]
|
||||||
public int ReminderIntervalDays { get; set; } = 0;
|
public int? ReminderIntervalDays { get; set; }
|
||||||
|
|
||||||
[Column("CONTRACT_TYPE")]
|
[Column("CONTRACT_TYPE")]
|
||||||
public int ContractType { get; set; }
|
public int? ContractType { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public bool TFA_Enabled { get; set; } = false;
|
public bool TFA_Enabled { get; set; } = false;
|
||||||
@@ -70,14 +70,14 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int ExpiresWhenDays
|
public int ExpiresWhenDays
|
||||||
{
|
{
|
||||||
get => ExpiresDays;
|
get => ExpiresDays ?? 0;
|
||||||
set => ExpiresDays = value;
|
set => ExpiresDays = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int ExpiresWarningWhenDays
|
public int ExpiresWarningWhenDays
|
||||||
{
|
{
|
||||||
get => ExpiresWarningDays;
|
get => ExpiresWarningDays ?? 0;
|
||||||
set => ExpiresWarningDays = value;
|
set => ExpiresWarningDays = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
7
EnvelopeGenerator.Domain/Resources/Model.cs
Normal file
7
EnvelopeGenerator.Domain/Resources/Model.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace EnvelopeGenerator.Domain.Resources
|
||||||
|
{
|
||||||
|
// Marker type for IStringLocalizer lookup of Resources/Model.resx.
|
||||||
|
public class Model
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -276,4 +276,61 @@
|
|||||||
<data name="YesWithAttachment" xml:space="preserve">
|
<data name="YesWithAttachment" xml:space="preserve">
|
||||||
<value>Yes, with Attachment</value>
|
<value>Yes, with Attachment</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ElectronicSignature" xml:space="preserve">
|
||||||
|
<value>Electronic Signature</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopeType" xml:space="preserve">
|
||||||
|
<value>Envelope Type</value>
|
||||||
|
</data>
|
||||||
|
<data name="Language" xml:space="preserve">
|
||||||
|
<value>Language</value>
|
||||||
|
</data>
|
||||||
|
<data name="CertificationType" xml:space="preserve">
|
||||||
|
<value>Certification</value>
|
||||||
|
</data>
|
||||||
|
<data name="TFAEnabled" xml:space="preserve">
|
||||||
|
<value>2FA enabled</value>
|
||||||
|
</data>
|
||||||
|
<data name="UseAccessCode" xml:space="preserve">
|
||||||
|
<value>Use Access Code</value>
|
||||||
|
</data>
|
||||||
|
<data name="FinalEmailToCreator" xml:space="preserve">
|
||||||
|
<value>Final Email to Creator</value>
|
||||||
|
</data>
|
||||||
|
<data name="FinalEmailToReceivers" xml:space="preserve">
|
||||||
|
<value>Final Email to Receivers</value>
|
||||||
|
</data>
|
||||||
|
<data name="SendReminderEmails" xml:space="preserve">
|
||||||
|
<value>Send Reminder Emails</value>
|
||||||
|
</data>
|
||||||
|
<data name="FirstReminderDays" xml:space="preserve">
|
||||||
|
<value>First Reminder (Days)</value>
|
||||||
|
</data>
|
||||||
|
<data name="ReminderIntervalDays" xml:space="preserve">
|
||||||
|
<value>Reminder Interval (Days)</value>
|
||||||
|
</data>
|
||||||
|
<data name="ExpiresWhenDays" xml:space="preserve">
|
||||||
|
<value>Expires After (Days)</value>
|
||||||
|
</data>
|
||||||
|
<data name="ExpiresWarningWhenDays" xml:space="preserve">
|
||||||
|
<value>Expiry Warning (Days)</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_EnvelopeSettings" xml:space="preserve">
|
||||||
|
<value>Envelope Settings</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_AdvancedOptional" xml:space="preserve">
|
||||||
|
<value>Advanced</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_SelectTemplate" xml:space="preserve">
|
||||||
|
<value>Select Template</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_Validation_ReminderInterval" xml:space="preserve">
|
||||||
|
<value>Please enter a reminder interval greater than 0 days.</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_Validation_FirstReminder" xml:space="preserve">
|
||||||
|
<value>Please enter valid days for the first reminder.</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_Validation_ExpiryWarning" xml:space="preserve">
|
||||||
|
<value>The expiry warning cannot be after the expiry date.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
173
EnvelopeGenerator.Domain/Resources/Model.fr-FR.resx
Normal file
173
EnvelopeGenerator.Domain/Resources/Model.fr-FR.resx
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
|
||||||
|
<data name="AccessCodeIncorrect" xml:space="preserve">
|
||||||
|
<value>Code d'acces incorrect</value>
|
||||||
|
</data>
|
||||||
|
<data name="DocumentRejected" xml:space="preserve">
|
||||||
|
<value>Document rejete</value>
|
||||||
|
</data>
|
||||||
|
<data name="DocumentSigned" xml:space="preserve">
|
||||||
|
<value>Document signe</value>
|
||||||
|
</data>
|
||||||
|
<data name="Draft" xml:space="preserve">
|
||||||
|
<value>Brouillon</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopeCompletelySigned" xml:space="preserve">
|
||||||
|
<value>Entierement signe</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopeCreated" xml:space="preserve">
|
||||||
|
<value>Enveloppe creee</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopeDeleted" xml:space="preserve">
|
||||||
|
<value>Enveloppe supprimee</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopePartlySigned" xml:space="preserve">
|
||||||
|
<value>Partiellement signee</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopeQueued" xml:space="preserve">
|
||||||
|
<value>Enveloppe en file d'attente</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopeRejected" xml:space="preserve">
|
||||||
|
<value>Enveloppe rejetee</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopeSaved" xml:space="preserve">
|
||||||
|
<value>Enregistree</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopeSent" xml:space="preserve">
|
||||||
|
<value>Envoyee</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopeWithdrawn" xml:space="preserve">
|
||||||
|
<value>Enveloppe retiree</value>
|
||||||
|
</data>
|
||||||
|
<data name="MessageAccessCodeSent" xml:space="preserve">
|
||||||
|
<value>Code d'acces envoye</value>
|
||||||
|
</data>
|
||||||
|
<data name="MessageCompletionSent" xml:space="preserve">
|
||||||
|
<value>E-mail de cloture envoye</value>
|
||||||
|
</data>
|
||||||
|
<data name="MessageConfirmationSent" xml:space="preserve">
|
||||||
|
<value>Confirmation finale envoyee</value>
|
||||||
|
</data>
|
||||||
|
<data name="MessageDeletionSent" xml:space="preserve">
|
||||||
|
<value>Notification de suppression envoyee</value>
|
||||||
|
</data>
|
||||||
|
<data name="MessageInvitationSent" xml:space="preserve">
|
||||||
|
<value>Invitation envoyee</value>
|
||||||
|
</data>
|
||||||
|
<data name="ElectronicSignature" xml:space="preserve">
|
||||||
|
<value>Signature electronique</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopeType" xml:space="preserve">
|
||||||
|
<value>Type d'enveloppe</value>
|
||||||
|
</data>
|
||||||
|
<data name="Language" xml:space="preserve">
|
||||||
|
<value>Langue</value>
|
||||||
|
</data>
|
||||||
|
<data name="CertificationType" xml:space="preserve">
|
||||||
|
<value>Certification</value>
|
||||||
|
</data>
|
||||||
|
<data name="TFAEnabled" xml:space="preserve">
|
||||||
|
<value>2FA active</value>
|
||||||
|
</data>
|
||||||
|
<data name="UseAccessCode" xml:space="preserve">
|
||||||
|
<value>Utiliser un code d'acces</value>
|
||||||
|
</data>
|
||||||
|
<data name="FinalEmailToCreator" xml:space="preserve">
|
||||||
|
<value>E-mail final au createur</value>
|
||||||
|
</data>
|
||||||
|
<data name="FinalEmailToReceivers" xml:space="preserve">
|
||||||
|
<value>E-mail final aux destinataires</value>
|
||||||
|
</data>
|
||||||
|
<data name="SendReminderEmails" xml:space="preserve">
|
||||||
|
<value>Envoyer des e-mails de rappel</value>
|
||||||
|
</data>
|
||||||
|
<data name="FirstReminderDays" xml:space="preserve">
|
||||||
|
<value>Premier rappel (jours)</value>
|
||||||
|
</data>
|
||||||
|
<data name="ReminderIntervalDays" xml:space="preserve">
|
||||||
|
<value>Intervalle de rappel (jours)</value>
|
||||||
|
</data>
|
||||||
|
<data name="ExpiresWhenDays" xml:space="preserve">
|
||||||
|
<value>Expire apres (jours)</value>
|
||||||
|
</data>
|
||||||
|
<data name="ExpiresWarningWhenDays" xml:space="preserve">
|
||||||
|
<value>Avertissement d'expiration (jours)</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_EnvelopeSettings" xml:space="preserve">
|
||||||
|
<value>Parametres de l'enveloppe</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_AdvancedOptional" xml:space="preserve">
|
||||||
|
<value>Avance</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_SelectTemplate" xml:space="preserve">
|
||||||
|
<value>Selectionner un modele</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_Validation_ReminderInterval" xml:space="preserve">
|
||||||
|
<value>Veuillez saisir un intervalle de rappel superieur a 0 jour.</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_Validation_FirstReminder" xml:space="preserve">
|
||||||
|
<value>Veuillez saisir des jours valides pour le premier rappel.</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_Validation_ExpiryWarning" xml:space="preserve">
|
||||||
|
<value>L'avertissement d'expiration ne peut pas etre apres la date d'expiration.</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
||||||
@@ -279,4 +279,61 @@
|
|||||||
<data name="YesWithAttachment" xml:space="preserve">
|
<data name="YesWithAttachment" xml:space="preserve">
|
||||||
<value>Ja, mit Anhang</value>
|
<value>Ja, mit Anhang</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ElectronicSignature" xml:space="preserve">
|
||||||
|
<value>Elektronische Signatur</value>
|
||||||
|
</data>
|
||||||
|
<data name="EnvelopeType" xml:space="preserve">
|
||||||
|
<value>Umschlagtyp</value>
|
||||||
|
</data>
|
||||||
|
<data name="Language" xml:space="preserve">
|
||||||
|
<value>Sprache</value>
|
||||||
|
</data>
|
||||||
|
<data name="CertificationType" xml:space="preserve">
|
||||||
|
<value>Zertifizierung</value>
|
||||||
|
</data>
|
||||||
|
<data name="TFAEnabled" xml:space="preserve">
|
||||||
|
<value>2FA aktiviert</value>
|
||||||
|
</data>
|
||||||
|
<data name="UseAccessCode" xml:space="preserve">
|
||||||
|
<value>Zugriffscode verwenden</value>
|
||||||
|
</data>
|
||||||
|
<data name="FinalEmailToCreator" xml:space="preserve">
|
||||||
|
<value>Finale E-Mail an Ersteller</value>
|
||||||
|
</data>
|
||||||
|
<data name="FinalEmailToReceivers" xml:space="preserve">
|
||||||
|
<value>Finale E-Mail an Empfänger</value>
|
||||||
|
</data>
|
||||||
|
<data name="SendReminderEmails" xml:space="preserve">
|
||||||
|
<value>Erinnerungs-E-Mails senden</value>
|
||||||
|
</data>
|
||||||
|
<data name="FirstReminderDays" xml:space="preserve">
|
||||||
|
<value>Erste Erinnerung (Tage)</value>
|
||||||
|
</data>
|
||||||
|
<data name="ReminderIntervalDays" xml:space="preserve">
|
||||||
|
<value>Erinnerungsintervall (Tage)</value>
|
||||||
|
</data>
|
||||||
|
<data name="ExpiresWhenDays" xml:space="preserve">
|
||||||
|
<value>Läuft ab nach (Tage)</value>
|
||||||
|
</data>
|
||||||
|
<data name="ExpiresWarningWhenDays" xml:space="preserve">
|
||||||
|
<value>Ablaufwarnung (Tage)</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_EnvelopeSettings" xml:space="preserve">
|
||||||
|
<value>Envelope-Einstellungen</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_AdvancedOptional" xml:space="preserve">
|
||||||
|
<value>Erweitert</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_SelectTemplate" xml:space="preserve">
|
||||||
|
<value>Vorlage auswählen</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_Validation_ReminderInterval" xml:space="preserve">
|
||||||
|
<value>Bitte geben Sie ein Erinnerungsintervall größer als 0 Tage ein.</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_Validation_FirstReminder" xml:space="preserve">
|
||||||
|
<value>Bitte geben Sie gültige Tage für die erste Erinnerung ein.</value>
|
||||||
|
</data>
|
||||||
|
<data name="SenderEditor_Validation_ExpiryWarning" xml:space="preserve">
|
||||||
|
<value>Die Ablaufwarnung darf nicht nach dem Ablaufdatum liegen.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -105,10 +105,10 @@ Public Class frmEnvelopeMainData
|
|||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
Private Function TranslateCertificationType(pType As CertificationType) As String
|
Private Function TranslateCertificationType(pType As CertificationType) As String
|
||||||
Return Resources.Model.ResourceManager.GetString(pType.ToString())
|
Return CommonServices.My.Resources.Model.ResourceManager.GetString(pType.ToString())
|
||||||
End Function
|
End Function
|
||||||
Private Function TranslateFinalEmailType(pType As FinalEmailType) As String
|
Private Function TranslateFinalEmailType(pType As FinalEmailType) As String
|
||||||
Return Resources.Model.ResourceManager.GetString(pType.ToString())
|
Return CommonServices.My.Resources.Model.ResourceManager.GetString(pType.ToString())
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Sub btOK_Click(sender As Object, e As EventArgs) Handles btOK.Click
|
Private Sub btOK_Click(sender As Object, e As EventArgs) Handles btOK.Click
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Configurations;
|
||||||
|
using EnvelopeGenerator.Application.Common.Interfaces.Services;
|
||||||
|
using EnvelopeGenerator.Infrastructure.Crypt.Services;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Crypt.DependencyInjection;
|
||||||
|
|
||||||
|
public static class ServiceCollectionExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddCryptInfrastructure(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
services
|
||||||
|
.AddOptions<Pkcs11Options>()
|
||||||
|
.Bind(configuration.GetSection(Pkcs11Options.SectionName))
|
||||||
|
.ValidateDataAnnotations()
|
||||||
|
.ValidateOnStart();
|
||||||
|
|
||||||
|
services.AddSingleton<IPdfDigitalSignatureService, PdfDigitalSignatureService>();
|
||||||
|
services.AddSingleton<Pkcs11SelfTestStatusStore>();
|
||||||
|
services.AddSingleton<IPkcs11SelfTestStatusProvider>(sp => sp.GetRequiredService<Pkcs11SelfTestStatusStore>());
|
||||||
|
services.AddHostedService<Pkcs11StartupSelfTestHostedService>();
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DevExpress.Document.Processor" Version="25.2.3" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="9.0.6" />
|
||||||
|
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="9.0.6" />
|
||||||
|
<PackageReference Include="Pkcs11Interop" Version="5.3.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\EnvelopeGenerator.Application\EnvelopeGenerator.Application.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="resources\pkcs11\**\*">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
<TargetPath>pkcs11\%(RecursiveDir)%(Filename)%(Extension)</TargetPath>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
384
EnvelopeGenerator.Infrastructure.Crypt/README.md
Normal file
384
EnvelopeGenerator.Infrastructure.Crypt/README.md
Normal file
@@ -0,0 +1,384 @@
|
|||||||
|
# EnvelopeGenerator.Infrastructure.Crypt
|
||||||
|
|
||||||
|
Umfassende technische Dokumentation der PKCS#11/SoftHSM-Integration fuer `EnvelopeGenerator`.
|
||||||
|
|
||||||
|
Dieses Dokument konsolidiert und ersetzt die verteilten Runbooks aus:
|
||||||
|
|
||||||
|
- `pkcs11-proxy-production/README.md`
|
||||||
|
- `pkcs11-proxy-production/SSH_TEMP_ACCESS_MUST_DO.md`
|
||||||
|
- aeltere Abschnitte in diesem README
|
||||||
|
|
||||||
|
Zielgruppe: Senior Developer, Platform Engineers, DevOps, Security Owner.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Architekturueberblick
|
||||||
|
|
||||||
|
### 1.1 Ziel
|
||||||
|
|
||||||
|
`EnvelopeGenerator.Infrastructure.Crypt` stellt die kryptographische Infrastruktur fuer PDF-Signaturen bereit:
|
||||||
|
|
||||||
|
- Signaturerzeugung mit Schluesseln in SoftHSM/PKCS#11
|
||||||
|
- Zertifikat-Auslese aus Token
|
||||||
|
- Signaturpruefung auf PDF-Ebene
|
||||||
|
- Health/Startup-Selbsttest fuer Betriebsfaehigkeit
|
||||||
|
|
||||||
|
### 1.2 Topologie (aktueller Betriebsmodus)
|
||||||
|
|
||||||
|
Der aktuell implementierte Produktions-nahe Pfad ist:
|
||||||
|
|
||||||
|
1. Linux hostet SoftHSM + `pkcs11-daemon` (Proxy-Server).
|
||||||
|
2. Windows hostet `EnvelopeGenerator.Server`.
|
||||||
|
3. Windows laedt ein Windows-kompatibles Proxy-PKCS#11-Modul (`libpkcs11-proxy.dll`).
|
||||||
|
4. PKCS#11-Operationen werden ueber Socket (`PKCS11_PROXY_SOCKET`) an Linux weitergeleitet.
|
||||||
|
|
||||||
|
Wichtig:
|
||||||
|
|
||||||
|
- Ein Windows-Prozess kann **kein Linux `.so`** direkt laden.
|
||||||
|
- Private Keys verbleiben im Token (nicht exportierbar).
|
||||||
|
|
||||||
|
### 1.3 Laufzeitpfade in der Anwendung
|
||||||
|
|
||||||
|
`Pkcs11InteropBootstrap` loest Assets relativ zu `Crypt:Pkcs11:AssetsRootPath` auf:
|
||||||
|
|
||||||
|
- Modul: `pkcs11\windows\proxy\libpkcs11-proxy.dll`
|
||||||
|
- Tool-Fallback: `pkcs11\windows\opensc\tools\pkcs11-tool.exe`
|
||||||
|
|
||||||
|
Wenn `AssetsRootPath` leer ist, wird `AppContext.BaseDirectory` verwendet.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Linux-Seite: SoftHSM + Proxy Setup
|
||||||
|
|
||||||
|
### 2.1 Basispakete
|
||||||
|
|
||||||
|
Beispiel (Debian/Ubuntu):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt-get update && sudo apt-get install -y softhsm2 opensc p11-kit libengine-pkcs11-openssl
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.2 SoftHSM-Modulpfad pruefen
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ldconfig -p | grep softhsm
|
||||||
|
find /usr -name "libsofthsm2.so" 2>/dev/null
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.3 Token initialisieren
|
||||||
|
|
||||||
|
```bash
|
||||||
|
softhsm2-util --show-slots
|
||||||
|
softhsm2-util --init-token --slot <uninitialized-slot> --label CompanyProdToken --so-pin <so-pin> --pin <user-pin>
|
||||||
|
softhsm2-util --show-slots
|
||||||
|
```
|
||||||
|
|
||||||
|
Hinweis: Nach `--init-token` wird der Slot i. d. R. neu zugewiesen.
|
||||||
|
|
||||||
|
### 2.4 Schluesselpaar erzeugen
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so \
|
||||||
|
--slot <slot-id> --login --pin <user-pin> \
|
||||||
|
--keypairgen --key-type rsa:3072 --label company-sign-key-v1 --id 01
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.5 Zertifikat importieren
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so \
|
||||||
|
--slot <slot-id> --login --pin <user-pin> \
|
||||||
|
--write-object ./company-sign-cert-v1.der --type cert --id 01 --label company-sign-cert-v1
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.6 Objektzustand verifizieren
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --slot <slot-id> --login --pin <user-pin> --list-objects
|
||||||
|
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so --slot <slot-id> --login --pin <user-pin> --list-objects --type cert
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.7 Proxy-Daemon endpoint stabilisieren
|
||||||
|
|
||||||
|
Ein wiederkehrendes Betriebsproblem war ein zufaelliger/local-only Listener. Fix:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo mkdir -p /etc/systemd/system/pkcs11-proxy.service.d
|
||||||
|
printf "[Service]\nEnvironment=PKCS11_DAEMON_SOCKET=tcp://0.0.0.0:5657\n" | sudo tee /etc/systemd/system/pkcs11-proxy.service.d/override.conf
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl restart pkcs11-proxy.service
|
||||||
|
```
|
||||||
|
|
||||||
|
Pruefung:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemctl show pkcs11-proxy.service -p Environment --no-pager
|
||||||
|
ss -ltnp | grep 5657
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Web-API/Server-Seite: Installation und Asset-Bereitstellung
|
||||||
|
|
||||||
|
### 3.1 Bezugsquellen der Windows-Artefakte
|
||||||
|
|
||||||
|
Fuer den Proxy-Betrieb werden auf Windows benoetigt:
|
||||||
|
|
||||||
|
1. Proxy-PKCS#11-DLL (`libpkcs11-proxy.dll`)
|
||||||
|
2. Abhaengige Runtime-DLLs (z. B. MinGW runtime, je nach Build)
|
||||||
|
3. `pkcs11-tool.exe` + zugehoerige OpenSC-DLLs fuer Fallback
|
||||||
|
|
||||||
|
Beschaffung:
|
||||||
|
|
||||||
|
- Build aus derselben `pkcs11-proxy`-Codebasis/Commit wie Linux-Daemon (Kompatibilitaet sicherstellen)
|
||||||
|
- oder kontrolliert bereitgestellte, intern freigegebene Binaries
|
||||||
|
|
||||||
|
### 3.2 Empfohlene Ablage im Repo
|
||||||
|
|
||||||
|
Bundled Assets liegen unter:
|
||||||
|
|
||||||
|
- `EnvelopeGenerator.Infrastructure.Crypt/resources/pkcs11/windows/proxy/`
|
||||||
|
- `EnvelopeGenerator.Infrastructure.Crypt/resources/pkcs11/windows/opensc/tools/`
|
||||||
|
- `EnvelopeGenerator.Infrastructure.Crypt/resources/pkcs11/windows/opensc/pkcs11/`
|
||||||
|
|
||||||
|
Diese werden beim Build in den Output kopiert (siehe `.csproj`-Copy-Regeln).
|
||||||
|
|
||||||
|
### 3.3 Deployment-Muster
|
||||||
|
|
||||||
|
Es gibt zwei gueltige Wege:
|
||||||
|
|
||||||
|
1. **Bundled (Dev/QA, schnelle Reproduzierbarkeit)**
|
||||||
|
- Assets werden mit dem Build ausgeliefert.
|
||||||
|
- `AssetsRootPath = null` -> Aufloesung via `AppContext.BaseDirectory`.
|
||||||
|
|
||||||
|
2. **Zentraler Asset-Root (Prod, betriebliche Kontrolle)**
|
||||||
|
- Assets in zentralem Pfad (z. B. `E:\DataFiles\Digital Data\EnvelopeGenerator`).
|
||||||
|
- `AssetsRootPath` in `appsettings.json` auf diesen Root setzen.
|
||||||
|
|
||||||
|
### 3.4 Anwendungskonfiguration (`Crypt:Pkcs11`)
|
||||||
|
|
||||||
|
Beispiel:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Crypt": {
|
||||||
|
"Pkcs11": {
|
||||||
|
"AssetsRootPath": "E:\\DataFiles\\Digital Data\\EnvelopeGenerator",
|
||||||
|
"SlotId": 2021549410,
|
||||||
|
"TokenLabel": "CompanyProdToken",
|
||||||
|
"ProxySocket": "tcp://172.24.12.64:5657",
|
||||||
|
"UserPin": "<secret>",
|
||||||
|
"PrivateKeyLabel": "company-sign-key-v1",
|
||||||
|
"CertificateLabel": "company-sign-cert-v1",
|
||||||
|
"ApplicationName": "signFLOW",
|
||||||
|
"DefaultReason": null,
|
||||||
|
"UseUtcSigningTime": true,
|
||||||
|
"DefaultCertificationLevel": "NoCertification"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Sicherheitsregel:
|
||||||
|
|
||||||
|
- `UserPin` niemals in versionierte Dateien einchecken.
|
||||||
|
- Secrets nur in Secret Store / nicht versionierte `appsettings.Secrets.json` / Vault.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Implementierte Services, Modelle, DTOs
|
||||||
|
|
||||||
|
### 4.1 DI und Startverhalten
|
||||||
|
|
||||||
|
- `AddCryptInfrastructure(...)` in `DependencyInjection/ServiceCollectionExtensions.cs`
|
||||||
|
- bindet `Pkcs11Options`
|
||||||
|
- registriert `IPdfDigitalSignatureService`
|
||||||
|
- registriert Startup-Self-Test Hosted Service
|
||||||
|
|
||||||
|
### 4.2 Konfigurationsmodell
|
||||||
|
|
||||||
|
- `Pkcs11Options` (`EnvelopeGenerator.Application/Common/Configurations/Pkcs11Options.cs`)
|
||||||
|
- `AssetsRootPath`, `SlotId`, `TokenLabel`, `ProxySocket`
|
||||||
|
- `UserPin`, `PrivateKeyLabel`, `CertificateLabel`
|
||||||
|
- `ApplicationName`, `DefaultReason`, `UseUtcSigningTime`, `DefaultCertificationLevel`
|
||||||
|
- `ResolvedLibraryPath`, `ResolvedToolPath` (Runtime-resolved)
|
||||||
|
|
||||||
|
### 4.3 Kernservices
|
||||||
|
|
||||||
|
1. `PdfDigitalSignatureService`
|
||||||
|
- Signiert PDF via DevExpress `PdfDeferredSignatureBuilder`
|
||||||
|
- Nutzt `Pkcs11ExternalSigner` fuer externe Signatur
|
||||||
|
- Erzwingt `ApplicationName` aus Config (nicht client-overridable)
|
||||||
|
- Erweitert `Reason` um strukturiertes Metaformat:
|
||||||
|
- `SFMETA:v1;doc=<uuid>;sha256=<hash>`
|
||||||
|
- Parse beim Verify und Mapping in DTO
|
||||||
|
|
||||||
|
2. `Pkcs11InteropBootstrap`
|
||||||
|
- Loest Modul-/Toolpfade auf
|
||||||
|
- Setzt `PKCS11_PROXY_SOCKET`/`PKCS11_DAEMON_SOCKET`
|
||||||
|
- PATH-Ergaenzung fuer native Abhaengigkeiten
|
||||||
|
- Warmup via `pkcs11-tool -L`
|
||||||
|
|
||||||
|
3. `Pkcs11SessionRunner`
|
||||||
|
- Interop Library-Load mit mehreren Init-Modi (Fallback-Reihenfolge)
|
||||||
|
- Slot-Resolution (`SlotId`/`TokenLabel`)
|
||||||
|
- Session Login/Logout
|
||||||
|
|
||||||
|
4. `Pkcs11ToolBridge`
|
||||||
|
- Fallback via Prozessaufruf von `pkcs11-tool`
|
||||||
|
- Cert read und DigestInfo-Signatur
|
||||||
|
|
||||||
|
5. `Pkcs11StartupSelfTestHostedService`
|
||||||
|
- Fuehrt beim Start Interop-Probe aus
|
||||||
|
- Fallback-Probe bei Interop-Fehler
|
||||||
|
- Schreibt strukturierten Status
|
||||||
|
|
||||||
|
### 4.4 Wichtige Interfaces/DTOs
|
||||||
|
|
||||||
|
- `IPdfDigitalSignatureService`
|
||||||
|
- `SignPdfAsync(...)`, `CheckPdfSignatureAsync(...)`, `ExtractOriginalPdfAsync(...)`
|
||||||
|
- `IPkcs11SelfTestStatusProvider`
|
||||||
|
- `PdfSignOptionsDto`
|
||||||
|
- `UUID`, `Reason`, `Name`, `Location`, `Email`, `Phone`, `CertificationLevel`
|
||||||
|
- `PdfSignatureCheckResultDto` / `PdfSignatureCheckItemDto`
|
||||||
|
- inklusive `BusinessReason`, `UUID`, `OriginalDocumentSha256`
|
||||||
|
- `Pkcs11SelfTestStatusDto`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Betriebserfahrungen und Challenges
|
||||||
|
|
||||||
|
### 5.1 Interop vs Tool-Verhalten
|
||||||
|
|
||||||
|
Beobachtetes Muster in der realen Umgebung:
|
||||||
|
|
||||||
|
- `pkcs11-tool` konnte erfolgreich auf Token zugreifen und signieren.
|
||||||
|
- `Pkcs11Interop` scheiterte mit `CKR_FUNCTION_NOT_SUPPORTED` bzw. fehlendem `C_Initialize` Pointer in bestimmten Modi.
|
||||||
|
|
||||||
|
Konsequenz:
|
||||||
|
|
||||||
|
- Architektur wurde auf **interop-first + controlled tool-fallback** erweitert.
|
||||||
|
- Health-Endpunkt differenziert Modus (`interop`, `pkcs11-tool`, `failed`).
|
||||||
|
|
||||||
|
### 5.2 Typische Fehlbilder
|
||||||
|
|
||||||
|
- `CKR_DEVICE_ERROR` bei Socket-/Proxy-Problemen
|
||||||
|
- `CRYPT_PROVIDER_UNAVAILABLE` bei Pfad/ABI/Dependency-Mismatch
|
||||||
|
- `CRYPT_SLOT_NOT_FOUND` bei Slot-/Label-Mismatch
|
||||||
|
- `CKR_PIN_INCORRECT` bei PIN-Fehler
|
||||||
|
- 307 Redirects bei HTTP/HTTPS-Mix in manuellen Tests
|
||||||
|
|
||||||
|
### 5.3 Plattformfallen
|
||||||
|
|
||||||
|
- MSVC vs MinGW Build-Unterschiede fuer Proxy-Client
|
||||||
|
- fehlende Laufzeit-DLLs (`PATH`/Side-by-side)
|
||||||
|
- Architektur-Mismatch x86 vs x64
|
||||||
|
- Daemon-Bindings nicht stabil (random localhost port statt fixed endpoint)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. Health, Monitoring und Verifikation
|
||||||
|
|
||||||
|
### 6.1 API Health
|
||||||
|
|
||||||
|
- Endpoint: `GET /api/health/crypt`
|
||||||
|
- Liefert:
|
||||||
|
- `success`, `mode`, `summary`, `interopError`, `toolError`, `checkedAtUtc`
|
||||||
|
|
||||||
|
Empfehlung:
|
||||||
|
|
||||||
|
- In Monitoring aufnehmen und bei `mode=pkcs11-tool` ueber laengere Zeit Warnung triggern.
|
||||||
|
|
||||||
|
### 6.2 Smoke-Test (empfohlen vor Release)
|
||||||
|
|
||||||
|
1. `GET /api/health/crypt` -> `success=true`
|
||||||
|
2. `POST /api/PdfSignature/sign` mit Test-PDF
|
||||||
|
3. `POST /api/PdfSignature/is-signed`
|
||||||
|
4. Pruefen:
|
||||||
|
- `signed=true`
|
||||||
|
- `allSignaturesCryptographicallyValid=true`
|
||||||
|
- `UUID`/`OriginalDocumentSha256` korrekt gemappt
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. Sicherheits- und Betriebsrichtlinien
|
||||||
|
|
||||||
|
### 7.1 Geheimnisse
|
||||||
|
|
||||||
|
- PIN, SO-PIN, Root-Creds niemals in Doku/Screenshots/Repo.
|
||||||
|
- Nach Troubleshooting: Credentials rotieren.
|
||||||
|
|
||||||
|
### 7.2 Temporare SSH-Freigaben zwingend rueckbauen
|
||||||
|
|
||||||
|
Wenn SSH temporaer geoeffnet wurde, MUSS danach Rollback erfolgen:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo systemctl disable --now ssh && sudo ufw delete allow from 172.24.10.11 to any port 22 proto tcp && sudo ufw status verbose && sudo systemctl status ssh --no-pager
|
||||||
|
```
|
||||||
|
|
||||||
|
Optional harte Bereinigung:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt-get purge -y openssh-server && sudo apt-get autoremove -y
|
||||||
|
```
|
||||||
|
|
||||||
|
### 7.3 Schluesselrotation
|
||||||
|
|
||||||
|
- Neue Labels (`...-v2`) anlegen
|
||||||
|
- App umkonfigurieren
|
||||||
|
- Sign/Verify Regression testen
|
||||||
|
- Altmaterial erst nach Freigabe entfernen
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8. API-Verhalten bei Signaturmetadaten
|
||||||
|
|
||||||
|
Aktueller Standard:
|
||||||
|
|
||||||
|
- `UUID` kommt aus Sign-Input (nullable string). Wenn ungeltig/leer -> neue Guid wird erzeugt.
|
||||||
|
- `Reason` wird intern angereichert mit strukturiertem Meta (`SFMETA:v1`).
|
||||||
|
- `ApplicationName` ist rein serverseitig aus `appsettings` gesetzt.
|
||||||
|
- `SigningTime` ist rein serverseitig und wird automatisch gesetzt (`UseUtcSigningTime=true` => `UtcNow`, sonst lokale Zeit).
|
||||||
|
- `CertificationLevel` wird im Controller serverseitig gesetzt (`FormFillingAndAnnotations`), nicht vom Client.
|
||||||
|
|
||||||
|
Damit ist das Verhalten deterministisch und manipulationsaermer fuer Integrationsclients.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 9. Troubleshooting-Checkliste (praxisnah)
|
||||||
|
|
||||||
|
1. Erreichbarkeit Linux Proxy:
|
||||||
|
- `Test-NetConnection <linux-host> -Port 5657`
|
||||||
|
2. Token sichtbar?
|
||||||
|
- `pkcs11-tool --module <dll> -L -v`
|
||||||
|
3. Zertifikat lesbar?
|
||||||
|
- `--read-object --type cert --label <cert-label>`
|
||||||
|
4. Signatur technisch moeglich?
|
||||||
|
- `--sign -m SHA256-RSA-PKCS ...`
|
||||||
|
5. App-Health check:
|
||||||
|
- `/api/health/crypt`
|
||||||
|
6. App-sign/verify end-to-end:
|
||||||
|
- `/api/PdfSignature/sign` + `/api/PdfSignature/is-signed`
|
||||||
|
|
||||||
|
Wenn Interop scheitert, aber Tool funktioniert:
|
||||||
|
|
||||||
|
- Betrieb bleibt verfuegbar (Fallback),
|
||||||
|
- aber Incident/Bug fuer Interop-Kompatibilitaet erfassen.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 10. Ausblick / empfohlene Verbesserungen
|
||||||
|
|
||||||
|
1. Binary Transport statt Base64 bei grossen PDFs in Render/Sign-Pipelines.
|
||||||
|
2. Persistente Metriken fuer Fallback-Quote (`interop` vs `tool`).
|
||||||
|
3. Zertifikatskette/OCSP/CRL Validierung als optionales Policy-Modul.
|
||||||
|
4. CI-Pruefung auf unsichere SQL-Muster (parallel zum Security-Workstream).
|
||||||
|
5. Standardisierte Toast/UX-Rueckmeldungen fuer Signierfehler in UI.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 11. Referenzen
|
||||||
|
|
||||||
|
- SoftHSMv2: `https://github.com/softhsm/SoftHSMv2`
|
||||||
|
- OpenSC / pkcs11-tool: `https://github.com/OpenSC/OpenSC/wiki/Using-pkcs11-tool-and-OpenSSL`
|
||||||
|
- PKCS#11 Standard: `https://www.oasis-open.org/committees/pkcs11/`
|
||||||
@@ -0,0 +1,617 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Configurations;
|
||||||
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
using EnvelopeGenerator.Application.Common.Enums;
|
||||||
|
using EnvelopeGenerator.Application.Common.Interfaces.Services;
|
||||||
|
using DevExpress.Office.DigitalSignatures;
|
||||||
|
using DevExpress.Pdf;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using System.Formats.Asn1;
|
||||||
|
using System.Security.Cryptography.Pkcs;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Crypt.Services;
|
||||||
|
|
||||||
|
public sealed class PdfDigitalSignatureService(IOptions<Pkcs11Options> options) : IPdfDigitalSignatureService
|
||||||
|
{
|
||||||
|
private static readonly Regex SignatureReasonMetaRegex = new(@"\|\s*SFMETA:v1;doc=(?<doc>[0-9a-fA-F-]{36});sha256=(?<sha>[A-Fa-f0-9]{64})$", RegexOptions.CultureInvariant | RegexOptions.Compiled);
|
||||||
|
|
||||||
|
public async Task SignPdfAsync(Stream inputPdf, Stream outputPdf, PdfSignOptionsDto? optionsModel = null, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(inputPdf);
|
||||||
|
ArgumentNullException.ThrowIfNull(outputPdf);
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
var (workingInput, ownsWorkingInput) = await EnsureSeekableInputAsync(inputPdf, cancellationToken);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
workingInput.Position = 0;
|
||||||
|
var sourceHashHex = Convert.ToHexString(await SHA256.HashDataAsync(workingInput, cancellationToken));
|
||||||
|
workingInput.Position = 0;
|
||||||
|
|
||||||
|
var pkcs11Options = options.Value;
|
||||||
|
var request = optionsModel ?? new PdfSignOptionsDto();
|
||||||
|
var uuid = ResolveUuid(request.UUID);
|
||||||
|
var reasonWithMeta = BuildReasonWithMeta(request.Reason ?? pkcs11Options.DefaultReason, uuid, sourceHashHex);
|
||||||
|
|
||||||
|
using var signer = new PdfDocumentSigner(workingInput);
|
||||||
|
|
||||||
|
var digestCalculator = new DigestCalculator(HashAlgorithmType.SHA256);
|
||||||
|
var signerInfo = new ExternalSignerInfo(PdfSignatureType.Pkcs7, 32768, digestCalculator);
|
||||||
|
var signatureFieldInfo = new PdfSignatureFieldInfo(1)
|
||||||
|
{
|
||||||
|
Name = $"Sig_{DateTimeOffset.UtcNow:yyyyMMddHHmmss}"
|
||||||
|
};
|
||||||
|
|
||||||
|
var builder = new PdfDeferredSignatureBuilder(signerInfo, signatureFieldInfo)
|
||||||
|
{
|
||||||
|
Name = request.Name ?? pkcs11Options.CertificateLabel,
|
||||||
|
Reason = reasonWithMeta,
|
||||||
|
Location = request.Location,
|
||||||
|
ContactInfo = BuildContactInfo(request.Email, request.Phone),
|
||||||
|
SigningTime = pkcs11Options.UseUtcSigningTime ? DateTimeOffset.UtcNow : DateTimeOffset.Now,
|
||||||
|
ApplicationName = pkcs11Options.ApplicationName,
|
||||||
|
CertificationLevel = ToDevExpressCertificationLevel(request.CertificationLevel)
|
||||||
|
?? ToDevExpressCertificationLevel(pkcs11Options.DefaultCertificationLevel)
|
||||||
|
?? PdfCertificationLevel.NoCertification
|
||||||
|
};
|
||||||
|
|
||||||
|
var deferredSigner = signer.SignDeferred(builder);
|
||||||
|
var externalSigner = new Pkcs11ExternalSigner(pkcs11Options);
|
||||||
|
deferredSigner.Sign(outputPdf, externalSigner.BuildSignature(deferredSigner.HashValue, digestCalculator.AlgorithmOid));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (ownsWorkingInput)
|
||||||
|
await workingInput.DisposeAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SignPdfAsync(Stream inputPdf, Stream outputPdf, IReadOnlyList<PdfSignOptionsDto> optionsList, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(inputPdf);
|
||||||
|
ArgumentNullException.ThrowIfNull(outputPdf);
|
||||||
|
ArgumentNullException.ThrowIfNull(optionsList);
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
if (optionsList.Count == 0)
|
||||||
|
{
|
||||||
|
await inputPdf.CopyToAsync(outputPdf, cancellationToken);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var (currentInput, ownsCurrentInput) = await EnsureSeekableInputAsync(inputPdf, cancellationToken);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (var i = 0; i < optionsList.Count; i++)
|
||||||
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
var isLast = i == optionsList.Count - 1;
|
||||||
|
|
||||||
|
if (isLast)
|
||||||
|
{
|
||||||
|
await SignPdfAsync(currentInput, outputPdf, optionsList[i], cancellationToken);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var intermediateOutput = new MemoryStream();
|
||||||
|
await SignPdfAsync(currentInput, intermediateOutput, optionsList[i], cancellationToken);
|
||||||
|
|
||||||
|
if (ownsCurrentInput)
|
||||||
|
await currentInput.DisposeAsync();
|
||||||
|
|
||||||
|
intermediateOutput.Position = 0;
|
||||||
|
currentInput = intermediateOutput;
|
||||||
|
ownsCurrentInput = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (ownsCurrentInput)
|
||||||
|
await currentInput.DisposeAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PdfSignatureCheckResultDto> CheckPdfSignatureAsync(Stream inputPdf, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(inputPdf);
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
var pdfBytes = await ReadAllBytesAsync(inputPdf, cancellationToken);
|
||||||
|
|
||||||
|
using var pdfStream = new MemoryStream(pdfBytes);
|
||||||
|
using var signer = new PdfDocumentSigner(pdfStream);
|
||||||
|
var signatures = signer.GetSignatureInfo();
|
||||||
|
var byteRanges = ParseByteRanges(pdfBytes);
|
||||||
|
|
||||||
|
if (signatures is null || signatures.Count == 0)
|
||||||
|
{
|
||||||
|
return new PdfSignatureCheckResultDto(
|
||||||
|
Signed: false,
|
||||||
|
Signatures: []);
|
||||||
|
}
|
||||||
|
|
||||||
|
var items = new List<PdfSignatureCheckItemDto>(signatures.Count);
|
||||||
|
|
||||||
|
for (var i = 0; i < signatures.Count; i++)
|
||||||
|
{
|
||||||
|
var signature = signatures[i];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var pkcs7 = signer.GetPdfPkcs7Signature(signature.FieldName);
|
||||||
|
bool valid = pkcs7.VerifySignature();
|
||||||
|
var byteRange = i < byteRanges.Count ? byteRanges[i] : null;
|
||||||
|
var coversWholeDocument = CoversWholeDocument(byteRange, pdfBytes.LongLength);
|
||||||
|
var certificate = pkcs7.GetSignatureCertificate();
|
||||||
|
var issuedTo = ParsePrincipal(certificate?.Subject);
|
||||||
|
var issuedBy = ParsePrincipal(certificate?.Issuer);
|
||||||
|
var reasonMeta = ParseReasonMeta(signature.Reason);
|
||||||
|
var contact = ParseContactInfo(signature.ContactInfo);
|
||||||
|
|
||||||
|
items.Add(new PdfSignatureCheckItemDto(
|
||||||
|
CoversWholeDoc: coversWholeDocument,
|
||||||
|
Reason: signature.Reason,
|
||||||
|
BusinessReason: reasonMeta.BusinessReason,
|
||||||
|
Location: signature.Location,
|
||||||
|
DeclaredName: signature.SignerName,
|
||||||
|
ContactInfo: signature.ContactInfo,
|
||||||
|
Email: contact.Email,
|
||||||
|
Phone: contact.Phone,
|
||||||
|
DigestAlgorithm: InferDigestAlgorithm(certificate),
|
||||||
|
SignatureAlgorithm: InferSignatureAlgorithm(certificate),
|
||||||
|
SignerName: issuedTo.CommonName ?? signature.SignerName,
|
||||||
|
Issuer: issuedBy.Full,
|
||||||
|
SerialNumber: ToColonSerial(certificate?.SerialNumber),
|
||||||
|
ValidFrom: certificate is null ? null : new DateTimeOffset(certificate.NotBefore).ToUniversalTime(),
|
||||||
|
ValidTo: certificate is null ? null : new DateTimeOffset(certificate.NotAfter).ToUniversalTime(),
|
||||||
|
ExpiryCheckedAgainst: "now",
|
||||||
|
Certificates: [BuildCertificateInfo(certificate, DateTimeOffset.UtcNow)],
|
||||||
|
Unchanged: valid && coversWholeDocument,
|
||||||
|
FieldName: signature.FieldName,
|
||||||
|
IsCryptographicallyValid: valid,
|
||||||
|
SigningTime: signature.SigningTime?.ToUniversalTime().ToString("O"),
|
||||||
|
Filter: signature.Filter,
|
||||||
|
SubFilter: signature.SubFilter,
|
||||||
|
ApplicationName: null,
|
||||||
|
UUID: reasonMeta.UUID,
|
||||||
|
OriginalDocumentSha256: reasonMeta.OriginalDocumentSha256,
|
||||||
|
MessageDigestHex: TryExtractMessageDigestHex(signature.Contents),
|
||||||
|
Error: null));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
var reasonMeta = ParseReasonMeta(signature.Reason);
|
||||||
|
var contact = ParseContactInfo(signature.ContactInfo);
|
||||||
|
|
||||||
|
items.Add(new PdfSignatureCheckItemDto(
|
||||||
|
CoversWholeDoc: false,
|
||||||
|
Reason: signature.Reason,
|
||||||
|
BusinessReason: reasonMeta.BusinessReason,
|
||||||
|
Location: signature.Location,
|
||||||
|
DeclaredName: signature.SignerName,
|
||||||
|
ContactInfo: signature.ContactInfo,
|
||||||
|
Email: contact.Email,
|
||||||
|
Phone: contact.Phone,
|
||||||
|
DigestAlgorithm: null,
|
||||||
|
SignatureAlgorithm: null,
|
||||||
|
SignerName: signature.SignerName,
|
||||||
|
Issuer: null,
|
||||||
|
SerialNumber: null,
|
||||||
|
ValidFrom: null,
|
||||||
|
ValidTo: null,
|
||||||
|
ExpiryCheckedAgainst: "now",
|
||||||
|
Certificates: [],
|
||||||
|
Unchanged: false,
|
||||||
|
FieldName: signature.FieldName,
|
||||||
|
IsCryptographicallyValid: false,
|
||||||
|
SigningTime: signature.SigningTime?.ToUniversalTime().ToString("O"),
|
||||||
|
Filter: signature.Filter,
|
||||||
|
SubFilter: signature.SubFilter,
|
||||||
|
ApplicationName: null,
|
||||||
|
UUID: reasonMeta.UUID,
|
||||||
|
OriginalDocumentSha256: reasonMeta.OriginalDocumentSha256,
|
||||||
|
MessageDigestHex: null,
|
||||||
|
Error: ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PdfSignatureCheckResultDto(
|
||||||
|
Signed: true,
|
||||||
|
Signatures: items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ExtractOriginalPdfAsync(Stream inputPdf, Stream outputPdf, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(inputPdf);
|
||||||
|
ArgumentNullException.ThrowIfNull(outputPdf);
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
var pdfBytes = await ReadAllBytesAsync(inputPdf, cancellationToken);
|
||||||
|
|
||||||
|
var byteRanges = ParseByteRanges(pdfBytes);
|
||||||
|
if (byteRanges.Count == 0)
|
||||||
|
{
|
||||||
|
await outputPdf.WriteAsync(pdfBytes, cancellationToken);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var revisionLength = byteRanges
|
||||||
|
.Select(GetSignedRevisionLength)
|
||||||
|
.Where(x => x > 0)
|
||||||
|
.DefaultIfEmpty(pdfBytes.LongLength)
|
||||||
|
.Min();
|
||||||
|
|
||||||
|
if (revisionLength > pdfBytes.LongLength)
|
||||||
|
throw new InvalidOperationException("Invalid ByteRange in signed PDF.");
|
||||||
|
|
||||||
|
await outputPdf.WriteAsync(pdfBytes.AsMemory(0, (int)revisionLength), cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<(Stream Stream, bool OwnsStream)> EnsureSeekableInputAsync(Stream input, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (input.CanSeek)
|
||||||
|
{
|
||||||
|
input.Position = 0;
|
||||||
|
return (input, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
var buffered = new MemoryStream();
|
||||||
|
await input.CopyToAsync(buffered, cancellationToken);
|
||||||
|
buffered.Position = 0;
|
||||||
|
return (buffered, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<byte[]> ReadAllBytesAsync(Stream input, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (input is MemoryStream memory && memory.TryGetBuffer(out var buffer))
|
||||||
|
return buffer.AsSpan(0, (int)memory.Length).ToArray();
|
||||||
|
|
||||||
|
if (input.CanSeek)
|
||||||
|
input.Position = 0;
|
||||||
|
|
||||||
|
using var ms = new MemoryStream();
|
||||||
|
await input.CopyToAsync(ms, cancellationToken);
|
||||||
|
return ms.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PdfSignatureCertificateInfoDto BuildCertificateInfo(X509Certificate2? certificate, DateTimeOffset now)
|
||||||
|
{
|
||||||
|
if (certificate is null)
|
||||||
|
{
|
||||||
|
return new PdfSignatureCertificateInfoDto(
|
||||||
|
IssuedTo: new PdfSignaturePrincipalDto(null, null, null, null),
|
||||||
|
IssuedBy: new PdfSignaturePrincipalDto(null, null, null, null),
|
||||||
|
SerialNumber: null,
|
||||||
|
ValidFrom: null,
|
||||||
|
ValidTo: null,
|
||||||
|
SelfSigned: false,
|
||||||
|
Expired: false,
|
||||||
|
NotYetValid: false,
|
||||||
|
IsSigner: true,
|
||||||
|
Version: null,
|
||||||
|
KeyAlgorithm: null,
|
||||||
|
SignatureAlgorithm: null,
|
||||||
|
Pem: null,
|
||||||
|
KeySizeBits: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
var issuedTo = ParsePrincipal(certificate.Subject);
|
||||||
|
var issuedBy = ParsePrincipal(certificate.Issuer);
|
||||||
|
var validFrom = new DateTimeOffset(certificate.NotBefore).ToUniversalTime();
|
||||||
|
var validTo = new DateTimeOffset(certificate.NotAfter).ToUniversalTime();
|
||||||
|
|
||||||
|
return new PdfSignatureCertificateInfoDto(
|
||||||
|
IssuedTo: issuedTo,
|
||||||
|
IssuedBy: issuedBy,
|
||||||
|
SerialNumber: ToColonSerial(certificate.SerialNumber),
|
||||||
|
ValidFrom: validFrom,
|
||||||
|
ValidTo: validTo,
|
||||||
|
SelfSigned: string.Equals(certificate.Subject, certificate.Issuer, StringComparison.OrdinalIgnoreCase),
|
||||||
|
Expired: validTo < now,
|
||||||
|
NotYetValid: validFrom > now,
|
||||||
|
IsSigner: true,
|
||||||
|
Version: certificate.Version,
|
||||||
|
KeyAlgorithm: certificate.PublicKey.Oid?.FriendlyName ?? certificate.PublicKey.Oid?.Value,
|
||||||
|
SignatureAlgorithm: certificate.SignatureAlgorithm.FriendlyName ?? certificate.SignatureAlgorithm.Value,
|
||||||
|
Pem: ToPem(certificate.RawData),
|
||||||
|
KeySizeBits: TryGetKeySize(certificate));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int? TryGetKeySize(X509Certificate2 certificate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return certificate.PublicKey.Key.KeySize;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? InferDigestAlgorithm(X509Certificate2? certificate)
|
||||||
|
{
|
||||||
|
if (certificate?.SignatureAlgorithm is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var source = (certificate.SignatureAlgorithm.FriendlyName ?? certificate.SignatureAlgorithm.Value ?? string.Empty).ToUpperInvariant();
|
||||||
|
if (source.Contains("SHA512", StringComparison.Ordinal)) return "SHA-512";
|
||||||
|
if (source.Contains("SHA384", StringComparison.Ordinal)) return "SHA-384";
|
||||||
|
if (source.Contains("SHA256", StringComparison.Ordinal)) return "SHA-256";
|
||||||
|
if (source.Contains("SHA1", StringComparison.Ordinal)) return "SHA-1";
|
||||||
|
return certificate.SignatureAlgorithm.FriendlyName ?? certificate.SignatureAlgorithm.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? InferSignatureAlgorithm(X509Certificate2? certificate)
|
||||||
|
{
|
||||||
|
var oidName = certificate?.PublicKey.Oid?.FriendlyName?.ToUpperInvariant();
|
||||||
|
if (oidName is not null && oidName.Contains("RSA", StringComparison.Ordinal))
|
||||||
|
return "RSA";
|
||||||
|
if (oidName is not null && oidName.Contains("ECDSA", StringComparison.Ordinal))
|
||||||
|
return "ECDSA";
|
||||||
|
return certificate?.PublicKey.Oid?.FriendlyName ?? certificate?.PublicKey.Oid?.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PdfSignaturePrincipalDto ParsePrincipal(string? dn)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(dn))
|
||||||
|
return new PdfSignaturePrincipalDto(null, null, null, dn);
|
||||||
|
|
||||||
|
string? commonName = null;
|
||||||
|
string? organization = null;
|
||||||
|
string? country = null;
|
||||||
|
|
||||||
|
foreach (var part in dn.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
var equalsIndex = part.IndexOf('=');
|
||||||
|
if (equalsIndex <= 0 || equalsIndex >= part.Length - 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var key = part[..equalsIndex].Trim();
|
||||||
|
var value = part[(equalsIndex + 1)..].Trim();
|
||||||
|
|
||||||
|
if (key.Equals("CN", StringComparison.OrdinalIgnoreCase)) commonName = value;
|
||||||
|
else if (key.Equals("O", StringComparison.OrdinalIgnoreCase)) organization = value;
|
||||||
|
else if (key.Equals("C", StringComparison.OrdinalIgnoreCase)) country = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PdfSignaturePrincipalDto(commonName, organization, country, dn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PdfCertificationLevel? ToDevExpressCertificationLevel(PdfSignatureCertificationLevel? value)
|
||||||
|
{
|
||||||
|
return value is null ? null : (PdfCertificationLevel)(int)value.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? ToColonSerial(string? raw)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(raw))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var normalized = raw.Replace(":", string.Empty, StringComparison.Ordinal).Trim();
|
||||||
|
if (normalized.Length % 2 != 0)
|
||||||
|
return normalized;
|
||||||
|
|
||||||
|
return string.Join(':', Enumerable.Range(0, normalized.Length / 2).Select(i => normalized.Substring(i * 2, 2).ToUpperInvariant()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ToPem(byte[] der)
|
||||||
|
{
|
||||||
|
var base64 = Convert.ToBase64String(der, Base64FormattingOptions.InsertLineBreaks);
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
sb.AppendLine("-----BEGIN CERTIFICATE-----");
|
||||||
|
sb.AppendLine(base64);
|
||||||
|
sb.Append("-----END CERTIFICATE-----");
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? TryExtractMessageDigestHex(byte[]? signatureContents)
|
||||||
|
{
|
||||||
|
if (signatureContents is null || signatureContents.Length == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cms = new SignedCms();
|
||||||
|
cms.Decode(signatureContents);
|
||||||
|
|
||||||
|
var signerInfo = cms.SignerInfos.Count > 0 ? cms.SignerInfos[0] : null;
|
||||||
|
if (signerInfo is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
foreach (CryptographicAttributeObject attr in signerInfo.SignedAttributes)
|
||||||
|
{
|
||||||
|
if (!string.Equals(attr.Oid?.Value, "1.2.840.113549.1.9.4", StringComparison.Ordinal))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (var value in attr.Values)
|
||||||
|
{
|
||||||
|
var octets = TryReadOctetString(value.RawData);
|
||||||
|
if (octets is not null && octets.Length > 0)
|
||||||
|
return Convert.ToHexString(octets);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[]? TryReadOctetString(byte[] rawData)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var reader = new AsnReader(rawData, AsnEncodingRules.BER);
|
||||||
|
var octets = reader.ReadOctetString();
|
||||||
|
if (reader.HasData)
|
||||||
|
return null;
|
||||||
|
return octets;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<long[]> ParseByteRanges(byte[] pdfBytes)
|
||||||
|
{
|
||||||
|
var text = Encoding.Latin1.GetString(pdfBytes);
|
||||||
|
var matches = Regex.Matches(text, @"/ByteRange\s*\[(?<values>[\d\s]+)\]", RegexOptions.CultureInvariant);
|
||||||
|
var ranges = new List<long[]>(matches.Count);
|
||||||
|
|
||||||
|
foreach (Match match in matches)
|
||||||
|
{
|
||||||
|
var raw = match.Groups["values"].Value;
|
||||||
|
var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
var values = new long[parts.Length];
|
||||||
|
var ok = true;
|
||||||
|
|
||||||
|
for (var i = 0; i < parts.Length; i++)
|
||||||
|
{
|
||||||
|
if (!long.TryParse(parts[i], out values[i]))
|
||||||
|
{
|
||||||
|
ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok && values.Length >= 4 && values.Length % 2 == 0)
|
||||||
|
ranges.Add(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ranges;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool CoversWholeDocument(long[]? byteRange, long fileLength)
|
||||||
|
{
|
||||||
|
if (byteRange is null || byteRange.Length < 4 || byteRange.Length % 2 != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (byteRange[0] != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
long previousEnd = -1;
|
||||||
|
for (var i = 0; i < byteRange.Length; i += 2)
|
||||||
|
{
|
||||||
|
var start = byteRange[i];
|
||||||
|
var length = byteRange[i + 1];
|
||||||
|
if (start < 0 || length < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var end = start + length;
|
||||||
|
if (previousEnd > start)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
previousEnd = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
return previousEnd == fileLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long GetSignedRevisionLength(long[] byteRange)
|
||||||
|
{
|
||||||
|
if (byteRange.Length < 2)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
var start = byteRange[^2];
|
||||||
|
var length = byteRange[^1];
|
||||||
|
if (start < 0 || length < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return start + length;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ResolveUuid(string? uuid)
|
||||||
|
{
|
||||||
|
return Guid.TryParse(uuid, out var parsed)
|
||||||
|
? parsed.ToString()
|
||||||
|
: Guid.NewGuid().ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string BuildReasonWithMeta(string? businessReason, string uuid, string sourceHashHex)
|
||||||
|
{
|
||||||
|
var trimmedReason = string.IsNullOrWhiteSpace(businessReason) ? null : businessReason.Trim();
|
||||||
|
var prefix = string.IsNullOrWhiteSpace(trimmedReason) ? string.Empty : trimmedReason + " ";
|
||||||
|
return $"{prefix}| SFMETA:v1;doc={uuid};sha256={sourceHashHex}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? BuildContactInfo(string? email, string? phone)
|
||||||
|
{
|
||||||
|
var normalizedEmail = string.IsNullOrWhiteSpace(email) ? null : email.Trim();
|
||||||
|
var normalizedPhone = string.IsNullOrWhiteSpace(phone) ? null : phone.Trim();
|
||||||
|
|
||||||
|
if (normalizedEmail is null && normalizedPhone is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (normalizedEmail is null)
|
||||||
|
return $"tel:{normalizedPhone}";
|
||||||
|
|
||||||
|
if (normalizedPhone is null)
|
||||||
|
return $"mailto:{normalizedEmail}";
|
||||||
|
|
||||||
|
return $"mailto:{normalizedEmail};tel:{normalizedPhone}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static (string? Email, string? Phone) ParseContactInfo(string? contactInfo)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(contactInfo))
|
||||||
|
return (null, null);
|
||||||
|
|
||||||
|
string? email = null;
|
||||||
|
string? phone = null;
|
||||||
|
|
||||||
|
foreach (var part in contactInfo.Split(';', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
if (part.StartsWith("mailto:", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
email = part[7..].Trim();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (part.StartsWith("tel:", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
phone = part[4..].Trim();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (email is null && part.Contains('@', StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
email = part.Trim();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (phone is null)
|
||||||
|
phone = part.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
string.IsNullOrWhiteSpace(email) ? null : email,
|
||||||
|
string.IsNullOrWhiteSpace(phone) ? null : phone);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static (string? BusinessReason, string? UUID, string? OriginalDocumentSha256) ParseReasonMeta(string? reason)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(reason))
|
||||||
|
return (reason, null, null);
|
||||||
|
|
||||||
|
var match = SignatureReasonMetaRegex.Match(reason);
|
||||||
|
if (!match.Success)
|
||||||
|
return (reason, null, null);
|
||||||
|
|
||||||
|
var businessReason = reason[..match.Index].Trim();
|
||||||
|
if (string.IsNullOrWhiteSpace(businessReason))
|
||||||
|
businessReason = null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
businessReason,
|
||||||
|
match.Groups["doc"].Value,
|
||||||
|
match.Groups["sha"].Value.ToUpperInvariant());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Crypt.Services;
|
||||||
|
|
||||||
|
internal static class Pkcs11DigestInfoBuilder
|
||||||
|
{
|
||||||
|
public static byte[] Build(byte[] hash, HashAlgorithmName hashAlgorithm)
|
||||||
|
{
|
||||||
|
byte[] prefix = hashAlgorithm.Name switch
|
||||||
|
{
|
||||||
|
"SHA256" =>
|
||||||
|
[
|
||||||
|
0x30, 0x31,
|
||||||
|
0x30, 0x0d,
|
||||||
|
0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01,
|
||||||
|
0x05, 0x00,
|
||||||
|
0x04, 0x20
|
||||||
|
],
|
||||||
|
"SHA384" =>
|
||||||
|
[
|
||||||
|
0x30, 0x41,
|
||||||
|
0x30, 0x0d,
|
||||||
|
0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02,
|
||||||
|
0x05, 0x00,
|
||||||
|
0x04, 0x30
|
||||||
|
],
|
||||||
|
"SHA512" =>
|
||||||
|
[
|
||||||
|
0x30, 0x51,
|
||||||
|
0x30, 0x0d,
|
||||||
|
0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03,
|
||||||
|
0x05, 0x00,
|
||||||
|
0x04, 0x40
|
||||||
|
],
|
||||||
|
_ => throw new NotSupportedException($"Hash algorithm '{hashAlgorithm.Name}' is not supported.")
|
||||||
|
};
|
||||||
|
|
||||||
|
var digestInfo = new byte[prefix.Length + hash.Length];
|
||||||
|
Buffer.BlockCopy(prefix, 0, digestInfo, 0, prefix.Length);
|
||||||
|
Buffer.BlockCopy(hash, 0, digestInfo, prefix.Length, hash.Length);
|
||||||
|
return digestInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Configurations;
|
||||||
|
using DevExpress.Office.DigitalSignatures;
|
||||||
|
using DevExpress.Pdf;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Crypt.Services;
|
||||||
|
|
||||||
|
internal sealed class Pkcs11ExternalSigner(Pkcs11Options options) : Pkcs7SignerBase
|
||||||
|
{
|
||||||
|
private readonly Pkcs11PdfSigningRsa rsa = new(options);
|
||||||
|
private readonly DigestCalculator digestCalculator = new(HashAlgorithmType.SHA256);
|
||||||
|
private readonly IReadOnlyList<byte[]> certificates = [ReadCertificateBytesWithFallback(options)];
|
||||||
|
|
||||||
|
protected override IDigestCalculator DigestCalculator => digestCalculator;
|
||||||
|
|
||||||
|
protected override string SigningAlgorithmOID => "1.2.840.113549.1.1.1";
|
||||||
|
|
||||||
|
protected override IEnumerable<byte[]> GetCertificates() => certificates;
|
||||||
|
|
||||||
|
protected override byte[] SignDigest(byte[] digest)
|
||||||
|
{
|
||||||
|
return rsa.SignHash(digest, System.Security.Cryptography.HashAlgorithmName.SHA256, System.Security.Cryptography.RSASignaturePadding.Pkcs1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] ReadCertificateBytesWithFallback(Pkcs11Options options)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Pkcs11SessionRunner.Run(options, session =>
|
||||||
|
{
|
||||||
|
var attrs = new List<Net.Pkcs11Interop.HighLevelAPI.IObjectAttribute>
|
||||||
|
{
|
||||||
|
session.Factories.ObjectAttributeFactory.Create(Net.Pkcs11Interop.Common.CKA.CKA_CLASS, Net.Pkcs11Interop.Common.CKO.CKO_CERTIFICATE),
|
||||||
|
session.Factories.ObjectAttributeFactory.Create(Net.Pkcs11Interop.Common.CKA.CKA_LABEL, options.CertificateLabel)
|
||||||
|
};
|
||||||
|
|
||||||
|
var handles = session.FindAllObjects(attrs);
|
||||||
|
if (handles.Count == 0)
|
||||||
|
throw new InvalidOperationException($"Certificate '{options.CertificateLabel}' not found in token.");
|
||||||
|
|
||||||
|
var values = session.GetAttributeValue(handles[0], new List<Net.Pkcs11Interop.Common.CKA> { Net.Pkcs11Interop.Common.CKA.CKA_VALUE });
|
||||||
|
return values[0].GetValueAsByteArray();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch when (Pkcs11ToolBridge.IsAvailable(options))
|
||||||
|
{
|
||||||
|
return Pkcs11ToolBridge.ReadCertificateBytes(options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Configurations;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Crypt.Services;
|
||||||
|
|
||||||
|
internal static class Pkcs11InteropBootstrap
|
||||||
|
{
|
||||||
|
private static readonly object Sync = new();
|
||||||
|
private static bool Initialized;
|
||||||
|
private const string ProxyRelativePath = "pkcs11\\windows\\proxy\\libpkcs11-proxy.dll";
|
||||||
|
private const string ToolRelativePath = "pkcs11\\windows\\opensc\\tools\\pkcs11-tool.exe";
|
||||||
|
|
||||||
|
public static void EnsureLoaded(Pkcs11Options options)
|
||||||
|
{
|
||||||
|
if (Initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lock (Sync)
|
||||||
|
{
|
||||||
|
if (Initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var libraryPath = ResolveLibraryPath(options);
|
||||||
|
var toolPath = ResolveToolPath(options);
|
||||||
|
options.SetResolvedPaths(libraryPath, toolPath);
|
||||||
|
|
||||||
|
EnsureNativeDependencySearchPath(options.ResolvedLibraryPath);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(options.ProxySocket))
|
||||||
|
{
|
||||||
|
Environment.SetEnvironmentVariable("PKCS11_PROXY_SOCKET", options.ProxySocket);
|
||||||
|
Environment.SetEnvironmentVariable("PKCS11_DAEMON_SOCKET", options.ProxySocket);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(options.ResolvedToolPath))
|
||||||
|
{
|
||||||
|
var toolDir = Path.GetDirectoryName(options.ResolvedToolPath);
|
||||||
|
if (!string.IsNullOrWhiteSpace(toolDir))
|
||||||
|
EnsurePathContains(toolDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
WarmupWithPkcs11Tool(options);
|
||||||
|
Initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ResolveLibraryPath(Pkcs11Options options)
|
||||||
|
{
|
||||||
|
var assetsRoot = string.IsNullOrWhiteSpace(options.AssetsRootPath)
|
||||||
|
? AppContext.BaseDirectory
|
||||||
|
: options.AssetsRootPath;
|
||||||
|
|
||||||
|
var resolved = Path.Combine(assetsRoot, ProxyRelativePath);
|
||||||
|
if (File.Exists(resolved))
|
||||||
|
return resolved;
|
||||||
|
|
||||||
|
throw new FileNotFoundException($"PKCS#11 proxy module not found. Checked path: {resolved}", resolved);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string? ResolveToolPath(Pkcs11Options options)
|
||||||
|
{
|
||||||
|
var assetsRoot = string.IsNullOrWhiteSpace(options.AssetsRootPath)
|
||||||
|
? AppContext.BaseDirectory
|
||||||
|
: options.AssetsRootPath;
|
||||||
|
|
||||||
|
var resolved = Path.Combine(assetsRoot, ToolRelativePath);
|
||||||
|
if (File.Exists(resolved))
|
||||||
|
return resolved;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WarmupWithPkcs11Tool(Pkcs11Options options)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(options.ResolvedToolPath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!File.Exists(options.ResolvedToolPath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var process = new System.Diagnostics.Process
|
||||||
|
{
|
||||||
|
StartInfo = new System.Diagnostics.ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = options.ResolvedToolPath,
|
||||||
|
Arguments = $"--module \"{options.ResolvedLibraryPath}\" -L",
|
||||||
|
UseShellExecute = false,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true,
|
||||||
|
CreateNoWindow = true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
process.Start();
|
||||||
|
process.WaitForExit(15000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EnsureNativeDependencySearchPath(string libraryPath)
|
||||||
|
{
|
||||||
|
var directory = Path.GetDirectoryName(libraryPath);
|
||||||
|
if (string.IsNullOrWhiteSpace(directory))
|
||||||
|
return;
|
||||||
|
|
||||||
|
EnsurePathContains(directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EnsurePathContains(string directory)
|
||||||
|
{
|
||||||
|
var currentPath = Environment.GetEnvironmentVariable("PATH") ?? string.Empty;
|
||||||
|
var entries = currentPath.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||||
|
if (entries.Any(p => string.Equals(p, directory, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var updatedPath = string.IsNullOrWhiteSpace(currentPath)
|
||||||
|
? directory
|
||||||
|
: directory + ";" + currentPath;
|
||||||
|
|
||||||
|
Environment.SetEnvironmentVariable("PATH", updatedPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Configurations;
|
||||||
|
using Net.Pkcs11Interop.Common;
|
||||||
|
using Net.Pkcs11Interop.HighLevelAPI;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Crypt.Services;
|
||||||
|
|
||||||
|
internal sealed class Pkcs11PdfSigningRsa(Pkcs11Options options) : RSA
|
||||||
|
{
|
||||||
|
public override int KeySize
|
||||||
|
{
|
||||||
|
get => KeySizeValue;
|
||||||
|
set => KeySizeValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override KeySizes[] LegalKeySizes => [new(1024, 8192, 8)];
|
||||||
|
public override string? KeyExchangeAlgorithm => "RSA";
|
||||||
|
public override string SignatureAlgorithm => "RSA";
|
||||||
|
|
||||||
|
public override byte[] SignHash(byte[] hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
|
||||||
|
{
|
||||||
|
if (padding != RSASignaturePadding.Pkcs1)
|
||||||
|
throw new NotSupportedException("Only RSA PKCS#1 v1.5 padding is supported.");
|
||||||
|
|
||||||
|
byte[] digestInfo = Pkcs11DigestInfoBuilder.Build(hash, hashAlgorithm);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Pkcs11SessionRunner.Run(options, session =>
|
||||||
|
{
|
||||||
|
var attrs = new List<IObjectAttribute>
|
||||||
|
{
|
||||||
|
session.Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, CKO.CKO_PRIVATE_KEY),
|
||||||
|
session.Factories.ObjectAttributeFactory.Create(CKA.CKA_LABEL, options.PrivateKeyLabel)
|
||||||
|
};
|
||||||
|
|
||||||
|
var handles = session.FindAllObjects(attrs);
|
||||||
|
if (handles.Count == 0)
|
||||||
|
throw new InvalidOperationException($"Private key '{options.PrivateKeyLabel}' not found in token.");
|
||||||
|
|
||||||
|
var mechanism = session.Factories.MechanismFactory.Create(CKM.CKM_RSA_PKCS);
|
||||||
|
return session.Sign(mechanism, handles[0], digestInfo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch when (Pkcs11ToolBridge.IsAvailable(options))
|
||||||
|
{
|
||||||
|
return Pkcs11ToolBridge.SignDigestInfo(options, digestInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool VerifyHash(byte[] hash, byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
|
||||||
|
=> throw new NotSupportedException();
|
||||||
|
|
||||||
|
public override byte[] Decrypt(byte[] data, RSAEncryptionPadding padding)
|
||||||
|
=> throw new NotSupportedException();
|
||||||
|
|
||||||
|
public override byte[] Encrypt(byte[] data, RSAEncryptionPadding padding)
|
||||||
|
=> throw new NotSupportedException();
|
||||||
|
|
||||||
|
public override RSAParameters ExportParameters(bool includePrivateParameters)
|
||||||
|
=> throw new NotSupportedException();
|
||||||
|
|
||||||
|
public override void ImportParameters(RSAParameters parameters)
|
||||||
|
=> throw new NotSupportedException();
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
using EnvelopeGenerator.Application.Common.Interfaces.Services;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Crypt.Services;
|
||||||
|
|
||||||
|
internal sealed class Pkcs11SelfTestStatusStore : IPkcs11SelfTestStatusProvider
|
||||||
|
{
|
||||||
|
private Pkcs11SelfTestStatusDto _status = new(
|
||||||
|
Completed: false,
|
||||||
|
Success: false,
|
||||||
|
Mode: "pending",
|
||||||
|
Summary: "PKCS#11 startup self-test has not run yet.",
|
||||||
|
CheckedAtUtc: null,
|
||||||
|
InteropError: null,
|
||||||
|
ToolError: null);
|
||||||
|
|
||||||
|
public Pkcs11SelfTestStatusDto GetStatus() => Volatile.Read(ref _status);
|
||||||
|
|
||||||
|
public void SetStatus(Pkcs11SelfTestStatusDto status)
|
||||||
|
{
|
||||||
|
Volatile.Write(ref _status, status);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Configurations;
|
||||||
|
using Net.Pkcs11Interop.Common;
|
||||||
|
using Net.Pkcs11Interop.HighLevelAPI;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Crypt.Services;
|
||||||
|
|
||||||
|
internal static class Pkcs11SessionRunner
|
||||||
|
{
|
||||||
|
public static T Run<T>(Pkcs11Options options, Func<ISession, T> action)
|
||||||
|
{
|
||||||
|
Pkcs11InteropBootstrap.EnsureLoaded(options);
|
||||||
|
|
||||||
|
var factories = new Pkcs11InteropFactories();
|
||||||
|
using var pkcs11 = LoadLibraryWithFallback(factories, options.ResolvedLibraryPath, options.ProxySocket);
|
||||||
|
var slot = ResolveSlot(pkcs11.GetSlotList(SlotsType.WithTokenPresent), options);
|
||||||
|
|
||||||
|
using var session = slot.OpenSession(SessionType.ReadOnly);
|
||||||
|
session.Login(CKU.CKU_USER, options.UserPin);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return action(session);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
session.Logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IPkcs11Library LoadLibraryWithFallback(Pkcs11InteropFactories factories, string libraryPath, string? proxySocket)
|
||||||
|
{
|
||||||
|
List<Exception> errors = [];
|
||||||
|
foreach (string candidate in BuildLibraryCandidates(libraryPath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return factories.Pkcs11LibraryFactory.LoadPkcs11Library(factories, candidate, AppType.MultiThreaded);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
errors.Add(new InvalidOperationException($"{candidate} | MultiThreaded+WithFunctionList", ex));
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return factories.Pkcs11LibraryFactory.LoadPkcs11Library(factories, candidate, AppType.SingleThreaded);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
errors.Add(new InvalidOperationException($"{candidate} | SingleThreaded+WithFunctionList", ex));
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return factories.Pkcs11LibraryFactory.LoadPkcs11Library(factories, candidate, AppType.MultiThreaded, InitType.WithoutFunctionList);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
errors.Add(new InvalidOperationException($"{candidate} | MultiThreaded+WithoutFunctionList", ex));
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return factories.Pkcs11LibraryFactory.LoadPkcs11Library(factories, candidate, AppType.SingleThreaded, InitType.WithoutFunctionList);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
errors.Add(new InvalidOperationException($"{candidate} | SingleThreaded+WithoutFunctionList", ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var socketInfo = string.IsNullOrWhiteSpace(proxySocket) ? "<empty>" : proxySocket;
|
||||||
|
throw new AggregateException($"Unable to initialize PKCS#11 library '{libraryPath}' with any supported initialization mode. PKCS11_PROXY_SOCKET={socketInfo}", errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<string> BuildLibraryCandidates(string configuredPath)
|
||||||
|
{
|
||||||
|
var unique = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
configuredPath
|
||||||
|
};
|
||||||
|
|
||||||
|
var directory = Path.GetDirectoryName(configuredPath);
|
||||||
|
if (!string.IsNullOrWhiteSpace(directory))
|
||||||
|
{
|
||||||
|
string[] alternates =
|
||||||
|
[
|
||||||
|
"client.dll",
|
||||||
|
"pkcs11-proxy.dll",
|
||||||
|
"libpkcs11-proxy.dll"
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach (var fileName in alternates)
|
||||||
|
{
|
||||||
|
var candidate = Path.Combine(directory, fileName);
|
||||||
|
if (File.Exists(candidate))
|
||||||
|
unique.Add(candidate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return unique;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ISlot ResolveSlot(IEnumerable<ISlot> slots, Pkcs11Options options)
|
||||||
|
{
|
||||||
|
if (options.SlotId.HasValue)
|
||||||
|
{
|
||||||
|
var bySlotId = slots.FirstOrDefault(s => s.SlotId == options.SlotId.Value);
|
||||||
|
if (bySlotId is not null)
|
||||||
|
return bySlotId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(options.TokenLabel))
|
||||||
|
{
|
||||||
|
var byTokenLabel = slots.FirstOrDefault(s =>
|
||||||
|
string.Equals(s.GetTokenInfo().Label?.Trim(), options.TokenLabel.Trim(), StringComparison.Ordinal));
|
||||||
|
|
||||||
|
if (byTokenLabel is not null)
|
||||||
|
return byTokenLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new InvalidOperationException("Unable to resolve PKCS#11 slot. Check Crypt:Pkcs11:SlotId / TokenLabel.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Configurations;
|
||||||
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Net.Pkcs11Interop.Common;
|
||||||
|
using Net.Pkcs11Interop.HighLevelAPI;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Crypt.Services;
|
||||||
|
|
||||||
|
internal sealed class Pkcs11StartupSelfTestHostedService(
|
||||||
|
IOptions<Pkcs11Options> options,
|
||||||
|
Pkcs11SelfTestStatusStore statusStore,
|
||||||
|
ILogger<Pkcs11StartupSelfTestHostedService> logger) : IHostedService
|
||||||
|
{
|
||||||
|
public Task StartAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var pkcs11 = options.Value;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RunInteropProbe(pkcs11);
|
||||||
|
statusStore.SetStatus(new Pkcs11SelfTestStatusDto(
|
||||||
|
Completed: true,
|
||||||
|
Success: true,
|
||||||
|
Mode: "interop",
|
||||||
|
Summary: "PKCS#11 startup self-test succeeded via interop.",
|
||||||
|
CheckedAtUtc: DateTimeOffset.UtcNow,
|
||||||
|
InteropError: null,
|
||||||
|
ToolError: null));
|
||||||
|
logger.LogInformation("PKCS#11 startup self-test succeeded (mode=interop, library={LibraryPath}, proxy={ProxySocket}).", pkcs11.ResolvedLibraryPath, pkcs11.ProxySocket);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
catch (Exception interopEx) when (Pkcs11ToolBridge.IsAvailable(pkcs11))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RunToolProbe(pkcs11);
|
||||||
|
statusStore.SetStatus(new Pkcs11SelfTestStatusDto(
|
||||||
|
Completed: true,
|
||||||
|
Success: true,
|
||||||
|
Mode: "pkcs11-tool",
|
||||||
|
Summary: "PKCS#11 interop failed, tool fallback succeeded.",
|
||||||
|
CheckedAtUtc: DateTimeOffset.UtcNow,
|
||||||
|
InteropError: interopEx.Message,
|
||||||
|
ToolError: null));
|
||||||
|
logger.LogWarning(interopEx, "PKCS#11 interop self-test failed, but tool fallback is healthy (mode=pkcs11-tool, tool={ToolPath}).", pkcs11.ResolvedToolPath);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
catch (Exception toolEx)
|
||||||
|
{
|
||||||
|
statusStore.SetStatus(new Pkcs11SelfTestStatusDto(
|
||||||
|
Completed: true,
|
||||||
|
Success: false,
|
||||||
|
Mode: "failed",
|
||||||
|
Summary: "PKCS#11 startup self-test failed for both interop and tool fallback.",
|
||||||
|
CheckedAtUtc: DateTimeOffset.UtcNow,
|
||||||
|
InteropError: interopEx.Message,
|
||||||
|
ToolError: toolEx.Message));
|
||||||
|
logger.LogError(toolEx, "PKCS#11 startup self-test failed for both interop and tool fallback. library={LibraryPath}, proxy={ProxySocket}, tool={ToolPath}", pkcs11.ResolvedLibraryPath, pkcs11.ProxySocket, pkcs11.ResolvedToolPath);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
statusStore.SetStatus(new Pkcs11SelfTestStatusDto(
|
||||||
|
Completed: true,
|
||||||
|
Success: false,
|
||||||
|
Mode: "failed",
|
||||||
|
Summary: "PKCS#11 startup self-test failed via interop and no tool fallback is available.",
|
||||||
|
CheckedAtUtc: DateTimeOffset.UtcNow,
|
||||||
|
InteropError: ex.Message,
|
||||||
|
ToolError: null));
|
||||||
|
logger.LogError(ex, "PKCS#11 startup self-test failed (mode=interop, no fallback available). library={LibraryPath}, proxy={ProxySocket}", pkcs11.ResolvedLibraryPath, pkcs11.ProxySocket);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||||
|
|
||||||
|
private static void RunInteropProbe(Pkcs11Options options)
|
||||||
|
{
|
||||||
|
Pkcs11SessionRunner.Run(options, session =>
|
||||||
|
{
|
||||||
|
EnsureObjectExists(session, CKO.CKO_CERTIFICATE, options.CertificateLabel, "certificate");
|
||||||
|
EnsureObjectExists(session, CKO.CKO_PRIVATE_KEY, options.PrivateKeyLabel, "private key");
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RunToolProbe(Pkcs11Options options)
|
||||||
|
{
|
||||||
|
_ = Pkcs11ToolBridge.ReadCertificateBytes(options);
|
||||||
|
var testDigest = SHA256.HashData([1, 2, 3, 4]);
|
||||||
|
var digestInfo = Pkcs11DigestInfoBuilder.Build(testDigest, HashAlgorithmName.SHA256);
|
||||||
|
_ = Pkcs11ToolBridge.SignDigestInfo(options, digestInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EnsureObjectExists(ISession session, CKO objectClass, string label, string objectType)
|
||||||
|
{
|
||||||
|
var attrs = new List<IObjectAttribute>
|
||||||
|
{
|
||||||
|
session.Factories.ObjectAttributeFactory.Create(CKA.CKA_CLASS, objectClass),
|
||||||
|
session.Factories.ObjectAttributeFactory.Create(CKA.CKA_LABEL, label)
|
||||||
|
};
|
||||||
|
|
||||||
|
var handles = session.FindAllObjects(attrs);
|
||||||
|
if (handles.Count == 0)
|
||||||
|
throw new InvalidOperationException($"PKCS#11 {objectType} '{label}' not found in token.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Configurations;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Crypt.Services;
|
||||||
|
|
||||||
|
internal static class Pkcs11ToolBridge
|
||||||
|
{
|
||||||
|
public static bool IsAvailable(Pkcs11Options options)
|
||||||
|
{
|
||||||
|
return !string.IsNullOrWhiteSpace(options.ResolvedToolPath) && File.Exists(options.ResolvedToolPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] ReadCertificateBytes(Pkcs11Options options)
|
||||||
|
{
|
||||||
|
EnsureAvailable(options);
|
||||||
|
|
||||||
|
var outputFile = Path.Combine(Path.GetTempPath(), $"pkcs11-cert-{Guid.NewGuid():N}.der");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var args = CreateBaseArgs(options);
|
||||||
|
args.Add("--read-object");
|
||||||
|
args.Add("--type");
|
||||||
|
args.Add("cert");
|
||||||
|
args.Add("--label");
|
||||||
|
args.Add(options.CertificateLabel);
|
||||||
|
args.Add("--output-file");
|
||||||
|
args.Add(outputFile);
|
||||||
|
|
||||||
|
Execute(options, args);
|
||||||
|
return File.ReadAllBytes(outputFile);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DeleteIfExists(outputFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] SignDigestInfo(Pkcs11Options options, byte[] digestInfo)
|
||||||
|
{
|
||||||
|
EnsureAvailable(options);
|
||||||
|
|
||||||
|
var inputFile = Path.Combine(Path.GetTempPath(), $"pkcs11-sign-in-{Guid.NewGuid():N}.bin");
|
||||||
|
var outputFile = Path.Combine(Path.GetTempPath(), $"pkcs11-sign-out-{Guid.NewGuid():N}.bin");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.WriteAllBytes(inputFile, digestInfo);
|
||||||
|
|
||||||
|
var args = CreateBaseArgs(options);
|
||||||
|
args.Add("--sign");
|
||||||
|
args.Add("--mechanism");
|
||||||
|
args.Add("RSA-PKCS");
|
||||||
|
args.Add("--type");
|
||||||
|
args.Add("privkey");
|
||||||
|
args.Add("--label");
|
||||||
|
args.Add(options.PrivateKeyLabel);
|
||||||
|
args.Add("--input-file");
|
||||||
|
args.Add(inputFile);
|
||||||
|
args.Add("--output-file");
|
||||||
|
args.Add(outputFile);
|
||||||
|
|
||||||
|
Execute(options, args);
|
||||||
|
return File.ReadAllBytes(outputFile);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DeleteIfExists(inputFile);
|
||||||
|
DeleteIfExists(outputFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<string> CreateBaseArgs(Pkcs11Options options)
|
||||||
|
{
|
||||||
|
var args = new List<string>
|
||||||
|
{
|
||||||
|
"--module",
|
||||||
|
options.ResolvedLibraryPath,
|
||||||
|
"--login",
|
||||||
|
"--pin",
|
||||||
|
options.UserPin
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options.SlotId.HasValue)
|
||||||
|
{
|
||||||
|
args.Add("--slot");
|
||||||
|
args.Add(options.SlotId.Value.ToString());
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrWhiteSpace(options.TokenLabel))
|
||||||
|
{
|
||||||
|
args.Add("--token-label");
|
||||||
|
args.Add(options.TokenLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Execute(Pkcs11Options options, IReadOnlyList<string> arguments)
|
||||||
|
{
|
||||||
|
var process = new Process
|
||||||
|
{
|
||||||
|
StartInfo = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = options.ResolvedToolPath!,
|
||||||
|
UseShellExecute = false,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true,
|
||||||
|
CreateNoWindow = true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var argument in arguments)
|
||||||
|
process.StartInfo.ArgumentList.Add(argument);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(options.ProxySocket))
|
||||||
|
{
|
||||||
|
process.StartInfo.Environment["PKCS11_PROXY_SOCKET"] = options.ProxySocket;
|
||||||
|
process.StartInfo.Environment["PKCS11_DAEMON_SOCKET"] = options.ProxySocket;
|
||||||
|
}
|
||||||
|
|
||||||
|
process.Start();
|
||||||
|
|
||||||
|
string stdOut = process.StandardOutput.ReadToEnd();
|
||||||
|
string stdErr = process.StandardError.ReadToEnd();
|
||||||
|
|
||||||
|
if (!process.WaitForExit(30000))
|
||||||
|
{
|
||||||
|
try { process.Kill(entireProcessTree: true); } catch { }
|
||||||
|
throw new TimeoutException($"pkcs11-tool timed out. Args: {string.Join(' ', process.StartInfo.ArgumentList)}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.ExitCode != 0)
|
||||||
|
throw new InvalidOperationException($"pkcs11-tool failed with exit code {process.ExitCode}. StdOut: {stdOut} StdErr: {stdErr}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EnsureAvailable(Pkcs11Options options)
|
||||||
|
{
|
||||||
|
if (!IsAvailable(options))
|
||||||
|
throw new InvalidOperationException("pkcs11-tool is not available at resolved pkcs11 assets path.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DeleteIfExists(string path)
|
||||||
|
{
|
||||||
|
if (File.Exists(path))
|
||||||
|
File.Delete(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,301 @@
|
|||||||
|
# FES Signature Infrastructure Plan
|
||||||
|
|
||||||
|
## 1. Goal
|
||||||
|
|
||||||
|
Build a reusable and modular cryptography infrastructure in `EnvelopeGenerator.Infrastructure.Crypt` to support FES (Advanced Electronic Signature) workflows.
|
||||||
|
|
||||||
|
This module must:
|
||||||
|
|
||||||
|
- use PKCS#11 providers (SoftHSMv2 first, real HSM later),
|
||||||
|
- stay independent from UI/API concerns,
|
||||||
|
- expose clean interfaces to `Application` layer use-cases,
|
||||||
|
- support future extensions (timestamping, certificate chain validation, multiple key algorithms).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Context and Constraints
|
||||||
|
|
||||||
|
1. SoftHSMv2 is **not** a REST service. It is a PKCS#11 module loaded as a native library.
|
||||||
|
2. `EnvelopeGenerator.Server` is presentation only; cryptographic implementation belongs to infrastructure.
|
||||||
|
3. Clean Architecture boundaries must be respected:
|
||||||
|
- `Application` depends on abstractions.
|
||||||
|
- `Infrastructure.Crypt` implements abstractions.
|
||||||
|
4. Initial target framework is `net8.0`.
|
||||||
|
5. We need production-ready behavior, not only PoC signing.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. High-Level Design
|
||||||
|
|
||||||
|
## 3.1 Architecture slice
|
||||||
|
|
||||||
|
- **Application layer (contracts/use-cases):**
|
||||||
|
- request signing hash/document,
|
||||||
|
- request certificate/public key material,
|
||||||
|
- request verification,
|
||||||
|
- consume signature evidence result.
|
||||||
|
|
||||||
|
- **Infrastructure.Crypt layer (this project):**
|
||||||
|
- PKCS#11 session handling,
|
||||||
|
- key/certificate object discovery,
|
||||||
|
- hash signing operations,
|
||||||
|
- local cryptographic verification,
|
||||||
|
- certificate parsing helpers,
|
||||||
|
- error normalization.
|
||||||
|
|
||||||
|
## 3.2 Provider model
|
||||||
|
|
||||||
|
Define provider-agnostic APIs and add one concrete provider first:
|
||||||
|
|
||||||
|
- `Pkcs11SignatureProvider` (primary)
|
||||||
|
- future providers:
|
||||||
|
- `RemoteSigningProvider` (if a dedicated signing gateway is introduced)
|
||||||
|
- `MockSignatureProvider` (for deterministic test scenarios)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Deliverables (Phase by Phase)
|
||||||
|
|
||||||
|
## Phase 0 - Contracts and Domain Language
|
||||||
|
|
||||||
|
Create neutral models and interfaces in `Infrastructure.Crypt` (or shared abstractions if needed later):
|
||||||
|
|
||||||
|
- `SigningAlgorithm` (enum/value object)
|
||||||
|
- `Pkcs11ProviderOptions`
|
||||||
|
- `KeyLocator` (label/id/slot/token selectors)
|
||||||
|
- `SignHashRequest`
|
||||||
|
- `SignHashResult`
|
||||||
|
- `VerifySignatureRequest`
|
||||||
|
- `VerifySignatureResult`
|
||||||
|
- `CertificateDescriptor`
|
||||||
|
- `SignatureEvidence` (technical evidence payload)
|
||||||
|
|
||||||
|
Interfaces:
|
||||||
|
|
||||||
|
- `ISignatureProvider`
|
||||||
|
- `ICertificateProvider`
|
||||||
|
- `ISignatureVerifier`
|
||||||
|
- `ICryptographicHealthCheck`
|
||||||
|
|
||||||
|
Acceptance criteria:
|
||||||
|
|
||||||
|
- no dependency on ASP.NET types,
|
||||||
|
- no UI/API naming leakage,
|
||||||
|
- all model names are business-neutral.
|
||||||
|
|
||||||
|
## Phase 1 - PKCS#11 Core Adapter (SoftHSM-ready)
|
||||||
|
|
||||||
|
Implement:
|
||||||
|
|
||||||
|
- `Pkcs11LibraryLoader`
|
||||||
|
- `Pkcs11SessionFactory`
|
||||||
|
- `Pkcs11ObjectFinder`
|
||||||
|
- `Pkcs11SignatureProvider`
|
||||||
|
- `Pkcs11CertificateProvider`
|
||||||
|
|
||||||
|
Capabilities:
|
||||||
|
|
||||||
|
1. load module path from options (`libsofthsm2.so` or proxy module when required),
|
||||||
|
2. enumerate slots/tokens,
|
||||||
|
3. open read-write session,
|
||||||
|
4. login with user pin,
|
||||||
|
5. find private key by label/id,
|
||||||
|
6. sign digest with selected mechanism,
|
||||||
|
7. read certificate object by label/id.
|
||||||
|
|
||||||
|
Acceptance criteria:
|
||||||
|
|
||||||
|
- deterministic disposal of sessions,
|
||||||
|
- no leaked native handles,
|
||||||
|
- detailed typed errors (not raw exception strings only).
|
||||||
|
|
||||||
|
## Phase 2 - Verification and Certificate Utilities
|
||||||
|
|
||||||
|
Implement:
|
||||||
|
|
||||||
|
- `DefaultSignatureVerifier`
|
||||||
|
- `X509CertificateParser`
|
||||||
|
- optional `CertificateChainValidator` (toggleable)
|
||||||
|
|
||||||
|
Capabilities:
|
||||||
|
|
||||||
|
1. verify signature using returned certificate/public key,
|
||||||
|
2. expose certificate metadata (`thumbprint`, `subject`, `issuer`, `notBefore`, `notAfter`),
|
||||||
|
3. map validation failures into stable error codes.
|
||||||
|
|
||||||
|
Acceptance criteria:
|
||||||
|
|
||||||
|
- same request yields same verification outcome,
|
||||||
|
- invalid signature returns structured negative result.
|
||||||
|
|
||||||
|
## Phase 3 - Evidence Builder
|
||||||
|
|
||||||
|
Implement:
|
||||||
|
|
||||||
|
- `SignatureEvidenceBuilder`
|
||||||
|
|
||||||
|
Evidence payload should contain:
|
||||||
|
|
||||||
|
- transaction/correlation id,
|
||||||
|
- algorithm,
|
||||||
|
- hash metadata,
|
||||||
|
- key locator snapshot (safe subset),
|
||||||
|
- certificate fingerprint and subject,
|
||||||
|
- sign timestamp (UTC),
|
||||||
|
- verification outcome,
|
||||||
|
- provider type (`PKCS11`).
|
||||||
|
|
||||||
|
Acceptance criteria:
|
||||||
|
|
||||||
|
- no secret values in evidence (pin, private key id internals),
|
||||||
|
- evidence serializable for storage/audit.
|
||||||
|
|
||||||
|
## Phase 4 - Dependency Injection Module
|
||||||
|
|
||||||
|
Implement:
|
||||||
|
|
||||||
|
- `CryptInfrastructureDependencyInjection` extension methods
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
|
||||||
|
- `AddCryptInfrastructure(...)`
|
||||||
|
- `AddPkcs11Provider(...)`
|
||||||
|
|
||||||
|
Acceptance criteria:
|
||||||
|
|
||||||
|
- one-line registration from composition root,
|
||||||
|
- options validation on startup.
|
||||||
|
|
||||||
|
## Phase 5 - Test Suite (`EnvelopeGenerator.Tests`)
|
||||||
|
|
||||||
|
Add test categories for `net8.0`:
|
||||||
|
|
||||||
|
1. `Unit`:
|
||||||
|
- request validation,
|
||||||
|
- algorithm mapping,
|
||||||
|
- evidence building,
|
||||||
|
- error mapping.
|
||||||
|
2. `Integration` (conditional/manual profile):
|
||||||
|
- SoftHSM slot listing,
|
||||||
|
- login,
|
||||||
|
- sign hash,
|
||||||
|
- verify,
|
||||||
|
- certificate read.
|
||||||
|
|
||||||
|
Acceptance criteria:
|
||||||
|
|
||||||
|
- unit tests run in CI without native SoftHSM,
|
||||||
|
- integration tests run when module path + pins are provided via environment variables.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Proposed Project Structure
|
||||||
|
|
||||||
|
```text
|
||||||
|
EnvelopeGenerator.Infrastructure.Crypt/
|
||||||
|
Abstractions/
|
||||||
|
ISignatureProvider.cs
|
||||||
|
ICertificateProvider.cs
|
||||||
|
ISignatureVerifier.cs
|
||||||
|
ICryptographicHealthCheck.cs
|
||||||
|
Models/
|
||||||
|
SigningAlgorithm.cs
|
||||||
|
SignHashRequest.cs
|
||||||
|
SignHashResult.cs
|
||||||
|
VerifySignatureRequest.cs
|
||||||
|
VerifySignatureResult.cs
|
||||||
|
SignatureEvidence.cs
|
||||||
|
CertificateDescriptor.cs
|
||||||
|
KeyLocator.cs
|
||||||
|
Options/
|
||||||
|
Pkcs11ProviderOptions.cs
|
||||||
|
Pkcs11/
|
||||||
|
Pkcs11LibraryLoader.cs
|
||||||
|
Pkcs11SessionFactory.cs
|
||||||
|
Pkcs11ObjectFinder.cs
|
||||||
|
Pkcs11SignatureProvider.cs
|
||||||
|
Pkcs11CertificateProvider.cs
|
||||||
|
Verification/
|
||||||
|
DefaultSignatureVerifier.cs
|
||||||
|
X509CertificateParser.cs
|
||||||
|
Evidence/
|
||||||
|
SignatureEvidenceBuilder.cs
|
||||||
|
DependencyInjection/
|
||||||
|
CryptInfrastructureDependencyInjection.cs
|
||||||
|
Exceptions/
|
||||||
|
CryptographicOperationException.cs
|
||||||
|
Pkcs11ProviderException.cs
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. Configuration Strategy
|
||||||
|
|
||||||
|
Use options (bound from host config) with environment override support:
|
||||||
|
|
||||||
|
- `Crypt:Provider = PKCS11`
|
||||||
|
- `Crypt:Pkcs11:AssetsRootPath` (base path that contains bundled `pkcs11` assets)
|
||||||
|
- `Crypt:Pkcs11:SlotId` or token selectors
|
||||||
|
- `Crypt:Pkcs11:UserPin` (from secret store/env, not plain committed value)
|
||||||
|
- `Crypt:Pkcs11:PrivateKeyLabel`
|
||||||
|
- `Crypt:Pkcs11:CertificateLabel`
|
||||||
|
- `Crypt:Pkcs11:LoginType`
|
||||||
|
|
||||||
|
Validation rules:
|
||||||
|
|
||||||
|
- resolved module path must exist under configured/default assets root,
|
||||||
|
- at least one key locator required,
|
||||||
|
- pin required for signing operations.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. Error Model
|
||||||
|
|
||||||
|
Define stable error codes to prevent provider-specific leakage:
|
||||||
|
|
||||||
|
- `CRYPT_PROVIDER_UNAVAILABLE`
|
||||||
|
- `CRYPT_SLOT_NOT_FOUND`
|
||||||
|
- `CRYPT_LOGIN_FAILED`
|
||||||
|
- `CRYPT_KEY_NOT_FOUND`
|
||||||
|
- `CRYPT_CERT_NOT_FOUND`
|
||||||
|
- `CRYPT_SIGN_FAILED`
|
||||||
|
- `CRYPT_VERIFY_FAILED`
|
||||||
|
|
||||||
|
Map low-level exceptions to these codes with safe diagnostics.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8. Non-Functional Requirements
|
||||||
|
|
||||||
|
1. **Security:** never log pins or raw private key handles.
|
||||||
|
2. **Reliability:** deterministic cleanup (`IDisposable`/`IAsyncDisposable`).
|
||||||
|
3. **Observability:** structured logs with correlation id.
|
||||||
|
4. **Performance:** avoid repeated login per operation when a safe session strategy is available.
|
||||||
|
5. **Extensibility:** algorithm/provider mapping must be open for extension.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 9. Implementation Order (Small Tasks)
|
||||||
|
|
||||||
|
1. Add models + interfaces.
|
||||||
|
2. Add options + validators.
|
||||||
|
3. Add PKCS#11 low-level loader/session wrappers.
|
||||||
|
4. Implement `Pkcs11SignatureProvider` for hash signing.
|
||||||
|
5. Implement certificate retrieval.
|
||||||
|
6. Implement verifier.
|
||||||
|
7. Implement evidence builder.
|
||||||
|
8. Add DI registration extension.
|
||||||
|
9. Add unit tests.
|
||||||
|
10. Add optional integration tests (SoftHSM profile).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 10. Definition of Done
|
||||||
|
|
||||||
|
Done means:
|
||||||
|
|
||||||
|
1. `Infrastructure.Crypt` exposes generic cryptographic services usable by Application use-cases.
|
||||||
|
2. SoftHSM-backed PKCS#11 sign/verify path works in integration tests.
|
||||||
|
3. All sensitive configuration is externalized.
|
||||||
|
4. Structured error codes are returned for expected failure scenarios.
|
||||||
|
5. Documentation exists for host registration and required settings.
|
||||||
@@ -0,0 +1,228 @@
|
|||||||
|
# FES (Advanced Electronic Signature) Summary and Integration Plan - EN
|
||||||
|
|
||||||
|
This document summarizes the shared diagram flow (`Ablauf SignFlow Unternehmenszertifikat`) and provides a small-step integration plan for the `EnvelopeGenerator` solution.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1) Simplified flow summary
|
||||||
|
|
||||||
|
Flow logic:
|
||||||
|
|
||||||
|
1. The sender uploads a document and defines signers.
|
||||||
|
2. If a valid company certificate already exists in HSM, it is used with the company key pair.
|
||||||
|
3. If no valid company certificate exists, CA issuance/renewal flow is required.
|
||||||
|
4. The signer receives an e-mail with a signing link.
|
||||||
|
5. The signer completes SMS OTP (2FA) and performs UI signature interaction.
|
||||||
|
6. Backend computes the hash for the current signing stage and sends it to HSM.
|
||||||
|
7. HSM signs the hash with the private key and returns signature + certificate context.
|
||||||
|
8. Backend embeds digital signature and certificate into PDF and writes audit trail.
|
||||||
|
9. After all signers complete, the final artifact is archived.
|
||||||
|
10. The final signed document is distributed to signers.
|
||||||
|
|
||||||
|
Important: The visible UI signature is not yet the legal electronic signature. The legal signature is produced in backend+HSM steps.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2) Relation to current codebase (as-is)
|
||||||
|
|
||||||
|
- `EnvelopeGenerator.Server` is the presentation layer host (Blazor + API hosting).
|
||||||
|
- Business flow is handled in `Application` via MediatR pipelines.
|
||||||
|
- Current receiver flow is centered around UI overlay/signature capture.
|
||||||
|
- Missing FES core: PKCS#11 hash-sign-verify + certificate-based PDF embedding pipeline.
|
||||||
|
|
||||||
|
Critical deployment fact:
|
||||||
|
|
||||||
|
- `EnvelopeGenerator.Server` is planned to run on Windows.
|
||||||
|
- SoftHSM is currently planned to run on Linux.
|
||||||
|
- A Windows process cannot directly load Linux PKCS#11 module (`libsofthsm2.so`).
|
||||||
|
- Therefore, architecture must include a compatibility bridge (service or proxy) unless HSM/SoftHSM is local to Windows.
|
||||||
|
|
||||||
|
Conclusion: FES is not a replacement of the current flow; it is a cryptographic hardening layer behind it.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3) Why SoftHSM tests are foundational
|
||||||
|
|
||||||
|
The tests defined in `SOFTHSM_TEST_KILAVUZU_TR.md` are the technical prerequisite for FES:
|
||||||
|
|
||||||
|
- `slots/login` -> HSM connectivity and authentication
|
||||||
|
- `certificate` -> certificate retrieval path
|
||||||
|
- `sign` -> hash signing with private key
|
||||||
|
- `verify` -> signature and certificate consistency validation
|
||||||
|
|
||||||
|
Without these tests passing, diagram steps 6-8 should not go live.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4) Target architecture (clean architecture aligned)
|
||||||
|
|
||||||
|
### Deployment topology options (must choose one)
|
||||||
|
|
||||||
|
1. **Linux signing service (recommended)**
|
||||||
|
- Windows `EnvelopeGenerator.Server` calls Linux signing API over HTTPS.
|
||||||
|
- Linux signing service performs PKCS#11 operations against SoftHSM.
|
||||||
|
- Private keys never leave Linux/HSM boundary.
|
||||||
|
|
||||||
|
2. **PKCS#11 proxy bridge**
|
||||||
|
- Windows host loads a Windows PKCS#11 proxy client DLL.
|
||||||
|
- Proxy forwards PKCS#11 operations to Linux side connected to SoftHSM.
|
||||||
|
|
||||||
|
3. **Windows-local SoftHSM (dev/test)**
|
||||||
|
- SoftHSM also installed on Windows and used locally.
|
||||||
|
- Useful for local testing, not preferred production topology.
|
||||||
|
|
||||||
|
Decision note:
|
||||||
|
|
||||||
|
- For production-critical FES, choose option 1 by default unless enterprise HSM policy requires option 2.
|
||||||
|
- Keep option 3 for development convenience only.
|
||||||
|
|
||||||
|
### Layer responsibilities
|
||||||
|
|
||||||
|
- `EnvelopeGenerator.Server`:
|
||||||
|
- API endpoints, auth orchestration, input validation.
|
||||||
|
- FES branch routing: standard-sign path vs external signing-service/proxy path.
|
||||||
|
- No private-key material handling.
|
||||||
|
|
||||||
|
- `EnvelopeGenerator.Application`:
|
||||||
|
- Use cases such as `SignWithHsmCommand`.
|
||||||
|
- MediatR pipeline orchestration for status/history/audit.
|
||||||
|
- FES evidence model aggregation (ip/email/phone/user-agent/otp proof/timestamps).
|
||||||
|
|
||||||
|
- `EnvelopeGenerator.Infrastructure`:
|
||||||
|
- Implementations for `IPkcs11Service`, `IPdfSignatureService`, `ITimestampService`.
|
||||||
|
- Pkcs11Interop integration and cryptographic operations.
|
||||||
|
- Optional client for Linux signing service if topology option 1 is selected.
|
||||||
|
|
||||||
|
- `Domain`:
|
||||||
|
- Signature evidence and audit-trail models.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5) Small-step integration plan
|
||||||
|
|
||||||
|
## Phase 0 - Scope and contracts
|
||||||
|
|
||||||
|
1. Finalize signing algorithms (for example `SHA256_RSA_PKCS`).
|
||||||
|
2. Confirm strategy: company certificate vs signer-specific certificate.
|
||||||
|
3. Freeze mandatory audit fields:
|
||||||
|
- identity, OTP proof, IP, user-agent, transaction id, timestamps, hash metadata.
|
||||||
|
4. Freeze deployment topology decision:
|
||||||
|
- option 1 (Linux signing service), option 2 (PKCS#11 proxy), or option 3 (Windows-local SoftHSM).
|
||||||
|
5. Define production host mapping:
|
||||||
|
- where `EnvelopeGenerator.Server` runs,
|
||||||
|
- where HSM/SoftHSM runs,
|
||||||
|
- where certificate lifecycle is managed.
|
||||||
|
|
||||||
|
Deliverable: Technical decision record (ADR-style markdown).
|
||||||
|
|
||||||
|
## Phase 1 - PKCS#11 connector (infrastructure)
|
||||||
|
|
||||||
|
1. Define `IPkcs11Service` interface.
|
||||||
|
2. Add `Pkcs11Interop` implementation.
|
||||||
|
3. Add config model:
|
||||||
|
- library path, slot, token label, key label, certificate label.
|
||||||
|
4. Ensure secure secret handling for PIN.
|
||||||
|
5. Ensure host-compatible module loading:
|
||||||
|
- Windows server must load Windows DLL,
|
||||||
|
- Linux server must load Linux `.so`.
|
||||||
|
|
||||||
|
Deliverable: Testable PKCS#11 service with health/slot/login/sign/verify capabilities.
|
||||||
|
|
||||||
|
## Phase 1.5 - Cross-host bridge implementation
|
||||||
|
|
||||||
|
1. If option 1 selected:
|
||||||
|
- implement Linux signing service API contract (`/sign`, `/certificate`, `/health`),
|
||||||
|
- implement authenticated HTTP client in `EnvelopeGenerator.Server`.
|
||||||
|
2. If option 2 selected:
|
||||||
|
- install/configure PKCS#11 proxy client DLL on Windows,
|
||||||
|
- install/configure proxy server on Linux and bind to SoftHSM.
|
||||||
|
|
||||||
|
Deliverable: Windows-to-Linux signing communication path proven end-to-end.
|
||||||
|
|
||||||
|
## Phase 2 - Application use case
|
||||||
|
|
||||||
|
1. Add `SignDocumentHashCommand` (or equivalent).
|
||||||
|
2. Pipeline flow:
|
||||||
|
- compute/receive hash,
|
||||||
|
- sign with HSM,
|
||||||
|
- attach certificate context,
|
||||||
|
- verify,
|
||||||
|
- produce evidence object.
|
||||||
|
3. Add resilient error mapping and retry strategy.
|
||||||
|
|
||||||
|
Deliverable: HSM signing use case in Application layer.
|
||||||
|
|
||||||
|
## Phase 3 - PDF signature embedding
|
||||||
|
|
||||||
|
1. Implement PDF signature embedding via `IPdfSignatureService`.
|
||||||
|
2. Build signer-specific audit-trail pages.
|
||||||
|
3. Append all audit pages to final PDF artifact.
|
||||||
|
|
||||||
|
Deliverable: Signed PDF with certificate context and audit trail pages.
|
||||||
|
|
||||||
|
## Phase 4 - Presentation/API integration
|
||||||
|
|
||||||
|
1. Integrate FES option into submit flow (feature flag guarded).
|
||||||
|
2. Add operational endpoints:
|
||||||
|
- HSM health/check
|
||||||
|
- signature evidence query (restricted roles)
|
||||||
|
3. Keep DTOs safe; avoid exposing sensitive cryptographic material.
|
||||||
|
4. In `SignatureController.Submit`, add FES branch that sends signing payload + audit context to selected signing backend.
|
||||||
|
|
||||||
|
Deliverable: API-level orchestration with minimal UI disruption.
|
||||||
|
|
||||||
|
## Phase 5 - Audit, archive, distribution
|
||||||
|
|
||||||
|
1. Persist signature evidence records.
|
||||||
|
2. Include hash/cert metadata in archival package.
|
||||||
|
3. Add signed artifact reference to distribution e-mails.
|
||||||
|
|
||||||
|
Deliverable: Alignment with diagram steps 9-10.
|
||||||
|
|
||||||
|
## Phase 6 - Testing and operations
|
||||||
|
|
||||||
|
1. Postman collection + Newman automation.
|
||||||
|
2. Positive/negative matrix:
|
||||||
|
- wrong pin, wrong slot, missing cert, expired cert, HSM timeout.
|
||||||
|
3. Observability:
|
||||||
|
- structured logs, correlation id, latency metrics.
|
||||||
|
|
||||||
|
Deliverable: Production readiness checklist.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6) Transition strategy from test API to production flow
|
||||||
|
|
||||||
|
1. Keep `/api/pkcs11-test/*` only for non-production.
|
||||||
|
2. In production, use the same internal services through business endpoints only.
|
||||||
|
3. Roll out by feature flag:
|
||||||
|
- `FesEnabled=false` initially
|
||||||
|
- pilot sender group
|
||||||
|
- full rollout
|
||||||
|
|
||||||
|
4. Keep explicit environment matrix:
|
||||||
|
- local dev (option 3),
|
||||||
|
- integration/staging (option 1 or 2),
|
||||||
|
- production (option 1 or 2 only).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7) Risks and mitigations
|
||||||
|
|
||||||
|
- Certificate expiry risk -> proactive monitoring and renewal alerting.
|
||||||
|
- HSM connectivity risk -> retry policy, circuit breaker, fallback queue.
|
||||||
|
- PIN/secret exposure risk -> vault-backed secrets and rotation policy.
|
||||||
|
- Verification failure risk -> block PDF sealing and move envelope to technical hold state.
|
||||||
|
- Cross-host connectivity risk -> mTLS/JWT auth + timeout/retry/circuit breaker + health probe.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8) Short done checklist
|
||||||
|
|
||||||
|
- [ ] PKCS#11 service interface + implementation
|
||||||
|
- [ ] Application command + pipeline behaviors
|
||||||
|
- [ ] PDF signature embedding
|
||||||
|
- [ ] Audit-trail generation
|
||||||
|
- [ ] API integration + feature flag
|
||||||
|
- [ ] Postman/Newman regression suite
|
||||||
|
- [ ] Operational runbook and alerting rules
|
||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
84
EnvelopeGenerator.Infrastructure.Crypt/resources/ticket.md
Normal file
84
EnvelopeGenerator.Infrastructure.Crypt/resources/ticket.md
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
10/6/26, 10:46 PM
|
||||||
|
|
||||||
|
Test SoftHSM : SWINFRA-54
|
||||||
|
|
||||||
|
Projects / Infrastruktur Software / Issues /
|
||||||
|
|
||||||
|
Enter search…
|
||||||
|
|
||||||
|
SWINFRA-54
|
||||||
|
|
||||||
|
All…
|
||||||
|
|
||||||
|
Created by Marvin Kamm 3 months ago
|
||||||
|
|
||||||
|
Visible to issue readers 1
|
||||||
|
|
||||||
|
Updated by Matthias Dewald about 1 month ago
|
||||||
|
|
||||||
|
# **Test SoftHSM**
|
||||||
|
|
||||||
|
Project Priorität Status **SWI** Infrastruktur Softwa H Hoch O Offen re… Bearbeiter Fälligkeit Projekteinfluss MD _ ? ? Matthias Dewald Kein fälligkeit Kein projektbezug Boards No visible boards
|
||||||
|
|
||||||
|
Bitte eine Test-VM mit der Software SoftHSM bereitstellen.
|
||||||
|
|
||||||
|
Laut Info von @Henning Emrich soll die Installation unter Debian Linux deutlich einfacher sein, als unter Windows. Bitte prüfen.
|
||||||
|
|
||||||
|
@Hakan Tek & @OlgunR
|
||||||
|
|
||||||
|
Sollen bitte die API Ansteuerung testen
|
||||||
|
|
||||||
|
FYI
|
||||||
|
|
||||||
|
@Marlon Schreiber @Jan-Ulrich Hoss @Henning Emrich @Hakan Tek @OlgunR
|
||||||
|
|
||||||
|
**Attachments** 1
|
||||||
|
|
||||||
|
Files Attached to Comments
|
||||||
|
|
||||||
|
**PDF**
|
||||||
|
|
||||||
|
Ablauf SignFlow Un ternehme… 83 kB
|
||||||
|
|
||||||
|
MD _ **Matthias Dewald** Commented 3 months ago Ist für Dienstag 30.6 10:00 Uhr Eingeplant
|
||||||
|
|
||||||
|
HT **Hakan Tek** Commented 3 months ago
|
||||||
|
|
||||||
|
Für die Integration auf der .NET-Seite können wir die Pkcs11Interop-Bibliothek und die entsprechende DevExpress-Infrastruktur verwenden. @OlgunR, falls du noch weitere Vorschläge hast, füge sie bitte hinzu. @Marvin Kamm, @Henning Emrich, @Matthias Dewald, um mit den Tests beginnen zu können, benötigen wir die entsprechenden Verbindungsdaten für SoftHSM (Slot-ID, PIN, Bibliothekspfad usw.).
|
||||||
|
|
||||||
|
FYI
|
||||||
|
|
||||||
|
@Marlon Schreiber @Jan-Ulrich Hoss
|
||||||
|
|
||||||
|
bugtracker.dd:8080/issue/SWINFRA-54/Test-SoftHSM
|
||||||
|
|
||||||
|
1/2
|
||||||
|
|
||||||
|
10/6/26, 10:46 PM
|
||||||
|
|
||||||
|
Test SoftHSM : SWINFRA-54
|
||||||
|
|
||||||
|
MD
|
||||||
|
|
||||||
|
## **Matthias Dewald** Commented 3 months ago
|
||||||
|
|
||||||
|
Hallo zusammen, SoftHSM ist auf der 172.24.12.64 installiert:
|
||||||
|
|
||||||
|
Der Proxy läuft auf Port 5657 und erwartet Verbindungen über die Proxy-Bibliothek (libpkcs11-proxy.so)
|
||||||
|
|
||||||
|
@Hakan Tek Bitte testen
|
||||||
|
|
||||||
|
MD
|
||||||
|
|
||||||
|
## **Matthias Dewald** Commented about 1 month ago
|
||||||
|
|
||||||
|
Ablauf SignFlow Unternehmenszertifikat.drawio.pdf
|
||||||
|
|
||||||
|
**PDF**
|
||||||
|
|
||||||
|
Ablauf SignFlow Un ternehme… 83 kB
|
||||||
|
|
||||||
|
bugtracker.dd:8080/issue/SWINFRA-54/Test-SoftHSM
|
||||||
|
|
||||||
|
2/2
|
||||||
|
|
||||||
18
EnvelopeGenerator.Infrastructure.Doc/DependencyInjection.cs
Normal file
18
EnvelopeGenerator.Infrastructure.Doc/DependencyInjection.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Interfaces.Doc;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Doc;
|
||||||
|
|
||||||
|
public static class DependencyInjection
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddDocInfrastructure(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddScoped<IPdfPageImageRenderer, PdfPageImageRenderer>();
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\EnvelopeGenerator.Application\EnvelopeGenerator.Application.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="DevExpress.Document.Processor" Version="25.2.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
57
EnvelopeGenerator.Infrastructure.Doc/PdfPageImageRenderer.cs
Normal file
57
EnvelopeGenerator.Infrastructure.Doc/PdfPageImageRenderer.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using DevExpress.Drawing;
|
||||||
|
using DevExpress.Pdf;
|
||||||
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
using EnvelopeGenerator.Application.Common.Interfaces.Doc;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Infrastructure.Doc;
|
||||||
|
|
||||||
|
public class PdfPageImageRenderer : IPdfPageImageRenderer
|
||||||
|
{
|
||||||
|
private const float RenderDpi = 110f;
|
||||||
|
|
||||||
|
public Task<IReadOnlyList<PdfPageImageDto>> RenderPagesAsImagesAsync(byte[] pdfBytes, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
ArgumentNullException.ThrowIfNull(pdfBytes);
|
||||||
|
|
||||||
|
if (pdfBytes.Length == 0)
|
||||||
|
return Task.FromResult<IReadOnlyList<PdfPageImageDto>>(Array.Empty<PdfPageImageDto>());
|
||||||
|
|
||||||
|
using var stream = new MemoryStream(pdfBytes, writable: false);
|
||||||
|
using var processor = new PdfDocumentProcessor();
|
||||||
|
processor.LoadDocument(stream);
|
||||||
|
|
||||||
|
var pages = processor.Document.Pages;
|
||||||
|
if (pages.Count == 0)
|
||||||
|
return Task.FromResult<IReadOnlyList<PdfPageImageDto>>(Array.Empty<PdfPageImageDto>());
|
||||||
|
|
||||||
|
var renderOptions = PdfPageRenderingParameters.CreateWithResolution(RenderDpi);
|
||||||
|
var results = new List<PdfPageImageDto>(pages.Count);
|
||||||
|
|
||||||
|
for (var i = 0; i < pages.Count; i++)
|
||||||
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
var pageNumber = i + 1;
|
||||||
|
var page = pages[i];
|
||||||
|
var cropBox = page.CropBox;
|
||||||
|
|
||||||
|
using DXBitmap bitmap = processor.CreateDXBitmap(pageNumber, renderOptions);
|
||||||
|
using var imageStream = new MemoryStream();
|
||||||
|
bitmap.Save(imageStream, DXImageFormat.Png);
|
||||||
|
|
||||||
|
var dataUrl = $"data:image/png;base64,{Convert.ToBase64String(imageStream.ToArray())}";
|
||||||
|
|
||||||
|
results.Add(new PdfPageImageDto
|
||||||
|
{
|
||||||
|
PageNumber = pageNumber,
|
||||||
|
WidthPt = cropBox.Width,
|
||||||
|
HeightPt = cropBox.Height,
|
||||||
|
WidthPx = bitmap.Width,
|
||||||
|
HeightPx = bitmap.Height,
|
||||||
|
ImageDataUrl = dataUrl
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.FromResult<IReadOnlyList<PdfPageImageDto>>(results);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace EnvelopeGenerator.Server.Client.Components.PdfEditor;
|
||||||
|
|
||||||
|
public sealed record SenderPdfFieldMoveRequest(
|
||||||
|
int Index,
|
||||||
|
int Page,
|
||||||
|
double XPt,
|
||||||
|
double YPt);
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace EnvelopeGenerator.Server.Client.Components.PdfEditor;
|
||||||
|
|
||||||
|
public sealed record SenderPdfFieldOverlay(
|
||||||
|
int Index,
|
||||||
|
int Page,
|
||||||
|
double XPt,
|
||||||
|
double YPt,
|
||||||
|
string ReceiverName,
|
||||||
|
string Color);
|
||||||
@@ -0,0 +1,458 @@
|
|||||||
|
@using EnvelopeGenerator.Application.Resources
|
||||||
|
@using EnvelopeGenerator.Application.Common.Dto
|
||||||
|
@using System.Globalization
|
||||||
|
@using Microsoft.AspNetCore.Components.Web
|
||||||
|
@using Microsoft.Extensions.Localization
|
||||||
|
@inject IStringLocalizer<Resource> UiLocalizer
|
||||||
|
@inject IJSRuntime JSRuntime
|
||||||
|
|
||||||
|
<div class="sender-image-editor-shell">
|
||||||
|
@if (PageCount > 0)
|
||||||
|
{
|
||||||
|
<div class="sender-image-editor__toolbar-host">
|
||||||
|
<SenderPdfImageEditorToolbar CurrentPage="@_currentPage"
|
||||||
|
TotalPages="@PageCount"
|
||||||
|
ZoomPercent="@_zoomPercent"
|
||||||
|
MinZoomPercent="@MinZoomPercent"
|
||||||
|
MaxZoomPercent="@MaxZoomPercent"
|
||||||
|
ZoomStepPercent="@ZoomStepPercent"
|
||||||
|
GoFirstPage="OnGoFirstPageAsync"
|
||||||
|
GoPreviousPage="OnGoPreviousPageAsync"
|
||||||
|
GoNextPage="OnGoNextPageAsync"
|
||||||
|
GoLastPage="OnGoLastPageAsync"
|
||||||
|
GoToPage="OnGoToPageAsync"
|
||||||
|
ZoomOut="OnZoomOutAsync"
|
||||||
|
ZoomIn="OnZoomInAsync"
|
||||||
|
SetZoomPercent="OnSetZoomPercentAsync"
|
||||||
|
CanDownloadPdf="@CanDownloadPdf"
|
||||||
|
CanPrintPdf="@CanPrintPdf"
|
||||||
|
IsDownloading="@_isDownloading"
|
||||||
|
IsPrinting="@_isPrinting"
|
||||||
|
DownloadPdf="OnDownloadPdfAsync"
|
||||||
|
PrintPdf="OnPrintPdfAsync" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="pdf-editor-wrapper sender-image-editor sender-editor-pdf-viewer"
|
||||||
|
style="cursor: @(IsPlacementMode ? "crosshair" : (_isDragging ? "grabbing" : "default"));"
|
||||||
|
tabindex="0"
|
||||||
|
@onclick="HandleClickAsync"
|
||||||
|
@onwheel="OnEditorWheelAsync"
|
||||||
|
@onwheel:preventDefault="true"
|
||||||
|
@onscroll="OnEditorScrollAsync"
|
||||||
|
@onmousemove="OnEditorMouseMoveAsync"
|
||||||
|
@onmouseup="OnEditorMouseUp"
|
||||||
|
@onmouseleave="OnEditorMouseUp">
|
||||||
|
@if (PageCount <= 0)
|
||||||
|
{
|
||||||
|
<div class="sender-image-editor__empty">@L("SenderEditor_NoPagesToDisplay", "Keine Seiten zur Anzeige verfügbar.")</div>
|
||||||
|
}
|
||||||
|
else if (Pages.Count == 0 && !string.IsNullOrWhiteSpace(PdfDataUrl))
|
||||||
|
{
|
||||||
|
<div class="sender-image-editor__native-preview" style="@GetZoomStyle()">
|
||||||
|
<iframe class="sender-image-editor__native-frame"
|
||||||
|
src="@PdfDataUrl"
|
||||||
|
title="PDF Preview"></iframe>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="sender-image-editor__pages" style="@GetZoomStyle()">
|
||||||
|
@for (var pageIndex = 0; pageIndex < PageCount; pageIndex++)
|
||||||
|
{
|
||||||
|
var pagePreview = pageIndex < Pages.Count ? Pages[pageIndex] : null;
|
||||||
|
var pageNumber = pagePreview?.PageNumber ?? (pageIndex + 1);
|
||||||
|
var widthPt = pagePreview?.WidthPt ?? 595.0;
|
||||||
|
var heightPt = pagePreview?.HeightPt ?? 842.0;
|
||||||
|
|
||||||
|
<div class="sender-image-editor__page-block"
|
||||||
|
data-editor-page="@pageNumber"
|
||||||
|
data-page-width-pt="@widthPt"
|
||||||
|
data-page-height-pt="@heightPt">
|
||||||
|
<div class="sender-image-editor__page-canvas"
|
||||||
|
data-editor-page-canvas="@pageNumber"
|
||||||
|
style="@GetPageCanvasStyle(widthPt, heightPt)">
|
||||||
|
@if (!string.IsNullOrWhiteSpace(pagePreview?.ImageDataUrl))
|
||||||
|
{
|
||||||
|
<img class="sender-image-editor__page-image"
|
||||||
|
src="@(pagePreview!.ImageDataUrl)"
|
||||||
|
alt="PDF Page @pageNumber"
|
||||||
|
draggable="false" />
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="sender-image-editor__page-placeholder">@L("SenderEditor_PageLabel", "Seite") @pageNumber</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@foreach (var field in Fields.Where(f => f.Page == pageNumber))
|
||||||
|
{
|
||||||
|
<div class="sender-image-editor__field"
|
||||||
|
style="@GetFieldStyle(field, widthPt, heightPt)"
|
||||||
|
title="@field.ReceiverName"
|
||||||
|
@onmousedown="args => OnFieldMouseDownAsync(args, field)"
|
||||||
|
@onmousedown:preventDefault="true"
|
||||||
|
@onclick:stopPropagation="true">
|
||||||
|
<span class="sender-image-editor__field-label">@field.ReceiverName</span>
|
||||||
|
<button type="button"
|
||||||
|
class="sender-image-editor__field-remove"
|
||||||
|
title='@L("Delete", "Löschen")'
|
||||||
|
draggable="false"
|
||||||
|
@onclick:stopPropagation="true"
|
||||||
|
@onclick="() => RemoveField.InvokeAsync(field.Index)">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
||||||
|
<path d="M4 4L12 12M12 4L4 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public bool IsPlacementMode { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public int PageCount { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public IReadOnlyList<PdfPageImageDto> Pages { get; set; } = Array.Empty<PdfPageImageDto>();
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string? PdfDataUrl { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string? PdfFileName { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public IReadOnlyList<SenderPdfFieldOverlay> Fields { get; set; } = Array.Empty<SenderPdfFieldOverlay>();
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<MouseEventArgs> EditorClick { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<int> RemoveField { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<SenderPdfFieldMoveRequest> MoveField { get; set; }
|
||||||
|
|
||||||
|
private int? _draggedFieldIndex;
|
||||||
|
private bool _isDragging;
|
||||||
|
private double _grabOffsetXPt;
|
||||||
|
private double _grabOffsetYPt;
|
||||||
|
private int _currentPage = 1;
|
||||||
|
private int _zoomPercent = 112;
|
||||||
|
private bool _zoomOverrideInitialized;
|
||||||
|
private bool _isDownloading;
|
||||||
|
private bool _isPrinting;
|
||||||
|
|
||||||
|
private const int MinZoomPercent = 50;
|
||||||
|
private const int MaxZoomPercent = 300;
|
||||||
|
private const int ZoomStepPercent = 5;
|
||||||
|
private bool CanDownloadPdf => !string.IsNullOrWhiteSpace(PdfDataUrl);
|
||||||
|
private bool CanPrintPdf => !string.IsNullOrWhiteSpace(PdfDataUrl);
|
||||||
|
|
||||||
|
private static string GetFieldStyle(SenderPdfFieldOverlay field, double pageWidthPt, double pageHeightPt)
|
||||||
|
{
|
||||||
|
var leftPercent = (field.XPt / pageWidthPt) * 100.0;
|
||||||
|
var topPercent = (field.YPt / pageHeightPt) * 100.0;
|
||||||
|
var widthPercent = (127.44 / pageWidthPt) * 100.0;
|
||||||
|
var heightPercent = (141.12 / pageHeightPt) * 100.0;
|
||||||
|
|
||||||
|
var left = leftPercent.ToString("F4", CultureInfo.InvariantCulture);
|
||||||
|
var top = topPercent.ToString("F4", CultureInfo.InvariantCulture);
|
||||||
|
var width = widthPercent.ToString("F4", CultureInfo.InvariantCulture);
|
||||||
|
var height = heightPercent.ToString("F4", CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
return string.Join(' ',
|
||||||
|
"position:absolute;",
|
||||||
|
$"left:{left}%;",
|
||||||
|
$"top:{top}%;",
|
||||||
|
$"width:{width}%;",
|
||||||
|
$"height:{height}%;",
|
||||||
|
"border:2px solid;",
|
||||||
|
"border-radius:8px;",
|
||||||
|
"display:flex;",
|
||||||
|
"align-items:flex-start;",
|
||||||
|
"justify-content:space-between;",
|
||||||
|
"gap:0.35rem;",
|
||||||
|
"padding:0.2rem 0.3rem;",
|
||||||
|
"overflow:hidden;",
|
||||||
|
"z-index:30;",
|
||||||
|
$"border-color:{field.Color};",
|
||||||
|
$"background-color:{field.Color}22;");
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetPageCanvasStyle(double pageWidthPt, double pageHeightPt)
|
||||||
|
{
|
||||||
|
var ratio = pageHeightPt <= 0 ? 595.0 / 842.0 : pageWidthPt / pageHeightPt;
|
||||||
|
var ratioText = ratio.ToString("F6", CultureInfo.InvariantCulture);
|
||||||
|
var cursor = _isDragging
|
||||||
|
? "grabbing"
|
||||||
|
: (IsPlacementMode ? "crosshair" : "default");
|
||||||
|
return $"aspect-ratio:{ratioText};cursor:{cursor};";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetZoomStyle()
|
||||||
|
{
|
||||||
|
var factor = (_zoomPercent / 100.0).ToString("F4", CultureInfo.InvariantCulture);
|
||||||
|
return $"zoom:{factor};";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
if (PageCount <= 0)
|
||||||
|
{
|
||||||
|
_currentPage = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_currentPage = Math.Max(1, Math.Min(_currentPage, PageCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (_zoomOverrideInitialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await JSRuntime.InvokeVoidAsync(
|
||||||
|
"envelopeEditor.ensureZoomOverride",
|
||||||
|
"sender-editor-pdf-viewer");
|
||||||
|
|
||||||
|
_zoomOverrideInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task HandleClickAsync(MouseEventArgs args)
|
||||||
|
{
|
||||||
|
if (EditorClick.HasDelegate)
|
||||||
|
await EditorClick.InvokeAsync(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnFieldMouseDownAsync(MouseEventArgs args, SenderPdfFieldOverlay field)
|
||||||
|
{
|
||||||
|
var coords = await JSRuntime.InvokeAsync<EditorCoords?>(
|
||||||
|
"envelopeEditor.getClickCoordsOnPdfPage",
|
||||||
|
"sender-editor-pdf-viewer",
|
||||||
|
args.ClientX,
|
||||||
|
args.ClientY);
|
||||||
|
|
||||||
|
if (coords is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var pageNumber = coords.PageNumber;
|
||||||
|
var (pageWidthPt, pageHeightPt) = GetPageSize(pageNumber);
|
||||||
|
var pointerXPt = coords.NormX * pageWidthPt;
|
||||||
|
var pointerYPt = coords.NormY * pageHeightPt;
|
||||||
|
|
||||||
|
_draggedFieldIndex = field.Index;
|
||||||
|
_isDragging = true;
|
||||||
|
_grabOffsetXPt = pointerXPt - field.XPt;
|
||||||
|
_grabOffsetYPt = pointerYPt - field.YPt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnEditorMouseMoveAsync(MouseEventArgs args)
|
||||||
|
{
|
||||||
|
if (_draggedFieldIndex is null || !MoveField.HasDelegate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var coords = await JSRuntime.InvokeAsync<EditorCoords?>(
|
||||||
|
"envelopeEditor.getClickCoordsOnPdfPage",
|
||||||
|
"sender-editor-pdf-viewer",
|
||||||
|
args.ClientX,
|
||||||
|
args.ClientY);
|
||||||
|
|
||||||
|
if (coords is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var pageNumber = coords.PageNumber;
|
||||||
|
var (pageWidthPt, pageHeightPt) = GetPageSize(pageNumber);
|
||||||
|
|
||||||
|
const double sigWidthPt = 1.77 * 72;
|
||||||
|
const double sigHeightPt = 1.96 * 72;
|
||||||
|
|
||||||
|
var xPt = (coords.NormX * pageWidthPt) - _grabOffsetXPt;
|
||||||
|
var yPt = (coords.NormY * pageHeightPt) - _grabOffsetYPt;
|
||||||
|
xPt = Math.Max(0, Math.Min(xPt, pageWidthPt - sigWidthPt));
|
||||||
|
yPt = Math.Max(0, Math.Min(yPt, pageHeightPt - sigHeightPt));
|
||||||
|
|
||||||
|
await MoveField.InvokeAsync(new SenderPdfFieldMoveRequest(_draggedFieldIndex.Value, pageNumber, xPt, yPt));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnGoFirstPageAsync()
|
||||||
|
{
|
||||||
|
await NavigateToPageAsync(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnGoPreviousPageAsync()
|
||||||
|
{
|
||||||
|
await NavigateToPageAsync(_currentPage - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnGoNextPageAsync()
|
||||||
|
{
|
||||||
|
await NavigateToPageAsync(_currentPage + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnGoLastPageAsync()
|
||||||
|
{
|
||||||
|
await NavigateToPageAsync(PageCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnGoToPageAsync(int page)
|
||||||
|
{
|
||||||
|
await NavigateToPageAsync(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task NavigateToPageAsync(int targetPage)
|
||||||
|
{
|
||||||
|
if (PageCount <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var page = Math.Max(1, Math.Min(targetPage, PageCount));
|
||||||
|
_currentPage = page;
|
||||||
|
|
||||||
|
await JSRuntime.InvokeVoidAsync(
|
||||||
|
"envelopeEditor.scrollToPdfPage",
|
||||||
|
"sender-editor-pdf-viewer",
|
||||||
|
page);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnEditorScrollAsync(EventArgs _)
|
||||||
|
{
|
||||||
|
if (PageCount <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var visiblePage = await JSRuntime.InvokeAsync<int?>(
|
||||||
|
"envelopeEditor.getVisiblePdfPageNumber",
|
||||||
|
"sender-editor-pdf-viewer");
|
||||||
|
|
||||||
|
if (!visiblePage.HasValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var clamped = Math.Max(1, Math.Min(visiblePage.Value, PageCount));
|
||||||
|
if (clamped == _currentPage)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_currentPage = clamped;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnZoomOutAsync()
|
||||||
|
{
|
||||||
|
SetZoomPercent(_zoomPercent - ZoomStepPercent);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnZoomInAsync()
|
||||||
|
{
|
||||||
|
SetZoomPercent(_zoomPercent + ZoomStepPercent);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnSetZoomPercentAsync(int zoomPercent)
|
||||||
|
{
|
||||||
|
SetZoomPercent(zoomPercent);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnEditorWheelAsync(WheelEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.CtrlKey)
|
||||||
|
{
|
||||||
|
if (args.DeltaY < 0)
|
||||||
|
await OnZoomInAsync();
|
||||||
|
else if (args.DeltaY > 0)
|
||||||
|
await OnZoomOutAsync();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await JSRuntime.InvokeVoidAsync(
|
||||||
|
"envelopeEditor.scrollPdfViewerByDelta",
|
||||||
|
"sender-editor-pdf-viewer",
|
||||||
|
args.DeltaY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetZoomPercent(int value)
|
||||||
|
{
|
||||||
|
_zoomPercent = Math.Max(MinZoomPercent, Math.Min(value, MaxZoomPercent));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnDownloadPdfAsync()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(PdfDataUrl) || _isDownloading || _isPrinting)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_isDownloading = true;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var fallbackName = string.IsNullOrWhiteSpace(PdfFileName)
|
||||||
|
? "document.pdf"
|
||||||
|
: PdfFileName;
|
||||||
|
|
||||||
|
var fileName = fallbackName.EndsWith(".pdf", StringComparison.OrdinalIgnoreCase)
|
||||||
|
? fallbackName
|
||||||
|
: $"{fallbackName}.pdf";
|
||||||
|
|
||||||
|
await JSRuntime.InvokeVoidAsync(
|
||||||
|
"envelopeEditor.downloadDataUrlAsFile",
|
||||||
|
PdfDataUrl,
|
||||||
|
fileName,
|
||||||
|
"application/pdf");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isDownloading = false;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnPrintPdfAsync()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(PdfDataUrl) || _isPrinting || _isDownloading)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_isPrinting = true;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await JSRuntime.InvokeVoidAsync(
|
||||||
|
"envelopeEditor.printDataUrlPdf",
|
||||||
|
PdfDataUrl,
|
||||||
|
"application/pdf");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_isPrinting = false;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEditorMouseUp(MouseEventArgs args)
|
||||||
|
{
|
||||||
|
_draggedFieldIndex = null;
|
||||||
|
_isDragging = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private (double WidthPt, double HeightPt) GetPageSize(int pageNumber)
|
||||||
|
{
|
||||||
|
var page = Pages.FirstOrDefault(p => p.PageNumber == pageNumber);
|
||||||
|
return page is null ? (595.0, 842.0) : (page.WidthPt, page.HeightPt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed record EditorCoords(double NormX, double NormY, int PageIndex, int PageNumber);
|
||||||
|
|
||||||
|
private string L(string key, string fallback)
|
||||||
|
{
|
||||||
|
var value = UiLocalizer[key];
|
||||||
|
return value.ResourceNotFound ? fallback : value.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,267 @@
|
|||||||
|
<div class="sender-image-toolbar" @onclick:stopPropagation="true">
|
||||||
|
<div class="sender-image-toolbar__group sender-image-toolbar__group--nav" role="group" aria-label="Page navigation">
|
||||||
|
<button type="button" class="sender-image-toolbar__icon-btn" title="First page" disabled="@(!CanGoPrevious)" @onclick="GoToFirstAsync">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||||
|
<path d="M8 6V18" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
||||||
|
<path d="M16 7L11 12L16 17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" class="sender-image-toolbar__icon-btn" title="Previous page" disabled="@(!CanGoPrevious)" @onclick="GoToPreviousAsync">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||||
|
<path d="M15 7L10 12L15 17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="sender-image-toolbar__value-box">
|
||||||
|
<input type="number"
|
||||||
|
min="1"
|
||||||
|
max="@TotalPagesDisplay"
|
||||||
|
value="@CurrentPageDisplay"
|
||||||
|
class="sender-image-toolbar__page-input"
|
||||||
|
@onchange="OnPageInputChangedAsync"
|
||||||
|
disabled="@(TotalPagesDisplay <= 0)" />
|
||||||
|
<span class="sender-image-toolbar__page-total">of @TotalPagesDisplay</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="sender-image-toolbar__select-wrap" title="Page list">
|
||||||
|
<button type="button" class="sender-image-toolbar__icon-btn sender-image-toolbar__icon-btn--caret" disabled="@(TotalPagesDisplay <= 0)">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||||
|
<path d="M6 9L12 15L18 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<select class="sender-image-toolbar__page-select"
|
||||||
|
aria-label="Select page"
|
||||||
|
disabled="@(TotalPagesDisplay <= 0)"
|
||||||
|
value="@CurrentPageDisplay"
|
||||||
|
@onchange="OnPageSelectChangedAsync">
|
||||||
|
@for (var pageNumber = 1; pageNumber <= TotalPagesDisplay; pageNumber++)
|
||||||
|
{
|
||||||
|
<option value="@pageNumber">@pageNumber</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button" class="sender-image-toolbar__icon-btn" title="Next page" disabled="@(!CanGoNext)" @onclick="GoToNextAsync">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||||
|
<path d="M9 7L14 12L9 17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button" class="sender-image-toolbar__icon-btn" title="Last page" disabled="@(!CanGoNext)" @onclick="GoToLastAsync">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||||
|
<path d="M16 6V18" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
||||||
|
<path d="M8 7L13 12L8 17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="sender-image-toolbar__group sender-image-toolbar__group--zoom" role="group" aria-label="Zoom controls">
|
||||||
|
<button type="button" class="sender-image-toolbar__icon-btn" title="Zoom out" disabled="@(!CanZoomOut)" @onclick="ZoomOutAsync">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||||
|
<path d="M6 12H18" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="sender-image-toolbar__value-box" aria-hidden="true">
|
||||||
|
<span>@ZoomPercentDisplay%</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="range"
|
||||||
|
class="sender-image-toolbar__zoom-slider"
|
||||||
|
min="@MinZoomPercent"
|
||||||
|
max="@MaxZoomPercent"
|
||||||
|
step="@ZoomStepPercent"
|
||||||
|
value="@ZoomPercentDisplay"
|
||||||
|
@oninput="OnZoomSliderInputAsync"
|
||||||
|
aria-label="Zoom slider" />
|
||||||
|
|
||||||
|
<button type="button" class="sender-image-toolbar__icon-btn" title="Zoom in" disabled="@(!CanZoomIn)" @onclick="ZoomInAsync">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||||
|
<path d="M12 6V18" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
||||||
|
<path d="M6 12H18" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="sender-image-toolbar__group sender-image-toolbar__group--actions" role="group" aria-label="Document actions">
|
||||||
|
<button type="button"
|
||||||
|
class="sender-image-toolbar__icon-btn @(IsPrinting ? "sender-image-toolbar__icon-btn--busy" : string.Empty)"
|
||||||
|
title="@(IsPrinting ? "Preparing print..." : "Print")"
|
||||||
|
disabled="@(!CanPrintPdf || IsPrinting || IsDownloading)"
|
||||||
|
@onclick="PrintPdfAsync">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||||
|
<path d="M7 9V4H17V9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||||
|
<rect x="5" y="9" width="14" height="8" rx="2" stroke="currentColor" stroke-width="2" />
|
||||||
|
<path d="M7 14H17V20H7V14Z" stroke="currentColor" stroke-width="2" stroke-linejoin="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button type="button"
|
||||||
|
class="sender-image-toolbar__icon-btn @(IsDownloading ? "sender-image-toolbar__icon-btn--busy" : string.Empty)"
|
||||||
|
title="@(IsDownloading ? "Preparing download..." : "Download PDF")"
|
||||||
|
disabled="@(!CanDownloadPdf || IsDownloading || IsPrinting)"
|
||||||
|
@onclick="DownloadPdfAsync">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||||
|
<path d="M12 4V14" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
||||||
|
<path d="M8 10L12 14L16 10" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||||
|
<path d="M5 18H19" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public int CurrentPage { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public int TotalPages { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public int ZoomPercent { get; set; } = 112;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public int MinZoomPercent { get; set; } = 50;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public int MaxZoomPercent { get; set; } = 300;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public int ZoomStepPercent { get; set; } = 5;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback GoFirstPage { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback GoPreviousPage { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback GoNextPage { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback GoLastPage { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<int> GoToPage { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback ZoomOut { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback ZoomIn { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<int> SetZoomPercent { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool CanDownloadPdf { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool CanPrintPdf { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool IsDownloading { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool IsPrinting { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback DownloadPdf { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback PrintPdf { get; set; }
|
||||||
|
|
||||||
|
private int CurrentPageDisplay => CurrentPage > 0 ? CurrentPage : 0;
|
||||||
|
private int TotalPagesDisplay => TotalPages > 0 ? TotalPages : 0;
|
||||||
|
private int ZoomPercentDisplay => ZoomPercent > 0 ? ZoomPercent : 100;
|
||||||
|
private bool CanGoPrevious => CurrentPageDisplay > 1;
|
||||||
|
private bool CanGoNext => TotalPagesDisplay > 0 && CurrentPageDisplay < TotalPagesDisplay;
|
||||||
|
private bool CanZoomOut => ZoomPercentDisplay > MinZoomPercent;
|
||||||
|
private bool CanZoomIn => ZoomPercentDisplay < MaxZoomPercent;
|
||||||
|
|
||||||
|
private async Task GoToFirstAsync()
|
||||||
|
{
|
||||||
|
if (GoFirstPage.HasDelegate)
|
||||||
|
await GoFirstPage.InvokeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GoToPreviousAsync()
|
||||||
|
{
|
||||||
|
if (GoPreviousPage.HasDelegate)
|
||||||
|
await GoPreviousPage.InvokeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GoToNextAsync()
|
||||||
|
{
|
||||||
|
if (GoNextPage.HasDelegate)
|
||||||
|
await GoNextPage.InvokeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task GoToLastAsync()
|
||||||
|
{
|
||||||
|
if (GoLastPage.HasDelegate)
|
||||||
|
await GoLastPage.InvokeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnPageInputChangedAsync(ChangeEventArgs args)
|
||||||
|
{
|
||||||
|
if (!GoToPage.HasDelegate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!int.TryParse(args.Value?.ToString(), out var page))
|
||||||
|
return;
|
||||||
|
|
||||||
|
page = Math.Max(1, Math.Min(page, Math.Max(1, TotalPagesDisplay)));
|
||||||
|
await GoToPage.InvokeAsync(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnPageSelectChangedAsync(ChangeEventArgs args)
|
||||||
|
{
|
||||||
|
if (!GoToPage.HasDelegate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!int.TryParse(args.Value?.ToString(), out var page))
|
||||||
|
return;
|
||||||
|
|
||||||
|
page = Math.Max(1, Math.Min(page, Math.Max(1, TotalPagesDisplay)));
|
||||||
|
await GoToPage.InvokeAsync(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ZoomOutAsync()
|
||||||
|
{
|
||||||
|
if (ZoomOut.HasDelegate)
|
||||||
|
await ZoomOut.InvokeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ZoomInAsync()
|
||||||
|
{
|
||||||
|
if (ZoomIn.HasDelegate)
|
||||||
|
await ZoomIn.InvokeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnZoomSliderInputAsync(ChangeEventArgs args)
|
||||||
|
{
|
||||||
|
if (!SetZoomPercent.HasDelegate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!int.TryParse(args.Value?.ToString(), out var zoomPercent))
|
||||||
|
return;
|
||||||
|
|
||||||
|
zoomPercent = Math.Max(MinZoomPercent, Math.Min(zoomPercent, MaxZoomPercent));
|
||||||
|
await SetZoomPercent.InvokeAsync(zoomPercent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DownloadPdfAsync()
|
||||||
|
{
|
||||||
|
if (DownloadPdf.HasDelegate)
|
||||||
|
await DownloadPdf.InvokeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task PrintPdfAsync()
|
||||||
|
{
|
||||||
|
if (PrintPdf.HasDelegate)
|
||||||
|
await PrintPdf.InvokeAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
|||||||
|
namespace EnvelopeGenerator.Server.Client.Components.Sender;
|
||||||
|
|
||||||
|
public sealed record CreateEnvelopeWizardResult(
|
||||||
|
string Title,
|
||||||
|
string Message,
|
||||||
|
int? EnvelopeTypeId,
|
||||||
|
string Language,
|
||||||
|
bool UseAccessCode,
|
||||||
|
bool TFAEnabled,
|
||||||
|
int CertificationType,
|
||||||
|
int FinalEmailToCreator,
|
||||||
|
int FinalEmailToReceivers,
|
||||||
|
bool SendReminderEmails,
|
||||||
|
int FirstReminderDays,
|
||||||
|
int ReminderIntervalDays,
|
||||||
|
int ExpiresWhenDays,
|
||||||
|
int ExpiresWarningWhenDays,
|
||||||
|
IReadOnlyList<CreateEnvelopeWizardReceiver> Receivers,
|
||||||
|
byte[]? DocumentBytes,
|
||||||
|
string? DocumentFileName);
|
||||||
|
|
||||||
|
public sealed record CreateEnvelopeWizardReceiver(string FullName, string EmailAddress);
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
@using Microsoft.AspNetCore.Components.Forms
|
||||||
|
|
||||||
|
<div class="sender-pdf-dropzone @DropZoneClass">
|
||||||
|
<div class="sender-pdf-dropzone__content">
|
||||||
|
<div class="sender-pdf-dropzone__title">@CurrentActionText</div>
|
||||||
|
@if (!string.IsNullOrWhiteSpace(DragDropHintText))
|
||||||
|
{
|
||||||
|
<div class="sender-pdf-dropzone__hint">@DragDropHintText</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<InputFile OnChange="OnFileSelectedAsync"
|
||||||
|
accept="@Accept"
|
||||||
|
disabled="@Disabled"
|
||||||
|
@ondragenter="OnDragEnter"
|
||||||
|
@ondragleave="OnDragLeave"
|
||||||
|
@ondragover="OnDragOver"
|
||||||
|
@ondrop="OnDrop"
|
||||||
|
class="sender-pdf-dropzone__input" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public bool Disabled { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool HasDocument { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Accept { get; set; } = ".pdf";
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string UploadText { get; set; } = "PDF hochladen";
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string ReplaceText { get; set; } = "PDF ersetzen";
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string DragDropHintText { get; set; } = "Datei hierhin ziehen oder klicken";
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public EventCallback<InputFileChangeEventArgs> FileSelected { get; set; }
|
||||||
|
|
||||||
|
private int _dragDepth;
|
||||||
|
private bool _isDragActive;
|
||||||
|
|
||||||
|
private string CurrentActionText => HasDocument ? ReplaceText : UploadText;
|
||||||
|
|
||||||
|
private string DropZoneClass
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Disabled)
|
||||||
|
return "sender-pdf-dropzone--disabled";
|
||||||
|
|
||||||
|
return _isDragActive ? "sender-pdf-dropzone--drag-active" : string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDragEnter(DragEventArgs _)
|
||||||
|
{
|
||||||
|
if (Disabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_dragDepth++;
|
||||||
|
_isDragActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDragLeave(DragEventArgs _)
|
||||||
|
{
|
||||||
|
if (Disabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_dragDepth = Math.Max(0, _dragDepth - 1);
|
||||||
|
if (_dragDepth == 0)
|
||||||
|
_isDragActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDragOver(DragEventArgs _)
|
||||||
|
{
|
||||||
|
if (Disabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_isDragActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDrop(DragEventArgs _)
|
||||||
|
{
|
||||||
|
_dragDepth = 0;
|
||||||
|
_isDragActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnFileSelectedAsync(InputFileChangeEventArgs args)
|
||||||
|
{
|
||||||
|
_dragDepth = 0;
|
||||||
|
_isDragActive = false;
|
||||||
|
|
||||||
|
if (Disabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (FileSelected.HasDelegate)
|
||||||
|
await FileSelected.InvokeAsync(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
namespace EnvelopeGenerator.Server.Client.Components.Sender.ReceiverSuggestionFilter;
|
||||||
|
|
||||||
|
public readonly record struct ReceiverFilterCriteria
|
||||||
|
{
|
||||||
|
public readonly string FullName;
|
||||||
|
public readonly string EmailAddress;
|
||||||
|
|
||||||
|
public ReceiverFilterCriteria(string? fullName = "", string? emailAddress = "")
|
||||||
|
{
|
||||||
|
FullName = Normalize(fullName);
|
||||||
|
EmailAddress = Normalize(emailAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly bool Matches(ReceiverFilterCriteria criteria)
|
||||||
|
=> FullName.Contains(criteria.FullName, StringComparison.Ordinal)
|
||||||
|
&& EmailAddress.Contains(criteria.EmailAddress, StringComparison.Ordinal);
|
||||||
|
|
||||||
|
private static string Normalize(string? text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
return string.Concat(text.Where(c => !char.IsWhiteSpace(c))).ToLowerInvariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Dto.Receiver;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Server.Client.Components.Sender.ReceiverSuggestionFilter;
|
||||||
|
|
||||||
|
public class ReceiverSuggestionFilterHandler(IEnumerable<RecentReceiverSuggestionDto> suggestions)
|
||||||
|
{
|
||||||
|
private readonly IReadOnlyList<Entry> _entries = suggestions
|
||||||
|
.Where(x => !string.IsNullOrWhiteSpace(x.FullName) && !string.IsNullOrWhiteSpace(x.EmailAddress))
|
||||||
|
.Select(x => new Entry(new ReceiverFilterCriteria(x.FullName, x.EmailAddress), x))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
private readonly record struct Entry(ReceiverFilterCriteria Criteria, RecentReceiverSuggestionDto Suggestion);
|
||||||
|
|
||||||
|
public IEnumerable<RecentReceiverSuggestionDto> Filter(ReceiverFilterCriteria criteria)
|
||||||
|
{
|
||||||
|
return _entries
|
||||||
|
.Where(x => x.Criteria.Matches(criteria))
|
||||||
|
.Select(x => x.Suggestion);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<RecentReceiverSuggestionDto> Filter(string fullName, string emailAddress)
|
||||||
|
{
|
||||||
|
var criteria = new ReceiverFilterCriteria(fullName, emailAddress);
|
||||||
|
return Filter(criteria);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
@using EnvelopeGenerator.Server.Client.Services
|
||||||
|
@using EnvelopeGenerator.Application.Resources
|
||||||
|
@using Microsoft.Extensions.Localization
|
||||||
|
@rendermode InteractiveWebAssembly
|
||||||
|
|
||||||
|
@inject LocalizationService LocalizationService
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
@inject IStringLocalizer<Resource> UiLocalizer
|
||||||
|
|
||||||
|
<div class="sf-lang-combo">
|
||||||
|
<button type="button"
|
||||||
|
class="sf-lang-trigger"
|
||||||
|
@onclick="ToggleMenu"
|
||||||
|
aria-label="@L("Language", "Language")"
|
||||||
|
aria-expanded="@_isOpen">
|
||||||
|
<span class="fi @_selected.FlagClass"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
@if (_isOpen)
|
||||||
|
{
|
||||||
|
<button type="button"
|
||||||
|
class="sf-lang-backdrop"
|
||||||
|
aria-label="@L("CloseLanguageMenu", "Close language menu")"
|
||||||
|
@onclick="CloseMenu">
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="sf-lang-menu" role="listbox" aria-label="@L("Languages", "Languages")">
|
||||||
|
@foreach (var option in _options)
|
||||||
|
{
|
||||||
|
<button type="button"
|
||||||
|
class="sf-lang-option @(_selected.Code == option.Code ? "sf-lang-option--active" : string.Empty)"
|
||||||
|
role="option"
|
||||||
|
aria-selected="@(_selected.Code == option.Code)"
|
||||||
|
@onmousedown:preventDefault="true"
|
||||||
|
@onclick="() => SelectLanguageAsync(option)">
|
||||||
|
<span class="fi @option.FlagClass"></span>
|
||||||
|
<span>@option.ShortName</span>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private readonly IReadOnlyList<LanguageOption> _options =
|
||||||
|
[
|
||||||
|
new("de-DE", "fi-de", "DE"),
|
||||||
|
new("en-US", "fi-us", "EN"),
|
||||||
|
new("fr-FR", "fi-fr", "FR")
|
||||||
|
];
|
||||||
|
|
||||||
|
private LanguageOption _selected = new("de-DE", "fi-de", "DE");
|
||||||
|
private bool _isOpen;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
var currentLanguage = await LocalizationService.GetLanguageAsync();
|
||||||
|
_selected = _options.FirstOrDefault(x => x.Code.Equals(currentLanguage, StringComparison.OrdinalIgnoreCase))
|
||||||
|
?? _options[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToggleMenu()
|
||||||
|
{
|
||||||
|
_isOpen = !_isOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CloseMenu()
|
||||||
|
{
|
||||||
|
_isOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SelectLanguageAsync(LanguageOption option)
|
||||||
|
{
|
||||||
|
if (_selected.Code.Equals(option.Code, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
_isOpen = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_selected = option;
|
||||||
|
_isOpen = false;
|
||||||
|
await LocalizationService.SetLanguageAsync(option.Code);
|
||||||
|
Navigation.NavigateTo(Navigation.Uri, forceLoad: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed record LanguageOption(string Code, string FlagClass, string ShortName);
|
||||||
|
|
||||||
|
string L(string key, string fallback)
|
||||||
|
{
|
||||||
|
var value = UiLocalizer[key];
|
||||||
|
return value.ResourceNotFound ? fallback : value.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,14 @@
|
|||||||
@using EnvelopeGenerator.Server.Client.Services
|
@using EnvelopeGenerator.Server.Client.Services
|
||||||
|
@using EnvelopeGenerator.Application.Resources
|
||||||
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
|
@using Microsoft.Extensions.Localization
|
||||||
|
@using System.Globalization
|
||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
@inject ThemeService ThemeService
|
@inject ThemeService ThemeService
|
||||||
|
@inject IStringLocalizer<Resource> UiLocalizer
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
|
||||||
<HeadContent>
|
<HeadContent>
|
||||||
<link href="@ThemeService.ThemeCssHref" rel="stylesheet" />
|
<link href="@ThemeService.ThemeCssHref" rel="stylesheet" />
|
||||||
@@ -18,10 +24,13 @@
|
|||||||
<div class="receiver-footer__left">
|
<div class="receiver-footer__left">
|
||||||
<span>© SignFlow 2023-2024 <a href="https://digitaldata.works" target="_blank" rel="noopener">Digital Data GmbH</a></span>
|
<span>© SignFlow 2023-2024 <a href="https://digitaldata.works" target="_blank" rel="noopener">Digital Data GmbH</a></span>
|
||||||
<span class="receiver-footer__sep">|</span>
|
<span class="receiver-footer__sep">|</span>
|
||||||
<a href="docs/privacy-policy.de-DE.html" target="_blank" rel="noopener">Datenschutz</a>
|
<a href="@GetPrivacyPolicyPath()" target="_blank" rel="noopener">@L("PrivacyPolicy", "Datenschutz")</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ThemeControls />
|
<div class="receiver-footer__right">
|
||||||
|
<LanguageControls />
|
||||||
|
<ThemeControls />
|
||||||
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -32,6 +41,7 @@
|
|||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
Navigation.LocationChanged += OnLocationChanged;
|
||||||
await FontLoader.LoadFonts(HttpClientFactory, ["opensans.ttf"]);
|
await FontLoader.LoadFonts(HttpClientFactory, ["opensans.ttf"]);
|
||||||
_themeChangeHandler = () => InvokeAsync(StateHasChanged);
|
_themeChangeHandler = () => InvokeAsync(StateHasChanged);
|
||||||
ThemeService.OnChange += _themeChangeHandler;
|
ThemeService.OnChange += _themeChangeHandler;
|
||||||
@@ -39,5 +49,31 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
=> ThemeService.OnChange -= _themeChangeHandler;
|
{
|
||||||
|
ThemeService.OnChange -= _themeChangeHandler;
|
||||||
|
Navigation.LocationChanged -= OnLocationChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
|
||||||
|
=> _ = InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
private string GetPrivacyPolicyPath()
|
||||||
|
{
|
||||||
|
var current = CultureInfo.CurrentUICulture.Name;
|
||||||
|
var code = current switch
|
||||||
|
{
|
||||||
|
"de-DE" => "de-DE",
|
||||||
|
"en-US" => "en-US",
|
||||||
|
"fr-FR" => "fr-FR",
|
||||||
|
_ => "de-DE"
|
||||||
|
};
|
||||||
|
|
||||||
|
return $"docs/privacy-policy.{code}.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
string L(string key, string fallback)
|
||||||
|
{
|
||||||
|
var value = UiLocalizer[key];
|
||||||
|
return value.ResourceNotFound ? fallback : value.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
@page "/envelope/signed-result"
|
||||||
|
@rendermode InteractiveWebAssembly
|
||||||
|
@using EnvelopeGenerator.Application.Resources
|
||||||
|
@using Microsoft.Extensions.Localization
|
||||||
|
@inject IStringLocalizer<Resource> UiLocalizer
|
||||||
|
|
||||||
|
<div class="receiver-signed-result-page">
|
||||||
|
<div class="receiver-signed-result-card">
|
||||||
|
<div class="receiver-signed-result-icon" aria-hidden="true">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" fill="currentColor" viewBox="0 0 16 16">
|
||||||
|
<path d="M2.5 8a5.5 5.5 0 0 1 8.25-4.764.5.5 0 0 0 .5-.866A6.5 6.5 0 1 0 14.5 8a.5.5 0 0 0-1 0 5.5 5.5 0 1 1-11 0z" />
|
||||||
|
<path d="M15.354 3.354a.5.5 0 0 0-.708-.708L8 9.293 5.354 6.646a.5.5 0 1 0-.708.708l3 3a.5.5 0 0 0 .708 0l7-7z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1 class="receiver-signed-result-title">@L("DocumentSuccessfullySigned", "Dokument erfolgreich unterzeichnet")</h1>
|
||||||
|
<p class="receiver-signed-result-message">
|
||||||
|
@L("DocumentSignedConfirmationMessage", "Vielen Dank. Ihre Unterschrift wurde erfolgreich gespeichert und an die beteiligten Parteien übermittelt.")
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
string L(string key, string fallback)
|
||||||
|
{
|
||||||
|
var value = UiLocalizer[key];
|
||||||
|
return value.ResourceNotFound ? fallback : value.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
|
@using EnvelopeGenerator.Application.Resources
|
||||||
|
@using Microsoft.Extensions.Localization
|
||||||
@inject IJSRuntime JS
|
@inject IJSRuntime JS
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
@inject EnvelopeGenerator.Server.Client.Services.CustomImagesService CustomImagesService
|
@inject EnvelopeGenerator.Server.Client.Services.CustomImagesService CustomImagesService
|
||||||
|
@inject IStringLocalizer<Resource> UiLocalizer
|
||||||
@rendermode InteractiveWebAssembly
|
@rendermode InteractiveWebAssembly
|
||||||
|
|
||||||
<div class="home-page-wrapper">
|
<div class="home-page-wrapper">
|
||||||
@@ -24,7 +27,7 @@
|
|||||||
}
|
}
|
||||||
<div>
|
<div>
|
||||||
<h1 class="home-hero-header__title">SignFlow</h1>
|
<h1 class="home-hero-header__title">SignFlow</h1>
|
||||||
<p class="home-hero-header__subtitle">Willkommen im eSign-Portal</p>
|
<p class="home-hero-header__subtitle">@L("Index_Subtitle", "Willkommen im eSign-Portal")</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -43,7 +46,7 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="currentColor" viewBox="0 0 16 16">
|
||||||
<path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4Zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1H2Zm13 2.383-4.708 2.825L15 11.105V5.383Zm-.034 6.876-5.64-3.471L8 9.583l-1.326-.795-5.64 3.47A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.741ZM1 11.105l4.708-2.897L1 5.383v5.722Z"/>
|
<path d="M0 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V4Zm2-1a1 1 0 0 0-1 1v.217l7 4.2 7-4.2V4a1 1 0 0 0-1-1H2Zm13 2.383-4.708 2.825L15 11.105V5.383Zm-.034 6.876-5.64-3.471L8 9.583l-1.326-.795-5.64 3.47A1 1 0 0 0 2 13h12a1 1 0 0 0 .966-.741ZM1 11.105l4.708-2.897L1 5.383v5.722Z"/>
|
||||||
</svg>
|
</svg>
|
||||||
Zur Umschlag-Übersicht
|
@L("Index_ToEnvelopeOverview", "Zur Umschlag-Übersicht")
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16">
|
||||||
<path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/>
|
<path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/>
|
||||||
</svg>
|
</svg>
|
||||||
@@ -54,20 +57,20 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" class="me-1" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" class="me-1" viewBox="0 0 16 16">
|
||||||
<path d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2z"/>
|
<path d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2z"/>
|
||||||
</svg>
|
</svg>
|
||||||
Sicherer Zugang
|
@L("Index_SecureAccess", "Sicherer Zugang")
|
||||||
</div>
|
</div>
|
||||||
<div class="home-feature-badge">
|
<div class="home-feature-badge">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" class="me-1" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" class="me-1" viewBox="0 0 16 16">
|
||||||
<path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z"/>
|
<path d="M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z"/>
|
||||||
</svg>
|
</svg>
|
||||||
Digitale Unterschrift
|
@L("Index_DigitalSignature", "Digitale Unterschrift")
|
||||||
</div>
|
</div>
|
||||||
<div class="home-feature-badge">
|
<div class="home-feature-badge">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" class="me-1" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" class="me-1" viewBox="0 0 16 16">
|
||||||
<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/>
|
<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/>
|
||||||
<path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/>
|
<path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z"/>
|
||||||
</svg>
|
</svg>
|
||||||
PDF-Export
|
@L("Index_PdfExport", "PDF-Export")
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -80,10 +83,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private const string HomePageDescription =
|
private string HomePageDescription => L(
|
||||||
"Das digitale Unterschriftenportal ist eine Plattform, die entwickelt wurde, um Ihre Dokumente sicher zu unterschreiben und zu verwalten. " +
|
"HomePageDescription",
|
||||||
"Mit seiner benutzerfreundlichen Oberfläche können Sie Ihre Dokumente schnell hochladen, die Unterschriftsprozesse verfolgen und Ihre digitalen Unterschriftenanwendungen einfach durchführen. " +
|
"Das digitale Unterschriftenportal ist eine Plattform, die entwickelt wurde, um Ihre Dokumente sicher zu unterschreiben und zu verwalten. Mit seiner benutzerfreundlichen Oberfläche können Sie Ihre Dokumente schnell hochladen, die Unterschriftsprozesse verfolgen und Ihre digitalen Unterschriftenanwendungen einfach durchführen. Dieses Portal beschleunigt Ihren Arbeitsablauf mit rechtlich gültigen Unterschriften und erhöht gleichzeitig die Sicherheit Ihrer Dokumente.");
|
||||||
"Dieses Portal beschleunigt Ihren Arbeitsablauf mit rechtlich gültigen Unterschriften und erhöht gleichzeitig die Sicherheit Ihrer Dokumente.";
|
|
||||||
|
|
||||||
private EnvelopeGenerator.Server.Client.Services.CustomImageDto? _appLogo;
|
private EnvelopeGenerator.Server.Client.Services.CustomImageDto? _appLogo;
|
||||||
|
|
||||||
@@ -99,4 +101,10 @@
|
|||||||
if (!firstRender) return;
|
if (!firstRender) return;
|
||||||
await JS.InvokeVoidAsync("receiverSignature.startTyped", "home-description", HomePageDescription, 15);
|
await JS.InvokeVoidAsync("receiverSignature.startTyped", "home-description", HomePageDescription, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string L(string key, string fallback)
|
||||||
|
{
|
||||||
|
var value = UiLocalizer[key];
|
||||||
|
return value.ResourceNotFound ? fallback : value.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
@page "/envelope/login/{EnvelopeKey}"
|
@page "/envelope/login/{EnvelopeKey}"
|
||||||
@rendermode InteractiveWebAssembly
|
@rendermode InteractiveWebAssembly
|
||||||
@using EnvelopeGenerator.Server.Client.Services
|
@using EnvelopeGenerator.Server.Client.Services
|
||||||
|
@using EnvelopeGenerator.Application.Resources
|
||||||
|
@using Microsoft.Extensions.Localization
|
||||||
@inject AuthService AuthService
|
@inject AuthService AuthService
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
|
@inject IStringLocalizer<Resource> UiLocalizer
|
||||||
|
|
||||||
<div class="login-page-wrapper d-flex align-items-center justify-content-center min-vh-100">
|
<div class="login-page-wrapper d-flex align-items-center justify-content-center min-vh-100">
|
||||||
<div class="login-card card shadow border-0" style="max-width: 440px; width: 100%;">
|
<div class="login-card card shadow border-0" style="max-width: 440px; width: 100%;">
|
||||||
@@ -13,14 +16,14 @@
|
|||||||
<path d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2z" />
|
<path d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2z" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<h5 class="mb-0 fw-semibold">Dokument öffnen</h5>
|
<h5 class="mb-0 fw-semibold">@L("OpenDocument", "Dokument öffnen")</h5>
|
||||||
<p class="mb-0 mt-1 opacity-75" style="font-size: 0.85rem;">Sicherer Zugang mit Zugangscode</p>
|
<p class="mb-0 mt-1 opacity-75" style="font-size: 0.85rem;">@L("ReceiverLogin_Subtitle", "Sicherer Zugang mit Zugangscode")</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
|
|
||||||
<p class="text-muted mb-4" style="font-size: 0.875rem; line-height: 1.5;">
|
<p class="text-muted mb-4" style="font-size: 0.875rem; line-height: 1.5;">
|
||||||
Bitte geben Sie den Zugangscode ein, den Sie per E-Mail erhalten haben, um das Dokument sicher zu öffnen.
|
@L("ReceiverLogin_Description", "Bitte geben Sie den Zugangscode ein, den Sie per E-Mail erhalten haben, um das Dokument sicher zu öffnen.")
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@if (LoginResult == EnvelopeLoginResult.NotFound)
|
@if (LoginResult == EnvelopeLoginResult.NotFound)
|
||||||
@@ -30,8 +33,8 @@
|
|||||||
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z" />
|
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z" />
|
||||||
</svg>
|
</svg>
|
||||||
<div>
|
<div>
|
||||||
<strong>Dokument nicht gefunden.</strong><br />
|
<strong>@L("ReceiverLogin_NotFound_Title", "Dokument nicht gefunden.")</strong><br />
|
||||||
<span style="font-size:0.85rem;">Der angegebene Zugangscode konnte keinem Dokument zugeordnet werden. Bitte prüfen Sie den Link in Ihrer E-Mail.</span>
|
<span style="font-size:0.85rem;">@L("ReceiverLogin_NotFound_Body", "Der angegebene Zugangscode konnte keinem Dokument zugeordnet werden. Bitte prüfen Sie den Link in Ihrer E-Mail.")</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -42,8 +45,8 @@
|
|||||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z" />
|
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z" />
|
||||||
</svg>
|
</svg>
|
||||||
<div>
|
<div>
|
||||||
<strong>Ungültiger Zugangscode.</strong><br />
|
<strong>@L("ReceiverLogin_InvalidCode_Title", "Ungültiger Zugangscode.")</strong><br />
|
||||||
<span style="font-size:0.85rem;">Der eingegebene Code ist falsch. Bitte versuchen Sie es erneut.</span>
|
<span style="font-size:0.85rem;">@L("ReceiverLogin_InvalidCode_Body", "Der eingegebene Code ist falsch. Bitte versuchen Sie es erneut.")</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
@@ -55,15 +58,15 @@
|
|||||||
<path d="M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z" />
|
<path d="M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z" />
|
||||||
</svg>
|
</svg>
|
||||||
<div>
|
<div>
|
||||||
<strong>Serverfehler.</strong><br />
|
<strong>@L("ServerError", "Serverfehler.")</strong><br />
|
||||||
<span style="font-size:0.85rem;">Ein unerwarteter Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.</span>
|
<span style="font-size:0.85rem;">@L("UnexpectedErrorTryAgainLater", "Ein unerwarteter Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.")</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label class="form-label fw-medium" for="login-access-code">
|
<label class="form-label fw-medium" for="login-access-code">
|
||||||
Zugangscode
|
@L("AccessCode", "Zugangscode")
|
||||||
<span class="text-danger ms-1">*</span>
|
<span class="text-danger ms-1">*</span>
|
||||||
</label>
|
</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
@@ -75,7 +78,7 @@
|
|||||||
<input id="login-access-code"
|
<input id="login-access-code"
|
||||||
type="@(ShowCode ? "text" : "password")"
|
type="@(ShowCode ? "text" : "password")"
|
||||||
class="form-control border-start-0 border-end-0 @(LoginResult == EnvelopeLoginResult.InvalidCode ? "is-invalid" : null)"
|
class="form-control border-start-0 border-end-0 @(LoginResult == EnvelopeLoginResult.InvalidCode ? "is-invalid" : null)"
|
||||||
placeholder="Zugangscode eingeben"
|
placeholder="@L("ReceiverLogin_AccessCode_Placeholder", "Zugangscode eingeben")"
|
||||||
@bind="AccessCode"
|
@bind="AccessCode"
|
||||||
@bind:event="oninput"
|
@bind:event="oninput"
|
||||||
@onkeydown="OnKeyDownAsync"
|
@onkeydown="OnKeyDownAsync"
|
||||||
@@ -113,21 +116,21 @@
|
|||||||
@if (IsLoading)
|
@if (IsLoading)
|
||||||
{
|
{
|
||||||
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>
|
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>
|
||||||
<span>Überprüfen …</span>
|
<span>@L("VerifyInProgress", "Überprüfen …")</span>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="me-2" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="me-2" viewBox="0 0 16 16">
|
||||||
<path d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2z" />
|
<path d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2z" />
|
||||||
</svg>
|
</svg>
|
||||||
<span>Dokument öffnen</span>
|
<span>@L("OpenDocument", "Dokument öffnen")</span>
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-footer text-center text-muted py-3 border-0 bg-transparent" style="font-size: 0.78rem;">
|
<div class="card-footer text-center text-muted py-3 border-0 bg-transparent" style="font-size: 0.78rem;">
|
||||||
Bei Problemen wenden Sie sich bitte an den Absender des Dokuments.
|
@L("ReceiverLogin_FooterHelp", "Bei Problemen wenden Sie sich bitte an den Absender des Dokuments.")
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -141,6 +144,14 @@
|
|||||||
bool IsLoading;
|
bool IsLoading;
|
||||||
EnvelopeLoginResult? LoginResult;
|
EnvelopeLoginResult? LoginResult;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(EnvelopeKey))
|
||||||
|
return;
|
||||||
|
|
||||||
|
_ = await AuthService.RequestEnvelopeReceiverAccessCodeAsync(EnvelopeKey);
|
||||||
|
}
|
||||||
|
|
||||||
async Task OnKeyDownAsync(Microsoft.AspNetCore.Components.Web.KeyboardEventArgs e)
|
async Task OnKeyDownAsync(Microsoft.AspNetCore.Components.Web.KeyboardEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == "Enter")
|
if (e.Key == "Enter")
|
||||||
@@ -159,7 +170,7 @@
|
|||||||
|
|
||||||
if (result == EnvelopeLoginResult.Success)
|
if (result == EnvelopeLoginResult.Success)
|
||||||
{
|
{
|
||||||
Navigation.NavigateTo($"/envelope/{Uri.EscapeDataString(EnvelopeKey)}", forceLoad: true);
|
Navigation.NavigateTo($"/envelope/{Uri.EscapeDataString(EnvelopeKey)}", forceLoad: false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,5 +178,11 @@
|
|||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string L(string key, string fallback)
|
||||||
|
{
|
||||||
|
var value = UiLocalizer[key];
|
||||||
|
return value.ResourceNotFound ? fallback : value.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
@page "/sender/login"
|
@page "/sender/login"
|
||||||
@rendermode InteractiveWebAssembly
|
@rendermode InteractiveWebAssembly
|
||||||
@using EnvelopeGenerator.Server.Client.Services
|
@using EnvelopeGenerator.Server.Client.Services
|
||||||
|
@using EnvelopeGenerator.Application.Resources
|
||||||
|
@using Microsoft.Extensions.Localization
|
||||||
@inject AuthService AuthService
|
@inject AuthService AuthService
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
|
@inject IStringLocalizer<Resource> UiLocalizer
|
||||||
|
|
||||||
<div class="login-page-wrapper d-flex align-items-center justify-content-center min-vh-100">
|
<div class="login-page-wrapper d-flex align-items-center justify-content-center min-vh-100">
|
||||||
<div class="login-card card shadow border-0" style="max-width: 440px; width: 100%;">
|
<div class="login-card card shadow border-0" style="max-width: 440px; width: 100%;">
|
||||||
@@ -14,14 +17,14 @@
|
|||||||
<path fill-rule="evenodd" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z"/>
|
<path fill-rule="evenodd" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z"/>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<h5 class="mb-0 fw-semibold">Sender Anmeldung</h5>
|
<h5 class="mb-0 fw-semibold">@L("SenderLogin_Title", "Sender Anmeldung")</h5>
|
||||||
<p class="mb-0 mt-1 opacity-75" style="font-size: 0.85rem;">Sicherer Zugang zum Sender-Dashboard</p>
|
<p class="mb-0 mt-1 opacity-75" style="font-size: 0.85rem;">@L("SenderLogin_Subtitle", "Sicherer Zugang zum Sender-Dashboard")</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
|
|
||||||
<p class="text-muted mb-4" style="font-size: 0.875rem; line-height: 1.5;">
|
<p class="text-muted mb-4" style="font-size: 0.875rem; line-height: 1.5;">
|
||||||
Bitte melden Sie sich mit Ihren Zugangsdaten an, um auf das Sender-Dashboard zuzugreifen.
|
@L("SenderLogin_Description", "Bitte melden Sie sich mit Ihren Zugangsdaten an, um auf das Sender-Dashboard zuzugreifen.")
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@if (LoginResult == SenderLoginResult.InvalidCredentials) {
|
@if (LoginResult == SenderLoginResult.InvalidCredentials) {
|
||||||
@@ -30,8 +33,8 @@
|
|||||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z"/>
|
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z"/>
|
||||||
</svg>
|
</svg>
|
||||||
<div>
|
<div>
|
||||||
<strong>Ungültige Anmeldedaten.</strong><br />
|
<strong>@L("SenderLogin_InvalidCredentials_Title", "Ungültige Anmeldedaten.")</strong><br />
|
||||||
<span style="font-size:0.85rem;">Benutzername oder Passwort ist falsch. Bitte versuchen Sie es erneut.</span>
|
<span style="font-size:0.85rem;">@L("SenderLogin_InvalidCredentials_Body", "Benutzername oder Passwort ist falsch. Bitte versuchen Sie es erneut.")</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
} else if (LoginResult == SenderLoginResult.Error) {
|
} else if (LoginResult == SenderLoginResult.Error) {
|
||||||
@@ -41,15 +44,15 @@
|
|||||||
<path d="M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z"/>
|
<path d="M7.002 11a1 1 0 1 1 2 0 1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z"/>
|
||||||
</svg>
|
</svg>
|
||||||
<div>
|
<div>
|
||||||
<strong>Serverfehler.</strong><br />
|
<strong>@L("ServerError", "Serverfehler.")</strong><br />
|
||||||
<span style="font-size:0.85rem;">Ein unerwarteter Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.</span>
|
<span style="font-size:0.85rem;">@L("UnexpectedErrorTryAgainLater", "Ein unerwarteter Fehler ist aufgetreten. Bitte versuchen Sie es später erneut.")</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label fw-medium" for="login-username">
|
<label class="form-label fw-medium" for="login-username">
|
||||||
Benutzername
|
@L("UserName", "Benutzername")
|
||||||
<span class="text-danger ms-1">*</span>
|
<span class="text-danger ms-1">*</span>
|
||||||
</label>
|
</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
@@ -61,7 +64,7 @@
|
|||||||
<input id="login-username"
|
<input id="login-username"
|
||||||
type="text"
|
type="text"
|
||||||
class="form-control @(LoginResult == SenderLoginResult.InvalidCredentials ? "is-invalid" : null)"
|
class="form-control @(LoginResult == SenderLoginResult.InvalidCredentials ? "is-invalid" : null)"
|
||||||
placeholder="Benutzername eingeben"
|
placeholder="@L("SenderLogin_Username_Placeholder", "Benutzername eingeben")"
|
||||||
@bind="Username"
|
@bind="Username"
|
||||||
@bind:event="oninput"
|
@bind:event="oninput"
|
||||||
@onkeydown="OnKeyDownAsync"
|
@onkeydown="OnKeyDownAsync"
|
||||||
@@ -72,7 +75,7 @@
|
|||||||
|
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label class="form-label fw-medium" for="login-password">
|
<label class="form-label fw-medium" for="login-password">
|
||||||
Passwort
|
@L("Password", "Passwort")
|
||||||
<span class="text-danger ms-1">*</span>
|
<span class="text-danger ms-1">*</span>
|
||||||
</label>
|
</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
@@ -84,7 +87,7 @@
|
|||||||
<input id="login-password"
|
<input id="login-password"
|
||||||
type="@(ShowPassword ? "text" : "password")"
|
type="@(ShowPassword ? "text" : "password")"
|
||||||
class="form-control border-start-0 border-end-0 @(LoginResult == SenderLoginResult.InvalidCredentials ? "is-invalid" : null)"
|
class="form-control border-start-0 border-end-0 @(LoginResult == SenderLoginResult.InvalidCredentials ? "is-invalid" : null)"
|
||||||
placeholder="Passwort eingeben"
|
placeholder="@L("SenderLogin_Password_Placeholder", "Passwort eingeben")"
|
||||||
@bind="Password"
|
@bind="Password"
|
||||||
@bind:event="oninput"
|
@bind:event="oninput"
|
||||||
@onkeydown="OnKeyDownAsync"
|
@onkeydown="OnKeyDownAsync"
|
||||||
@@ -118,20 +121,20 @@
|
|||||||
disabled="@(IsLoading || string.IsNullOrWhiteSpace(Username) || string.IsNullOrWhiteSpace(Password))">
|
disabled="@(IsLoading || string.IsNullOrWhiteSpace(Username) || string.IsNullOrWhiteSpace(Password))">
|
||||||
@if (IsLoading) {
|
@if (IsLoading) {
|
||||||
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>
|
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>
|
||||||
<span>Anmelden …</span>
|
<span>@L("LoginInProgress", "Anmelden …")</span>
|
||||||
} else {
|
} else {
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="me-2" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="me-2" viewBox="0 0 16 16">
|
||||||
<path fill-rule="evenodd" d="M10 3.5a.5.5 0 0 0-.5-.5h-8a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-2a.5.5 0 0 1 1 0v2A1.5 1.5 0 0 1 9.5 14h-8A1.5 1.5 0 0 1 0 12.5v-9A1.5 1.5 0 0 1 1.5 2h8A1.5 1.5 0 0 1 11 3.5v2a.5.5 0 0 1-1 0v-2z"/>
|
<path fill-rule="evenodd" d="M10 3.5a.5.5 0 0 0-.5-.5h-8a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h8a.5.5 0 0 0 .5-.5v-2a.5.5 0 0 1 1 0v2A1.5 1.5 0 0 1 9.5 14h-8A1.5 1.5 0 0 1 0 12.5v-9A1.5 1.5 0 0 1 1.5 2h8A1.5 1.5 0 0 1 11 3.5v2a.5.5 0 0 1-1 0v-2z"/>
|
||||||
<path fill-rule="evenodd" d="M4.146 8.354a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L5.707 7.5H14.5a.5.5 0 0 1 0 1H5.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3z"/>
|
<path fill-rule="evenodd" d="M4.146 8.354a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L5.707 7.5H14.5a.5.5 0 0 1 0 1H5.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3z"/>
|
||||||
</svg>
|
</svg>
|
||||||
<span>Anmelden</span>
|
<span>@L("Login", "Anmelden")</span>
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-footer text-center text-muted py-3 border-0 bg-transparent" style="font-size: 0.78rem;">
|
<div class="card-footer text-center text-muted py-3 border-0 bg-transparent" style="font-size: 0.78rem;">
|
||||||
Bei Problemen wenden Sie sich bitte an den Administrator.
|
@L("SenderLogin_FooterHelp", "Bei Problemen wenden Sie sich bitte an den Administrator.")
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -159,7 +162,7 @@
|
|||||||
var result = await AuthService.LoginSenderAsync(Username.Trim(), Password.Trim());
|
var result = await AuthService.LoginSenderAsync(Username.Trim(), Password.Trim());
|
||||||
|
|
||||||
if (result == SenderLoginResult.Success) {
|
if (result == SenderLoginResult.Success) {
|
||||||
Navigation.NavigateTo("/sender", forceLoad: true);
|
Navigation.NavigateTo("/sender", forceLoad: false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,4 +170,10 @@
|
|||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string L(string key, string fallback)
|
||||||
|
{
|
||||||
|
var value = UiLocalizer[key];
|
||||||
|
return value.ResourceNotFound ? fallback : value.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -5,9 +5,17 @@ using DevExpress.Blazor.Reporting;
|
|||||||
using DevExpress.XtraReports.Web.Extensions;
|
using DevExpress.XtraReports.Web.Extensions;
|
||||||
using DevExpress.DataAccess.Web;
|
using DevExpress.DataAccess.Web;
|
||||||
using DevExpress.XtraReports.Services;
|
using DevExpress.XtraReports.Services;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||||
|
|
||||||
|
var initialCulture = await ResolveInitialCultureAsync(builder.HostEnvironment.BaseAddress);
|
||||||
|
var cultureInfo = new CultureInfo(initialCulture);
|
||||||
|
CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
|
||||||
|
CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
|
||||||
|
|
||||||
|
builder.Services.AddLocalization();
|
||||||
|
|
||||||
// Named HttpClient for API calls (both for services and DevExpress components)
|
// Named HttpClient for API calls (both for services and DevExpress components)
|
||||||
builder.Services.AddHttpClient("EnvelopeGenerator.Server", client =>
|
builder.Services.AddHttpClient("EnvelopeGenerator.Server", client =>
|
||||||
{
|
{
|
||||||
@@ -33,6 +41,11 @@ builder.Services.AddScoped<SignatureService>();
|
|||||||
builder.Services.AddScoped<SignatureCacheService>();
|
builder.Services.AddScoped<SignatureCacheService>();
|
||||||
builder.Services.AddSingleton<AppVersionService>();
|
builder.Services.AddSingleton<AppVersionService>();
|
||||||
builder.Services.AddScoped<EnvelopeService>();
|
builder.Services.AddScoped<EnvelopeService>();
|
||||||
|
builder.Services.AddScoped<EnvelopeTypeService>();
|
||||||
|
builder.Services.AddScoped<LocalizationService>();
|
||||||
|
builder.Services.AddScoped<ReceiverService>();
|
||||||
|
builder.Services.AddScoped<PdfRenderService>();
|
||||||
|
builder.Services.AddScoped<CreateEnvelopeBootstrapStorageService>();
|
||||||
|
|
||||||
// UI Preferences & Theme
|
// UI Preferences & Theme
|
||||||
builder.Services.AddScoped<UserPreferencesService>();
|
builder.Services.AddScoped<UserPreferencesService>();
|
||||||
@@ -66,3 +79,23 @@ ReportStorageWebExtension.RegisterExtensionGlobal(new InMemoryReportStorageWebEx
|
|||||||
var host = builder.Build();
|
var host = builder.Build();
|
||||||
await FontLoader.LoadFonts(host.Services.GetRequiredService<IHttpClientFactory>(), new List<string> { "opensans.ttf" });
|
await FontLoader.LoadFonts(host.Services.GetRequiredService<IHttpClientFactory>(), new List<string> { "opensans.ttf" });
|
||||||
await host.RunAsync();
|
await host.RunAsync();
|
||||||
|
|
||||||
|
static async Task<string> ResolveInitialCultureAsync(string baseAddress)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var http = new HttpClient { BaseAddress = new Uri(baseAddress) };
|
||||||
|
var response = await http.GetAsync("/api/Localization/lang");
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
return "de-DE";
|
||||||
|
|
||||||
|
var value = await response.Content.ReadAsStringAsync();
|
||||||
|
var culture = value.Trim().Trim('"');
|
||||||
|
return string.IsNullOrWhiteSpace(culture) ? "de-DE" : culture;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return "de-DE";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,4 +26,24 @@ public class AnnotationService(IHttpClientFactory httpClientFactory)
|
|||||||
var result = await response.Content.ReadFromJsonAsync<List<AnnotationDto>>(_jsonOptions, cancel);
|
var result = await response.Content.ReadFromJsonAsync<List<AnnotationDto>>(_jsonOptions, cancel);
|
||||||
return result ?? [];
|
return result ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task RejectAsync(string envelopeKey, string? reason, CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
using var http = httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||||
|
|
||||||
|
var response = await http.PostAsJsonAsync(
|
||||||
|
$"/api/Annotation/reject/{Uri.EscapeDataString(envelopeKey)}",
|
||||||
|
reason,
|
||||||
|
_jsonOptions,
|
||||||
|
cancel);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var body = await response.Content.ReadAsStringAsync(cancel);
|
||||||
|
throw new HttpRequestException(
|
||||||
|
$"Failed to reject envelope {envelopeKey}: {(int)response.StatusCode} {response.StatusCode} - {body}",
|
||||||
|
null,
|
||||||
|
response.StatusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,20 @@ public class AuthService(IHttpClientFactory httpClientFactory)
|
|||||||
return response.StatusCode == HttpStatusCode.OK;
|
return response.StatusCode == HttpStatusCode.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Triggers access code e-mail request flow for the receiver login page.
|
||||||
|
/// Calls POST /api/Auth/envelope-receiver/{key}/request-access-code.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<bool> RequestEnvelopeReceiverAccessCodeAsync(string envelopeKey, CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
using var http = CreateDefaultClient();
|
||||||
|
var response = await http.PostAsync(
|
||||||
|
$"/api/Auth/envelope-receiver/{Uri.EscapeDataString(envelopeKey)}/request-access-code",
|
||||||
|
null,
|
||||||
|
cancel);
|
||||||
|
return response.IsSuccessStatusCode;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Submits the access code for the given envelope key.
|
/// Submits the access code for the given envelope key.
|
||||||
/// Calls POST /api/Auth/envelope-receiver/{key} with multipart/form-data.
|
/// Calls POST /api/Auth/envelope-receiver/{key} with multipart/form-data.
|
||||||
@@ -72,6 +86,18 @@ public class AuthService(IHttpClientFactory httpClientFactory)
|
|||||||
return response.IsSuccessStatusCode;
|
return response.IsSuccessStatusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shares the current envelope in read-only mode for the specified receiver and expiration date.
|
||||||
|
/// Calls POST /api/readonly/{envelopeKey}.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<bool> ShareEnvelopeReadOnlyAsync(string envelopeKey, string receiverMail, DateTime dateValid, CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
using var http = CreateDefaultClient();
|
||||||
|
var payload = new { receiverMail, dateValid };
|
||||||
|
var response = await http.PostAsJsonAsync($"/api/readonly/{Uri.EscapeDataString(envelopeKey)}", payload, cancel);
|
||||||
|
return response.IsSuccessStatusCode;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Removes the per-envelope receiver cookie for the given envelope key.
|
/// Removes the per-envelope receiver cookie for the given envelope key.
|
||||||
/// Calls POST /api/auth/logout/envelope/{envelopeKey}.
|
/// Calls POST /api/auth/logout/envelope/{envelopeKey}.
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using Microsoft.JSInterop;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Server.Client.Services;
|
||||||
|
|
||||||
|
public sealed class CreateEnvelopeBootstrapStorageService(IJSRuntime jsRuntime)
|
||||||
|
{
|
||||||
|
private const string StorageKeyPrefix = "sender.createEnvelope.bootstrap.";
|
||||||
|
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);
|
||||||
|
|
||||||
|
public async Task<string> StoreAsync(CreateEnvelopeBootstrapPayload payload)
|
||||||
|
{
|
||||||
|
var token = Guid.NewGuid().ToString("N");
|
||||||
|
var key = BuildStorageKey(token);
|
||||||
|
var json = JsonSerializer.Serialize(payload, JsonOptions);
|
||||||
|
await jsRuntime.InvokeVoidAsync("sessionStorage.setItem", key, json);
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<CreateEnvelopeBootstrapPayload?> ConsumeAsync(string? token)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(token))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var key = BuildStorageKey(token);
|
||||||
|
var raw = await jsRuntime.InvokeAsync<string?>("sessionStorage.getItem", key);
|
||||||
|
await jsRuntime.InvokeVoidAsync("sessionStorage.removeItem", key);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(raw))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return JsonSerializer.Deserialize<CreateEnvelopeBootstrapPayload>(raw, JsonOptions);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string BuildStorageKey(string token) => $"{StorageKeyPrefix}{token}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed record CreateEnvelopeBootstrapPayload(
|
||||||
|
string Title,
|
||||||
|
string Message,
|
||||||
|
int? EnvelopeTypeId,
|
||||||
|
string Language,
|
||||||
|
bool UseAccessCode,
|
||||||
|
bool TFAEnabled,
|
||||||
|
int CertificationType,
|
||||||
|
int FinalEmailToCreator,
|
||||||
|
int FinalEmailToReceivers,
|
||||||
|
bool SendReminderEmails,
|
||||||
|
int FirstReminderDays,
|
||||||
|
int ReminderIntervalDays,
|
||||||
|
int ExpiresWhenDays,
|
||||||
|
int ExpiresWarningWhenDays,
|
||||||
|
IReadOnlyList<CreateEnvelopeBootstrapReceiver> Receivers,
|
||||||
|
byte[]? DocumentBytes,
|
||||||
|
string? DocumentFileName);
|
||||||
|
|
||||||
|
public sealed record CreateEnvelopeBootstrapReceiver(string FullName, string EmailAddress);
|
||||||
@@ -1,10 +1,23 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Http.Json;
|
||||||
|
using System.Text.Json;
|
||||||
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Server.Client.Services;
|
namespace EnvelopeGenerator.Server.Client.Services;
|
||||||
|
|
||||||
public class DocumentService(IHttpClientFactory httpClientFactory)
|
public class DocumentService(IHttpClientFactory httpClientFactory)
|
||||||
{
|
{
|
||||||
|
private static readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
|
||||||
|
|
||||||
|
private static HttpRequestException CreateHttpException(string messagePrefix, HttpStatusCode statusCode, string? reasonPhrase)
|
||||||
|
{
|
||||||
|
var statusCodeInt = (int)statusCode;
|
||||||
|
return new HttpRequestException(
|
||||||
|
$"{messagePrefix}. Status: {statusCodeInt} ({reasonPhrase ?? "Unknown error"})",
|
||||||
|
null,
|
||||||
|
statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches the PDF bytes for the given envelope key from the API.
|
/// Fetches the PDF bytes for the given envelope key from the API.
|
||||||
@@ -17,16 +30,75 @@ public class DocumentService(IHttpClientFactory httpClientFactory)
|
|||||||
var response = await http.GetAsync($"/api/Document/{Uri.EscapeDataString(envelopeKey)}", cancel);
|
var response = await http.GetAsync($"/api/Document/{Uri.EscapeDataString(envelopeKey)}", cancel);
|
||||||
|
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
throw CreateHttpException("Failed to load document", response.StatusCode, response.ReasonPhrase);
|
||||||
var statusCode = (int)response.StatusCode;
|
|
||||||
var reasonPhrase = response.ReasonPhrase ?? "Unknown error";
|
|
||||||
throw new HttpRequestException(
|
|
||||||
$"Failed to load document. Status: {statusCode} ({reasonPhrase})",
|
|
||||||
null,
|
|
||||||
response.StatusCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
var bytes = await response.Content.ReadAsByteArrayAsync(cancel);
|
var bytes = await response.Content.ReadAsByteArrayAsync(cancel);
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fetches sender document details (including signature elements) by envelope id.
|
||||||
|
/// Uses GET /api/Document/details?EnvelopeId={envelopeId}.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<DocumentDto?> GetSenderDocumentDetailsByEnvelopeIdAsync(int envelopeId, CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
using var http = httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||||
|
var detailsResponse = await http.GetAsync($"/api/Document/details?EnvelopeId={envelopeId}", cancel);
|
||||||
|
|
||||||
|
if (detailsResponse.StatusCode == HttpStatusCode.NotFound)
|
||||||
|
{
|
||||||
|
var fallbackBytes = await TryGetSenderDocumentBytesByEnvelopeIdAsync(http, envelopeId, cancel);
|
||||||
|
if (fallbackBytes is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new DocumentDto(fallbackBytes, new DocumentDetailsDto
|
||||||
|
{
|
||||||
|
EnvelopeId = envelopeId,
|
||||||
|
AddedWhen = DateTime.UtcNow,
|
||||||
|
Elements = []
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!detailsResponse.IsSuccessStatusCode)
|
||||||
|
throw CreateHttpException("Failed to load sender document details", detailsResponse.StatusCode, detailsResponse.ReasonPhrase);
|
||||||
|
|
||||||
|
var details = await detailsResponse.Content.ReadFromJsonAsync<DocumentDetailsDto>(_jsonOptions, cancel)
|
||||||
|
?? throw new HttpRequestException("Failed to deserialize sender document details response.");
|
||||||
|
|
||||||
|
var byteData = await TryGetSenderDocumentBytesByEnvelopeIdAsync(http, envelopeId, cancel);
|
||||||
|
if (byteData is null)
|
||||||
|
byteData = [];
|
||||||
|
|
||||||
|
return new DocumentDto(byteData, details);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fetches sender document bytes by envelope id.
|
||||||
|
/// Uses GET /api/Document?EnvelopeId={envelopeId}.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<byte[]?> GetSenderDocumentBytesByEnvelopeIdAsync(int envelopeId, CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
using var http = httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||||
|
var response = await http.GetAsync($"/api/Document?EnvelopeId={envelopeId}", cancel);
|
||||||
|
|
||||||
|
if (response.StatusCode == HttpStatusCode.NotFound)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
throw CreateHttpException("Failed to load sender document bytes", response.StatusCode, response.ReasonPhrase);
|
||||||
|
|
||||||
|
return await response.Content.ReadAsByteArrayAsync(cancel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task<byte[]?> TryGetSenderDocumentBytesByEnvelopeIdAsync(HttpClient http, int envelopeId, CancellationToken cancel)
|
||||||
|
{
|
||||||
|
var bytesResponse = await http.GetAsync($"/api/Document?EnvelopeId={envelopeId}", cancel);
|
||||||
|
if (bytesResponse.StatusCode == HttpStatusCode.NotFound)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (!bytesResponse.IsSuccessStatusCode)
|
||||||
|
throw CreateHttpException("Failed to load sender document bytes", bytesResponse.StatusCode, bytesResponse.ReasonPhrase);
|
||||||
|
|
||||||
|
return await bytesResponse.Content.ReadAsByteArrayAsync(cancel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using EnvelopeGenerator.Application.Common.Dto;
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
using EnvelopeGenerator.Application.Envelopes.Commands;
|
||||||
using Microsoft.AspNetCore.WebUtilities;
|
using Microsoft.AspNetCore.WebUtilities;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Json;
|
using System.Net.Http.Json;
|
||||||
@@ -12,6 +13,8 @@ namespace EnvelopeGenerator.Server.Client.Services;
|
|||||||
public class EnvelopeService(IHttpClientFactory clientFactory)
|
public class EnvelopeService(IHttpClientFactory clientFactory)
|
||||||
{
|
{
|
||||||
private static readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
|
private static readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
|
||||||
|
private sealed record DeleteEnvelopeRequest(string Reason);
|
||||||
|
private sealed record ErrorResponse(string? Message);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches envelopes from the API with optional filters.
|
/// Fetches envelopes from the API with optional filters.
|
||||||
@@ -61,4 +64,64 @@ public class EnvelopeService(IHttpClientFactory clientFactory)
|
|||||||
|
|
||||||
return await response.Content.ReadFromJsonAsync<IEnumerable<EnvelopeDto>>(_jsonOptions, cancel);
|
return await response.Content.ReadFromJsonAsync<IEnumerable<EnvelopeDto>>(_jsonOptions, cancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task DeleteAsync(int envelopeId, string reason, CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
var httpClient = clientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||||
|
using var request = new HttpRequestMessage(HttpMethod.Delete, $"/api/Envelope/{envelopeId}")
|
||||||
|
{
|
||||||
|
Content = JsonContent.Create(new DeleteEnvelopeRequest(reason), options: _jsonOptions)
|
||||||
|
};
|
||||||
|
|
||||||
|
var response = await httpClient.SendAsync(request, cancel);
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string? message = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var error = await response.Content.ReadFromJsonAsync<ErrorResponse>(_jsonOptions, cancel);
|
||||||
|
message = error?.Message;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
message = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var statusCode = (int)response.StatusCode;
|
||||||
|
var reasonPhrase = response.ReasonPhrase ?? "Unknown error";
|
||||||
|
throw new HttpRequestException(
|
||||||
|
$"Failed to delete envelope. Status: {statusCode} ({reasonPhrase}){(string.IsNullOrWhiteSpace(message) ? string.Empty : $" - {message}")}",
|
||||||
|
null,
|
||||||
|
response.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<EnvelopeDto?> UpsertAsync(
|
||||||
|
CreateEnvelopeCommand request,
|
||||||
|
CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
var httpClient = clientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||||
|
var response = await httpClient.PostAsJsonAsync("/api/Envelope", request, _jsonOptions, cancel);
|
||||||
|
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
return await response.Content.ReadFromJsonAsync<EnvelopeDto>(_jsonOptions, cancel);
|
||||||
|
|
||||||
|
string? message = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var error = await response.Content.ReadFromJsonAsync<ErrorResponse>(_jsonOptions, cancel);
|
||||||
|
message = error?.Message;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
message = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var statusCode = (int)response.StatusCode;
|
||||||
|
var reasonPhrase = response.ReasonPhrase ?? "Unknown error";
|
||||||
|
throw new HttpRequestException(
|
||||||
|
$"Failed to save envelope. Status: {statusCode} ({reasonPhrase}){(string.IsNullOrWhiteSpace(message) ? string.Empty : $" - {message}")}",
|
||||||
|
null,
|
||||||
|
response.StatusCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
using System.Net.Http.Json;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Server.Client.Services;
|
||||||
|
|
||||||
|
public class EnvelopeTypeService(IHttpClientFactory clientFactory)
|
||||||
|
{
|
||||||
|
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);
|
||||||
|
|
||||||
|
public async Task<IReadOnlyList<EnvelopeTypeDto>> GetAsync(CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
var http = clientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||||
|
var response = await http.GetAsync("/api/EnvelopeType", cancel);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
var data = await response.Content.ReadFromJsonAsync<List<EnvelopeTypeDto>>(JsonOptions, cancel);
|
||||||
|
return data ?? [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using System.Net;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Server.Client.Services;
|
||||||
|
|
||||||
|
public class LocalizationService(IHttpClientFactory httpClientFactory)
|
||||||
|
{
|
||||||
|
private HttpClient CreateDefaultClient() => httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||||
|
|
||||||
|
public async Task<string> GetLanguageAsync(CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
using var http = CreateDefaultClient();
|
||||||
|
var response = await http.GetAsync("/api/Localization/lang", cancel);
|
||||||
|
|
||||||
|
if (response.StatusCode == HttpStatusCode.NotFound)
|
||||||
|
return "de-DE";
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
return "de-DE";
|
||||||
|
|
||||||
|
var language = await response.Content.ReadAsStringAsync(cancel);
|
||||||
|
return string.IsNullOrWhiteSpace(language) ? "de-DE" : language.Trim('"');
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SetLanguageAsync(string language, CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
using var http = CreateDefaultClient();
|
||||||
|
var response = await http.PostAsync($"/api/Localization/lang?language={Uri.EscapeDataString(language)}", null, cancel);
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using System.Net.Http.Json;
|
||||||
|
using System.Text.Json;
|
||||||
|
using EnvelopeGenerator.Application.Common.Dto;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Server.Client.Services;
|
||||||
|
|
||||||
|
public class PdfRenderService(IHttpClientFactory httpClientFactory)
|
||||||
|
{
|
||||||
|
private static readonly JsonSerializerOptions _jsonOptions = new(JsonSerializerDefaults.Web);
|
||||||
|
|
||||||
|
public async Task<IReadOnlyList<PdfPageImageDto>> RenderPagesAsync(byte[] pdfBytes, CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
using var http = httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||||
|
using var response = await http.PostAsJsonAsync(
|
||||||
|
"/api/PdfRender/pages",
|
||||||
|
new PdfRenderRequestDto { PdfBytes = pdfBytes },
|
||||||
|
_jsonOptions,
|
||||||
|
cancel);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var statusCode = (int)response.StatusCode;
|
||||||
|
var reasonPhrase = response.ReasonPhrase ?? "Unknown error";
|
||||||
|
throw new HttpRequestException(
|
||||||
|
$"Failed to render PDF pages. Status: {statusCode} ({reasonPhrase})",
|
||||||
|
null,
|
||||||
|
response.StatusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await response.Content.ReadFromJsonAsync<List<PdfPageImageDto>>(_jsonOptions, cancel) ?? [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using System.Net.Http.Json;
|
||||||
|
using System.Text.Json;
|
||||||
|
using EnvelopeGenerator.Application.Common.Dto.Receiver;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Server.Client.Services;
|
||||||
|
|
||||||
|
public class ReceiverService(IHttpClientFactory httpClientFactory)
|
||||||
|
{
|
||||||
|
private static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fetches receiver email suggestions from sender-authorized API.
|
||||||
|
/// Calls GET /api/Receiver?EmailAddressSearch={term}&onlyEmailAddress=true.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<IReadOnlyList<string>> SearchReceiverEmailsAsync(string searchTerm, CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(searchTerm))
|
||||||
|
return [];
|
||||||
|
|
||||||
|
using var http = httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||||
|
var url = $"/api/Receiver?EmailAddressSearch={Uri.EscapeDataString(searchTerm)}&onlyEmailAddress=true";
|
||||||
|
var response = await http.GetAsync(url, cancel);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
var emails = await response.Content.ReadFromJsonAsync<List<string>>(JsonOptions, cancel);
|
||||||
|
return emails ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fetches recent receiver suggestions for the authenticated sender.
|
||||||
|
/// Calls GET /api/EnvelopeReceiver/recent-suggestions?take={take}.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<IReadOnlyList<RecentReceiverSuggestionDto>> GetRecentReceiverSuggestionsAsync(int take = 20, CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
using var http = httpClientFactory.CreateClient("EnvelopeGenerator.Server");
|
||||||
|
var url = $"/api/EnvelopeReceiver/recent-suggestions?take={take}";
|
||||||
|
var response = await http.GetAsync(url, cancel);
|
||||||
|
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
var suggestions = await response.Content.ReadFromJsonAsync<List<RecentReceiverSuggestionDto>>(JsonOptions, cancel);
|
||||||
|
return suggestions ?? [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
@using EnvelopeGenerator.Server.Client.Services
|
@using EnvelopeGenerator.Server.Client.Services
|
||||||
@using EnvelopeGenerator.Server.Client.Models
|
@using EnvelopeGenerator.Server.Client.Models
|
||||||
@using EnvelopeGenerator.Server.Client.Options
|
@using EnvelopeGenerator.Server.Client.Options
|
||||||
|
@using EnvelopeGenerator.Server.Client.Components.PdfEditor
|
||||||
@using DevExpress.Blazor
|
@using DevExpress.Blazor
|
||||||
@using DevExpress.Blazor.PdfViewer
|
@using DevExpress.Blazor.PdfViewer
|
||||||
@using DevExpress.Blazor.Reporting
|
@using DevExpress.Blazor.Reporting
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<base href="/" />
|
<base href="/" />
|
||||||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
|
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flag-icons@7.2.3/css/flag-icons.min.css" />
|
||||||
<link rel="stylesheet" href="css/app.css" />
|
<link rel="stylesheet" href="css/app.css" />
|
||||||
<link rel="stylesheet" href="css/envelope-viewer.css" />
|
<link rel="stylesheet" href="css/envelope-viewer.css" />
|
||||||
<link rel="stylesheet" href="EnvelopeGenerator.Server.styles.css" />
|
<link rel="stylesheet" href="EnvelopeGenerator.Server.styles.css" />
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user