Parse EllipticCurveJsonWebKey from string

Issue #88 closed
Former user created an issue
 EllipticCurveJsonWebKey receiverJwk= EcJwkGenerator.generateJwk(EllipticCurves.P384,"BC", new SecureRandom());
String KeyFromServer= Base64.toBase64String(receiverJwk.getPublicKey().getEncoded());

assume the key is generated from server side and it is encoded to string..

and again we want key parese from string for validating Token in java application.

then how to parse EllipticCurveJsonWebKey from string

Comments (3)

  1. Brian Campbell repo owner

    JWK is a nice format for this kind of thing. Serilize the JWK object to JSON and read that in on the other side. Something like:

      EllipticCurveJsonWebKey jwk = EcJwkGenerator.generateJwk(EllipticCurves.P384);
    
      String jwkJson = jwk.toJson(JsonWebKey.OutputControlLevel.PUBLIC_ONLY);
    
      PublicJsonWebKey publicJwkFromJson = PublicJsonWebKey.Factory.newPublicJwk(jwkJson);
    
  2. Log in to comment