bas64 decoded signature prior to verifying, modified unit rsa unit test, and fixed ecdsa signer verify

pull/59/head
nemonik 2012-04-02 21:32:42 -04:00
parent 985a4619fa
commit 267f1b2de3
3 changed files with 7 additions and 6 deletions

View File

@ -217,6 +217,8 @@ public class EcdsaSigner extends AbstractJwtSigner implements InitializingBean {
@Override
public boolean verify(String jwtString) {
boolean value = false;
// split on the dots
List<String> parts = Lists.newArrayList(Splitter.on(".").split(
jwtString));
@ -234,13 +236,13 @@ public class EcdsaSigner extends AbstractJwtSigner implements InitializingBean {
try {
signer.initVerify(publicKey);
signer.update(signingInput.getBytes("UTF-8"));
signer.verify(s64.getBytes("UTF-8"));
value = signer.verify(Base64.decodeBase64(s64));
} catch (GeneralSecurityException e) {
logger.error(e);
} catch (UnsupportedEncodingException e) {
logger.error(e);
}
return true;
return value;
}
}

View File

@ -253,13 +253,11 @@ public class RsaSigner extends AbstractJwtSigner implements InitializingBean {
try {
signer.initVerify(publicKey);
signer.update(signingInput.getBytes("UTF-8"));
value = signer.verify(s64.getBytes("UTF-8"));
value = signer.verify(Base64.decodeBase64(s64));
} catch (GeneralSecurityException e) {
logger.error(e);
return false;
} catch (UnsupportedEncodingException e) {
logger.error(e);
return false;
}
return value;

View File

@ -162,7 +162,8 @@ public class JwtTest {
signer.sign(jwt);
String actual = jwt.toString();
assertThat(signer.verify(actual), equalTo(true));
assertThat(actual, equalTo(expected));
assertThat(jwt.getSignature(), equalTo(signature));
}