bas64 decoded signature prior to verifying, modified unit rsa unit test, and fixed ecdsa signer verify
parent
985a4619fa
commit
267f1b2de3
|
@ -217,6 +217,8 @@ public class EcdsaSigner extends AbstractJwtSigner implements InitializingBean {
|
||||||
@Override
|
@Override
|
||||||
public boolean verify(String jwtString) {
|
public boolean verify(String jwtString) {
|
||||||
|
|
||||||
|
boolean value = false;
|
||||||
|
|
||||||
// split on the dots
|
// split on the dots
|
||||||
List<String> parts = Lists.newArrayList(Splitter.on(".").split(
|
List<String> parts = Lists.newArrayList(Splitter.on(".").split(
|
||||||
jwtString));
|
jwtString));
|
||||||
|
@ -234,13 +236,13 @@ public class EcdsaSigner extends AbstractJwtSigner implements InitializingBean {
|
||||||
try {
|
try {
|
||||||
signer.initVerify(publicKey);
|
signer.initVerify(publicKey);
|
||||||
signer.update(signingInput.getBytes("UTF-8"));
|
signer.update(signingInput.getBytes("UTF-8"));
|
||||||
signer.verify(s64.getBytes("UTF-8"));
|
value = signer.verify(Base64.decodeBase64(s64));
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -253,13 +253,11 @@ public class RsaSigner extends AbstractJwtSigner implements InitializingBean {
|
||||||
try {
|
try {
|
||||||
signer.initVerify(publicKey);
|
signer.initVerify(publicKey);
|
||||||
signer.update(signingInput.getBytes("UTF-8"));
|
signer.update(signingInput.getBytes("UTF-8"));
|
||||||
value = signer.verify(s64.getBytes("UTF-8"));
|
value = signer.verify(Base64.decodeBase64(s64));
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
return false;
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
|
@ -162,7 +162,8 @@ public class JwtTest {
|
||||||
signer.sign(jwt);
|
signer.sign(jwt);
|
||||||
|
|
||||||
String actual = jwt.toString();
|
String actual = jwt.toString();
|
||||||
|
|
||||||
|
assertThat(signer.verify(actual), equalTo(true));
|
||||||
assertThat(actual, equalTo(expected));
|
assertThat(actual, equalTo(expected));
|
||||||
assertThat(jwt.getSignature(), equalTo(signature));
|
assertThat(jwt.getSignature(), equalTo(signature));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue