Skip to content

Commit 789d281

Browse files
albertrodriguezin2rogermiretin2AlbaLopez552rubenmodamiooriolcanades
authored
Release/2.x (#121)
* fix(backend): adapt endpoints to oidc4vci (#111) * transaction code * update credential response * refactor(project): fix sonar issues (cherry picked from commit 1d20432) * build(gradle): update version * fix(workflow): remove unused if * feat(workflow): lear credential machine * fix(service): check optionally exp in jwt proof payload * fix(service): change learcredentialmachine verifications * Feature/add sign access request (#128) * fix(shared): add new sad call in remote signature service * fix(service): change remote signature * fix(service): change media type on credentials authorize call * test(controller): global exception handler * fix(domain): change credential status enum name * feat(domain): add credential status * feat(domain): build credential with status * feat(controller): add credential status controller * feat(workflow): add credential status workflow * feat(service): add credential status service * feat(service): add credential revocation * feat(controller): add list id * refactor(project): naming * ci(github): add trigger * refactor(domain): fix name * fix(service): allow save entity, adding other id * test(service): fix entity construction * fix(flyway): fix sql * fix(domain): fix repo jpa sentence * fix(flyway): make nonce unique * fix(domain): create credential status list index as nonce * feat(service): add authorization * test(service): add more tests * test(service): add more tests * fix(domain): fix getClaimFromPayload returning raw string claims without quotes * credential_status update * fix auth and nonce * fix status * validated status * changed credential_status for lifeCycleStatus * No security for revocation GET endpoint * fix(chore): fix merge conflicts * fix(domain): fix credential status url * Feature/label credential (#129) * add updated api contract * add updated api contract * update credential offer types * label credential * fix(chore): fix errors * fix(flyway): change version number * refactor(domain): remove comments --------- Co-authored-by: Albert Rodríguez <[email protected]> * set organizationId in label credential credential procedure (#137) * fix(service): add organization identifier * refactor(service): replace lambda * fix(service): notification label credential * fix(domain): json property typo * credentialStatus * modified revoke credential method * credentialStatus in LabelCredential * fix in bindIssuer for status * changes read token mandator * Revert "lear" This reverts commit 3028a42. * Revert "changes read token mandator" This reverts commit c12286b. * fix type * Label credential Factory tests * Sonar fixes * fix mail * credentialStatus for LearCredentialMachine * revoked credential notification * version * wallet url fix * notification for expired credentials * type fix * error control * Feature/2.x lear credential machine back back (#139) * feat(workflow): lear credential machine * fix(service): change learcredentialmachine verifications * build(gradle): update version * fix(chore): fix merge conflicts * changes read token mandator * lear * Revert "lear" This reverts commit 3028a42. * Revert "changes read token mandator" This reverts commit c12286b. * fix mail * fix credential service * fix machine signature * changed template * fixed template * updates in send mail * changed title * changed title 2 * chron fix * Expired fix * isExpiredAndNotAlreadyMarked method * deleted test chron * test cron 2 min * fixed tests * test logs * fix isLearCredentialEmployeeMandatorOrganizationIdentifierAllowedSignerLEARCredentialMachine * fix(VerifiableCredentialPolicyAuthorizationServiceImpl): remove mock and test logs * fix changelog * fix(CredentialIssuanceWorkflowImpl): use mandator name instead of default in email text * changed template text * Updates in EmailService * fix tests and update las update * fix sonar issues * Hotifx/machine notification (#146) * feat(CredentialProcedureServiceImpl): Add LEARCredentialMachine notification * refactor(GlobalExceptionHandler) (#148) * refactor(GlobalExceptionHandler): use GlobalErrorMessage following RFC 7807 criteria * refactor: split global exception handler in an exception handler for each directory. * remove unused exception handlers and the correponding exceptions * remove unused exceptions * refactor: convert error types to enum to avoid arch unit error * enhance error types naming * Hotfix/credential serialization exception (#151) * handle credential serialization exception * handle send PIN error * change handleSadError for handleSadException * refactor pipelines and naming (#159) Co-authored-by: Oriol Canadés <[email protected]> * refactor pipelines * refactor pipelines 2 * Update pipelines * update build.yml to push snapshot image when a PR to release/** is opened * feature/refactor_securityFilters_2.x (#155) * (issuer) [2.x] refactor securityConfig - update version # Conflicts: # CHANGELOG.md # build.gradle * (issuer) [2.x] refactor securityConfig # Conflicts: # src/main/java/es/in2/issuer/backend/backoffice/infrastructure/config/security/CustomAuthenticationManager.java # src/main/java/es/in2/issuer/backend/backoffice/infrastructure/config/security/PublicCORSConfig.java # src/main/java/es/in2/issuer/backend/backoffice/infrastructure/config/security/SecurityConfig.java * (issuer) [2.x] refactor securityConfig - la clase verifier en shelve a revisar -> configuración pasa a Custom (pendiente) * (issuer) [2.x] refactor securityConfig - fixing cherrypick * (issuer) [2.x] refactor securityConfig - update paths - CredentialProcedureController * (issuer) [2.x] refactor securityConfig - update paths - NotificationController * (issuer) [2.x] refactor securityConfig - update paths - NotificationController + fix security config * (issuer) [2.x] refactor securityConfig - update paths - NotificationController + fix security config * (issuer) [2.x] refactor securityConfig - update paths - NotificationController + fix security config * (issuer) [2.x] refactor securityConfig - update paths - NotificationController + fix security config * (issuer) [2.x] refactor securityConfig - update paths - NotificationController + fix security config * (issuer) [2.x] refactor securityConfig - update paths - NotificationController + fix security config * (issuer) [2.x] refactor securityConfig - update paths - NotificationController + fix security config * (issuer) [2.x] refactor securityConfig - update paths - DeferredCredentialMetadataController + fix security config * (issuer) [2.x] refactor securityConfig - update paths - DeferredCredentialMetadataController + fix security config * (issuer) [2.x] refactor securityConfig - update paths - SignUnsignedCredentialController + CredentialSignerController + TODO para las /ops * (issuer) [2.x] refactor securityConfig - update paths - securityConfig retry signed test * (issuer) [2.x] refactor securityConfig - update paths - securityConfig retry signed test * (issuer) [2.x] refactor securityConfig - update paths - securityConfig retry signed test * (issuer) [2.x] refactor securityConfig - update paths - securityConfig retry signed test * (issuer) [2.x] refactor securityConfig - update paths - securityConfig retry signed test * (issuer) [2.x] refactor securityConfig - update paths - securityConfig retry signed test * (issuer) [2.x] refactor securityConfig - update paths - securityConfig retry signed test * (issuer) [2.x] refactor securityConfig - update paths - securityConfig improved RemoteSignatureServiceImpl error handler * (issuer) [2.x] refactor securityConfig - improved logs * (issuer) [2.x] refactor securityConfig - restore release.yml * (issuer) [2.x] refactor securityConfig - restore release.yml * (issuer) [2.x] refactor securityConfig - review github fixes * (issuer) [2.x] refactor securityConfig - review github fixes * fix: remove CustomAuthenticationFilter from backofficeFilterChain * test log * remove test logs * remove OID4VCI_CREDENTIAL_OFFER_PATH from custom authentication web filter --------- Co-authored-by: Roger Miret <[email protected]> * refactor: auth error handling (#168) * fix build pipeline * refactor CustomAuthenticationManager.authenticate to reduce cognitive complexity * make credential status path public * changed activate credential mail * changed release.yml * activation link added * href fix * changed template * changed padding in template * deleted release/** deploy * Hotfix/restore machine organization identifier (#173) * restore LEARCredentialMachine organizationIdentifier in mandator * fix(CredentialSignerWorkflow): fix getting email and product id in retrySignUnsignedCredential * refactor: sonar issues (remove unused imports, add todos, use primitive boolean expression in IssuerFactory, remove redundant eq in test, create CREDENTIALS_CONTEXT_V2 constant ) --------- Co-authored-by: roger <[email protected]> Co-authored-by: albalh <[email protected]> Co-authored-by: rubenmodamioin2 <[email protected]> Co-authored-by: Oriol Canadés <[email protected]> Co-authored-by: Oriol Canadés <[email protected]> Co-authored-by: mmirrab <[email protected]>
1 parent 7e5554c commit 789d281

File tree

203 files changed

+8718
-5188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+8718
-5188
lines changed

.github/workflows/release.yml

Lines changed: 102 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Release
2+
23
on:
34
push:
45
branches:
@@ -10,13 +11,18 @@ on:
1011

1112
permissions:
1213
contents: write
14+
packages: write
1315

1416
jobs:
1517
release-snapshot:
1618
if: github.event_name == 'pull_request'
1719
name: Release Snapshot
20+
concurrency:
21+
group: docker-${{ github.head_ref || github.ref_name }}
22+
cancel-in-progress: true
1823
runs-on: ubuntu-latest
1924
steps:
25+
2026
- name: Checkout Repository
2127
uses: actions/checkout@v4
2228

@@ -29,9 +35,17 @@ jobs:
2935
- name: Make Gradlew Executable
3036
run: chmod +x ./gradlew
3137

38+
- name: Get Project Name
39+
id: project_name
40+
run: echo "PROJECT_NAME=$(./gradlew -q properties | grep '^name:' | awk '{print $2}')" >> $GITHUB_ENV
41+
3242
- name: Get Project Version
33-
id: get_version
34-
run: echo "VERSION=$(./gradlew -q printVersion)" >> $GITHUB_ENV
43+
id: project_version
44+
run: echo "VERSION=$(./gradlew -q properties | grep '^version:' | awk '{print $2}')" >> $GITHUB_ENV
45+
46+
- name: Compute PR-based snapshot suffix
47+
if: github.event_name == 'pull_request'
48+
run: echo "SNAPSHOT_SUFFIX=-pr-${{ github.event.number }}" >> $GITHUB_ENV
3549

3650
- name: Check for existing release tag (only on PR)
3751
if: github.event_name == 'pull_request'
@@ -47,19 +61,45 @@ jobs:
4761
echo "No existing release with tag v$VERSION found. Proceeding with build."
4862
fi
4963
50-
- name: Build and Push docker image
51-
run: |
52-
PROJECT_NAME=$(./gradlew -q printProjectName)
53-
IMAGE_TAG="$PROJECT_NAME:v$VERSION$SUFFIX"
54-
docker build --file Dockerfile --build-arg SKIP_TESTS=true --tag $DOCKER_HUB_CLIENT_NAME/$IMAGE_TAG .
55-
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
56-
docker push $DOCKER_HUB_CLIENT_NAME/$IMAGE_TAG
64+
# Logins
65+
- name: Login to Docker Hub
66+
uses: docker/login-action@v3
67+
with:
68+
username: ${{ secrets.DOCKERHUB_USERNAME }}
69+
password: ${{ secrets.DOCKERHUB_PAT }}
70+
71+
- name: Configure AWS credentials
72+
uses: aws-actions/configure-aws-credentials@v4
73+
with:
74+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
75+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
76+
aws-region: ${{ secrets.AWS_REGION }}
77+
78+
- name: Login to Amazon ECR
79+
id: ecr
80+
uses: aws-actions/amazon-ecr-login@v2
81+
82+
- name: Build and Push docker image (DockerHub + ECR)
5783
env:
84+
PROJECT_NAME: ${{ env.PROJECT_NAME }}
5885
VERSION: ${{ env.VERSION }}
59-
SUFFIX: -snapshot
60-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
61-
DOCKER_PASSWORD: ${{ secrets.DOCKER_TOKEN }}
62-
DOCKER_HUB_CLIENT_NAME: in2workspace
86+
SNAPSHOT_SUFFIX: ${{ env.SNAPSHOT_SUFFIX }}
87+
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
88+
ECR_REGISTRY: ${{ steps.ecr.outputs.registry }}
89+
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
90+
run: |
91+
set -euo pipefail
92+
TAG="v${VERSION}${SNAPSHOT_SUFFIX}"
93+
94+
DH_IMAGE="docker.io/${DOCKERHUB_ORG}/${PROJECT_NAME}:${TAG}"
95+
ECR_IMAGE="${ECR_REGISTRY}/${ECR_REPOSITORY}:${TAG}"
96+
97+
docker build -f Dockerfile --build-arg SKIP_TESTS=true -t "${DH_IMAGE}" .
98+
docker tag "${DH_IMAGE}" "${ECR_IMAGE}"
99+
100+
docker push "${DH_IMAGE}"
101+
102+
docker push "${ECR_IMAGE}"
63103
64104
release:
65105
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
@@ -78,9 +118,13 @@ jobs:
78118
- name: Make Gradlew Executable
79119
run: chmod +x ./gradlew
80120

121+
- name: Get Project Name
122+
id: project_name
123+
run: echo "PROJECT_NAME=$(./gradlew -q properties | grep '^name:' | awk '{print $2}')" >> $GITHUB_ENV
124+
81125
- name: Get Project Version
82-
id: get_version
83-
run: echo "VERSION=$(./gradlew -q printVersion)" >> $GITHUB_ENV
126+
id: project_version
127+
run: echo "VERSION=$(./gradlew -q properties | grep '^version:' | awk '{print $2}')" >> $GITHUB_ENV
84128

85129
- name: Check for existing release tag (only on PR)
86130
if: github.event_name == 'pull_request'
@@ -96,18 +140,51 @@ jobs:
96140
echo "No existing release with tag v$VERSION found. Proceeding with build."
97141
fi
98142
99-
- name: Build and Push docker image
100-
run: |
101-
PROJECT_NAME=$(./gradlew -q printProjectName)
102-
IMAGE_TAG="$PROJECT_NAME:v$VERSION"
103-
docker build --file Dockerfile --build-arg SKIP_TESTS=true --tag $DOCKER_HUB_CLIENT_NAME/$IMAGE_TAG .
104-
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
105-
docker push $DOCKER_HUB_CLIENT_NAME/$IMAGE_TAG
143+
# Logins
144+
- name: Login to Docker Hub
145+
uses: docker/login-action@v3
146+
with:
147+
username: ${{ secrets.DOCKERHUB_USERNAME }}
148+
password: ${{ secrets.DOCKERHUB_PAT }}
149+
150+
- name: Configure AWS credentials
151+
uses: aws-actions/configure-aws-credentials@v4
152+
with:
153+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
154+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
155+
aws-region: ${{ secrets.AWS_REGION }}
156+
157+
- name: Login to Amazon ECR
158+
id: ecr
159+
uses: aws-actions/amazon-ecr-login@v2
160+
161+
- name: Build and Push docker image (DockerHub + ECR)
106162
env:
163+
PROJECT_NAME: ${{ env.PROJECT_NAME }}
107164
VERSION: ${{ env.VERSION }}
108-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
109-
DOCKER_PASSWORD: ${{ secrets.DOCKER_TOKEN }}
110-
DOCKER_HUB_CLIENT_NAME: in2workspace
165+
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
166+
ECR_REGISTRY: ${{ steps.ecr.outputs.registry }}
167+
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
168+
run: |
169+
set -euo pipefail
170+
TAG="v${VERSION}"
171+
172+
DH_IMAGE="docker.io/${DOCKERHUB_ORG}/${PROJECT_NAME}:${TAG}"
173+
DH_LATEST="docker.io/${DOCKERHUB_ORG}/${PROJECT_NAME}:latest"
174+
175+
ECR_IMAGE="${ECR_REGISTRY}/${ECR_REPOSITORY}:${TAG}"
176+
ECR_LATEST="${ECR_REGISTRY}/${ECR_REPOSITORY}:latest"
177+
178+
docker build -f Dockerfile --build-arg SKIP_TESTS=true -t "${DH_IMAGE}" .
179+
docker tag "${DH_IMAGE}" "${DH_LATEST}"
180+
docker tag "${DH_IMAGE}" "${ECR_IMAGE}"
181+
docker tag "${DH_IMAGE}" "${ECR_LATEST}"
182+
183+
docker push "${DH_IMAGE}"
184+
docker push "${DH_LATEST}"
185+
186+
docker push "${ECR_IMAGE}"
187+
docker push "${ECR_LATEST}"
111188
112189
- name: Create GitHub Release
113190
uses: actions/create-release@v1

CHANGELOG.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,24 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [v1.7.1](https://github.com/in2workspace/in2-issuer-api/releases/tag/v1.7.1)Add commentMore actions
8-
### Fixed
9-
- Assign always default config. email to Issuer.
7+
## [v2.0.0](https://github.com/in2workspace/in2-issuer-api/releases/tag/v2.0.0)
8+
### Added
9+
- Label credential issuance.
10+
- LEARCredentialMachine issuance.
11+
- Sign access request.
12+
- Revocation endpoint.
13+
- Revoke and expired credential notification.
14+
- Handle error when sending PIN and when serializing credential.
15+
- Handle errors in security chains flow.
16+
17+
### Changed
18+
- Adapt endpoints to oid4vci.
19+
- Refactor SecurityConfig credential issuer filters.
20+
- Standardize error handling to RFC 7807 across all endpoints.
21+
- Move GlobalExceptionHandler to shared module and add specific ControllerAdvice for each domain.
22+
- Remove unused exceptions.
23+
24+
1025

1126
## [v1.7.0](https://github.com/in2workspace/in2-issuer-api/releases/tag/v1.7.0)
1227
### Added

build.gradle

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ plugins {
1111
}
1212

1313
group = 'es.in2'
14-
version = '1.7.1'
14+
15+
version = '2.0.0'
1516

1617
java {
1718
sourceCompatibility = '17'
@@ -197,18 +198,6 @@ tasks.jacocoTestReport {
197198
}))
198199
}
199200

200-
tasks.register('printVersion') {
201-
doLast {
202-
println version
203-
}
204-
}
205-
206-
tasks.register('printProjectName') {
207-
doLast {
208-
println rootProject.name
209-
}
210-
}
211-
212201
def isNonStable = { String version ->
213202
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
214203
def regex = /^[0-9,.v-]+(-r)?$/
@@ -219,4 +208,4 @@ tasks.named("dependencyUpdates").configure {
219208
rejectVersionIf {
220209
isNonStable(it.candidate.version)
221210
}
222-
}
211+
}

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'in2-issuer-backend'
1+
rootProject.name = 'eudistack-issuer-api'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package es.in2.issuer.backend.backoffice.application.workflow;
2+
3+
import reactor.core.publisher.Flux;
4+
import reactor.core.publisher.Mono;
5+
6+
public interface CredentialStatusWorkflow {
7+
Flux<String> getCredentialsByListId(String processId, int listId);
8+
9+
Mono<Void> revokeCredential(String processId, String bearerToken, String credentialId, int listId);
10+
}

src/main/java/es/in2/issuer/backend/backoffice/application/workflow/impl/ActivationCodeWorkflowImpl.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,14 @@ private Mono<CredentialOfferUriResponse> buildCredentialOfferUriInternal(String
4848
transactionCode,
4949
preAuthorizedCodeResponse.grants().preAuthorizedCode()
5050
)
51-
.then(
52-
credentialProcedureService.getMandateeEmailFromDecodedCredentialByProcedureId(procedureId)
53-
)
54-
.flatMap(email ->
55-
credentialOfferService.buildCustomCredentialOffer(
56-
credentialProcedure.getCredentialType(),
57-
preAuthorizedCodeResponse.grants(),
58-
email,
59-
preAuthorizedCodeResponse.pin()
60-
)
61-
.flatMap(credentialOfferCacheRepository::saveCustomCredentialOffer)
62-
.flatMap(credentialOfferService::createCredentialOfferUriResponse)
63-
)
51+
.then(Mono.defer(() -> credentialOfferService.buildCustomCredentialOffer(
52+
credentialProcedure.getCredentialType(),
53+
preAuthorizedCodeResponse.grants(),
54+
credentialProcedure.getOwnerEmail(),
55+
preAuthorizedCodeResponse.pin()
56+
)
57+
.flatMap(credentialOfferCacheRepository::saveCustomCredentialOffer)
58+
.flatMap(credentialOfferService::createCredentialOfferUriResponse)))
6459
)
6560
.flatMap(credentialOfferUri ->
6661
deferredCredentialMetadataService.updateCacheStoreForCTransactionCode(transactionCode)
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package es.in2.issuer.backend.backoffice.application.workflow.impl;
2+
3+
import com.fasterxml.jackson.core.JsonParseException;
4+
import com.fasterxml.jackson.core.JsonProcessingException;
5+
import com.fasterxml.jackson.databind.JsonNode;
6+
import com.fasterxml.jackson.databind.ObjectMapper;
7+
import es.in2.issuer.backend.backoffice.application.workflow.CredentialStatusWorkflow;
8+
import es.in2.issuer.backend.backoffice.domain.service.CredentialStatusAuthorizationService;
9+
import es.in2.issuer.backend.backoffice.domain.service.CredentialStatusService;
10+
import es.in2.issuer.backend.backoffice.domain.exception.InvalidStatusException;
11+
import es.in2.issuer.backend.shared.domain.model.dto.credential.CredentialStatus;
12+
import es.in2.issuer.backend.shared.domain.model.entities.CredentialProcedure;
13+
import es.in2.issuer.backend.shared.domain.model.enums.CredentialStatusEnum;
14+
import es.in2.issuer.backend.shared.domain.service.AccessTokenService;
15+
import es.in2.issuer.backend.shared.domain.service.CredentialProcedureService;
16+
import es.in2.issuer.backend.shared.domain.service.EmailService;
17+
import lombok.RequiredArgsConstructor;
18+
import lombok.extern.slf4j.Slf4j;
19+
import org.springframework.stereotype.Service;
20+
import reactor.core.publisher.Flux;
21+
import reactor.core.publisher.Mono;
22+
23+
import static es.in2.issuer.backend.shared.domain.model.enums.CredentialStatusEnum.*;
24+
25+
26+
@Slf4j
27+
@Service
28+
@RequiredArgsConstructor
29+
public class CredentialStatusWorkflowImpl implements CredentialStatusWorkflow {
30+
31+
private final CredentialStatusService credentialStatusService;
32+
private final AccessTokenService accessTokenService;
33+
private final CredentialStatusAuthorizationService credentialStatusAuthorizationService;
34+
private final CredentialProcedureService credentialProcedureService;
35+
private final ObjectMapper objectMapper;
36+
private final EmailService emailService;
37+
38+
@Override
39+
public Flux<String> getCredentialsByListId(String processId, int listId) {
40+
return credentialStatusService.getCredentialsByListId(listId)
41+
.doFirst(() -> log.debug("Process ID: {} - Getting Credentials Status...", processId))
42+
.doOnComplete(() -> log.debug(
43+
"Process ID: {} - All Credential Status retrieved successfully.",
44+
processId));
45+
}
46+
47+
@Override
48+
public Mono<Void> revokeCredential(String processId, String bearerToken, String credentialId, int listId) {
49+
return accessTokenService.getCleanBearerToken(bearerToken)
50+
.flatMap(token -> credentialStatusAuthorizationService.authorize(processId, token, credentialId)
51+
.then(credentialProcedureService.getCredentialByCredentialId(credentialId))
52+
)
53+
.flatMap(credential -> validateStatus(credential.getCredentialStatus())
54+
.thenReturn(credential)
55+
)
56+
.flatMap(credential -> Mono.just(credential.getCredentialDecoded())
57+
.flatMap(decodedCredential -> {
58+
JsonNode credentialStatusNode;
59+
try {
60+
credentialStatusNode = objectMapper.readTree(decodedCredential).get("credentialStatus");
61+
} catch (JsonProcessingException e) {
62+
return Mono.error(new JsonParseException("Error processing credential status json"));
63+
}
64+
CredentialStatus credentialStatus = mapToCredentialStatus(credentialStatusNode);
65+
return revokeAndUpdateCredentialStatus(credential, processId, credentialId, listId, credentialStatus);
66+
}));
67+
68+
}
69+
private CredentialStatus mapToCredentialStatus(JsonNode credentialStatusNode) {
70+
return CredentialStatus.builder()
71+
.id(credentialStatusNode.get("id").asText())
72+
.type(credentialStatusNode.get("type").asText())
73+
.statusPurpose(credentialStatusNode.get("statusPurpose").asText())
74+
.statusListIndex(credentialStatusNode.get("statusListIndex").asText())
75+
.statusListCredential(credentialStatusNode.get("statusListCredential").asText())
76+
.build();
77+
}
78+
79+
private Mono<Void> revokeAndUpdateCredentialStatus(CredentialProcedure credentialProcedure, String processId, String credentialId, int listId, CredentialStatus credentialStatus) {
80+
return credentialStatusService.revokeCredential(listId, credentialStatus)
81+
.then(credentialProcedureService.updateCredentialProcedureCredentialStatusToRevoke(credentialProcedure))
82+
.doFirst(() -> log.debug(
83+
"Process ID: {} - Revoking Credential with ID: {}",
84+
processId,
85+
credentialId))
86+
.then(emailService.notifyIfCredentialStatusChanges(credentialProcedure, REVOKED.toString()))
87+
.doOnSuccess(
88+
aVoid -> log.debug(
89+
"Process ID: {} - Credential with ID: {} revoked successfully.",
90+
processId,
91+
credentialId));
92+
}
93+
94+
private Mono<Void> validateStatus(CredentialStatusEnum credentialStatus) {
95+
if (credentialStatus.equals(CredentialStatusEnum.VALID)) {
96+
return Mono.empty();
97+
} else {
98+
return Mono.error(new InvalidStatusException(
99+
"Invalid status: " + credentialStatus));
100+
}
101+
}
102+
}

src/main/java/es/in2/issuer/backend/backoffice/domain/exception/CreateDateException.java

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)