Ejemplo n.º 1
0
        public void CreateSignedBundleTest()
        {
            //Arrange
            Bundler      bundle         = new Bundler();
            const string outputFileName = @"TestBundleWithMetadata.p7m";

            var secString = new SecureString();

            foreach (var secchar in "passw0rd!".ToCharArray())
            {
                secString.AppendChar(secchar);
            }

            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), _incominganchors)
                    , Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            ISignProvider signProvider =
                new FileSignerProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), _privateRedmondPfx),
                    secString);

            byte[] cmsdata = bundle.Create(resourceProvider, signProvider);

            //Assert (Using agent bundler resolver code)
            Assert.Null(Record.Exception(() => resourceProvider.StoreBundle(cmsdata)));
            byte[]       p7BData      = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;

            Assert.Null(Record.Exception(() => anchorBundle = new AnchorBundle(p7BData, true)));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.Null(anchorBundle.Metadata);
        }
Ejemplo n.º 2
0
        protected override void ProcessRecord()
        {
            try
            {

                Bundler bundle = new Bundler();

                ISignProvider signProvider =
                    new FileSignerProvider(
                        Name,
                        PassKey);


                byte[] p7BData = _bundle as byte[];
                byte[] p7MData = bundle.Sign(p7BData, signProvider);

                WriteObject(p7MData);
            }
            catch (Exception e)
            {
                WriteError(
                    new ErrorRecord(
                        e,
                        "Export-Bundle",
                        ErrorCategory.NotSpecified,
                        Name
                        )
                    );
            }
        }
Ejemplo n.º 3
0
        protected override void ProcessRecord()
        {
            try
            {
                Bundler bundle = new Bundler();

                ISignProvider signProvider =
                    new FileSignerProvider(
                        Name,
                        PassKey);


                byte[] p7BData = _bundle as byte[];
                byte[] p7MData = bundle.Sign(p7BData, signProvider);

                WriteObject(p7MData);
            }
            catch (Exception e)
            {
                WriteError(
                    new ErrorRecord(
                        e,
                        "Export-Bundle",
                        ErrorCategory.NotSpecified,
                        Name
                        )
                    );
            }
        }
Ejemplo n.º 4
0
        public void CreateSignedBundleWithMetadataTest()
        {
            //Arrange
            Bundler      bundle         = new Bundler();
            const string outputFileName = @"TestBundleSignedWithMetadata.p7m";

            var secString = new SecureString();

            foreach (var secchar in "passw0rd!".ToCharArray())
            {
                secString.AppendChar(secchar);
            }


            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(Path.Combine(Directory.GetCurrentDirectory()
                                                      , @"Certificates\nhind\IncomingAnchors"),
                                         Path.Combine(Directory.GetCurrentDirectory(), outputFileName)
                                         , null
                                         , @"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>");
            ISignProvider signProvider =
                new FileSignerProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\redmond\Private\redmond.pfx"),
                    secString);

            byte[] cmsdata = bundle.Create(resourceProvider, signProvider);

            //Assert (Using agent bundler resolver code)
            Assert.DoesNotThrow(() => resourceProvider.StoreBundle(cmsdata));
            byte[]       p7BData      = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;

            Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(p7BData, true));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.NotNull(anchorBundle.Metadata);
            Assert.Equal(@"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>", anchorBundle.Metadata);
        }
Ejemplo n.º 5
0
        public void CreateSignedBundleIndependentTest()
        {
            //Arrange
            Bundler      bundle         = new Bundler();
            const string outputFileName = @"TestBundleSignedIndependent.p7m";

            var secString = new SecureString();

            foreach (var secchar in "passw0rd!".ToCharArray())
            {
                secString.AppendChar(secchar);
            }


            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\nhind\IncomingAnchors")
                    , Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            ISignProvider signProvider =
                new FileSignerProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\redmond\Private\redmond.pfx"),
                    secString);

            byte[] cmsdata = bundle.Create(resourceProvider);
            cmsdata = bundle.Sign(cmsdata, signProvider);

            //Assert (Using agent bundler resolver code)
            Assert.DoesNotThrow(() => resourceProvider.StoreBundle(cmsdata));
            byte[]       p7BData      = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;

            Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(p7BData, true));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.Null(anchorBundle.Metadata);
        }
Ejemplo n.º 6
0
        public void CreateSignedBundleTest()
        {
            //Arrange
            Bundler bundle = new Bundler();
            const string outputFileName = @"TestBundleWithMetadata.p7m";

            var secString = new SecureString();
            foreach (var secchar in "passw0rd!".ToCharArray())
            {
                secString.AppendChar(secchar);
            }


            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\nhind\IncomingAnchors")
                    , Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            ISignProvider signProvider =
                new FileSignerProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\redmond\Private\redmond.pfx"),
                    secString);
            byte[] cmsdata = bundle.Create(resourceProvider, signProvider);

            //Assert (Using agent bundler resolver code)
            Assert.DoesNotThrow(() => resourceProvider.StoreBundle(cmsdata));
            byte[] p7BData = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;
            Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(p7BData, true));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.Null(anchorBundle.Metadata);


        }