private void prepareEncryptionDictAES(PDEncryption encryptionDictionary, COSName aesVName, byte[][] recipients) { PDCryptFilterDictionary cryptFilterDictionary = new PDCryptFilterDictionary(); cryptFilterDictionary.setCryptFilterMethod(aesVName); cryptFilterDictionary.setLength(keyLength); COSArray array = new COSArray(); for (byte[] recipient : recipients) { array.add(new COSString(recipient)); } cryptFilterDictionary.getCOSDictionary().setItem(COSName.RECIPIENTS, array); encryptionDictionary.setDefaultCryptFilterDictionary(cryptFilterDictionary); encryptionDictionary.setStreamFilterName(COSName.DEFAULT_CRYPT_FILTER); encryptionDictionary.setStringFilterName(COSName.DEFAULT_CRYPT_FILTER); cryptFilterDictionary.getCOSDictionary().setDirect(true); setAES(true); }
private void prepareEncryptionDictAES(PDEncryption encryptionDictionary, COSName aesVName) { PDCryptFilterDictionary cryptFilterDictionary = new PDCryptFilterDictionary(); cryptFilterDictionary.setCryptFilterMethod(aesVName); cryptFilterDictionary.setLength(keyLength); encryptionDictionary.setStdCryptFilterDictionary(cryptFilterDictionary); encryptionDictionary.setStreamFilterName(COSName.STD_CF); encryptionDictionary.setStringFilterName(COSName.STD_CF); setAES(true); }
array = (COSArray) defaultCryptFilterDictionary.getCOSDictionary().getItem(COSName.RECIPIENTS); if (defaultCryptFilterDictionary != null) COSName cryptFilterMethod = defaultCryptFilterDictionary.getCryptFilterMethod(); setAES(COSName.AESV2.equals(cryptFilterMethod) || COSName.AESV3.equals(cryptFilterMethod));
/** * Sets the crypt filter with the given name. * * @param cryptFilterName the name of the crypt filter * @param cryptFilterDictionary the crypt filter to set */ public void setCryptFilterDictionary(COSName cryptFilterName, PDCryptFilterDictionary cryptFilterDictionary) { COSDictionary cfDictionary = (COSDictionary)dictionary.getDictionaryObject( COSName.CF ); if (cfDictionary == null) { cfDictionary = new COSDictionary(); dictionary.setItem(COSName.CF, cfDictionary); } cfDictionary.setItem(cryptFilterName, cryptFilterDictionary.getCOSDictionary()); }
/** * Returns the crypt filter with the given name. * * @param cryptFilterName the name of the crypt filter * * @return the crypt filter with the given name if available */ public PDCryptFilterDictionary getCryptFilterDictionary(COSName cryptFilterName) { // See CF in "Table 20 – Entries common to all encryption dictionaries" COSBase base = dictionary.getDictionaryObject(COSName.CF); if (base instanceof COSDictionary) { COSBase base2 = ((COSDictionary) base).getDictionaryObject(cryptFilterName); if (base2 instanceof COSDictionary) { return new PDCryptFilterDictionary((COSDictionary) base2); } } return null; }
COSName cryptFilterMethod = stdCryptFilterDictionary.getCryptFilterMethod(); setAES(COSName.AESV2.equals(cryptFilterMethod) || COSName.AESV3.equals(cryptFilterMethod));
private void prepareEncryptionDictAES(PDEncryption encryptionDictionary, COSName aesVName) { PDCryptFilterDictionary cryptFilterDictionary = new PDCryptFilterDictionary(); cryptFilterDictionary.setCryptFilterMethod(aesVName); cryptFilterDictionary.setLength(keyLength); encryptionDictionary.setStdCryptFilterDictionary(cryptFilterDictionary); encryptionDictionary.setStreamFilterName(COSName.STD_CF); encryptionDictionary.setStringFilterName(COSName.STD_CF); setAES(true); }
/** * Sets the crypt filter with the given name. * * @param cryptFilterName the name of the crypt filter * @param cryptFilterDictionary the crypt filter to set */ public void setCryptFilterDictionary(COSName cryptFilterName, PDCryptFilterDictionary cryptFilterDictionary) { COSDictionary cfDictionary = (COSDictionary)dictionary.getDictionaryObject( COSName.CF ); if (cfDictionary == null) { cfDictionary = new COSDictionary(); dictionary.setItem(COSName.CF, cfDictionary); } cfDictionary.setItem(cryptFilterName, cryptFilterDictionary.getCOSDictionary()); }
/** * Returns the crypt filter with the given name. * * @param cryptFilterName the name of the crypt filter * * @return the crypt filter with the given name if available */ public PDCryptFilterDictionary getCryptFilterDictionary(COSName cryptFilterName) { COSDictionary cryptFilterDictionary = (COSDictionary) dictionary.getDictionaryObject( COSName.CF ); if (cryptFilterDictionary != null) { COSDictionary stdCryptFilterDictionary = (COSDictionary)cryptFilterDictionary.getDictionaryObject(cryptFilterName); if (stdCryptFilterDictionary != null) { return new PDCryptFilterDictionary(stdCryptFilterDictionary); } } return null; }
COSName cryptFilterMethod = stdCryptFilterDictionary.getCryptFilterMethod(); setAES(COSName.AESV2.equals(cryptFilterMethod) || COSName.AESV3.equals(cryptFilterMethod));
private void prepareEncryptionDictAES(PDEncryption encryptionDictionary, COSName aesVName) { PDCryptFilterDictionary cryptFilterDictionary = new PDCryptFilterDictionary(); cryptFilterDictionary.setCryptFilterMethod(aesVName); cryptFilterDictionary.setLength(keyLength); encryptionDictionary.setStdCryptFilterDictionary(cryptFilterDictionary); encryptionDictionary.setStreamFilterName(COSName.STD_CF); encryptionDictionary.setStringFilterName(COSName.STD_CF); setAES(true); }
/** * Sets the crypt filter with the given name. * * @param cryptFilterName the name of the crypt filter * @param cryptFilterDictionary the crypt filter to set */ public void setCryptFilterDictionary(COSName cryptFilterName, PDCryptFilterDictionary cryptFilterDictionary) { COSDictionary cfDictionary = (COSDictionary)dictionary.getDictionaryObject( COSName.CF ); if (cfDictionary == null) { cfDictionary = new COSDictionary(); dictionary.setItem(COSName.CF, cfDictionary); } cfDictionary.setItem(cryptFilterName, cryptFilterDictionary.getCOSDictionary()); }
/** * Returns the crypt filter with the given name. * * @param cryptFilterName the name of the crypt filter * * @return the crypt filter with the given name if available */ public PDCryptFilterDictionary getCryptFilterDictionary(COSName cryptFilterName) { COSDictionary cryptFilterDictionary = (COSDictionary) dictionary.getDictionaryObject( COSName.CF ); if (cryptFilterDictionary != null) { COSDictionary stdCryptFilterDictionary = (COSDictionary)cryptFilterDictionary.getDictionaryObject(cryptFilterName); if (stdCryptFilterDictionary != null) { return new PDCryptFilterDictionary(stdCryptFilterDictionary); } } return null; }
COSName cryptFilterMethod = stdCryptFilterDictionary.getCryptFilterMethod(); setAES(COSName.AESV2.equals(cryptFilterMethod) || COSName.AESV3.equals(cryptFilterMethod));