@@ -83,7 +83,7 @@ public DataIntegrityProof sign(JsonLDObject jsonLdObject, boolean addToJsonLdObj
8383
8484 // build the base proof object
8585
86- DataIntegrityProof dataIntegrityProof = DataIntegrityProof .builder ()
86+ DataIntegrityProof . Builder <? extends DataIntegrityProof . Builder <?>> ldProofOptionsBuilder = DataIntegrityProof .builder ()
8787 .defaultContexts (false )
8888 .defaultTypes (false )
8989 .type (this .getDataIntegritySuite ().getTerm ())
@@ -98,28 +98,23 @@ public DataIntegrityProof sign(JsonLDObject jsonLdObject, boolean addToJsonLdObj
9898 .previousProof (this .getPreviousProof ())
9999 .capability (this .getCapability ())
100100 .capabilityChains (this .getCapabilityChains ())
101- .capabilityAction (this .getCapabilityAction ())
102- .build ();
103- if (log .isDebugEnabled ()) log .debug ("Constructed data integrity proof: {}" , dataIntegrityProof );
101+ .capabilityAction (this .getCapabilityAction ());
104102
105103 // initialize
106104
107- DataIntegrityProof .Builder <? extends DataIntegrityProof .Builder <?>> ldProofBuilder = DataIntegrityProof .builder ()
108- .base (dataIntegrityProof )
109- .defaultContexts (defaultContexts );
110-
111- this .initialize (ldProofBuilder );
112-
113- // add missing context(s)
114-
115- this .loadMissingContext (jsonLdObject );
105+ this .initialize (ldProofOptionsBuilder );
116106
117107 // construct LD proof options
118108
119- DataIntegrityProof ldProofOptions = DataIntegrityProof . fromJson ( dataIntegrityProof . toJson () );
109+ DataIntegrityProof ldProofOptions = ldProofOptionsBuilder . build ( );
120110 if (ldProofOptions .getContexts () == null || ldProofOptions .getContexts ().isEmpty ()) {
121111 JsonLDUtils .jsonLdAdd (ldProofOptions , Keywords .CONTEXT , jsonLdObject .getContexts ().stream ().map (JsonLDUtils ::uriToString ).filter (Objects ::nonNull ).toList ());
122112 }
113+ if (log .isDebugEnabled ()) log .debug ("Data integrity proof options: {}" , ldProofOptions );
114+
115+ // add missing context(s)
116+
117+ this .loadMissingContext (jsonLdObject );
123118
124119 // obtain the canonicalized document
125120
@@ -129,9 +124,13 @@ public DataIntegrityProof sign(JsonLDObject jsonLdObject, boolean addToJsonLdObj
129124
130125 // sign
131126
127+ DataIntegrityProof .Builder <? extends DataIntegrityProof .Builder <?>> ldProofBuilder = DataIntegrityProof .builder ()
128+ .base (ldProofOptions )
129+ .defaultContexts (defaultContexts );
130+
132131 this .sign (ldProofBuilder , canonicalizationResult );
133132
134- dataIntegrityProof = ldProofBuilder .build ();
133+ DataIntegrityProof dataIntegrityProof = ldProofBuilder .build ();
135134 if (log .isDebugEnabled ()) log .debug ("Signed data integrity proof: {}" , dataIntegrityProof );
136135
137136 // add proof to JSON-LD
0 commit comments