Skip to content

Commit 9c59add

Browse files
committed
fix: Small improvement to returning "issuer" from VC 2.0
1 parent e567e01 commit 9c59add

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/com/danubetech/verifiablecredentials/VerifiableCredentialV2.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,17 @@ public static void removeFromJsonLdObject(JsonLDObject jsonLdObject) {
245245
*/
246246

247247
public Object getIssuer() {
248-
return JsonLDUtils.jsonLdGetJsonValue(this.getJsonObject(), VerifiableCredentialKeywords.JSONLD_TERM_ISSUER);
248+
Object issuer = JsonLDUtils.jsonLdGetJsonValue(this.getJsonObject(), VerifiableCredentialKeywords.JSONLD_TERM_ISSUER);
249+
if (issuer instanceof String issuerString) return JsonLDUtils.stringToUri(issuerString);
250+
if (issuer instanceof Map<?, ?> issuerMap) return issuerMap;
251+
return null;
249252
}
250253

251254
public URI getIssuerUri() {
252255
Object issuer = JsonLDUtils.jsonLdGetJsonValue(this.getJsonObject(), VerifiableCredentialKeywords.JSONLD_TERM_ISSUER);
253-
return (issuer instanceof String) ? URI.create(issuer.toString()) : URI.create((((Map<String,Object>)issuer).get(VerifiableCredentialKeywords.JSONLD_TERM_ISSUER)).toString());
256+
if (issuer instanceof String issuerString) return JsonLDUtils.stringToUri(issuerString);
257+
if (issuer instanceof Map<?, ?> issuerMap) return JsonLDUtils.stringToUri((String) issuerMap.get(VerifiableCredentialKeywords.JSONLD_TERM_ISSUER));
258+
return null;
254259
}
255260

256261
public Date getValidFrom() {

0 commit comments

Comments
 (0)