@@ -175,6 +175,9 @@ public AccessGrantClient session(final Session session) {
175175 */
176176 public CompletionStage <AccessGrant > issue (final URI type , final URI agent , final Set <URI > resources ,
177177 final Set <String > modes , final Set <String > purposes , final Instant expiration ) {
178+ Objects .requireNonNull (type , "Access Grant type may not be null!" );
179+ Objects .requireNonNull (resources , "Resources may not be null!" );
180+ Objects .requireNonNull (modes , "Access modes may not be null!" );
178181 return v1Metadata ().thenCompose (metadata -> {
179182 final Map <String , Object > data ;
180183 if (ACCESS_GRANT .equals (type )) {
@@ -522,6 +525,7 @@ static URI asUri(final Object value) {
522525
523526 static Map <String , Object > buildAccessGrantv1 (final URI agent , final Set <URI > resources , final Set <String > modes ,
524527 final Instant expiration , final Set <String > purposes ) {
528+ Objects .requireNonNull (agent , "Access grant agent may not be null!" );
525529 final Map <String , Object > consent = new HashMap <>();
526530 consent .put (MODE , modes );
527531 consent .put (HAS_STATUS , "https://w3id.org/GConsent#ConsentStatusExplicitlyGiven" );
@@ -536,7 +540,9 @@ static Map<String, Object> buildAccessGrantv1(final URI agent, final Set<URI> re
536540
537541 final Map <String , Object > credential = new HashMap <>();
538542 credential .put (CONTEXT , Arrays .asList (VC_CONTEXT_URI , INRUPT_CONTEXT_URI ));
539- credential .put ("expirationDate" , expiration .truncatedTo (ChronoUnit .SECONDS ).toString ());
543+ if (expiration != null ) {
544+ credential .put ("expirationDate" , expiration .truncatedTo (ChronoUnit .SECONDS ).toString ());
545+ }
540546 credential .put (CREDENTIAL_SUBJECT , subject );
541547
542548 final Map <String , Object > data = new HashMap <>();
@@ -547,10 +553,12 @@ static Map<String, Object> buildAccessGrantv1(final URI agent, final Set<URI> re
547553 static Map <String , Object > buildAccessRequestv1 (final URI agent , final Set <URI > resources , final Set <String > modes ,
548554 final Instant expiration , final Set <String > purposes ) {
549555 final Map <String , Object > consent = new HashMap <>();
550- consent .put (MODE , modes );
551556 consent .put (HAS_STATUS , "https://w3id.org/GConsent#ConsentStatusRequested" );
557+ consent .put (MODE , modes );
552558 consent .put (FOR_PERSONAL_DATA , resources );
553- consent .put (IS_PROVIDED_TO_PERSON , agent );
559+ if (agent != null ) {
560+ consent .put ("isConsentForDataSubject" , agent );
561+ }
554562 if (!purposes .isEmpty ()) {
555563 consent .put ("forPurpose" , purposes );
556564 }
@@ -560,7 +568,9 @@ static Map<String, Object> buildAccessRequestv1(final URI agent, final Set<URI>
560568
561569 final Map <String , Object > credential = new HashMap <>();
562570 credential .put (CONTEXT , Arrays .asList (VC_CONTEXT_URI , INRUPT_CONTEXT_URI ));
563- credential .put ("expirationDate" , expiration .truncatedTo (ChronoUnit .SECONDS ).toString ());
571+ if (expiration != null ) {
572+ credential .put ("expirationDate" , expiration .truncatedTo (ChronoUnit .SECONDS ).toString ());
573+ }
564574 credential .put (CREDENTIAL_SUBJECT , subject );
565575
566576 final Map <String , Object > data = new HashMap <>();
0 commit comments