Skip to content

Commit

Permalink
added issuer APIs (skeletons)
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Jan 17, 2025
1 parent 0c5a5e3 commit 22b0116
Show file tree
Hide file tree
Showing 28 changed files with 337 additions and 166 deletions.
4 changes: 1 addition & 3 deletions dist/bom/issuerservice-base-bom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ dependencies {
runtimeOnly(project(":core:identity-hub-keypairs"))
runtimeOnly(project(":extensions:did:local-did-publisher"))
// API modules
runtimeOnly(project(":extensions:protocols:dcp:credential-request-api"))
runtimeOnly(project(":extensions:protocols:dcp:credential-request-status-api"))
runtimeOnly(project(":extensions:protocols:dcp:issuer-metadata-api"))
runtimeOnly(project(":extensions:protocols:dcp:issuer-api"))

runtimeOnly(project(":extensions:sts:sts-account-provisioner"))
runtimeOnly(libs.edc.identity.did.core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class IssuerService extends SmokeTest {
put("web.http.version.path", "/api/version");
put("web.http.did.port", valueOf(getFreePort()));
put("web.http.did.path", "/api/did");
put("web.http.credential-request.port", valueOf(getFreePort()));
put("web.http.credential-request.path", "/api/issuance");
put("web.http.issuer-api.port", valueOf(getFreePort()));
put("web.http.issuer-api.path", "/api/issuer");
put("edc.sts.account.api.url", "https://sts.com/accounts");
put("edc.sts.accounts.api.auth.header.value", "password");
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ dependencies {

edcBuild {
swagger {
apiGroup.set("credential-request-api")
apiGroup.set("issuer-api")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
*
*/

package org.eclipse.edc.protocols.dcp.credentialrequest;
package org.eclipse.edc.identityhub.protocols.dcp.issuer;

import com.fasterxml.jackson.databind.DeserializationFeature;
import org.eclipse.edc.protocols.dcp.credentialrequest.v1alpha.api.CredentialRequestApiController;
import org.eclipse.edc.identityhub.protocols.dcp.issuer.api.v1alpha.credentialrequest.CredentialRequestApiController;
import org.eclipse.edc.identityhub.protocols.dcp.issuer.api.v1alpha.credentialrequeststatus.CredentialRequestStatusApiController;
import org.eclipse.edc.identityhub.protocols.dcp.issuer.api.v1alpha.issuermetadata.IssuerMetadataApiController;
import org.eclipse.edc.runtime.metamodel.annotation.Configuration;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
Expand All @@ -34,14 +36,14 @@
import java.io.IOException;
import java.util.stream.Stream;

import static org.eclipse.edc.identityhub.spi.webcontext.IdentityHubApiContext.CREDENTIAL_REQUEST;
import static org.eclipse.edc.protocols.dcp.credentialrequest.CredentialRequestApiExtension.NAME;
import static org.eclipse.edc.identityhub.protocols.dcp.issuer.IssuerApiExtension.NAME;
import static org.eclipse.edc.identityhub.spi.webcontext.IdentityHubApiContext.ISSUER_API;

@Extension(value = NAME)
public class CredentialRequestApiExtension implements ServiceExtension {
public static final String NAME = "CredentialRequestApiExtension";
public class IssuerApiExtension implements ServiceExtension {
public static final String NAME = "Issuer API extension";

private static final String API_VERSION_JSON_FILE = "credential-request-api-version.json";
private static final String API_VERSION_JSON_FILE = "issuer-api-version.json";

@Inject
private TypeManager typeManager;
Expand All @@ -58,10 +60,11 @@ public class CredentialRequestApiExtension implements ServiceExtension {
@Override
public void initialize(ServiceExtensionContext context) {

portMappingRegistry.register(new PortMapping(CREDENTIAL_REQUEST, apiConfiguration.port(), apiConfiguration.path()));
portMappingRegistry.register(new PortMapping(ISSUER_API, apiConfiguration.port(), apiConfiguration.path()));

var controller = new CredentialRequestApiController();
webService.registerResource(CREDENTIAL_REQUEST, controller);
webService.registerResource(ISSUER_API, new CredentialRequestApiController());
webService.registerResource(ISSUER_API, new CredentialRequestStatusApiController());
webService.registerResource(ISSUER_API, new IssuerMetadataApiController());

registerVersionInfo(getClass().getClassLoader());
}
Expand All @@ -74,17 +77,17 @@ private void registerVersionInfo(ClassLoader resourceClassLoader) {
Stream.of(typeManager.getMapper()
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
.readValue(versionContent, VersionRecord[].class))
.forEach(vr -> apiVersionService.addRecord("credential-request", vr));
.forEach(vr -> apiVersionService.addRecord("issuer-api", vr));
} catch (IOException e) {
throw new EdcException(e);
}
}

@Settings
record CredentialRequestApiConfiguration(
@Setting(key = "web.http." + CREDENTIAL_REQUEST + ".port", description = "Port for " + CREDENTIAL_REQUEST + " api context", defaultValue = 13132 + "")
@Setting(key = "web.http." + ISSUER_API + ".port", description = "Port for " + ISSUER_API + " api context", defaultValue = 13132 + "")
int port,
@Setting(key = "web.http." + CREDENTIAL_REQUEST + ".path", description = "Path for " + CREDENTIAL_REQUEST + " api context", defaultValue = "/api/issuance")
@Setting(key = "web.http." + ISSUER_API + ".path", description = "Path for " + ISSUER_API + " api context", defaultValue = "/api/issuer")
String path
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocols.dcp.credentialrequest.v1alpha.api;
package org.eclipse.edc.identityhub.protocols.dcp.issuer.api.v1alpha;

import io.swagger.v3.oas.annotations.media.Schema;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocols.dcp.credentialrequest.v1alpha.model;
package org.eclipse.edc.identityhub.protocols.dcp.issuer.api.v1alpha.credentialrequest;

import com.fasterxml.jackson.annotation.JsonProperty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.protocols.dcp.credentialrequest.v1alpha.api;
package org.eclipse.edc.identityhub.protocols.dcp.issuer.api.v1alpha.credentialrequest;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -27,7 +27,7 @@
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.core.Response;
import org.eclipse.edc.protocols.dcp.credentialrequest.v1alpha.model.CredentialRequestMessage;
import org.eclipse.edc.identityhub.protocols.dcp.issuer.api.v1alpha.ApiSchema;

@OpenAPIDefinition(
info = @Info(description = "This represents the Credential Request API as per DCP specification. It serves endpoints to request the issuance of Verifiable Credentials from an issuer.", title = "Credential Request API",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
*
*/

package org.eclipse.edc.protocols.dcp.credentialrequest.v1alpha.api;
package org.eclipse.edc.identityhub.protocols.dcp.issuer.api.v1alpha.credentialrequest;

import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Response;
import org.eclipse.edc.protocols.dcp.credentialrequest.v1alpha.model.CredentialRequestMessage;

import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON;

Expand All @@ -32,6 +31,6 @@ public class CredentialRequestApiController implements CredentialRequestApi {
@Path("/")
@Override
public Response requestCredential(CredentialRequestMessage message) {
return null;
return Response.noContent().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
*
*/

package org.eclipse.edc.protocols.dcp.credentialrequest.v1alpha.model;
package org.eclipse.edc.identityhub.protocols.dcp.issuer.api.v1alpha.credentialrequest;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

Expand Down Expand Up @@ -50,6 +51,7 @@ private Builder() {
instance = new CredentialRequestMessage();
}

@JsonCreator
public static Builder newInstance() {
return new Builder();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2025 Cofinity-X
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Cofinity-X - initial API and implementation
*
*/

package org.eclipse.edc.identityhub.protocols.dcp.issuer.api.v1alpha.credentialrequeststatus;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@JsonDeserialize(builder = CredentialRequestStatus.Builder.class)
public class CredentialRequestStatus {
private List<String> messages = new ArrayList<>();
private String requestStatus; //todo: change this to an enum later
private Instant timestamp;
private String requestId;

private CredentialRequestStatus() {
}

public List<String> getMessages() {
return messages;
}

public String getRequestStatus() {
return requestStatus;
}

public Instant getTimestamp() {
return timestamp;
}

public String getRequestId() {
return requestId;
}

@JsonPOJOBuilder(withPrefix = "")
public static final class Builder {
private final CredentialRequestStatus credentialRequestStatus;

private Builder() {
credentialRequestStatus = new CredentialRequestStatus();
}

@JsonCreator
public static Builder newInstance() {
return new Builder();
}

public Builder requestStatus(String requestStatus) {
this.credentialRequestStatus.requestStatus = requestStatus;
return this;
}

public Builder timestamp(Instant timestamp) {
this.credentialRequestStatus.timestamp = timestamp;
return this;
}

public Builder requestId(String requestId) {
this.credentialRequestStatus.requestId = requestId;
return this;
}

public Builder messages(List<String> messages) {
this.credentialRequestStatus.messages = messages;
return this;
}

public Builder message(String message) {
this.credentialRequestStatus.messages.add(message);
return this;
}

public CredentialRequestStatus build() {
Objects.requireNonNull(credentialRequestStatus.requestId, "requestId");
Objects.requireNonNull(credentialRequestStatus.timestamp, "timestamp");
Objects.requireNonNull(credentialRequestStatus.requestStatus, "requestStatus");
return credentialRequestStatus;
}
}
}
Loading

0 comments on commit 22b0116

Please sign in to comment.