Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development to master #192

Merged
merged 7 commits into from
Apr 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class StringPool {
public static final String ACTION = "action";
public static final String SUBTYPE = "subType";
public static final String JSON_EXTENSION = ".json";
public static final String AGGREGATION_OF = "gx:aggregationOf";
public static final String AGGREGATION_OF = "gx:aggregationOfExists";
public static final String DEPENDS_ON = "gx:dependsOn";

public static final String CUSTOM_ATTRIBUTE = "gx:customAttribute";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ private void validateAggregationOf(CreateServiceOfferingRequest request) throws
}
JsonNode jsonNode = this.objectMapper.readTree(this.objectMapper.writeValueAsString(request.getCredentialSubject()));

JsonNode aggregationOfArray = jsonNode.at("/gx:aggregationOf");
JsonNode aggregationOfArray = jsonNode.at("/gx:aggregationOfExists");

List<String> ids = new ArrayList<>();
aggregationOfArray.forEach(item -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ private Map<String, Object> prepareCredentialSubjectForLegalParticipant(Particip
//Add @context in the credential
legalParticipant.put(CONTEXT, this.contextConfig.participant());
legalParticipant.put(TYPE, List.of(VERIFIABLE_CREDENTIAL));
legalParticipant.put(ID, participant.getDid());
String participantJsonUrl = this.formParticipantJsonUrl(participant.getDomain(), participant.getId());
legalParticipant.put(ID, participantJsonUrl + "#0");
legalParticipant.put(ISSUER, participant.getDid());
String issuanceDate = LocalDateTime.now().atZone(ZoneOffset.UTC).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
legalParticipant.put(ISSUANCE_DATE, issuanceDate);

Map<String, Object> participantCredentialSubject = this.mapper.convertValue(legalParticipant.get(CREDENTIAL_SUBJECT), typeReference);
String participantJsonUrl = this.formParticipantJsonUrl(participant.getDomain(), participant.getId());
participantCredentialSubject.put(ID, participantJsonUrl + "#0");
participantCredentialSubject.put(TYPE, GX_LEGAL_PARTICIPANT);
String registrationId = participantJsonUrl + "#1";
Expand All @@ -147,7 +147,7 @@ private Map<String, Object> prepareCredentialSubjectForLegalParticipant(Particip
Map<String, Object> tncVc = new TreeMap<>();
tncVc.put(CONTEXT, this.contextConfig.tnc());
tncVc.put(TYPE, List.of(VERIFIABLE_CREDENTIAL));
tncVc.put(ID, participant.getDid());
tncVc.put(ID, participantJsonUrl + "#2");
tncVc.put(ISSUER, participant.getDid());
tncVc.put(ISSUANCE_DATE, issuanceDate);

Expand All @@ -173,6 +173,13 @@ private String formParticipantJsonUrl(String domain, UUID participantId) {
return this.wizardHost + participantId.toString() + "/" + PARTICIPANT_JSON;
}

private String formServiceOfferingJsonUrl(String domain, UUID participantId, String name) {
if (StringUtils.hasText(domain)) {
return "https://" + domain + "/" + participantId.toString() + "/" + name + JSON_EXTENSION;
}
return this.wizardHost + participantId.toString() + "/" + name + JSON_EXTENSION;
}

public void createSignedLegalParticipant(Participant participant, String issuer, String verificationMethod, String key, boolean ownDid) {
log.info("SignerService(createParticipantJson) -> Initiate the legal participate creation process for participant {}, ownDid {}", participant.getId(), ownDid);
File file = new File(TEMP_FOLDER + "participant.json");
Expand Down Expand Up @@ -274,7 +281,7 @@ private void createParticipantCreationJob(Participant participant) {

public Map<String, String> signService(Participant participant, CreateServiceOfferingRequest request, String name) {
Map<String, String> response = new HashMap<>();
String id = this.wizardHost + participant.getId() + "/" + name + JSON_EXTENSION;
String id = formServiceOfferingJsonUrl(participant.getDomain(), participant.getId(), name);
Map<String, Object> providedBy = new HashMap<>();
providedBy.put(ID, request.getParticipantJsonUrl());
request.getCredentialSubject().put("gx:providedBy", providedBy);
Expand All @@ -288,7 +295,7 @@ public Map<String, String> signService(Participant participant, CreateServiceOff
.serviceOffering(VerifiableCredential.ServiceOffering.builder()
.context(this.contextConfig.serviceOffer())
.type(StringPool.VERIFIABLE_CREDENTIAL)
.id(participant.getDid())
.id(id)
.issuer(participant.getDid())
.issuanceDate(issuanceDate)
.credentialSubject(request.getCredentialSubject())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class ResourceController extends BaseController {
{"id":"https://wizard-api.smart-x.smartsenselabs.com/12081064-8878-477e-8092-564a240c69e2/participant.json" }
],
"gx:license": [ "http://smartproof.in/.well-known/license"],
"gx:aggregationOf": [{"id":"https://wizard-api.smart-x.smartsenselabs.com/12081064-8878-477e-8092-564a240c69e2/resource_b5b7e6b0-ae24-4458-b3f9-27572abc39e7.json"}],
"gx:aggregationOfExists": [{"id":"https://wizard-api.smart-x.smartsenselabs.com/12081064-8878-477e-8092-564a240c69e2/resource_b5b7e6b0-ae24-4458-b3f9-27572abc39e7.json"}],
"gx:customAttribute": "https://docs.gaia-x.eu/technical-committee/policy-rules-committee/trust-framework/latest/resource/"
}

Expand Down Expand Up @@ -188,7 +188,7 @@ public CommonResponse<Resource> createResource(@PathVariable(StringPool.PARTICIP
{"id":"https://wizard-api.smart-x.smartsenselabs.com/12081064-8878-477e-8092-564a240c69e2/participant.json" }
],
"gx:license": [ "http://smartproof.in/.well-known/license"],
"gx:aggregationOf": [{"id":"https://wizard-api.smart-x.smartsenselabs.com/12081064-8878-477e-8092-564a240c69e2/resource_b5b7e6b0-ae24-4458-b3f9-27572abc39e7.json"}],
"gx:aggregationOfExists": [{"id":"https://wizard-api.smart-x.smartsenselabs.com/12081064-8878-477e-8092-564a240c69e2/resource_b5b7e6b0-ae24-4458-b3f9-27572abc39e7.json"}],
"gx:customAttribute": "https://docs.gaia-x.eu/technical-committee/policy-rules-committee/trust-framework/latest/resource/"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class ServiceOfferController extends BaseController {
"gx:accessType": "physical",
"gx:formatType": "pdf"
},
"gx:aggregationOf": [
"gx:aggregationOfExists": [
{
"id": "https://exmaple.com/12081064-8878-477e-8092-564a240c69e2/resource_9a40cafd-43ed-41b0-a53e-4e2af164fde5.json"
}
Expand Down Expand Up @@ -769,7 +769,7 @@ public class ServiceOfferController extends BaseController {
"gx:accessType": "physical",
"gx:formatType": "pdf"
},
"gx:aggregationOf": [
"gx:aggregationOfExists": [
{
"id": "https://example.com/125/resource_9a40cafd-43ed-41b0-a53e-4e2af164fde5.json"
}
Expand Down Expand Up @@ -822,7 +822,7 @@ public class ServiceOfferController extends BaseController {
"gx:accessType": "physical",
"gx:formatType": "pdf"
},
"gx:aggregationOf": [
"gx:aggregationOfExists": [
{
"id": "https://example.com/125/resource_86e8a7a9-c341-4049-abc7-dcf20e1736fe.json"
}
Expand Down Expand Up @@ -957,7 +957,7 @@ public CommonResponse<ServiceOfferResponse> createServiceOffering(@Valid @Reques
"gx:accessType": "physical",
"gx:formatType": "pdf"
},
"gx:aggregationOf": [
"gx:aggregationOfExists": [
{
"id": "https://exmaple.com/12081064-8878-477e-8092-564a240c69e2/resource_9a40cafd-43ed-41b0-a53e-4e2af164fde5.json"
}
Expand Down Expand Up @@ -1038,7 +1038,7 @@ public void validateServiceOfferRequest(@Valid @RequestBody CreateServiceOfferin
"gx:accessType": "physical",
"gx:formatType": "pdf"
},
"gx:aggregationOf": [
"gx:aggregationOfExists": [
{
"id": "https://exmaple.com/12081064-8878-477e-8092-564a240c69e2/resource_9a40cafd-43ed-41b0-a53e-4e2af164fde5.json"
}
Expand Down Expand Up @@ -1748,7 +1748,7 @@ public void validateServiceOfferRequest(@Valid @RequestBody CreateServiceOfferin
"gx:accessType": "physical",
"gx:formatType": "pdf"
},
"gx:aggregationOf": [
"gx:aggregationOfExists": [
{
"id": "https://example.com/125/resource_9a40cafd-43ed-41b0-a53e-4e2af164fde5.json"
}
Expand Down Expand Up @@ -1801,7 +1801,7 @@ public void validateServiceOfferRequest(@Valid @RequestBody CreateServiceOfferin
"gx:accessType": "physical",
"gx:formatType": "pdf"
},
"gx:aggregationOf": [
"gx:aggregationOfExists": [
{
"id": "https://example.com/125/resource_86e8a7a9-c341-4049-abc7-dcf20e1736fe.json"
}
Expand Down
Loading
Loading