Class SDObjectBuilder

java.lang.Object
com.authlete.sd.SDObjectBuilder

public class SDObjectBuilder extends Object
A utility to create a Map instance that represents a JSON object which may contain the "_sd" array and the "_sd_alg" claim.

Example:

 Disclosure disclosure = Disclosure.parse(
     "WyI2cU1RdlJMNWhhaiIsICJmYW1pbHlfbmFtZSIsICJNw7ZiaXVzIl0");

 // Create an SDObjectBuilder instance with the default
 // hash algorithm "sha-256".
 SDObjectBuilder builder = new SDObjectBuilder();

 // Add the digest of the disclosure.
 builder.putSDClaim(disclosure);

 // Add an arbitrary claim.
 String claimName  = "my_claim_name";
 String claimValue = "my_claim_value";
 builder.putClaim(claimName, claimValue);

 // Build a map that represents a JSON object.
 Map<String, Object> map = builder.build(true);

 // map ->
 // {
 //   "my_claim_name": "my_claim_value",
 //   "_sd": [
 //     "uutlBuYeMDyjLLTpf6Jxi7yNkEF35jdyWMn9U7b_RYY"
 //   ],
 //   "_sd_alg": "sha-256"
 // }
 
Since:
1.0