Search in sources :

Example 56 with COSString

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

the class PDSeedValueCertificate method setOID.

/**
 * (Optional) A list of byte arrays that contain Object Identifiers (OIDs) of the certificate
 * policies that must be present in the signing certificate. This field is only applicable if
 * the value of Issuer is not empty.
 *
 * @param oidByteStrings list of byte arrays that contain OIDs
 */
public void setOID(List<byte[]> oidByteStrings) {
    COSArray array = new COSArray();
    for (byte[] oid : oidByteStrings) {
        array.add(new COSString(oid));
    }
    this.dictionary.setItem(COSName.OID, array);
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 57 with COSString

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

the class PDSeedValueCertificate method removeSubject.

/**
 * removes a subject from the list
 *
 * @param subject byte array containing DER-encoded X.509v3 certificate
 */
public void removeSubject(byte[] subject) {
    COSBase base = this.dictionary.getDictionaryObject(COSName.SUBJECT);
    if (base instanceof COSArray) {
        COSArray array = (COSArray) base;
        array.remove(new COSString(subject));
    }
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSBase(com.tom_roush.pdfbox.cos.COSBase) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 58 with COSString

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

the class PDSeedValueCertificate method setSubject.

/**
 * (Optional) A list of byte arrays containing DER-encoded X.509v3 certificates that are
 * acceptable for signing. if
 * <b>Subject</b> is not null and {@link #isSubjectRequired()} is true then the subject
 * constraint is enforced on the subjects in this array subjects.
 *
 * @param subjects list of byte arrays containing DER-encoded X.509v3 certificates that are
 * acceptable for signing.
 */
public void setSubject(List<byte[]> subjects) {
    COSArray array = new COSArray();
    for (byte[] subject : subjects) {
        array.add(new COSString(subject));
    }
    this.dictionary.setItem(COSName.SUBJECT, array);
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 59 with COSString

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

the class PDSeedValueCertificate method addKeyUsage.

/**
 * (Optional; PDF 1.7) specifies an acceptable key-usage extension that must be presennt in the
 * signing certificate for works like {@link #setKeyUsage(List)} but takes only one string
 *
 * @param keyUsageExtension String that consist only of {0, 1, X}
 */
public void addKeyUsage(String keyUsageExtension) {
    String allowedChars = "01X";
    for (int c = 0; c < keyUsageExtension.length(); c++) {
        if (allowedChars.indexOf(keyUsageExtension.charAt(c)) == -1) {
            throw new IllegalArgumentException("characters can only be 0, 1, X");
        }
    }
    COSBase base = this.dictionary.getDictionaryObject(COSName.KEY_USAGE);
    COSArray array;
    if (base instanceof COSArray) {
        array = (COSArray) base;
    } else {
        array = new COSArray();
    }
    COSString string = new COSString(keyUsageExtension);
    array.add(string);
    this.dictionary.setItem(COSName.KEY_USAGE, array);
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSBase(com.tom_roush.pdfbox.cos.COSBase) COSString(com.tom_roush.pdfbox.cos.COSString) COSString(com.tom_roush.pdfbox.cos.COSString)

Example 60 with COSString

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

the class PDSeedValueCertificate method removeKeyUsage.

/**
 * Removes a key usage extension
 *
 * @param keyUsageExtension ASCII string that consists of {0, 1, X}
 */
public void removeKeyUsage(String keyUsageExtension) {
    COSBase base = this.dictionary.getDictionaryObject(COSName.KEY_USAGE);
    if (base instanceof COSArray) {
        COSArray array = (COSArray) base;
        array.remove(new COSString(keyUsageExtension));
    }
}
Also used : COSArray(com.tom_roush.pdfbox.cos.COSArray) COSBase(com.tom_roush.pdfbox.cos.COSBase) 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