Skip to content

Commit

Permalink
introduce delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Feb 6, 2025
1 parent eee0cd0 commit abc4f5b
Show file tree
Hide file tree
Showing 15 changed files with 660 additions and 326 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.issuerservice.statuslist;

import org.eclipse.edc.issuerservice.spi.statuslist.StatusListCredentialFactoryRegistry;
import org.eclipse.edc.issuerservice.spi.statuslist.StatusListInfoFactory;

import java.util.HashMap;
import java.util.Map;

public class StatusListCredentialFactoryRegistryImpl implements StatusListCredentialFactoryRegistry {
private final Map<String, StatusListInfoFactory> registry = new HashMap<>();

@Override
public StatusListInfoFactory getStatusListCredential(String type) {
return registry.get(type);
}

@Override
public void register(String type, StatusListInfoFactory factory) {
registry.put(type, factory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
*
*/

package org.eclipse.edc.issuerservice.revocation;
package org.eclipse.edc.issuerservice.statuslist;

import org.eclipse.edc.identityhub.spi.verifiablecredentials.store.CredentialStore;
import org.eclipse.edc.issuerservice.spi.revocation.CredentialRevocationService;
import org.eclipse.edc.issuerservice.spi.statuslist.StatusListCredentialFactoryRegistry;
import org.eclipse.edc.issuerservice.spi.statuslist.StatusListService;
import org.eclipse.edc.issuerservice.statuslist.bitstring.BitstringStatusListFactory;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.runtime.metamodel.annotation.Provider;
Expand All @@ -26,12 +28,12 @@
import org.eclipse.edc.token.spi.TokenGenerationService;
import org.eclipse.edc.transaction.spi.TransactionContext;

import static org.eclipse.edc.issuerservice.revocation.BitstringRevocationServiceExtension.NAME;
import static org.eclipse.edc.issuerservice.statuslist.StatusListServiceExtension.NAME;
import static org.eclipse.edc.spi.constants.CoreConstants.JSON_LD;

@Extension(value = NAME)
public class BitstringRevocationServiceExtension implements ServiceExtension {
public static final String NAME = "BitString Revocation Service Extension";
public class StatusListServiceExtension implements ServiceExtension {
public static final String NAME = "Status List Service Extension";

@Setting(description = "Alias for the private key that is intended for signing status list credentials", key = "edc.issuer.statuslist.signing.key.alias")
private String privateKeyAlias;
Expand All @@ -43,10 +45,24 @@ public class BitstringRevocationServiceExtension implements ServiceExtension {
private TypeManager typeManager;
@Inject
private TokenGenerationService tokenGenerationService;
private StatusListCredentialFactoryRegistry factory;

@Provider(isDefault = true) // other status lists, e.g. StatusList2021 could be provided as optional extension
public CredentialRevocationService getCredentialRevocationService(ServiceExtensionContext context) {
return new BitStringStatusListRevocationService(store, transactionContext, typeManager.getMapper(JSON_LD), context.getMonitor(), tokenGenerationService,
() -> privateKeyAlias);
@Provider
public StatusListService getStatusListService(ServiceExtensionContext context) {
var fact = getFactory();

// Bitstring StatusList is provided by default. others can be added via extensions
fact.register("BitStringStatusListEntry", new BitstringStatusListFactory(store, typeManager.getMapper()));

return new StatusListServiceImpl(store, transactionContext, typeManager.getMapper(JSON_LD), context.getMonitor(), tokenGenerationService,
() -> privateKeyAlias, fact);
}

@Provider
public StatusListCredentialFactoryRegistry getFactory() {
if (factory == null) {
factory = new StatusListCredentialFactoryRegistryImpl();
}
return factory;
}
}
Loading

0 comments on commit abc4f5b

Please sign in to comment.