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;
  }
@Test
  public void testInvalidSignedText() throws Exception {
    Signer signer = new Signer(createStringSignerSecretProvider());
    try {
      signer.verifyAndExtract("test");
      Assert.fail();
    } catch (SignerException ex) {
      // Expected
    } catch (Throwable ex) {
      Assert.fail();
    }
  }