Skip to content

Commit f05aaff

Browse files
committed
✨ The expected VC type is now configurable in the identity extension
1 parent d262ac2 commit f05aaff

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

connector/iam/src/main/java/eu/datacellar/iam/VCIdentityExtension.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ public class VCIdentityExtension implements ServiceExtension {
4747
@Setting
4848
private static final String UNIVERSAL_RESOLVER_URL = "eu.datacellar.uniresolver.url";
4949

50+
@Setting
51+
private static final String VC_TYPE = "eu.datacellar.vc.type";
52+
5053
private static final String DEV_UNIRESOLVER_URL = "https://dev.uniresolver.io/1.0/identifiers";
5154

55+
private static final String DEFAULT_VC_TYPE = "DataCellarCredential";
56+
5257
@Inject
5358
private TypeManager typeManager;
5459

@@ -98,6 +103,7 @@ public void initialize(ServiceExtensionContext context) {
98103
}
99104

100105
String uniresolverUrl = context.getSetting(UNIVERSAL_RESOLVER_URL, DEV_UNIRESOLVER_URL);
106+
String vcType = context.getSetting(VC_TYPE, DEFAULT_VC_TYPE);
101107

102108
var participantId = context.getParticipantId();
103109
var monitor = context.getMonitor();
@@ -113,7 +119,8 @@ public void initialize(ServiceExtensionContext context) {
113119
participantId,
114120
identityServices,
115121
didTrustAnchor,
116-
uniresolverUrl));
122+
uniresolverUrl,
123+
vcType));
117124
} catch (IOException | InterruptedException e) {
118125
context.getMonitor().severe("Failed to initialize WaltIDIdentityServices", e);
119126
System.exit(1);

connector/iam/src/main/java/eu/datacellar/iam/VCIdentityService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class VCIdentityService implements IdentityService {
2626
// This is the type of Verifiable Credential that the connector will search for
2727
// in the wallet and then present to the counter-party.
28-
private static final String PRESENTED_VC_TYPE = "DataCellarCredential";
28+
private final String presentedVcType;
2929

3030
private final Monitor monitor;
3131
private final TypeManager typeManager;
@@ -45,15 +45,17 @@ public class VCIdentityService implements IdentityService {
4545
* providers.
4646
* @param didTrustAnchor The trust anchor for decentralized identifiers.
4747
* @param uniresolverUrl The URL of the uniresolver service.
48+
* @param presentedVcType The type of Verifiable Credential to present.
4849
*/
4950
public VCIdentityService(Monitor monitor, TypeManager typeManager, String clientId,
50-
WaltIDIdentityServices identityServices, String didTrustAnchor, String uniresolverUrl) {
51+
WaltIDIdentityServices identityServices, String didTrustAnchor, String uniresolverUrl, String presentedVcType) {
5152
this.monitor = monitor;
5253
this.typeManager = typeManager;
5354
this.clientId = clientId;
5455
this.identityServices = identityServices;
5556
this.didTrustAnchor = didTrustAnchor;
5657
this.keyResolver = new KeyResolver(uniresolverUrl, monitor);
58+
this.presentedVcType = presentedVcType;
5759
}
5860

5961
@Override
@@ -63,7 +65,7 @@ public Result<TokenRepresentation> obtainClientCredentials(TokenParameters param
6365
monitor.info(
6466
String.format("obtainClientCredentials: (audience=%s)", audience));
6567

66-
PresentationDefinition presentationDefinition = new PresentationDefinition(PRESENTED_VC_TYPE);
68+
PresentationDefinition presentationDefinition = new PresentationDefinition(presentedVcType);
6769
MatchCredentialsResponse matchCredentialsResponse;
6870

6971
try {

0 commit comments

Comments
 (0)