11package io .opentdf .platform .sdk ;
22
3+ import com .google .gson .JsonDeserializationContext ;
4+ import com .google .gson .JsonDeserializer ;
5+ import com .google .gson .JsonElement ;
6+ import com .google .gson .JsonParseException ;
7+ import com .google .gson .JsonSerializationContext ;
8+ import com .google .gson .JsonSerializer ;
9+ import com .google .gson .annotations .JsonAdapter ;
310import com .google .gson .annotations .SerializedName ;
411
12+ import java .lang .reflect .Type ;
513import java .util .ArrayList ;
614import java .util .List ;
15+ import java .util .Objects ;
716
817public class Manifest {
18+ @ Override
19+ public boolean equals (Object o ) {
20+ if (this == o ) return true ;
21+ if (o == null || getClass () != o .getClass ()) return false ;
22+ Manifest manifest = (Manifest ) o ;
23+ return Objects .equals (encryptionInformation , manifest .encryptionInformation ) && Objects .equals (payload , manifest .payload ) && Objects .equals (assertions , manifest .assertions );
24+ }
25+
26+ @ Override
27+ public int hashCode () {
28+ return Objects .hash (encryptionInformation , payload , assertions );
29+ }
30+
31+ private static class PolicyBindingSerializer implements JsonDeserializer <Object >, JsonSerializer <Object > {
32+ @ Override
33+ public Object deserialize (JsonElement json , Type typeOfT , JsonDeserializationContext context ) throws JsonParseException {
34+ if (json .isJsonObject ()) {
35+ return context .deserialize (json , Manifest .PolicyBinding .class );
36+ } else if (json .isJsonPrimitive () && json .getAsJsonPrimitive ().isString ()) {
37+ return json .getAsString ();
38+ } else {
39+ throw new JsonParseException ("Unexpected type for policyBinding" );
40+ }
41+ }
42+
43+ @ Override
44+ public JsonElement serialize (Object src , Type typeOfSrc , JsonSerializationContext context ) {
45+ return context .serialize (src , typeOfSrc );
46+ }
47+ }
948 static public class Segment {
1049 public String hash ;
1150 public long segmentSize ;
1251 public long encryptedSegmentSize ;
52+
53+ @ Override
54+ public boolean equals (Object o ) {
55+ if (this == o ) return true ;
56+ if (o == null || getClass () != o .getClass ()) return false ;
57+ Segment segment = (Segment ) o ;
58+ return segmentSize == segment .segmentSize && encryptedSegmentSize == segment .encryptedSegmentSize && Objects .equals (hash , segment .hash );
59+ }
60+
61+ @ Override
62+ public int hashCode () {
63+ return Objects .hash (hash , segmentSize , encryptedSegmentSize );
64+ }
1365 }
1466
1567 static public class RootSignature {
1668 @ SerializedName (value = "alg" )
1769 public String algorithm ;
1870 @ SerializedName (value = "sig" )
1971 public String signature ;
72+
73+ @ Override
74+ public boolean equals (Object o ) {
75+ if (this == o ) return true ;
76+ if (o == null || getClass () != o .getClass ()) return false ;
77+ RootSignature that = (RootSignature ) o ;
78+ return Objects .equals (algorithm , that .algorithm ) && Objects .equals (signature , that .signature );
79+ }
80+
81+ @ Override
82+ public int hashCode () {
83+ return Objects .hash (algorithm , signature );
84+ }
2085 }
2186
2287 static public class IntegrityInformation {
@@ -25,6 +90,37 @@ static public class IntegrityInformation {
2590 public int segmentSizeDefault ;
2691 public int encryptedSegmentSizeDefault ;
2792 public List <Segment > segments ;
93+
94+ @ Override
95+ public boolean equals (Object o ) {
96+ if (this == o ) return true ;
97+ if (o == null || getClass () != o .getClass ()) return false ;
98+ IntegrityInformation that = (IntegrityInformation ) o ;
99+ return segmentSizeDefault == that .segmentSizeDefault && encryptedSegmentSizeDefault == that .encryptedSegmentSizeDefault && Objects .equals (rootSignature , that .rootSignature ) && Objects .equals (segmentHashAlg , that .segmentHashAlg ) && Objects .equals (segments , that .segments );
100+ }
101+
102+ @ Override
103+ public int hashCode () {
104+ return Objects .hash (rootSignature , segmentHashAlg , segmentSizeDefault , encryptedSegmentSizeDefault , segments );
105+ }
106+ }
107+
108+ static public class PolicyBinding {
109+ public String alg ;
110+ public String hash ;
111+
112+ @ Override
113+ public boolean equals (Object o ) {
114+ if (this == o ) return true ;
115+ if (o == null || getClass () != o .getClass ()) return false ;
116+ PolicyBinding that = (PolicyBinding ) o ;
117+ return Objects .equals (alg , that .alg ) && Objects .equals (hash , that .hash );
118+ }
119+
120+ @ Override
121+ public int hashCode () {
122+ return Objects .hash (alg , hash );
123+ }
28124 }
29125
30126 static public class KeyAccess {
@@ -33,17 +129,47 @@ static public class KeyAccess {
33129 public String url ;
34130 public String protocol ;
35131 public String wrappedKey ;
36- public String policyBinding ;
132+ @ JsonAdapter (PolicyBindingSerializer .class )
133+ public Object policyBinding ;
134+
37135 public String encryptedMetadata ;
38136 public String kid ;
137+
138+ @ Override
139+ public boolean equals (Object o ) {
140+ if (this == o ) return true ;
141+ if (o == null || getClass () != o .getClass ()) return false ;
142+ KeyAccess keyAccess = (KeyAccess ) o ;
143+ return Objects .equals (keyType , keyAccess .keyType ) && Objects .equals (url , keyAccess .url ) && Objects .equals (protocol , keyAccess .protocol ) && Objects .equals (wrappedKey , keyAccess .wrappedKey ) && Objects .equals (policyBinding , keyAccess .policyBinding ) && Objects .equals (encryptedMetadata , keyAccess .encryptedMetadata ) && Objects .equals (kid , keyAccess .kid );
144+ }
145+
146+ @ Override
147+ public int hashCode () {
148+ return Objects .hash (keyType , url , protocol , wrappedKey , policyBinding , encryptedMetadata , kid );
149+ }
39150 }
40151
41152 static public class Method {
42153 public String algorithm ;
43154 public String iv ;
44155 public Boolean IsStreamable ;
156+
157+ @ Override
158+ public boolean equals (Object o ) {
159+ if (this == o ) return true ;
160+ if (o == null || getClass () != o .getClass ()) return false ;
161+ Method method = (Method ) o ;
162+ return Objects .equals (algorithm , method .algorithm ) && Objects .equals (iv , method .iv ) && Objects .equals (IsStreamable , method .IsStreamable );
163+ }
164+
165+ @ Override
166+ public int hashCode () {
167+ return Objects .hash (algorithm , iv , IsStreamable );
168+ }
45169 }
46170
171+
172+
47173 static public class EncryptionInformation {
48174 @ SerializedName (value = "type" )
49175 public String keyAccessType ;
@@ -53,6 +179,19 @@ static public class EncryptionInformation {
53179 public List <KeyAccess > keyAccessObj ;
54180 public Method method ;
55181 public IntegrityInformation integrityInformation ;
182+
183+ @ Override
184+ public boolean equals (Object o ) {
185+ if (this == o ) return true ;
186+ if (o == null || getClass () != o .getClass ()) return false ;
187+ EncryptionInformation that = (EncryptionInformation ) o ;
188+ return Objects .equals (keyAccessType , that .keyAccessType ) && Objects .equals (policy , that .policy ) && Objects .equals (keyAccessObj , that .keyAccessObj ) && Objects .equals (method , that .method ) && Objects .equals (integrityInformation , that .integrityInformation );
189+ }
190+
191+ @ Override
192+ public int hashCode () {
193+ return Objects .hash (keyAccessType , policy , keyAccessObj , method , integrityInformation );
194+ }
56195 }
57196
58197 static public class Payload {
@@ -61,6 +200,19 @@ static public class Payload {
61200 public String protocol ;
62201 public String mimeType ;
63202 public Boolean isEncrypted ;
203+
204+ @ Override
205+ public boolean equals (Object o ) {
206+ if (this == o ) return true ;
207+ if (o == null || getClass () != o .getClass ()) return false ;
208+ Payload payload = (Payload ) o ;
209+ return Objects .equals (type , payload .type ) && Objects .equals (url , payload .url ) && Objects .equals (protocol , payload .protocol ) && Objects .equals (mimeType , payload .mimeType ) && Objects .equals (isEncrypted , payload .isEncrypted );
210+ }
211+
212+ @ Override
213+ public int hashCode () {
214+ return Objects .hash (type , url , protocol , mimeType , isEncrypted );
215+ }
64216 }
65217
66218 public EncryptionInformation encryptionInformation ;
0 commit comments