فهرست منبع

PDFTool(Android) - 1.新增信任证书功能 2.修复bug

liuxiaolong 1 سال پیش
والد
کامیت
a025567615
18فایلهای تغییر یافته به همراه396 افزوده شده و 67 حذف شده
  1. BIN
      ComPDFKit_Repo/compdfkit/ComPDFKit.aar
  2. 6 0
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/adapter/CBaseQuickViewHolder.java
  3. 24 36
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/CertificateDigitalDatas.java
  4. 23 0
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/bean/CPDFCertAttrDataItem.java
  5. 1 1
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/importcert/create/CreateCertificateDigitalDialog.java
  6. 16 3
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/info/CertAttrListAdapter.java
  7. 29 1
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/info/CertDetailsDialog.java
  8. 52 1
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/info/CertDigitalSignAttributesDialog.java
  9. 56 15
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/info/CertDigitalSignInfoDialog.java
  10. 1 1
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/info/signlist/CPDFCertDigitalSignListDialog.java
  11. 5 5
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/pdfproperties/pdfsign/CDigitalSignStyleData.java
  12. 3 3
      ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/pdfproperties/pdfsign/CDigitalSignStylePreviewView.java
  13. 7 0
      ComPDFKit_Tools/src/main/res/drawable/tools_ic_cert_trusted_checkbox_radio.xml
  14. 23 0
      ComPDFKit_Tools/src/main/res/drawable/tools_ic_cert_trusted_normal.xml
  15. 10 0
      ComPDFKit_Tools/src/main/res/drawable/tools_ic_cert_trusted_select.xml
  16. 131 0
      ComPDFKit_Tools/src/main/res/layout/tools_sign_certificate_attributes_list_trusted_cert_item.xml
  17. 8 0
      ComPDFKit_Tools/src/main/res/values/tools_strings.xml
  18. 1 1
      config.gradle

BIN
ComPDFKit_Repo/compdfkit/ComPDFKit.aar


+ 6 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/common/utils/adapter/CBaseQuickViewHolder.java

@@ -6,6 +6,7 @@ import android.util.SparseArray;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.CheckBox;
 import android.widget.ImageView;
 import android.widget.TextView;
 
@@ -91,6 +92,11 @@ public class CBaseQuickViewHolder extends RecyclerView.ViewHolder {
         getView(viewId).setEnabled(enable);
     }
 
+    public void setChecked(@IdRes int viewId, boolean checked){
+        CheckBox checkBox = getView(viewId);
+        checkBox.setChecked(checked);
+    }
+
     public void setSelected(@IdRes int viewId, boolean selected) {
         getView(viewId).setSelected(selected);
     }

+ 24 - 36
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/CertificateDigitalDatas.java

@@ -113,29 +113,14 @@ public class CertificateDigitalDatas {
                                          String password,
                                          String savePath
     ) {
-        if (!TextUtils.isEmpty(document.getAbsolutePath())) {
-            return document.writeSignatureToPath(signatureWidget,
-                    document.getAbsolutePath(),
-                    savePath,
-                    certPath,
-                    password,
-                    styleData.getPosition(),
-                    styleData.getReason(),
-                    CPDFDocument.PDFDocMdpP.PDFDocMdpPForbidAllModify
-            );
-        } else if (document.getUri() != null) {
-            return document.writeSignatureToPath(signatureWidget,
-                    CUriUtil.getUriFd(document.getContext(), document.getUri()),
-                    savePath,
-                    certPath,
-                    password,
-                    styleData.getPosition(),
-                    styleData.getReason(),
-                    CPDFDocument.PDFDocMdpP.PDFDocMdpPForbidAllModify
-            );
-        } else {
-            return false;
-        }
+        return document.writeSignature(signatureWidget,
+                savePath,
+                certPath,
+                password,
+                styleData.getLocation(),
+                styleData.getReason(),
+                CPDFDocument.PDFDocMdpP.PDFDocMdpPForbidAllModify
+        );
     }
 
     /**
@@ -147,27 +132,30 @@ public class CertificateDigitalDatas {
      */
     public static CPDFSignatureStatusInfo verifyGetSignatureStatusInfo(CPDFDocument document, CPDFSignature signature) {
         CPDFSigner signer = signature.getSignerArr()[0];
-        boolean verifyValid;
-        if (!TextUtils.isEmpty(document.getAbsolutePath())) {
-            verifyValid =  signature.verifyByPath(signer, document.getAbsolutePath());
-        } else {
-            verifyValid =  signature.verifyByFd(signer, CUriUtil.getUriFd(document.getContext(), document.getUri()));
-        }
+        boolean verifyValid = signature.verify(document);
         boolean notChanged = signature.verifyDocument(document);
         // The signature is valid and the signature has not been modified to be valid
         boolean isSignVerified = verifyValid && notChanged;
         // Check if the certificate is trusted
-        boolean isCertTrusted = signer.getCert().verifyGetChain(document.getContext(), signature);
+        boolean certChainTrusted = signer.getCert().verifyGetChain(document.getContext(), signature);
+        boolean certificateIsTrusted = signer.getCert().checkCertificateIsTrusted(document.getContext());
+        boolean isTrusted = certChainTrusted || certificateIsTrusted;
         boolean isExpired = signer.getCert().isExpired();
         SignatureStatus status;
-        if (isSignVerified && isCertTrusted){
+        if (isSignVerified && isTrusted) {
             status = SignatureStatus.SUCCESS;
-        } else if (isSignVerified && !isCertTrusted){
+        } else if (isSignVerified && !isTrusted) {
             status = SignatureStatus.UNKNOWN;
         } else {
             status = SignatureStatus.FAILURE;
         }
-        return new CPDFSignatureStatusInfo(document.getContext(), signature,status, isSignVerified, isExpired, notChanged, isCertTrusted);
+        return new CPDFSignatureStatusInfo(document.getContext(), signature, status, isSignVerified, isExpired, notChanged, isTrusted);
+    }
+
+    public static boolean certIsTrusted(Context context, CPDFSignature signature, CPDFX509 cpdfx509){
+        boolean certChainTrusted = cpdfx509.verifyGetChain(context, signature);
+        boolean certificateIsTrusted = cpdfx509.checkCertificateIsTrusted(context);
+        return  certChainTrusted || certificateIsTrusted;
     }
 
     /**
@@ -203,8 +191,8 @@ public class CertificateDigitalDatas {
                 return new CPDFDocumentSignInfo(SignatureStatus.FAILURE, info);
             }
             String info;
-            if (hasUnknownStatusSign){
-                info = document.getContext().getString( R.string.tools_sign_validity_is_unknown);
+            if (hasUnknownStatusSign) {
+                info = document.getContext().getString(R.string.tools_sign_validity_is_unknown);
                 return new CPDFDocumentSignInfo(SignatureStatus.UNKNOWN, info);
             } else {
                 info = document.getContext().getString(R.string.tools_sign_the_sign_is_valid);
@@ -217,7 +205,7 @@ public class CertificateDigitalDatas {
 
     public static boolean removeDigitalSign(CPDFDocument document, CPDFSignature signature) {
         try {
-            boolean result = signature.removeSignature(document, true);
+            boolean result = document.removeSignature(signature, true);
             document.save();
             return result;
         } catch (Exception e) {

+ 23 - 0
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/bean/CPDFCertAttrDataItem.java

@@ -12,6 +12,9 @@ package com.compdfkit.tools.signature.bean;
 
 public class CPDFCertAttrDataItem {
 
+    public CPDFCertAttrDataItem() {
+    }
+
     public CPDFCertAttrDataItem(String headTitle){
         this.headTitle = headTitle;
         this.isHead = true;
@@ -24,6 +27,10 @@ public class CPDFCertAttrDataItem {
 
     private boolean isHead;
 
+    private boolean isCertTrustedType;
+
+    private boolean certIsTrusted;
+
     private String headTitle;
 
     private String title;
@@ -61,4 +68,20 @@ public class CPDFCertAttrDataItem {
     public void setHeadTitle(String headTitle) {
         this.headTitle = headTitle;
     }
+
+    public boolean isCertTrustedType() {
+        return isCertTrustedType;
+    }
+
+    public void setCertTrustedType(boolean certTrustedType) {
+        isCertTrustedType = certTrustedType;
+    }
+
+    public boolean isCertIsTrusted() {
+        return certIsTrusted;
+    }
+
+    public void setCertIsTrusted(boolean certIsTrusted) {
+        this.certIsTrusted = certIsTrusted;
+    }
 }

+ 1 - 1
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/importcert/create/CreateCertificateDigitalDialog.java

@@ -244,7 +244,7 @@ public class CreateCertificateDigitalDialog extends CBasicBottomSheetDialogFragm
             boolean success = CertificateDigitalDatas.generatePKCS12Cert(ownerInfo, etPassword.getText(),
                     saveDir, fileName);
             boolean exists = certFile.exists();
-            if (success && exists) {
+            if (success) {
                 if (selectCertFileListener != null) {
                     selectCertFileListener.certificateFile(certFile.getAbsolutePath(), etPassword.getText());
                 }

+ 16 - 3
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/info/CertAttrListAdapter.java

@@ -10,6 +10,7 @@
 package com.compdfkit.tools.signature.info;
 
 import android.content.Context;
+import android.view.View;
 import android.view.ViewGroup;
 
 import com.compdfkit.tools.R;
@@ -24,11 +25,15 @@ public class CertAttrListAdapter extends CBaseQuickAdapter<CPDFCertAttrDataItem,
 
     public static final int ITEM_CONTENT = 1;
 
+    public static final int ITEM_CERT_TRUSTED = 2;
+
     @Override
     protected CBaseQuickViewHolder onCreateViewHolder(Context context, ViewGroup parent, int viewType) {
         if (viewType == ITEM_HEAD){
             return new CBaseQuickViewHolder(R.layout.tools_sign_certificate_attributes_list_head_item, parent);
-        }else {
+        } else if (viewType == ITEM_CERT_TRUSTED) {
+            return new CBaseQuickViewHolder(R.layout.tools_sign_certificate_attributes_list_trusted_cert_item, parent);
+        } else {
             return new CBaseQuickViewHolder(R.layout.tools_sign_certificate_attributes_list_item, parent);
         }
     }
@@ -37,6 +42,8 @@ public class CertAttrListAdapter extends CBaseQuickAdapter<CPDFCertAttrDataItem,
     public int getItemViewType(int position) {
         if (list.get(position).isHead()) {
             return ITEM_HEAD;
+        } else if (list.get(position).isCertTrustedType()) {
+            return ITEM_CERT_TRUSTED;
         } else {
             return ITEM_CONTENT;
         }
@@ -46,10 +53,16 @@ public class CertAttrListAdapter extends CBaseQuickAdapter<CPDFCertAttrDataItem,
     protected void onBindViewHolder(CBaseQuickViewHolder holder, int position, CPDFCertAttrDataItem item) {
         if (item.isHead()) {
             holder.setText(R.id.tv_head, item.getHeadTitle());
-        }else {
+        } else if (item.isCertTrustedType()) {
+            holder.setChecked(R.id.cb_1, item.isCertIsTrusted());
+            holder.setChecked(R.id.cb_2, item.isCertIsTrusted());
+            holder.setChecked(R.id.cb_3, item.isCertIsTrusted());
+            holder.setChecked(R.id.cb_4, item.isCertIsTrusted());
+            holder.setChecked(R.id.cb_5, item.isCertIsTrusted());
+            holder.getView(R.id.btn_trusted).setVisibility(item.isCertIsTrusted() ? View.INVISIBLE : View.VISIBLE);
+        } else {
             holder.setText(R.id.tv_attr_title, item.getTitle() + ":");
             holder.setText(R.id.tv_attr_value, item.getValue());
         }
-
     }
 }

+ 29 - 1
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/info/CertDetailsDialog.java

@@ -10,9 +10,11 @@
 package com.compdfkit.tools.signature.info;
 
 
+import android.content.DialogInterface;
 import android.os.Bundle;
 import android.view.View;
 
+import androidx.annotation.NonNull;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 
@@ -20,6 +22,7 @@ import com.compdfkit.core.document.signature.CPDFSignature;
 import com.compdfkit.core.document.signature.CPDFX509;
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.common.basic.fragment.CBasicBottomSheetDialogFragment;
+import com.compdfkit.tools.common.interfaces.COnDialogDismissListener;
 import com.compdfkit.tools.common.utils.viewutils.CViewUtils;
 import com.compdfkit.tools.common.views.CToolBar;
 import com.compdfkit.tools.signature.CertificateDigitalDatas;
@@ -38,6 +41,9 @@ public class CertDetailsDialog extends CBasicBottomSheetDialogFragment {
 
     private CertDetailsListAdapter detailsListAdapter;
 
+    private COnDialogDismissListener dialogDismissListener;
+
+
     public static CertDetailsDialog newInstance(CPDFSignature signature) {
         Bundle args = new Bundle();
         CertDetailsDialog fragment = new CertDetailsDialog();
@@ -93,7 +99,8 @@ public class CertDetailsDialog extends CBasicBottomSheetDialogFragment {
         CertificateDigitalDatas.getCertDetails(getContext(), signature);
         detailsListAdapter.setOnItemClickListener((adapter, view1, position) -> {
             CPDFOwnerItemData item = detailsListAdapter.list.get(position);
-            CertDigitalSignAttributesDialog dialog = CertDigitalSignAttributesDialog.newInstance(item.getCpdfx509());
+            CertDigitalSignAttributesDialog dialog = CertDigitalSignAttributesDialog.newInstance(signature, item.getCpdfx509());
+            dialog.setTrustedCertRefreshListener(dialogDismissListener);
             dialog.show(getChildFragmentManager(), "certAttrDialog");
         });
         initData();
@@ -112,4 +119,25 @@ public class CertDetailsDialog extends CBasicBottomSheetDialogFragment {
         }
         detailsListAdapter.setList(dataList);
     }
+
+    @Override
+    public void onCancel(@NonNull DialogInterface dialog) {
+        super.onCancel(dialog);
+        if (dialogDismissListener != null) {
+            dialogDismissListener.dismiss();
+        }
+    }
+
+    @Override
+    public void onDismiss(@NonNull DialogInterface dialog) {
+        super.onDismiss(dialog);
+        if (dialogDismissListener != null) {
+            dialogDismissListener.dismiss();
+        }
+    }
+
+
+    public void setTrustedCertRefreshListener(COnDialogDismissListener dialogDismissListener) {
+        this.dialogDismissListener = dialogDismissListener;
+    }
 }

+ 52 - 1
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/info/CertDigitalSignAttributesDialog.java

@@ -10,17 +10,22 @@
 package com.compdfkit.tools.signature.info;
 
 
+import android.content.DialogInterface;
 import android.os.Bundle;
 import android.view.View;
 
+import androidx.annotation.NonNull;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 
+import com.compdfkit.core.document.signature.CPDFSignature;
 import com.compdfkit.core.document.signature.CPDFX509;
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.common.basic.fragment.CBasicBottomSheetDialogFragment;
+import com.compdfkit.tools.common.interfaces.COnDialogDismissListener;
 import com.compdfkit.tools.common.utils.viewutils.CViewUtils;
 import com.compdfkit.tools.common.views.CToolBar;
+import com.compdfkit.tools.signature.CertificateDigitalDatas;
 import com.compdfkit.tools.signature.bean.CPDFCertAttrDataItem;
 
 import java.util.ArrayList;
@@ -34,12 +39,19 @@ public class CertDigitalSignAttributesDialog extends CBasicBottomSheetDialogFrag
 
     private CPDFX509 cpdfx509;
 
+    private CPDFSignature signature;
+
     private CertAttrListAdapter attrListAdapter;
 
-    public static CertDigitalSignAttributesDialog newInstance(CPDFX509 cpdfx509) {
+    private COnDialogDismissListener dialogDismissListener;
+
+    private boolean isTrusted = false;
+
+    public static CertDigitalSignAttributesDialog newInstance(CPDFSignature signature, CPDFX509 cpdfx509) {
         Bundle args = new Bundle();
         CertDigitalSignAttributesDialog fragment = new CertDigitalSignAttributesDialog();
         fragment.setCpdfx509(cpdfx509);
+        fragment.setSignature(signature);
         fragment.setArguments(args);
         return fragment;
     }
@@ -48,6 +60,10 @@ public class CertDigitalSignAttributesDialog extends CBasicBottomSheetDialogFrag
         this.cpdfx509 = cpdfx509;
     }
 
+    public void setSignature(CPDFSignature signature) {
+        this.signature = signature;
+    }
+
     @Override
     protected int getStyle() {
         return R.style.Tools_Base_Theme_BasicBottomSheetDialogStyle;
@@ -87,6 +103,15 @@ public class CertDigitalSignAttributesDialog extends CBasicBottomSheetDialogFrag
         recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
         attrListAdapter = new CertAttrListAdapter();
         recyclerView.setAdapter(attrListAdapter);
+        attrListAdapter.addOnItemChildClickListener(R.id.btn_trusted, (adapter, view, position) -> {
+            boolean result = cpdfx509.addToTrustedCertificates(getContext());
+            CPDFCertAttrDataItem item = attrListAdapter.list.get(position);
+            if (result){
+                isTrusted = true;
+                item.setCertIsTrusted(true);
+                attrListAdapter.notifyDataSetChanged();
+            }
+        });
         initData();
     }
 
@@ -97,7 +122,33 @@ public class CertDigitalSignAttributesDialog extends CBasicBottomSheetDialogFrag
             list.addAll(CertAttrDatas.getAbstractInfo(getContext(), cpdfx509));
             list.add(new CPDFCertAttrDataItem(getString(R.string.tools_details)));
             list.addAll(CertAttrDatas.getCertAttrDetailInfoList(getContext(), cpdfx509));
+            list.add(new CPDFCertAttrDataItem(getString(R.string.tools_trust)));
+            CPDFCertAttrDataItem item = new CPDFCertAttrDataItem();
+            item.setCertTrustedType(true);
+            item.setCertIsTrusted(CertificateDigitalDatas.certIsTrusted(getContext(), signature, cpdfx509));
+            list.add(item);
             attrListAdapter.setList(list);
         }
     }
+
+    @Override
+    public void onCancel(@NonNull DialogInterface dialog) {
+        super.onCancel(dialog);
+        if (dialogDismissListener != null && isTrusted) {
+            dialogDismissListener.dismiss();
+        }
+    }
+
+    @Override
+    public void onDismiss(@NonNull DialogInterface dialog) {
+        super.onDismiss(dialog);
+        if (dialogDismissListener != null && isTrusted) {
+            dialogDismissListener.dismiss();
+        }
+    }
+
+
+    public void setTrustedCertRefreshListener(COnDialogDismissListener dialogDismissListener) {
+        this.dialogDismissListener = dialogDismissListener;
+    }
 }

+ 56 - 15
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/info/CertDigitalSignInfoDialog.java

@@ -10,9 +10,11 @@
 package com.compdfkit.tools.signature.info;
 
 
+import android.content.DialogInterface;
 import android.os.Bundle;
 import android.view.View;
 
+import androidx.annotation.NonNull;
 import androidx.appcompat.widget.AppCompatButton;
 import androidx.appcompat.widget.AppCompatImageView;
 import androidx.appcompat.widget.AppCompatTextView;
@@ -24,6 +26,7 @@ import com.compdfkit.core.document.signature.CPDFSigner;
 import com.compdfkit.core.document.signature.CPDFX509;
 import com.compdfkit.tools.R;
 import com.compdfkit.tools.common.basic.fragment.CBasicBottomSheetDialogFragment;
+import com.compdfkit.tools.common.interfaces.COnDialogDismissListener;
 import com.compdfkit.tools.common.utils.date.CDateUtil;
 import com.compdfkit.tools.signature.CertificateDigitalDatas;
 import com.compdfkit.tools.signature.bean.CPDFSignatureStatusInfo;
@@ -46,6 +49,10 @@ public class CertDigitalSignInfoDialog extends CBasicBottomSheetDialogFragment i
 
     private CPDFDocument document;
 
+    private COnDialogDismissListener dialogDismissListener;
+
+    private boolean refresh = false;
+
     public static CertDigitalSignInfoDialog newInstance() {
         Bundle args = new Bundle();
         CertDigitalSignInfoDialog fragment = new CertDigitalSignInfoDialog();
@@ -96,23 +103,32 @@ public class CertDigitalSignInfoDialog extends CBasicBottomSheetDialogFragment i
     @Override
     protected void onViewCreate() {
         tvTitle.setText(R.string.tools_digital_signature_detail);
-        if (cpdfSignature != null) {
-            CPDFSigner[] signers = cpdfSignature.getSignerArr();
-            if (signers != null && signers.length > 0) {
-                CPDFX509 cert = signers[0].getCert();
-                CPDFCertInfo certInfo = cert.getCertInfo();
-                String commonName = certInfo.getSubject().getCommonName();
-                tvFounder.setText(commonName);
-            }
-            String date = CDateUtil.transformPDFDate(cpdfSignature.getDate());
-            tvDateOfSignature.setText(CDateUtil.formatDate(date, CDateUtil.NORMAL_DATE_FORMAT_2));
-            CPDFSignatureStatusInfo signatureStatusInfo = CertificateDigitalDatas.verifyGetSignatureStatusInfo(document, cpdfSignature);
-            StringBuilder builder = new StringBuilder();
-            for (String certAuthorityStatement : signatureStatusInfo.getCertAuthorityStatements()) {
-                builder.append(certAuthorityStatement).append("\n\n");
+        refreshInfo();
+    }
+
+    private void refreshInfo() {
+        try {
+            if (cpdfSignature != null) {
+                CPDFSigner[] signers = cpdfSignature.getSignerArr();
+                if (signers != null && signers.length > 0) {
+                    CPDFX509 cert = signers[0].getCert();
+                    CPDFCertInfo certInfo = cert.getCertInfo();
+                    String commonName = certInfo.getSubject().getCommonName();
+                    tvFounder.setText(commonName);
+                }
+                String date = CDateUtil.transformPDFDate(cpdfSignature.getDate());
+                tvDateOfSignature.setText(CDateUtil.formatDate(date, CDateUtil.NORMAL_DATE_FORMAT_2));
+                CPDFSignatureStatusInfo signatureStatusInfo = CertificateDigitalDatas.verifyGetSignatureStatusInfo(document, cpdfSignature);
+                StringBuilder builder = new StringBuilder();
+                for (String certAuthorityStatement : signatureStatusInfo.getCertAuthorityStatements()) {
+                    builder.append(certAuthorityStatement).append("\n\n");
+                }
+                tvSignStatement.setText(builder);
             }
-            tvSignStatement.setText(builder);
+        }catch (Exception e){
+
         }
+
     }
 
     @Override
@@ -121,7 +137,32 @@ public class CertDigitalSignInfoDialog extends CBasicBottomSheetDialogFragment i
             dismiss();
         } else if (v.getId() == R.id.btn_cert_detail) {
             CertDetailsDialog detailsDialog = CertDetailsDialog.newInstance(cpdfSignature);
+            detailsDialog.setTrustedCertRefreshListener(() -> {
+                refresh = true;
+                refreshInfo();
+            });
             detailsDialog.show(getChildFragmentManager(), "certDetailDialog");
         }
     }
+
+    @Override
+    public void onCancel(@NonNull DialogInterface dialog) {
+        super.onCancel(dialog);
+        if (dialogDismissListener != null && refresh) {
+            dialogDismissListener.dismiss();
+        }
+    }
+
+    @Override
+    public void onDismiss(@NonNull DialogInterface dialog) {
+        super.onDismiss(dialog);
+        if (dialogDismissListener != null&& refresh) {
+            dialogDismissListener.dismiss();
+        }
+    }
+
+
+    public void setTrustedCertRefreshListener(COnDialogDismissListener dialogDismissListener) {
+        this.dialogDismissListener = dialogDismissListener;
+    }
 }

+ 1 - 1
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/info/signlist/CPDFCertDigitalSignListDialog.java

@@ -93,6 +93,7 @@ public class CPDFCertDigitalSignListDialog extends CBasicBottomSheetDialogFragme
         signListAdapter.setOnItemClickListener((adapter, view1, position) -> {
             CPDFSignatureStatusInfo signature = adapter.list.get(position);
             CertDigitalSignInfoDialog infoDialog = CertDigitalSignInfoDialog.newInstance();
+            infoDialog.setTrustedCertRefreshListener(()-> initSignatureDatas());
             infoDialog.setPDFSignature(signature.getSignature());
             infoDialog.setDocument(pdfView.getCPdfReaderView().getPDFDocument());
             infoDialog.show(getChildFragmentManager(), "signInfoDialog");
@@ -107,7 +108,6 @@ public class CPDFCertDigitalSignListDialog extends CBasicBottomSheetDialogFragme
                 boolean result = CertificateDigitalDatas.removeDigitalSign(pdfView.getCPdfReaderView().getPDFDocument(), signature.getSignature());
                 if (result) {
                     signListAdapter.remove(position);
-                    signListAdapter.notifyItemRemoved(position);
                 }
                 alertDialog.dismiss();
             });

+ 5 - 5
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/pdfproperties/pdfsign/CDigitalSignStyleData.java

@@ -40,7 +40,7 @@ public class CDigitalSignStyleData implements Serializable {
 
     private CDigitalSignStylePreviewView.Alignment alignment = CDigitalSignStylePreviewView.Alignment.left;
 
-    private String position;
+    private String location;
 
     private String reason;
 
@@ -62,12 +62,12 @@ public class CDigitalSignStyleData implements Serializable {
         this.signImagePath = signImagePath;
     }
 
-    public String getPosition() {
-        return position;
+    public String getLocation() {
+        return location;
     }
 
-    public void setPosition(String position) {
-        this.position = position;
+    public void setLocation(String location) {
+        this.location = location;
     }
 
     public String getReason() {

+ 3 - 3
ComPDFKit_Tools/src/main/java/com/compdfkit/tools/signature/pdfproperties/pdfsign/CDigitalSignStylePreviewView.java

@@ -131,7 +131,7 @@ public class CDigitalSignStylePreviewView extends FrameLayout {
     }
 
     public void setPosition(String position) {
-        previewData.setPosition(position);
+        previewData.setLocation(position);
         update();
     }
 
@@ -187,11 +187,11 @@ public class CDigitalSignStylePreviewView extends FrameLayout {
             if (showReason){
                 appendData(builder, showTab, R.string.tools_reason, previewData.getReason());
             }
-            if (!TextUtils.isEmpty(builder) && showPosition && !TextUtils.isEmpty(previewData.getPosition())){
+            if (!TextUtils.isEmpty(builder) && showPosition && !TextUtils.isEmpty(previewData.getLocation())){
                 builder.append("\n");
             }
             if (showPosition){
-                appendData(builder, showTab, R.string.tools_location, previewData.getPosition());
+                appendData(builder, showTab, R.string.tools_location, previewData.getLocation());
             }
             if (!TextUtils.isEmpty(builder) && showDate && !TextUtils.isEmpty(previewData.getDate())){
                 builder.append("\n");

+ 7 - 0
ComPDFKit_Tools/src/main/res/drawable/tools_ic_cert_trusted_checkbox_radio.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:drawable="@drawable/tools_ic_cert_trusted_select" android:state_checked="true"/>
+    <item android:drawable="@drawable/tools_ic_cert_trusted_select" android:state_selected="true"/>
+    <item android:drawable="@drawable/tools_ic_cert_trusted_normal"/>
+</selector>

+ 23 - 0
ComPDFKit_Tools/src/main/res/drawable/tools_ic_cert_trusted_normal.xml

@@ -0,0 +1,23 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="20dp"
+    android:height="20dp"
+    android:viewportWidth="20"
+    android:viewportHeight="20">
+  <path
+      android:pathData="M17.5,10C17.5,14.142 14.142,17.5 10,17.5C5.858,17.5 2.5,14.142 2.5,10C2.5,5.858 5.858,2.5 10,2.5C14.142,2.5 17.5,5.858 17.5,10Z"
+      android:fillColor="#FF6666"/>
+  <path
+      android:pathData="M12,8L8,12"
+      android:strokeLineJoin="round"
+      android:strokeWidth="1.5"
+      android:fillColor="#00000000"
+      android:strokeColor="#ffffff"
+      android:strokeLineCap="square"/>
+  <path
+      android:pathData="M8,8L12,12"
+      android:strokeLineJoin="round"
+      android:strokeWidth="1.5"
+      android:fillColor="#00000000"
+      android:strokeColor="#ffffff"
+      android:strokeLineCap="square"/>
+</vector>

+ 10 - 0
ComPDFKit_Tools/src/main/res/drawable/tools_ic_cert_trusted_select.xml

@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="20dp"
+    android:height="20dp"
+    android:viewportWidth="20"
+    android:viewportHeight="20">
+  <path
+      android:pathData="M10,17.5C14.142,17.5 17.5,14.142 17.5,10C17.5,5.858 14.142,2.5 10,2.5C5.858,2.5 2.5,5.858 2.5,10C2.5,14.142 5.858,17.5 10,17.5ZM9.743,12.98L13.91,7.98L12.757,7.02L9.116,11.389L7.197,9.47L6.136,10.53L8.636,13.03L9.217,13.611L9.743,12.98Z"
+      android:fillColor="#3CCD75"
+      android:fillType="evenOdd"/>
+</vector>

+ 131 - 0
ComPDFKit_Tools/src/main/res/layout/tools_sign_certificate_attributes_list_trusted_cert_item.xml

@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_marginVertical="16dp">
+
+
+    <androidx.appcompat.widget.AppCompatTextView
+        android:id="@+id/tv_attr_title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="16dp"
+        android:text="@string/tools_cert_is_trusted_to"
+        android:textColor="@color/tools_text_color_secondary"
+        android:textStyle="bold"
+        app:layout_constrainedWidth="true"
+        app:layout_constraintHorizontal_bias="0"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <androidx.appcompat.widget.AppCompatCheckBox
+        android:id="@+id/cb_1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="16dp"
+        android:layout_marginTop="8dp"
+        android:focusable="false"
+        android:clickable="false"
+        android:button="@drawable/tools_ic_cert_trusted_checkbox_radio"
+        android:paddingStart="8dp"
+        android:text="@string/tools_trusted_1"
+        app:layout_constrainedWidth="true"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/tv_attr_title" />
+
+    <androidx.appcompat.widget.AppCompatCheckBox
+        android:id="@+id/cb_2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="16dp"
+        android:layout_marginTop="8dp"
+        android:focusable="false"
+        android:clickable="false"
+        android:button="@drawable/tools_ic_cert_trusted_checkbox_radio"
+        android:paddingStart="8dp"
+        android:text="@string/tools_trusted_2"
+        app:layout_constrainedWidth="true"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/cb_1" />
+
+    <androidx.appcompat.widget.AppCompatCheckBox
+        android:id="@+id/cb_3"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="16dp"
+        android:layout_marginTop="8dp"
+        android:focusable="false"
+        android:clickable="false"
+        android:button="@drawable/tools_ic_cert_trusted_checkbox_radio"
+        android:paddingStart="8dp"
+        android:text="@string/tools_trusted_3"
+        app:layout_constrainedWidth="true"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/cb_2" />
+
+    <androidx.appcompat.widget.AppCompatCheckBox
+        android:id="@+id/cb_4"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="16dp"
+        android:layout_marginTop="8dp"
+        android:focusable="false"
+        android:clickable="false"
+        android:button="@drawable/tools_ic_cert_trusted_checkbox_radio"
+        android:paddingStart="8dp"
+        android:text="@string/tools_trusted_4"
+        app:layout_constrainedWidth="true"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/cb_3" />
+
+    <androidx.appcompat.widget.AppCompatCheckBox
+        android:id="@+id/cb_5"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="16dp"
+        android:layout_marginTop="8dp"
+        android:focusable="false"
+        android:clickable="false"
+        android:button="@drawable/tools_ic_cert_trusted_checkbox_radio"
+        android:paddingStart="8dp"
+        android:text="@string/tools_trusted_5"
+        app:layout_constrainedWidth="true"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/cb_4" />
+
+
+    <androidx.appcompat.widget.AppCompatButton
+        android:id="@+id/btn_trusted"
+        android:layout_width="match_parent"
+        android:layout_height="40dp"
+        android:layout_marginHorizontal="16dp"
+        android:layout_marginTop="32dp"
+        android:layout_marginBottom="24dp"
+        android:background="@drawable/tools_sign_cert_info_btn_bg"
+        android:foreground="@drawable/tools_common_btn_corner_ripple"
+        android:gravity="center"
+        android:text="@string/tools_add_to_trusted_cert"
+        android:textAllCaps="false"
+        android:textColor="@color/tools_color_accent"
+        android:textSize="16sp"
+        android:textStyle="bold"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@id/cb_5"
+        app:layout_constraintVertical_bias="1" />
+
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 8 - 0
ComPDFKit_Tools/src/main/res/values/tools_strings.xml

@@ -408,5 +408,13 @@
     <string name="tools_digital_signature_detail">Digital Signature Details</string>
     <string name="tools_digital_create_error">Failures</string>
     <string name="tools_digital_sign_success">Signature successful</string>
+    <string name="tools_cert_is_trusted_to">This Certificate Is Trusted to:</string>
+    <string name="tools_trusted_1">Sign document or data</string>
+    <string name="tools_trusted_2">Certify document</string>
+    <string name="tools_trusted_3">Execute dynamic content that is embedded in a certified document</string>
+    <string name="tools_trusted_4">Execute high privilege JavaScripts that are embedded in a certified document</string>
+    <string name="tools_trusted_5">Perform privileged system operations (networking, printing, file access, etc.)</string>
+    <string name="tools_trust">Trust</string>
+    <string name="tools_add_to_trusted_cert">Add to Trusted Certificates</string>
 
 </resources>

+ 1 - 1
config.gradle

@@ -3,7 +3,7 @@ ext {
             COMPILESDK: 33,
             MINSDK: 21,
             TARGETSDK: 33,
-            VERSIONCODE: 1003
+            VERSIONCODE: 1004
     ]
     sdk = [
             COMPDFKIT_SDK_VERSION : "1.9.1",