public static PDFDecrypter createDecryptor
            (PDFObject encryptDict, PDFObject documentId, PDFPassword password)
            throws
            IOException,
            EncryptionUnsupportedByPlatformException,
            EncryptionUnsupportedByProductException,
            PDFAuthenticationFailureException {

        // none of the classes beyond us want to see a null PDFPassword
        password = PDFPassword.nonNullPassword(password);

        if (encryptDict == null) {
            // No encryption specified
            return IdentityDecrypter.getInstance();
        } else {
            PDFObject filter = encryptDict.getDictRef("Filter");
            // this means that we'll fail if, for example, public key
            // encryption is employed
            if (filter != null && "Standard".equals(filter.getStringValue())) {
                final PDFObject vObj = encryptDict.getDictRef("V");
                int v = vObj != null ? vObj.getIntValue() : 0;
                if (v == 1 || v == 2) {
                    final PDFObject lengthObj =
                            encryptDict.getDictRef("Length");
                    final Integer length =
                            lengthObj != null ? lengthObj.getIntValue() : null;
                    return createStandardDecrypter(
                            encryptDict, documentId, password, length, false,
                            StandardDecrypter.EncryptionAlgorithm.RC4);
                } else if (v == 4) {
                    return createCryptFilterDecrypter(
                            encryptDict, documentId, password, v);
                } else {
                    throw new EncryptionUnsupportedByPlatformException(
                            "Unsupported encryption version: " + v);
                }
            } else if (filter == null) {
                throw new PDFParseException(
                        "No Filter specified in Encrypt dictionary");
            } else {
                throw new EncryptionUnsupportedByPlatformException(
                        "Unsupported encryption Filter: " + filter +
                                "; only Standard is supported.");
            }
        }
    }