List of usage examples for com.itextpdf.text.pdf PdfSignatureAppearance CERTIFIED_NO_CHANGES_ALLOWED
int CERTIFIED_NO_CHANGES_ALLOWED
To view the source code for com.itextpdf.text.pdf PdfSignatureAppearance CERTIFIED_NO_CHANGES_ALLOWED.
Click Source Link
From source file:view.WorkspacePanel.java
License:Open Source License
public void changeCard(CardEnum ce, boolean clear) { if (null == document) { return;// w w w. j av a 2 s . c om } if (status.equals(Status.SIGNING) || imagePanel.getStatus().equals(ImagePanel.Status.RENDERING)) { return; } cl.show(this.rightPanel, ce.name()); jSplitPane1.setDividerSize(5); jSplitPane1.setDividerLocation(0.6); rightPanel.setVisible(true); switch (ce) { case SIGN_PANEL: { try { if (CCInstance.getInstance().getCertificationLevel( document.getDocumentLocation()) != PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED) { status = Status.SIGNING; startSmartcardSearchThread(clear); if (clear) { clearSignatureFields(); createTempSignature(); jtValidation.clearSelection(); } signatureSettings = new CCSignatureSettings(false); btnAddBackground.setText(Bundle.getBundle().getString("btn.addBackground")); } else { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.failedToSign1"), WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE); } } catch (IOException ex) { Logger.getLogger(WorkspacePanel.class.getName()).log(Level.SEVERE, null, ex); } } break; case VALIDATE_PANEL: status = Status.VALIDATING; break; } }
From source file:view.WorkspacePanel.java
License:Open Source License
private void showSignatureValidationDetails(SignatureValidation sv) { if (null == sv) { panelSignatureDetails.setVisible(false); } else {/*from w w w . j av a 2s. com*/ lblRevision.setText("<html><u>" + sv.getRevision() + " " + Bundle.getBundle().getString("of") + " " + sv.getNumRevisions() + " (" + Bundle.getBundle().getString("label.clickToExtractRevision") + ")</u></html>"); final DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("Z"); if (sv.getSignature().getTimeStampToken() == null) { Calendar cal = sv.getSignature().getSignDate(); String date = df.format(cal.getTime()); lblDate.setText(date + " " + sdf.format(cal.getTime()) + " (" + Bundle.getBundle().getString("signerDateTimeSmall") + ")"); } else { Calendar ts = sv.getSignature().getTimeStampDate(); String date = df.format(ts.getTime()); lblDate.setText(date + " " + sdf.format(ts.getTime())); } boolean ltv = (sv.getOcspCertificateStatus() == CertificateStatus.OK || sv.getCrlCertificateStatus() == CertificateStatus.OK); lblLTV.setText(ltv ? Bundle.getBundle().getString("yes") : Bundle.getBundle().getString("no")); String reason = sv.getSignature().getReason(); if (reason == null) { lblReason.setText(Bundle.getBundle().getString("notDefined")); } else if (reason.isEmpty()) { lblReason.setText(Bundle.getBundle().getString("notDefined")); } else { lblReason.setText(reason); } String location = sv.getSignature().getLocation(); if (location == null) { lblLocation.setText(Bundle.getBundle().getString("notDefined")); } else if (location.isEmpty()) { lblLocation.setText(Bundle.getBundle().getString("notDefined")); } else { lblLocation.setText(location); } try { int certLevel = CCInstance.getInstance().getCertificationLevel(document.getDocumentLocation()); if (certLevel == PdfSignatureAppearance.CERTIFIED_FORM_FILLING) { lblAllowsChanges.setText(Bundle.getBundle().getString("onlyAnnotations")); } else if (certLevel == PdfSignatureAppearance.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS) { lblAllowsChanges.setText(Bundle.getBundle().getString("annotationsFormFilling")); } else if (certLevel == PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED) { lblAllowsChanges.setText(Bundle.getBundle().getString("no")); } else { lblAllowsChanges.setText(Bundle.getBundle().getString("yes")); } } catch (IOException ex) { controller.Logger.getLogger().addEntry(ex); } if (sv.getOcspCertificateStatus() == CertificateStatus.OK || sv.getCrlCertificateStatus() == CertificateStatus.OK) { msg = (Bundle.getBundle().getString("validationCheck1") + " " + (sv.getOcspCertificateStatus() == CertificateStatus.OK ? Bundle.getBundle().getString("validationCheck2") + ": " + CCInstance.getInstance().getCertificateProperty( sv.getSignature().getOcsp().getCerts()[0].getSubject(), "CN") + " " + Bundle.getBundle().getString("at") + " " + df.format(sv.getSignature().getOcsp().getProducedAt()) : (sv.getCrlCertificateStatus() == CertificateStatus.OK ? "CRL" : "")) + (sv.getSignature().getTimeStampToken() != null ? "\n" + Bundle.getBundle().getString("validationCheck3") + ": " + CCInstance.getInstance().getCertificateProperty( sv.getSignature().getTimeStampToken().getSID().getIssuer(), "O") : "")); lblAdditionalInfo .setText("<html><u>" + Bundle.getBundle().getString("label.clickToView") + "</u></html>"); lblAdditionalInfo.setForeground(new java.awt.Color(0, 0, 255)); lblAdditionalInfo.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); } else if (sv.getSignature().getTimeStampToken() != null) { msg = (Bundle.getBundle().getString("validationCheck3") + ": " + CCInstance.getInstance() .getCertificateProperty(sv.getSignature().getTimeStampToken().getSID().getIssuer(), "O")); lblAdditionalInfo .setText("<html><u>" + Bundle.getBundle().getString("label.clickToView") + "</u></html>"); lblAdditionalInfo.setForeground(new java.awt.Color(0, 0, 255)); lblAdditionalInfo.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); } else { msg = null; } panelSignatureDetails.setVisible(true); } }
From source file:view.WorkspacePanel.java
License:Open Source License
private void btnApplySignatureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApplySignatureActionPerformed if (tempCCAlias != null) { signatureSettings.setPageNumber(imagePanel.getPageNumber()); signatureSettings.setCcAlias(tempCCAlias); signatureSettings.setReason(tfReason.getText()); signatureSettings.setLocation(tfLocation.getText()); if (jRadioButton1.isSelected()) { signatureSettings.setCertificationLevel(PdfSignatureAppearance.NOT_CERTIFIED); } else if (jRadioButton2.isSelected()) { signatureSettings.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED); } else if (jRadioButton3.isSelected()) { signatureSettings.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING); } else if (jRadioButton4.isSelected()) { signatureSettings/*from w w w .ja v a 2s . co m*/ .setCertificationLevel(PdfSignatureAppearance.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS); } signatureSettings.setOcspClient(true); if (cbTimestamp.isSelected()) { signatureSettings.setTimestamp(true); if (tfTimestamp.getText().isEmpty()) { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.timestampEmpty"), "", JOptionPane.ERROR_MESSAGE); return; } else { signatureSettings.setTimestampServer(tfTimestamp.getText()); } } else { signatureSettings.setTimestamp(false); cbTimestamp.setSelected(false); tfTimestamp.setVisible(false); } signatureSettings.setVisibleSignature(cbVisibleSignature.isSelected()); if (cbVisibleSignature.isSelected()) { Point p = tempSignature.getScaledPositionOnDocument(); Dimension d = tempSignature.getScaledSizeOnDocument(); float p1 = (float) p.getX(); float p3 = (float) d.getWidth() + p1; float p2 = (float) ((document.getPageDimension(imagePanel.getPageNumber(), 0).getHeight()) - (p.getY() + d.getHeight())); float p4 = (float) d.getHeight() + p2; signatureSettings.setVisibleSignature(true); if (tempSignature.getImageLocation() != null) { signatureSettings.getAppearance().setImageLocation(tempSignature.getImageLocation()); } Rectangle rect = new Rectangle(p1, p2, p3, p4); signatureSettings.setSignaturePositionOnDocument(rect); signatureSettings.setText(tfText.getText()); } else { signatureSettings.setVisibleSignature(false); } if (mainWindow.getOpenedFiles().size() > 1) { Object[] options = { Bundle.getBundle().getString("menuItem.allDocuments"), Bundle.getBundle().getString("menuItem.onlyThis"), Bundle.getBundle().getString("btn.cancel") }; int i = JOptionPane.showOptionDialog(null, Bundle.getBundle().getString("msg.multipleDocumentsOpened"), Bundle.getBundle().getString("msg.multipleDocumentsOpenedTitle"), JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (i == 0) { signBatch(signatureSettings); } else if (i == 1) { signDocument(document, true, true); } } else { signDocument(document, true, true); } } else { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("noSmartcardFound"), WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE); changeCard(CardEnum.SIGN_PANEL, false); } }