public boolean verify(String elements, OAuthSecrets secrets, String signature) throws InvalidSecretException {

        Signature sig;

        try {
            sig = Signature.getInstance(SIGNATURE_ALGORITHM);
        }
        catch (NoSuchAlgorithmException nsae) {
            throw new IllegalStateException(nsae);
        }

        byte[] decodedPubKey;

        try {
            decodedPubKey = Base64.decode(secrets.getConsumerSecret());
        }
        catch (IOException ioe) {
            throw new InvalidSecretException("invalid consumer secret");
        }

        byte[] decodedSignature;

        try {
            decodedSignature = Base64.decode(signature);
        }
        catch (IOException ioe) {
            return false;
        }

        KeyFactory keyf;

        try {
            keyf = KeyFactory.getInstance(KEY_TYPE);
        }
        catch (NoSuchAlgorithmException nsae) {
            throw new IllegalStateException(nsae);
        }

        EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(decodedPubKey);

        RSAPublicKey rsaPubKey;

        try {
            rsaPubKey = (RSAPublicKey)keyf.generatePublic(keySpec);
        }
        catch (InvalidKeySpecException ikse) {
            throw new IllegalStateException(ikse);
        }

        try {
            sig.initVerify(rsaPubKey);
        }
        catch (InvalidKeyException ike) {
            throw new IllegalStateException(ike);
        }

        try {
            sig.update(elements.getBytes());
        }
        catch (SignatureException se) {
            throw new IllegalStateException(se);
        }
        
        try {
            return sig.verify(decodedSignature);
        }
        catch (SignatureException se) {
            throw new IllegalStateException(se);
        }
    }