抽象工厂加工厂方法双层抽象类图
2024-08-21 15:07:39 0 举报
这是一种抽象工厂模式,它使用两层抽象类来实现产品的生成。顶级抽象类作为工厂,负责创建产品家族的抽象类。每个具体工厂都继承自顶级抽象工厂类,并实现创建具体产品的方法。产品家族的抽象类作为模板,定义产品的基本结构。每个具体产品都继承自产品家族的抽象类,并实现具体的产品功能。这种双层抽象类的设计有助于实现代码解耦,增加系统的可扩展性和维护性。
作者其他创作
大纲/内容
ACAVersionCryptographyFactory
+ CreateCAVersionCryptography(): ACAVersionCryptography
IHashOperation
+ HashData(string algid=\"SM3\
CAKeyManagement
CAAsymmetricKeyAlgorithm
+ AsymKeyEncryption(AsymmetricInfo info)+ AsymKeyDecryption(AsymmetricInfo info)+ AsymKeySignatureHash(AsymmetricInfo info)+ AsymKeyVerifySignature(SignatureInfo info)
CAVersionCryptography(工厂方法入口类,根据version调用)
V24CAVersionCryptographyFactory
V30CAVersionCryptography
+ SymmetricKeyEncryption(SymmetricInfo symminfo)+ SymmetricKeyDecryption(SymmetricInfo symminfo)+ AsymKeyEncryption(AsymmetricInfo info)+ AsymKeyDecryption(AsymmetricInfo info)+ AsymKeySignatureHash(AsymmetricInfo info)+ AsymKeyVerifySignature(SignatureInfo info)+ HashData(string algid=\"SM3\
V24CAVersionCryptography
ISymmetricKeyEncryption
+ SymmetricKeyEncryption(SymmetricInfo symminfo): CryptedResult+ SymmetricKeyDecryption(SymmetricInfo symminfo): CryptedResult
试例1:CryptographyConfigManage.Instance.Initialization(ConfigSetting.GetDefaultBJCAConfigSetting(bjca_url)); //配置CryptographyFactory.CreateCryptographyFactory(ProductType.BJCA).CreateSymmetricKeyEncryption().SymmetricKeyEncryption(jhnationalcryptography.model.SymmetricInfo.GetDefaultBJCASymmetricInfo(\"123456789\")); //对称算法加密CryptographyFactory.CreateCryptographyFactory(ProductType.BJCA).CreateSymmetricKeyEncryption().SymmetricKeyDecryption(info); //对称算法解密
FisecSymmetricKeyEncryption
+ SymmetricKeyEncryption(SymmetricInfo symminfo)+ SymmetricKeyDecryption(SymmetricInfo symminfo)
IKeyManagement
SeckmsAsymmetricKeyAlgorithm
ICryptographyFactory
+ CreateSymmetricKeyEncryption(): ISymmetricKeyEncryption+ CreateAsymmetricKeyAlgorithm(): IAsymmetricKeyAlgorithm+ CreateHashOperation(): IHashOperation+ CreateKeyManagement(): IKeyManagement
SeckmsHashOperation
FisecHashOperation
DefaultCAVersionCryptographyFactory
CryptographyFactory(抽象工厂入口类根据产品类型创建工厂)
+CreateCryptographyFactory(ProductType product_type): ICryptographyFactory
IAsymmetricKeyAlgorithm
+ AsymKeyEncryption(AsymmetricInfo info): CryptedResult+ AsymKeyDecryption(AsymmetricInfo info): CryptedResult+ AsymKeySignatureHash(AsymmetricInfo info): CryptedResult+ AsymKeyVerifySignature(SignatureInfo info): VerifySignatureResult
FisecKeyManagement
CASymmetricKeyEncryption
ACAVersionCryptography
FisecCryptographyFactory
+ CreateSymmetricKeyEncryption()+ CreateAsymmetricKeyAlgorithm()+ CreateHashOperation()+ CreateKeyManagement()
CACryptographyFactory
CryptographyConfigManage(配置管理)
+ Instance:CryptographyConfigManage+ ConfigSetting:ConfigSetting+ IsOnce:bool(判断是否首次初始化)
- Initialization(ConfigSetting config_sett)- UpdConfigSetting(ConfigSetting config_sett)
SeckmsCryptographyFactory
根据密码机相关接口文档,提取出以下四类接口1: 非对称算法相关接口2: 对称算法相关接口 3:hash杂凑算法相关接口4: 密钥管理相关接口
CAHashOperation
SeckmsKeyManagement
DefaultCAVersionCryptography
试例1:CryptographyFactory.CreateCryptographyFactory(ProductType.BJCA).CreateAsymmetricKeyAlgorithm().AsymKeySignatureHash(info); //签名CryptographyFactory.CreateCryptographyFactory(ProductType.BJCA).CreateAsymmetricKeyAlgorithm().AsymKeyVerifySignature(info);//验签CryptographyFactory.CreateCryptographyFactory(ProductType.BJCA).CreateAsymmetricKeyAlgorithm().AsymKeyEncryption(info);//非对称算法加密CryptographyFactory.CreateCryptographyFactory(ProductType.BJCA).CreateAsymmetricKeyAlgorithm().AsymKeyEncryption(info);//非对称算法解密
FisecAsymmetricKeyAlgorithm
SeckmsSymmetricKeyEncryption
V30CAVersionCryptographyFactory
收藏
0 条评论
回复 删除
下一页