/** * Verifies a signed string and extracts the original string. * * @param signedStr the signed string to verify and extract. * * @return the extracted original string. * * @throws SignerException thrown if the given string is not a signed string or if the signature is invalid. */ 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; }
/** * Verifies a signed string and extracts the original string. * * @param signedStr the signed string to verify and extract. * * @return the extracted original string. * * @throws SignerException thrown if the given string is not a signed string or if the signature is invalid. */ 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; }
/** * Verifies a signed string and extracts the original string. * * @param signedStr the signed string to verify and extract. * * @return the extracted original string. * * @throws SignerException thrown if the given string is not a signed string or if the signature is invalid. */ 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; }
/** * Verifies a signed string and extracts the original string. * * @param signedStr the signed string to verify and extract. * * @return the extracted original string. * * @throws SignerException thrown if the given string is not a signed string or if the signature is invalid. */ 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; }
/** * Verifies a signed string and extracts the original string. * * @param signedStr the signed string to verify and extract. * * @return the extracted original string. * * @throws SignerException thrown if the given string is not a signed string or if the signature is invalid. */ 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; }
/** * Verifies a signed string and extracts the original string. * * @param signedStr the signed string to verify and extract. * * @return the extracted original string. * * @throws SignerException thrown if the given string is not a signed string or if the signature is invalid. */ 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; }
protected void checkSignatures(String rawValue, String originalSignature) throws SignerException { boolean isValid = false; byte[][] secrets = secretProvider.getAllSecrets(); for (int i = 0; i < secrets.length; i++) { byte[] secret = secrets[i]; if (secret != null) { String currentSignature = computeSignature(secret, rawValue); if (originalSignature.equals(currentSignature)) { isValid = true; break; } } } if (!isValid) { throw new SignerException("Invalid signature"); } } }
protected void checkSignatures(String rawValue, String originalSignature) throws SignerException { boolean isValid = false; byte[][] secrets = secretProvider.getAllSecrets(); for (int i = 0; i < secrets.length; i++) { byte[] secret = secrets[i]; if (secret != null) { String currentSignature = computeSignature(secret, rawValue); if (originalSignature.equals(currentSignature)) { isValid = true; break; } } } if (!isValid) { throw new SignerException("Invalid signature"); } } }
protected void checkSignatures(String rawValue, String originalSignature) throws SignerException { boolean isValid = false; byte[][] secrets = secretProvider.getAllSecrets(); for (int i = 0; i < secrets.length; i++) { byte[] secret = secrets[i]; if (secret != null) { String currentSignature = computeSignature(secret, rawValue); if (originalSignature.equals(currentSignature)) { isValid = true; break; } } } if (!isValid) { throw new SignerException("Invalid signature"); } } }
protected void checkSignatures(String rawValue, String originalSignature) throws SignerException { boolean isValid = false; byte[][] secrets = secretProvider.getAllSecrets(); for (int i = 0; i < secrets.length; i++) { byte[] secret = secrets[i]; if (secret != null) { String currentSignature = computeSignature(secret, rawValue); if (originalSignature.equals(currentSignature)) { isValid = true; break; } } } if (!isValid) { throw new SignerException("Invalid signature"); } } }
protected void checkSignatures(String rawValue, String originalSignature) throws SignerException { boolean isValid = false; byte[][] secrets = secretProvider.getAllSecrets(); for (int i = 0; i < secrets.length; i++) { byte[] secret = secrets[i]; if (secret != null) { String currentSignature = computeSignature(secret, rawValue); if (originalSignature.equals(currentSignature)) { isValid = true; break; } } } if (!isValid) { throw new SignerException("Invalid signature"); } } }
protected void checkSignatures(String rawValue, String originalSignature) throws SignerException { byte[] orginalSignatureBytes = StringUtils.getBytesUtf8(originalSignature); boolean isValid = false; byte[][] secrets = secretProvider.getAllSecrets(); for (int i = 0; i < secrets.length; i++) { byte[] secret = secrets[i]; if (secret != null) { String currentSignature = computeSignature(secret, rawValue); if (MessageDigest.isEqual(orginalSignatureBytes, StringUtils.getBytesUtf8(currentSignature))) { isValid = true; break; } } } if (!isValid) { throw new SignerException("Invalid signature"); } } }