Skip to content

Commit

Permalink
feat: More work on DID Traits support.
Browse files Browse the repository at this point in the history
  • Loading branch information
peacekeeper committed Nov 24, 2024
1 parent 5e5a8fa commit d634747
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public Map<String, Map<String, Object>> properties() throws ResolutionException

if (log.isDebugEnabled()) log.debug("Loading properties for driver " + driver.getClass().getSimpleName());

String driverKey = "driver-" + i;
String driverKey = (driver instanceof HttpDriver httpDriver) ? httpDriver.getPattern().toString() : "driver-" + i;
Map<String, Object> driverProperties = driver.properties();
if (driverProperties == null) driverProperties = Collections.emptyMap();

Expand Down Expand Up @@ -319,7 +319,7 @@ public Map<String, Map<String, Object>> traits() throws ResolutionException {

if (log.isDebugEnabled()) log.debug("Loading traits for driver " + driver.getClass().getSimpleName());

String driverKey = "driver-" + i;
String driverKey = (driver instanceof HttpDriver httpDriver) ? httpDriver.getPattern().toString() : "driver-" + i;
Map<String, Object> driverTraits = driver.traits();
if (driverTraits == null) driverTraits = Collections.emptyMap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static void configureLocalUniResolver(String filePath, LocalUniResolver l
driver.setResolveUri(url + "1.0/identifiers/");
if ("true".equals(propertiesEndpoint)) driver.setPropertiesUri(url + "1.0/properties");
}

if (testIdentifiers != null) driver.setTestIdentifiers(testIdentifiers);
if (traits != null) driver.setTraits(traits);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Configuration
public class WebAppConfig {
Expand Down Expand Up @@ -101,12 +102,13 @@ public void configureLocalUniresolver(DriverConfigs driverConfigs, LocalUniResol

List<Driver> drivers = new ArrayList<>();

for (DriverConfigs.DriverConfig dc : driverConfigs.getDrivers()) {
for (DriverConfigs.DriverConfig driverConfig : driverConfigs.getDrivers()) {

String pattern = dc.getPattern();
String url = dc.getUrl();
String propertiesEndpoint = dc.getPropertiesEndpoint();
List<String> testIdentifiers = dc.getTestIdentifiers();
String pattern = driverConfig.getPattern();
String url = driverConfig.getUrl();
String propertiesEndpoint = driverConfig.getPropertiesEndpoint();
List<String> testIdentifiers = driverConfig.getTestIdentifiers();
Map<String, Object> traits = driverConfig.getTraits();

if (pattern == null) throw new IllegalArgumentException("Missing 'pattern' entry in driver configuration.");
if (url == null) throw new IllegalArgumentException("Missing 'url' entry in driver configuration.");
Expand All @@ -125,12 +127,13 @@ public void configureLocalUniresolver(DriverConfigs driverConfigs, LocalUniResol
if ("true".equals(propertiesEndpoint)) driver.setPropertiesUri(normalizeUri((url + servletMappings.getProperties()), false));
}

driver.setTestIdentifiers(testIdentifiers);
if (testIdentifiers != null) driver.setTestIdentifiers(testIdentifiers);
if (traits != null) driver.setTraits(traits);

// done

drivers.add(driver);
if (log.isInfoEnabled()) log.info("Added driver for pattern '" + dc.getPattern() + "' at " + driver.getResolveUri() + " (" + driver.getPropertiesUri() + ")");
if (log.isInfoEnabled()) log.info("Added driver for pattern '" + driverConfig.getPattern() + "' at " + driver.getResolveUri() + " (" + driver.getPropertiesUri() + ")");
}

uniResolver.setDrivers(drivers);
Expand Down
10 changes: 5 additions & 5 deletions uni-resolver-web/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ uniresolver:
- did:sov:idunion:2GMSLg2A8JXcdYVsPC4Jui
- did:sov:idunion:test:BDrEcHc8Tb4Lb2VyQZWEDE
- did:sov:indicio:demo:KKyAeG7woJMV6MhhAREVKp
traits:
deactivatable: true
enumerable: true
historyAvailable: true
humanReadbale: false
- pattern: "^(did:indy:.+)$"
url: ${uniresolver_web_driver_url_did_indy:http://driver-did-indy:8080/}
propertiesEndpoint: "true"
Expand All @@ -41,11 +46,6 @@ uniresolver:
- did:indy:idunion:test:BDrEcHc8Tb4Lb2VyQZWEDE
- did:indy:indicio:demo:KKyAeG7woJMV6MhhAREVKp
- did:indy:nxd:LLDnZr8iaYM3F77pUWXnVX
traits:
deactivatable: true
enumerable: true
historyAvailable: true
humanReadbale: false
- pattern: "^(did:v1:nym:.+)$"
url: ${uniresolver_web_driver_url_did_v1_nym:http://uni-resolver-did-v1-driver:8080/}
propertiesEndpoint: "true"
Expand Down

0 comments on commit d634747

Please sign in to comment.