Class UserCertEncryptor

java.lang.Object
org.ofdrw.crypto.enryptor.UserCertEncryptor
All Implemented Interfaces:
UserFEKEncryptor

public class UserCertEncryptor extends Object implements UserFEKEncryptor
OFD用户证书加密器
Since:
2021-7-29 18:36:07
Author:
权观宇
  • Constructor Details

    • UserCertEncryptor

      public UserCertEncryptor(String username, String userType, Certificate certificate)
      OFD用户数字证书加密器
      Parameters:
      username - 用户名称
      userType - 用户角色类型 UserInfo.UserTypeOwner UserInfo.UserTypeUser
      certificate - 用户数字证书
    • UserCertEncryptor

      public UserCertEncryptor(String username, Certificate certificate)
      OFD用户数字证书加密器

      用户类型:User(用户) UserInfo.UserTypeUser

      Parameters:
      username - 用户名称
      certificate - 用户数字证书
  • Method Details

    • encrypt

      public org.ofdrw.core.crypto.encryt.UserInfo encrypt(byte[] fek, byte[] iv) throws org.bouncycastle.crypto.CryptoException, IOException, GeneralSecurityException
      加密 文件加密密钥 并封装为
      Specified by:
      encrypt in interface UserFEKEncryptor
      Parameters:
      fek - 文件加密密钥(File Encrypt Key )
      iv - 加密向量IV
      Returns:
      用户信息(包含加密的文件加密密钥)
      Throws:
      org.bouncycastle.crypto.CryptoException - 加密过程运行异常
      IOException - IO操作异常
      GeneralSecurityException - 加密异常
    • userCert

      public byte[] userCert() throws GeneralSecurityException
      用户加密时使用的证书,仅在使用证书加密的加密器中需要实现
      Specified by:
      userCert in interface UserFEKEncryptor
      Returns:
      证书文件字节内容(DER编码),在使用口令加密时可返还null
      Throws:
      GeneralSecurityException - 证书编码错误
    • encryptCaseId

      public String encryptCaseId()
      加密保护方案标识,见附录 A.1 ProtectionCaseID
      Specified by:
      encryptCaseId in interface UserFEKEncryptor
      Returns:
      加密保护方案标识