Package com.authlete.sd
Class SDObjectDecoder
java.lang.Object
com.authlete.sd.SDObjectDecoder
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
-
Method Summary
Modifier and TypeMethodDescriptiondecode
(List<?> encodedList, Collection<Disclosure> disclosures) Decode the given list with the specified disclosures and the default hash algorithm ("sha-256
").decode
(List<?> encodedList, Collection<Disclosure> disclosures, String hashAlgorithm) Decode the given list with the specified disclosures and hash algorithm.decode
(Map<String, Object> encodedMap, Collection<Disclosure> disclosures) Decode the given map with the specified disclosures.
-
Constructor Details
-
SDObjectDecoder
public SDObjectDecoder()
-
-
Method Details
-
decode
Decode the given map with the specified disclosures.- Parameters:
encodedMap
- The input map. Ifnull
is given,null
is returned.disclosures
- Disclosures for claims to disclose. Ifnull
is given, it means that none of selectively-disclosable elements in the input map are disclosed.- Returns:
- The decoded map.
-
decode
Decode the given list with the specified disclosures and the default hash algorithm ("sha-256
").- Parameters:
encodedList
- The input list. Ifnull
is given,null
is returned.disclosures
- Disclosures for claims to disclose. Ifnull
is 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. Ifnull
is given,null
is returned.disclosures
- Disclosures for claims to disclose. Ifnull
is given, it means that none of selectively-disclosable elements in the input list are disclosed.hashAlgorithm
- The hash algorithm for digests. Ifnull
is given, the default hash algorithm ("sha-256
") is used.- Returns:
- The decoded list.
-