Skip to content

Commit

Permalink
chore: withoutPadding, fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheibal committed Jul 16, 2024
1 parent 6273595 commit d2949f1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ public static class EcPublicKeyJwk extends PublicKeyJwk {
*/
public EcPublicKeyJwk(ECPublicKey ecPublicKey, List<String> base64EncodedCertificates) {
super("EC", base64EncodedCertificates);
valueX = Base64.getUrlEncoder().encodeToString(ecPublicKey.getW().getAffineX().toByteArray());
valueY = Base64.getUrlEncoder().encodeToString(ecPublicKey.getW().getAffineY().toByteArray());
valueX = Base64.getUrlEncoder().withoutPadding()
.encodeToString(ecPublicKey.getW().getAffineX().toByteArray());
valueY = Base64.getUrlEncoder().withoutPadding()
.encodeToString(ecPublicKey.getW().getAffineY().toByteArray());

ECNamedCurveSpec curveSpec = (ECNamedCurveSpec) ecPublicKey.getParams();
switch (curveSpec.getName()) {
Expand Down Expand Up @@ -118,7 +120,8 @@ public static class RsaPublicKeyJwk extends PublicKeyJwk {
*/
public RsaPublicKeyJwk(RSAPublicKey rsaPublicKey, List<String> base64EncodedCertificates) {
super("RSA", base64EncodedCertificates);
valueN = Base64.getUrlEncoder().encodeToString(rsaPublicKey.getModulus().toByteArray()).split("=")[0];
valueN = Base64.getUrlEncoder().withoutPadding()
.encodeToString(rsaPublicKey.getModulus().toByteArray());
valueE = Base64.getUrlEncoder().encodeToString(rsaPublicKey.getPublicExponent().toByteArray());
}
}
Expand Down
Loading

0 comments on commit d2949f1

Please sign in to comment.