Skip to content

Commit

Permalink
introduce new 'identity' api context instead of 'management'
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Jun 4, 2024
1 parent f6b43d5 commit 46cd536
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

package org.eclipse.edc.identityhub.publickey;

import org.eclipse.edc.identityhub.spi.participantcontext.model.ParticipantResource;
import org.eclipse.edc.identityhub.spi.store.KeyPairResourceStore;
import org.eclipse.edc.keys.LocalPublicKeyServiceImpl;
import org.eclipse.edc.keys.spi.KeyParserRegistry;
import org.eclipse.edc.spi.monitor.Monitor;
import org.eclipse.edc.spi.query.Criterion;
import org.eclipse.edc.spi.query.QuerySpec;
import org.eclipse.edc.spi.result.Result;
import org.eclipse.edc.spi.security.Vault;

Expand Down Expand Up @@ -51,7 +51,8 @@ public Result<PublicKey> resolveKey(String id) {
}

private Result<PublicKey> resolveFromDbOrVault(String publicKeyId) {
var result = keyPairResourceStore.query(QuerySpec.Builder.newInstance().filter(new Criterion("keyId", "=", publicKeyId)).build());
var query = ParticipantResource.queryByParticipantId("").filter(new Criterion("keyId", "=", publicKeyId)).build();
var result = keyPairResourceStore.query(query);
// store failed, e.g. data model does not match query, etc.
if (result.failed()) {
monitor.warning("Error querying database for KeyPairResource with key ID '%s': %s".formatted(publicKeyId, result.getFailureDetail()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public Map<String, String> controlPlaneConfiguration() {
put("web.http.path", "/api/v1");
put("web.http.resolution.port", String.valueOf(resolutionEndpoint.getUrl().getPort()));
put("web.http.resolution.path", resolutionEndpoint.getUrl().getPath());
put("web.http.management.port", String.valueOf(managementEndpoint.getUrl().getPort()));
put("web.http.management.path", managementEndpoint.getUrl().getPath());
put("web.http.identity.port", String.valueOf(managementEndpoint.getUrl().getPort()));
put("web.http.identity.path", managementEndpoint.getUrl().getPath());
put("edc.connector.name", name);
put("edc.ih.iam.publickey.alias", JwtCreationUtil.CONSUMER_KEY.getKeyID());
put("edc.ih.iam.id", "did:web:consumer");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public String name() {

@Override
public void initialize(ServiceExtensionContext context) {
var alias = IdentityHubApiContext.IH_MANAGEMENT;
var alias = IdentityHubApiContext.IDENTITY;
webService.registerResource(alias, new RoleBasedAccessFeature());
webService.registerResource(alias, new ServicePrincipalAuthenticationFilter(new ParticipantServicePrincipalResolver(participantContextService, vault)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public void initialize(ServiceExtensionContext context) {
authorizationService.addLookupFunction(DidResource.class, s -> didDocumentService.findById(s));
var controller = new DidManagementApiController(didDocumentService, authorizationService);
var getAllController = new GetAllDidsApiController(didDocumentService);
webService.registerResource(IdentityHubApiContext.IH_MANAGEMENT, controller);
webService.registerResource(IdentityHubApiContext.IH_MANAGEMENT, getAllController);
webService.registerResource(IdentityHubApiContext.IDENTITY, controller);
webService.registerResource(IdentityHubApiContext.IDENTITY, getAllController);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public void initialize(ServiceExtensionContext context) {
authorizationService.addLookupFunction(KeyPairResource.class, this::findById);
var api = new KeyPairResourceApiController(authorizationService, keyPairService, new KeyDescriptorValidator(context.getMonitor()));
var getAllApi = new GetAllKeyPairsApiController(keyPairService);
webService.registerResource(IdentityHubApiContext.IH_MANAGEMENT, api);
webService.registerResource(IdentityHubApiContext.IH_MANAGEMENT, getAllApi);
webService.registerResource(IdentityHubApiContext.IDENTITY, api);
webService.registerResource(IdentityHubApiContext.IDENTITY, getAllApi);
}

private ParticipantResource findById(String keyPairId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ public String name() {
public void initialize(ServiceExtensionContext context) {
authorizationService.addLookupFunction(ParticipantContext.class, s -> participantContextService.getParticipantContext(s).orElseThrow(exceptionMapper(ParticipantContext.class, s)));
var controller = new ParticipantContextApiController(new ParticipantManifestValidator(monitor), participantContextService, authorizationService);
webService.registerResource(IdentityHubApiContext.IH_MANAGEMENT, controller);
webService.registerResource(IdentityHubApiContext.IDENTITY, controller);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public void initialize(ServiceExtensionContext context) {
authorizationService.addLookupFunction(VerifiableCredentialResource.class, this::queryById);
var controller = new VerifiableCredentialsApiController(credentialStore, authorizationService);
var getAllController = new GetAllCredentialsApiController(credentialStore);
webService.registerResource(IdentityHubApiContext.IH_MANAGEMENT, controller);
webService.registerResource(IdentityHubApiContext.IH_MANAGEMENT, getAllController);
webService.registerResource(IdentityHubApiContext.IDENTITY, controller);
webService.registerResource(IdentityHubApiContext.IDENTITY, getAllController);
}

private ParticipantResource queryById(String credentialId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
package org.eclipse.edc.identityhub.spi;

public interface IdentityHubApiContext {
String IH_MANAGEMENT = "management";
String IDENTITY = "identity";
String IH_DID = "did";
}

0 comments on commit 46cd536

Please sign in to comment.