Search in sources :

Example 1 with JWAIdentifier

use of com.webauthn4j.data.jws.JWAIdentifier in project webauthn4j by webauthn4j.

the class JWSHeaderDeserializer method deserialize.

@Override
public JWSHeader deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    JsonNode jsonNode = p.getCodec().readTree(p);
    JWAIdentifier alg = p.getCodec().treeToValue(jsonNode.get("alg"), JWAIdentifier.class);
    JsonNode x5cNode = jsonNode.get("x5c");
    List<X509Certificate> certificates = new ArrayList<>();
    for (JsonNode node : x5cNode) {
        certificates.add(CertificateUtil.generateX509Certificate(Base64Util.decode(node.asText())));
    }
    CertPath x5c = CertificateUtil.generateCertPath(certificates);
    return new JWSHeader(alg, x5c);
}
Also used : JWAIdentifier(com.webauthn4j.data.jws.JWAIdentifier) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) CertPath(java.security.cert.CertPath) X509Certificate(java.security.cert.X509Certificate) JWSHeader(com.webauthn4j.data.jws.JWSHeader)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 JWAIdentifier (com.webauthn4j.data.jws.JWAIdentifier)1 JWSHeader (com.webauthn4j.data.jws.JWSHeader)1 CertPath (java.security.cert.CertPath)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1