diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-06-29 14:07:20 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-06-29 14:07:20 +0700 |
commit | fe7d3e0009ae2ba833be66729221f42ac3aa0464 (patch) | |
tree | 7008925a5fb5a59a32fcd40ab0638a8e6888de08 /crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs | |
parent | Refactor Asn1Dump (diff) | |
download | BouncyCastle.NET-ed25519-fe7d3e0009ae2ba833be66729221f42ac3aa0464.tar.xz |
Refactoring around Platform
Diffstat (limited to 'crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs')
-rw-r--r-- | crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs index 261f67a15..90ecf0748 100644 --- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs @@ -250,51 +250,40 @@ namespace Org.BouncyCastle.Cms protected override void Dispose(bool disposing) { if (disposing) - { - Platform.Dispose(_out); - - // TODO Parent context(s) should really be closed explicitly - - _eiGen.Close(); - - if (_outer.unprotectedAttributeGenerator != null) - { - Asn1.Cms.AttributeTable attrTable = _outer.unprotectedAttributeGenerator.GetAttributes(Platform.CreateHashtable()); - - Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector()); - - _envGen.AddObject(new DerTaggedObject(false, 1, unprotectedAttrs)); - } - - _envGen.Close(); - _cGen.Close(); + { + ImplClose(); } base.Dispose(disposing); } #else public override void Close() { - Platform.Dispose(_out); + ImplClose(); + base.Close(); + } +#endif + + private void ImplClose() + { + Platform.Dispose(_out); - // TODO Parent context(s) should really be closed explicitly + // TODO Parent context(s) should really be closed explicitly - _eiGen.Close(); + _eiGen.Close(); - if (_outer.unprotectedAttributeGenerator != null) - { + if (_outer.unprotectedAttributeGenerator != null) + { Asn1.Cms.AttributeTable attrTable = _outer.unprotectedAttributeGenerator.GetAttributes( new Dictionary<CmsAttributeTableParameter, object>()); - Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector()); + Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector()); - _envGen.AddObject(new DerTaggedObject(false, 1, unprotectedAttrs)); - } + _envGen.AddObject(new DerTaggedObject(false, 1, unprotectedAttrs)); + } _envGen.Close(); _cGen.Close(); - base.Close(); } -#endif } } } |