mirror of https://github.com/shred/acme4j
ClaimBuilder also returns a Map representation
parent
7f69a14e2a
commit
f87dba266f
|
@ -15,6 +15,7 @@ package org.shredzone.acme4j.util;
|
||||||
|
|
||||||
import java.security.Key;
|
import java.security.Key;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
@ -157,6 +158,13 @@ public class ClaimBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link Map} representation of the claims.
|
||||||
|
*/
|
||||||
|
public Map<String, Object> toMap() {
|
||||||
|
return Collections.unmodifiableMap(data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a JSON representation of the claims.
|
* Returns a JSON representation of the claims.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -62,6 +62,13 @@ public class ClaimBuilderTest {
|
||||||
assertThat(res, is(sameInstance(cb)));
|
assertThat(res, is(sameInstance(cb)));
|
||||||
|
|
||||||
assertThat(cb.toString(), is("{\"fooInt\":456,\"fooStr\":\"String\"}"));
|
assertThat(cb.toString(), is("{\"fooInt\":456,\"fooStr\":\"String\"}"));
|
||||||
|
|
||||||
|
Map<String, Object> map = cb.toMap();
|
||||||
|
assertThat(map.keySet(), hasSize(2));
|
||||||
|
assertThat(map, allOf(
|
||||||
|
hasEntry("fooInt", (Object) 456),
|
||||||
|
hasEntry("fooStr", (Object) "String")
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue