Skip to content

Commit d9449e4

Browse files
committed
Additional utility functions.
1 parent d9c6d90 commit d9449e4

File tree

1 file changed

+11
-0
lines changed
  • src/main/java/com/danubetech/keyformats/jose

1 file changed

+11
-0
lines changed

src/main/java/com/danubetech/keyformats/jose/JWK.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.danubetech.keyformats.jose;
22

3+
import com.fasterxml.jackson.core.JsonProcessingException;
34
import com.fasterxml.jackson.databind.ObjectMapper;
45
import org.apache.commons.codec.binary.Base64;
56

7+
import java.io.IOException;
8+
import java.io.StringReader;
69
import java.util.Map;
710

811
public class JWK {
@@ -23,6 +26,14 @@ public static JWK parse(Map<String, Object> json) {
2326
return objectMapper.convertValue(json, JWK.class);
2427
}
2528

29+
public static JWK parse(String string) throws IOException {
30+
return objectMapper.readValue(new StringReader(string), JWK.class);
31+
}
32+
33+
public String toJSONString() throws JsonProcessingException {
34+
return objectMapper.writeValueAsString(this);
35+
}
36+
2637
public String getKid() {
2738
return kid;
2839
}

0 commit comments

Comments
 (0)