public static boolean isEncrypted(PDFObject dict)
            throws IOException {

        PDFObject filter = dict.getDictRef("Filter");
        if (filter == null) {
            // just apply default decryption
            return dict.getDecrypter().isEncryptionPresent();
        } else {

            // apply filters
            FilterSpec spec = new FilterSpec(dict, filter);

            // determine whether default encryption applies or if there's a
            // specific Crypt filter; it must be the first filter according to
            // the errata for PDF1.7
            boolean specificCryptFilter = spec.ary.length != 0 &&
                    spec.ary[0].getStringValue().equals("Crypt");
            if (!specificCryptFilter) {
                // No Crypt filter, so we just need to refer to
                // the default decrypter
                return dict.getDecrypter().isEncryptionPresent();
            } else {
                String cfName = getCryptFilterName(spec.params[0]);
                // see whether the specified crypt filter really decrypts
                return dict.getDecrypter().isEncryptionPresent(cfName);
            }
        }

    }