Search in sources :

Example 21 with COSString

use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.

the class PDEncryption method getOwnerKey.

/**
 * This will get the O entry in the standard encryption dictionary.
 *
 * @return A 32 byte array or null if there is no owner key.
 *
 * @throws IOException If there is an error accessing the data.
 */
public byte[] getOwnerKey() throws IOException {
    byte[] o = null;
    COSString owner = (COSString) dictionary.getDictionaryObject(COSName.O);
    if (owner != null) {
        o = owner.getBytes();
    }
    return o;
}
Also used : COSString(com.tom_roush.pdfbox.cos.COSString)

Example 22 with COSString

use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.

the class PDEncryption method getUserEncryptionKey.

/**
 * This will get the UE entry in the standard encryption dictionary.
 *
 * @return A 32 byte array or null if there is no user encryption key.
 *
 * @throws IOException If there is an error accessing the data.
 */
public byte[] getUserEncryptionKey() throws IOException {
    byte[] ue = null;
    COSString userEncryptionKey = (COSString) dictionary.getDictionaryObject(COSName.UE);
    if (userEncryptionKey != null) {
        ue = userEncryptionKey.getBytes();
    }
    return ue;
}
Also used : COSString(com.tom_roush.pdfbox.cos.COSString)

Example 23 with COSString

use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.

the class PDEncryption method setRecipients.

/**
 * This will set the Recipients field of the dictionary. This field contains an array
 * of string.
 * @param recipients the array of bytes arrays to put in the Recipients field.
 * @throws IOException If there is an error setting the data.
 */
public void setRecipients(byte[][] recipients) throws IOException {
    COSArray array = new COSArray();
    for (byte[] recipient : recipients) {
        COSString recip = new COSString(recipient);
        array.add(recip);
    }
    dictionary.setItem(COSName.RECIPIENTS, array);
    array.setDirect(true);
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 24 with COSString

use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.

the class PDEncryption method getUserKey.

/**
 * This will get the U entry in the standard encryption dictionary.
 *
 * @return A 32 byte array or null if there is no user key.
 *
 * @throws IOException If there is an error accessing the data.
 */
public byte[] getUserKey() throws IOException {
    byte[] u = null;
    COSString user = (COSString) dictionary.getDictionaryObject(COSName.U);
    if (user != null) {
        u = user.getBytes();
    }
    return u;
}
Also used : COSString(com.tom_roush.pdfbox.cos.COSString)

Example 25 with COSString

use of com.tom_roush.pdfbox.cos.COSString in project PdfBox-Android by TomRoush.

the class PDEncryption method getPerms.

/**
 * Get the Perms entry in the encryption dictionary.
 *
 * @return A 16 byte array or null if there is no Perms entry.
 *
 * @throws IOException If there is an error accessing the data.
 */
public byte[] getPerms() throws IOException {
    byte[] perms = null;
    COSString permsCosString = (COSString) dictionary.getDictionaryObject(COSName.PERMS);
    if (permsCosString != null) {
        perms = permsCosString.getBytes();
    }
    return perms;
}
Also used : COSString(com.tom_roush.pdfbox.cos.COSString)

Aggregations

COSString (com.tom_roush.pdfbox.cos.COSString)65 COSArray (com.tom_roush.pdfbox.cos.COSArray)33 COSBase (com.tom_roush.pdfbox.cos.COSBase)24 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)7 COSDictionary (com.tom_roush.pdfbox.cos.COSDictionary)5 COSName (com.tom_roush.pdfbox.cos.COSName)5 COSArrayList (com.tom_roush.pdfbox.pdmodel.common.COSArrayList)4 Map (java.util.Map)4 COSBoolean (com.tom_roush.pdfbox.cos.COSBoolean)2 COSFloat (com.tom_roush.pdfbox.cos.COSFloat)2 COSInteger (com.tom_roush.pdfbox.cos.COSInteger)2 PDResources (com.tom_roush.pdfbox.pdmodel.PDResources)2 MessageDigest (java.security.MessageDigest)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Operator (com.tom_roush.pdfbox.contentstream.operator.Operator)1