@Test public void testInvalidSignedText() throws Exception { Signer signer = new Signer(new StringSignerSecretProvider("secret")); try { signer.verifyAndExtract("test"); Assert.fail(); } catch (SignerException ex) { } catch (Throwable ex) { Assert.fail(); } }
public String verifyAndExtract(String signedStr) throws SignerException { int index = signedStr.lastIndexOf(SIGNATURE); if (index == -1) { throw new SignerException("Invalid signed text: " + signedStr); } String originalSignature = signedStr.substring(index + SIGNATURE.length()); String rawValue = signedStr.substring(0, index); checkSignatures(rawValue, originalSignature); return rawValue; }
Signer { public String verifyAndExtract(String signedStr) throws SignerException { int index = signedStr.lastIndexOf(SIGNATURE); if (index == -1) { throw new SignerException("Invalid signed text: " + signedStr); } String originalSignature = signedStr.substring(index + SIGNATURE.length()); String rawValue = signedStr.substring(0, index); checkSignatures(rawValue, originalSignature); return rawValue; } }
Signer { public String verifyAndExtract(String signedStr) throws SignerException { int index = signedStr.lastIndexOf(SIGNATURE); if (index == -1) { throw new SignerException("Invalid signed text: " + signedStr); } String originalSignature = signedStr.substring(index + SIGNATURE.length()); String rawValue = signedStr.substring(0, index); checkSignatures(rawValue, originalSignature); return rawValue; } Signer(SignerSecretProvider secretProvider); }
Signer { public String verifyAndExtract(String signedStr) throws SignerException { int index = signedStr.lastIndexOf(SIGNATURE); if (index == -1) { throw new SignerException("Invalid signed text: " + signedStr); } String originalSignature = signedStr.substring(index + SIGNATURE.length()); String rawValue = signedStr.substring(0, index); checkSignatures(rawValue, originalSignature); return rawValue; } Signer(SignerSecretProvider secretProvider); synchronized String sign(String str); String verifyAndExtract(String signedStr); }
Signer { public String verifyAndExtract(String signedStr) throws SignerException { int index = signedStr.lastIndexOf(SIGNATURE); if (index == -1) { throw new SignerException("Invalid signed text: " + signedStr); } String originalSignature = signedStr.substring(index + SIGNATURE.length()); String rawValue = signedStr.substring(0, index); checkSignatures(rawValue, originalSignature); return rawValue; } Signer(SignerSecretProvider secretProvider); synchronized String sign(String str); String verifyAndExtract(String signedStr);  }