Skip to content

Commit 239b9d1

Browse files
committed
Various fixes.
Signed-off-by: Markus Sabadello <[email protected]>
1 parent 4edac66 commit 239b9d1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,12 @@ public LdSignature getLdSignature() {
112112
public String getId() {
113113

114114
Object object = this.jsonLdObject.get(JSONLD_TERM_ID);
115+
if (object == null) return null;
116+
115117
if (object instanceof URI) return ((URI) object).toString();
116118
if (object instanceof String) return (String) object;
117-
return null;
119+
120+
throw new IllegalStateException("Invalid object for '" + JSONLD_TERM_ID + "': " + object);
118121
}
119122

120123
public void setId(String id) {
@@ -128,9 +131,12 @@ public void setId(String id) {
128131
public String getCredentialSubject() {
129132

130133
Object object = this.getJsonLdCredentialSubject().get(JSONLD_TERM_ID);
134+
if (object == null) return null;
135+
131136
if (object instanceof URI) return ((URI) object).toString();
132137
if (object instanceof String) return (String) object;
133-
return null;
138+
139+
throw new IllegalStateException("Invalid object for '" + JSONLD_TERM_ID + "': " + object);
134140
}
135141

136142
public void setCredentialSubject(String subject) {
@@ -157,9 +163,12 @@ public void setContext(List<String> context) {
157163
public List<String> getType() {
158164

159165
Object object = this.jsonLdObject.get(JSONLD_TERM_TYPE);
166+
if (object == null) return null;
167+
160168
if (object instanceof List) return (List<String>) object;
161169
if (object instanceof String) return Collections.singletonList((String) object);
162-
return null;
170+
171+
throw new IllegalStateException("Invalid object for '" + JSONLD_TERM_TYPE + "': " + object);
163172
}
164173

165174
public void setType(List<String> type) {

src/main/java/com/danubetech/verifiablecredentials/jwt/JwtVerifiablePresentation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public static JwtVerifiablePresentation fromJwtVerifiableCredential(JwtVerifiabl
4747
payload.setJwtId("urn:uuid:" + UUID.randomUUID().toString());
4848
payload.setIssuer(jwtVerifiableCredential.getPayload().getSubject());
4949
payload.setIssuedAtToNow();
50+
payload.setNotBefore(payload.getIssuedAt());
5051
payload.setClaim(JWT_CLAIM_VP, verifiablePresentation.getJsonLdObject());
5152

5253
return new JwtVerifiablePresentation(payload, payloadJwtVerifiableCredential, null);

0 commit comments

Comments
 (0)