Package com.authlete.sd
Class SDObjectDecoder
- java.lang.Object
-
- com.authlete.sd.SDObjectDecoder
-
public class SDObjectDecoder extends Object
A utility to decode selectively-disclosable elements in a map or a list recursively.// Original dataset // // { // "key-1": "value-1", // "key-2": "value-2" // } // Map<String, Object> originalMap = Map.of( "key-1", "value-1", "key-2", "value-2" ); // Encoder SDObjectEncoder encoder = new SDObjectEncoder(); // Encode Map<String, Object> encodedMap = encoder.encode(originalMap); // Disclosures yielded as a result of the encoding process. List<Disclosure> disclosures = encoder.getDisclosures(); // Disclosures for claims to disclose. List<Disclosure> disclosed = disclosures.stream() .filter(d -> "key-1".equals(d.getClaimName())) .collect(Collectors.toList()); // Decode the encoded map with the selected disclosures. SDObjectDecoder decoder = new SDObjectDecoder(); Map<String, Object> decodedMap = decoder.decode(encodedMap, disclosed); // Decoded dataset // // { // "key-1": "value-1" // } //
- Since:
- 1.3
-
-
Constructor Summary
Constructors Constructor Description SDObjectDecoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Object>decode(List<?> encodedList, Collection<Disclosure> disclosures)Decode the given list with the specified disclosures and the default hash algorithm ("sha-256").List<Object>decode(List<?> encodedList, Collection<Disclosure> disclosures, String hashAlgorithm)Decode the given list with the specified disclosures and hash algorithm.Map<String,Object>decode(Map<String,Object> encodedMap, Collection<Disclosure> disclosures)Decode the given map with the specified disclosures.
-
-
-
Method Detail
-
decode
public Map<String,Object> decode(Map<String,Object> encodedMap, Collection<Disclosure> disclosures)
Decode the given map with the specified disclosures.- Parameters:
encodedMap- The input map. Ifnullis given,nullis returned.disclosures- Disclosures for claims to disclose. Ifnullis given, it means that none of selectively-disclosable elements in the input map are disclosed.- Returns:
- The decoded map.
-
decode
public List<Object> decode(List<?> encodedList, Collection<Disclosure> disclosures)
Decode the given list with the specified disclosures and the default hash algorithm ("sha-256").- Parameters:
encodedList- The input list. Ifnullis given,nullis returned.disclosures- Disclosures for claims to disclose. Ifnullis given, it means that none of selectively-disclosable elements in the input list are disclosed.- Returns:
- The decoded list.
-
decode
public List<Object> decode(List<?> encodedList, Collection<Disclosure> disclosures, String hashAlgorithm)
Decode the given list with the specified disclosures and hash algorithm.- Parameters:
encodedList- The input list. Ifnullis given,nullis returned.disclosures- Disclosures for claims to disclose. Ifnullis given, it means that none of selectively-disclosable elements in the input list are disclosed.hashAlgorithm- The hash algorithm for digests. Ifnullis given, the default hash algorithm ("sha-256") is used.- Returns:
- The decoded list.
-
-