SignatureClipper { public static void clipSignatures(Collection<PDAnnotation> annotations) { if (nonNull(annotations)) { for (PDAnnotation annotation : annotations) { if (COSName.WIDGET.getName().equals(annotation.getSubtype()) && COSName.SIG.equals(annotation.getCOSObject().getCOSName(COSName.FT))) { clipSignature(annotation.getCOSObject()); } } } } private  SignatureClipper(); static void clipSignatures(Collection<PDAnnotation> annotations); static void clipSignatures(PDDocument doc); static boolean clipSignature(PDField field);  }
@Test public void nullCollectionDoesntFail() { SignatureClipper.clipSignatures((Collection<PDAnnotation>) null); }
@Test public void clipWidget() { PDAnnotationWidget widget = new PDAnnotationWidget(dictionary); SignatureClipper.clipSignatures(Arrays.asList(widget)); assertFalse(widget.getCOSObject().containsKey(COSName.V)); assertFalse(widget.getCOSObject().containsKey(COSName.SV)); assertFalse(widget.getCOSObject().containsKey(COSName.LOCK)); }
@Test public void clipNonWidget() { PDAnnotationLink widget = new PDAnnotationLink(dictionary); SignatureClipper.clipSignatures(Arrays.asList(widget)); assertTrue(widget.getCOSObject().containsKey(COSName.V)); assertTrue(widget.getCOSObject().containsKey(COSName.SV)); assertTrue(widget.getCOSObject().containsKey(COSName.LOCK)); }
@Test public void clipWidgetNonSign() { dictionary.setItem(COSName.FT, COSName.BTN); PDAnnotationWidget widget = new PDAnnotationWidget(dictionary); SignatureClipper.clipSignatures(Arrays.asList(widget)); assertTrue(widget.getCOSObject().containsKey(COSName.V)); assertTrue(widget.getCOSObject().containsKey(COSName.SV)); assertTrue(widget.getCOSObject().containsKey(COSName.LOCK)); }