Skip to content

Commit 9c0fca0

Browse files
authored
Hotfix/expiration date in credentials schema (#48)
* Update pipeline * Update LEARCredentialEmployee Data Model * Update build.gradle * Update pipeline
1 parent 3f0ac5d commit 9c0fca0

File tree

11 files changed

+125
-196
lines changed

11 files changed

+125
-196
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ on:
33
push:
44
branches:
55
- main
6-
- hotfix/*
76
pull_request:
87
branches:
98
- main

.github/workflows/release.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,24 @@ jobs:
2929
- name: Make Gradlew Executable
3030
run: chmod +x ./gradlew
3131

32+
- name: Get Project Version
33+
id: get_version
34+
run: echo "VERSION=$(./gradlew -q printVersion)" >> $GITHUB_ENV
35+
3236
- name: Build and Push docker image
3337
run: |
34-
./gradlew printVersion
3538
./gradlew printProjectName
36-
VERSION=$(./gradlew -q printVersion)
3739
PROJECT_NAME=$(./gradlew -q printProjectName)
3840
IMAGE_TAG="$PROJECT_NAME:v$VERSION$SUFFIX"
3941
docker build --file Dockerfile --build-arg SKIP_TESTS=true --tag $DOCKER_HUB_CLIENT_NAME/$IMAGE_TAG .
4042
echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
4143
docker push $DOCKER_HUB_CLIENT_NAME/$IMAGE_TAG
4244
env:
45+
VERSION: ${{ env.VERSION }}
46+
SUFFIX: -snapshot
4347
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
4448
DOCKER_PASSWORD: ${{ secrets.DOCKER_TOKEN }}
4549
DOCKER_HUB_CLIENT_NAME: in2workspace
46-
SUFFIX: -snapshot
4750

4851
release:
4952
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
@@ -90,4 +93,4 @@ jobs:
9093
release_name: "v${{ env.VERSION }}"
9194
body: "Release of version v${{ env.VERSION }}"
9295
draft: false
93-
prerelease: true
96+
prerelease: false

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ 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.1.1](https://github.com/in2workspace/in2-issuer-api/releases/tag/v1.1.1)
8+
### Fixed
9+
- Fixed LEARCredentialEmployee data model. Implement W3C DATA model v2.0 (validFrom, validUntil).
10+
711
## v1.1.0
812
### Added
913
- LEARCredentialEmployee issuance in a synchronous way.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
}
1212

1313
group = 'es.in2'
14-
version = '1.1.0'
14+
version = '1.1.1'
1515

1616
java {
1717
sourceCompatibility = '17'

src/main/java/es/in2/issuer/application/workflow/impl/VerifiableCredentialIssuanceWorkflowImpl.java

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
@RequiredArgsConstructor
2525
public class VerifiableCredentialIssuanceWorkflowImpl implements VerifiableCredentialIssuanceWorkflow {
2626

27-
2827
private final RemoteSignatureService remoteSignatureService;
2928
private final VerifiableCredentialService verifiableCredentialService;
3029
private final AppConfig appConfig;
@@ -35,7 +34,6 @@ public class VerifiableCredentialIssuanceWorkflowImpl implements VerifiableCrede
3534
private final TrustFrameworkService trustFrameworkService;
3635
private final LEARCredentialEmployeeFactory credentialEmployeeFactory;
3736

38-
3937
@Override
4038
public Mono<Void> completeIssuanceCredentialProcess(String processId, String type, IssuanceRequest issuanceRequest) {
4139
return verifiableCredentialService.generateVc(processId, type, issuanceRequest)
@@ -47,11 +45,9 @@ public Mono<Void> completeIssuanceCredentialProcess(String processId, String typ
4745
}
4846

4947
@Override
50-
public Mono<VerifiableCredentialResponse> generateVerifiableCredentialResponse(
51-
String processId,
52-
CredentialRequest credentialRequest,
53-
String token
54-
) {
48+
public Mono<VerifiableCredentialResponse> generateVerifiableCredentialResponse(String processId,
49+
CredentialRequest credentialRequest,
50+
String token) {
5551
try {
5652
JWSObject jwsObject = JWSObject.parse(token);
5753
String authServerNonce = jwsObject.getPayload().toJSONObject().get("jti").toString();
@@ -65,32 +61,32 @@ public Mono<VerifiableCredentialResponse> generateVerifiableCredentialResponse(
6561
}
6662
})
6763
.flatMap(subjectDid ->
68-
deferredCredentialMetadataService.getOperationModeByAuthServerNonce(authServerNonce)
69-
.flatMap(operationMode ->
70-
verifiableCredentialService.buildCredentialResponse(processId, subjectDid, authServerNonce, credentialRequest.format(), token, operationMode)
71-
.flatMap(credentialResponse -> {
72-
if (operationMode.equals(ASYNC)) {
73-
return deferredCredentialMetadataService.getProcedureIdByAuthServerNonce(authServerNonce)
74-
.flatMap(credentialProcedureService::getSignerEmailFromDecodedCredentialByProcedureId)
75-
.flatMap(email ->
76-
emailService.sendPendingCredentialNotification(email, "Pending Credential")
77-
.then(Mono.just(credentialResponse))
78-
);
79-
} else if (operationMode.equals(SYNC)) {
80-
return deferredCredentialMetadataService.getProcedureIdByAuthServerNonce(authServerNonce)
81-
.flatMap(id -> credentialProcedureService.updateCredentialProcedureCredentialStatusToValidByProcedureId(id)
82-
.then(credentialProcedureService.getDecodedCredentialByProcedureId(id)
83-
.flatMap(decodedCredential -> processDecodedCredential(processId,decodedCredential))
84-
)
85-
)
86-
.then(deferredCredentialMetadataService.deleteDeferredCredentialMetadataByAuthServerNonce(authServerNonce))
87-
.then(Mono.just(credentialResponse));
88-
} else {
89-
return Mono.error(new IllegalArgumentException("Unknown operation mode: " + operationMode));
90-
}
64+
deferredCredentialMetadataService.getOperationModeByAuthServerNonce(authServerNonce)
65+
.flatMap(operationMode ->
66+
verifiableCredentialService.buildCredentialResponse(processId, subjectDid, authServerNonce, credentialRequest.format(), token, operationMode)
67+
.flatMap(credentialResponse -> {
68+
if (operationMode.equals(ASYNC)) {
69+
return deferredCredentialMetadataService.getProcedureIdByAuthServerNonce(authServerNonce)
70+
.flatMap(credentialProcedureService::getSignerEmailFromDecodedCredentialByProcedureId)
71+
.flatMap(email ->
72+
emailService.sendPendingCredentialNotification(email, "Pending Credential")
73+
.then(Mono.just(credentialResponse))
74+
);
75+
} else if (operationMode.equals(SYNC)) {
76+
return deferredCredentialMetadataService.getProcedureIdByAuthServerNonce(authServerNonce)
77+
.flatMap(id -> credentialProcedureService.updateCredentialProcedureCredentialStatusToValidByProcedureId(id)
78+
.then(credentialProcedureService.getDecodedCredentialByProcedureId(id)
79+
.flatMap(decodedCredential -> processDecodedCredential(processId, decodedCredential))
80+
)
81+
)
82+
.then(deferredCredentialMetadataService.deleteDeferredCredentialMetadataByAuthServerNonce(authServerNonce))
83+
.then(Mono.just(credentialResponse));
84+
} else {
85+
return Mono.error(new IllegalArgumentException("Unknown operation mode: " + operationMode));
9186
}
92-
)
93-
)
87+
}
88+
)
89+
)
9490
);
9591
} catch (ParseException e) {
9692
log.error("Error parsing the accessToken", e);
@@ -126,18 +122,6 @@ public Mono<VerifiableCredentialResponse> generateVerifiableCredentialDeferredRe
126122
@Override
127123
public Mono<Void> signDeferredCredential(String unsignedCredential, String userId, UUID credentialId, String token) {
128124
return null;
129-
// return verifiableCredentialService.generateDeferredCredentialResponse(unsignedCredential)
130-
// .flatMap(vcPayload -> {
131-
// SignatureRequest signatureRequest = SignatureRequest.builder()
132-
// .configuration(SignatureConfiguration.builder().type(SignatureType.JADES).parameters(Collections.emptyMap()).build())
133-
// .data(vcPayload)
134-
// .build();
135-
// return remoteSignatureService.sign(signatureRequest, token)
136-
// .publishOn(Schedulers.boundedElastic())
137-
// .map(SignedData::data);
138-
// })
139-
// .flatMap(signedCredential -> credentialManagementService.updateCredential(signedCredential, credentialId, userId))
140-
// .onErrorResume(e -> Mono.error(new RuntimeException("Failed to sign and update the credential.", e)));
141125
}
142126

143127
private Mono<String> extractDidFromJwtProof(String jwtProof) {
@@ -157,18 +141,18 @@ private Mono<Void> processDecodedCredential(String processId, String decodedCred
157141
LEARCredentialEmployeeJwtPayload learCredentialEmployeeJwtPayload = credentialEmployeeFactory.mapStringToLEARCredentialEmployee(decodedCredential);
158142

159143
String signerOrgIdentifier = learCredentialEmployeeJwtPayload.learCredentialEmployee().credentialSubject().mandate().signer().organizationIdentifier();
160-
if (signerOrgIdentifier == null || signerOrgIdentifier.isBlank() ){
144+
if (signerOrgIdentifier == null || signerOrgIdentifier.isBlank()) {
161145
log.error("ProcessID: {} Signer Organization Identifier connot be null or empty", processId);
162146
return Mono.error(new IllegalArgumentException("Organization Identifier not valid"));
163147
}
164148

165149
String mandatorOrgIdentifier = learCredentialEmployeeJwtPayload.learCredentialEmployee().credentialSubject().mandate().mandator().organizationIdentifier();
166-
if (mandatorOrgIdentifier == null || mandatorOrgIdentifier.isBlank() ){
150+
if (mandatorOrgIdentifier == null || mandatorOrgIdentifier.isBlank()) {
167151
log.error("ProcessID: {} Mandator Organization Identifier connot be null or empty", processId);
168152
return Mono.error(new IllegalArgumentException("Organization Identifier not valid"));
169153
}
170154

171-
return saveToTrustFramework(processId,signerOrgIdentifier, mandatorOrgIdentifier);
155+
return saveToTrustFramework(processId, signerOrgIdentifier, mandatorOrgIdentifier);
172156
}
173157

174158
private Mono<Void> saveToTrustFramework(String processId, String signerOrgIdentifier, String mandatorOrgIdentifier) {
@@ -179,7 +163,7 @@ private Mono<Void> saveToTrustFramework(String processId, String signerOrgIdenti
179163
return trustFrameworkService.validateDidFormat(processId, signerDid)
180164
.flatMap(isValid -> registerDidIfValid(processId, signerDid, isValid))
181165
.then(trustFrameworkService.validateDidFormat(processId, mandatorDid)
182-
.flatMap(isValid -> registerDidIfValid(processId, mandatorDid,isValid)));
166+
.flatMap(isValid -> registerDidIfValid(processId, mandatorDid, isValid)));
183167
}
184168

185169
private Mono<Void> registerDidIfValid(String processId, String did, boolean isValid) {

src/main/java/es/in2/issuer/domain/model/dto/LEARCredentialEmployee.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ public record LEARCredentialEmployee(
1111
@JsonProperty("id") String id,
1212
@JsonProperty("type") List<String> type,
1313
@JsonProperty("credentialSubject") CredentialSubject credentialSubject,
14-
@JsonProperty("expirationDate") String expirationDate,
15-
@JsonProperty("issuanceDate") String issuanceDate,
1614
@JsonProperty("issuer") String issuer,
17-
@JsonProperty("validFrom") String validFrom
15+
@JsonProperty("validFrom") String validFrom,
16+
@JsonProperty("validUntil") String validUntil
1817
) {
18+
1919
@Builder
20-
public record CredentialSubject(
21-
@JsonProperty("mandate") Mandate mandate
22-
) {
20+
public record CredentialSubject(@JsonProperty("mandate") Mandate mandate) {
21+
2322
@Builder
2423
public record Mandate(
2524
@JsonProperty("id") String id,
@@ -29,19 +28,24 @@ public record Mandate(
2928
@JsonProperty("power") List<Power> power,
3029
@JsonProperty("signer") Signer signer
3130
) {
31+
3232
@Builder
3333
public record LifeSpan(
3434
@JsonProperty("end_date_time") String endDateTime,
3535
@JsonProperty("start_date_time") String startDateTime
36-
) {}
36+
) {
37+
}
38+
3739
@Builder
3840
public record Mandatee(
3941
@JsonProperty("id") String id,
4042
@JsonProperty("email") String email,
4143
@JsonProperty("first_name") String firstName,
4244
@JsonProperty("last_name") String lastName,
4345
@JsonProperty("mobile_phone") String mobilePhone
44-
) {}
46+
) {
47+
}
48+
4549
@Builder
4650
public record Mandator(
4751
@JsonProperty("commonName") String commonName,
@@ -50,16 +54,18 @@ public record Mandator(
5054
@JsonProperty("organization") String organization,
5155
@JsonProperty("organizationIdentifier") String organizationIdentifier,
5256
@JsonProperty("serialNumber") String serialNumber
53-
) {}
54-
@Builder
57+
) {
58+
}
5559

60+
@Builder
5661
public record Power(
5762
@JsonProperty("id") String id,
5863
@JsonProperty("tmf_action") Object tmfAction,
5964
@JsonProperty("tmf_domain") String tmfDomain,
6065
@JsonProperty("tmf_function") String tmfFunction,
6166
@JsonProperty("tmf_type") String tmfType
62-
) {}
67+
) {
68+
}
6369

6470
@Builder
6571
public record Signer(
@@ -69,10 +75,9 @@ public record Signer(
6975
@JsonProperty("organization") String organization,
7076
@JsonProperty("organizationIdentifier") String organizationIdentifier,
7177
@JsonProperty("serialNumber") String serialNumber
72-
) {}
78+
) {
79+
}
80+
7381
}
7482
}
7583
}
76-
77-
78-

0 commit comments

Comments
 (0)