Exemplo n.º 1
0
        public void TestRevoke2NullUser()
        {
            HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null);

            client.CryptoSuite = crypto;
            client.Revoke(null, admin.Name, "keyCompromise");
        }
Exemplo n.º 2
0
        public UserManager()
        {
            keyStorePath  = @"D:\Projetos\Hyperledger\fabcar\hfc-key-store\";
            admin         = SampleUser.Load("admin", keyStorePath);
            fabric_client = HFClient.Create();
            var crypto = new Hyperledger.Fabric.SDK.Security.CryptoPrimitives();

            crypto.Init();
            crypto.Store.AddCertificate(admin.Enrollment.Cert);

            fabric_client.CryptoSuite = crypto;

            fabric_client.UserContext = admin;

            channel = fabric_client.NewChannel("mychannel");
            var peer = fabric_client.NewPeer("p1", $"grpc://{Startup.HyperleaderServer}:7051");

            channel.AddPeer(peer);

            var ordered = fabric_client.NewOrderer("o1", $"grpc://{Startup.HyperleaderServer}:7050");

            channel.AddOrderer(ordered);

            channel.Initialize();

            fabric_ca_client             = new Hyperledger.Fabric_CA.SDK.HFCAClient("", $"http://{Startup.HyperleaderServer}:7054", new Hyperledger.Fabric.SDK.Helper.Properties());
            fabric_ca_client.CryptoSuite = crypto;
        }
Exemplo n.º 3
0
        public void TestHFCAIdentityCryptoNull()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = null;
            client.NewHFCAIdentity("testid");
        }
Exemplo n.º 4
0
        public void TestHFCAIdentityIDNull()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = crypto;
            client.NewHFCAAffiliation(null);
        }
Exemplo n.º 5
0
        public void TestReenrollNullUser()
        {
            HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null);

            client.CryptoSuite = crypto;
            client.Reenroll(null);
        }
Exemplo n.º 6
0
        public void TestBadAffiliationNameEndingDot()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = crypto;
            client.NewHFCAAffiliation("foo.");
        }
Exemplo n.º 7
0
        public void TestIdemixNullEnrollment()
        {
            HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null);

            client.CryptoSuite = crypto;
            client.IdemixEnroll(null, "idemixMSP");
        }
Exemplo n.º 8
0
        public void TestHFCAIdentityCryptoNull()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = null;
            client.NewHFCAAffiliation("org1");
        }
Exemplo n.º 9
0
        public void TestBadAffiliationNameMultipleDots()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = crypto;
            client.NewHFCAAffiliation("foo...bar");
        }
Exemplo n.º 10
0
        public void TestNewInstanceWithName()
        {
            HFCAClient memberServices = HFCAClient.Create("name", "http://localhost:99", null);

            Assert.IsNotNull(memberServices);
            Assert.AreSame(typeof(HFCAClient), memberServices.GetType());
        }
Exemplo n.º 11
0
        public void TestRevoke2NullEnrollment()
        {
            HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null);

            client.CryptoSuite = crypto;
            client.Revoke(admin, (string)null, "keyCompromise");
        }
Exemplo n.º 12
0
        public void TestNewInstanceWithNameAndProperties()
        {
            Properties testProps      = new Properties();
            HFCAClient memberServices = HFCAClient.Create("name", "http://localhost:99", testProps);

            Assert.IsNotNull(memberServices);
            Assert.AreSame(typeof(HFCAClient), memberServices.GetType());
        }
Exemplo n.º 13
0
        public void TestReenrollNullEnrollment()
        {
            HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null);

            client.CryptoSuite = crypto;
            admin.Enrollment   = null;
            client.Reenroll(admin);
        }
Exemplo n.º 14
0
        public void TestIdemixWrongEnrollment()
        {
            HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null);

            client.CryptoSuite = crypto;
            IEnrollment enrollment = new IdemixEnrollment(null, null, "mspid", null, null, null, "ou", IdemixRoles.MEMBER);

            client.IdemixEnroll(enrollment, "mspid");
        }
Exemplo n.º 15
0
        public void GetAffiliationNoServerResponse()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = crypto;
            HFCAAffiliation aff = client.NewHFCAAffiliation("neworg1");

            aff.Read(admin);
        }
Exemplo n.º 16
0
        public void DeleteAffiliationNoServer()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = crypto;
            HFCAAffiliation aff = client.NewHFCAAffiliation("neworg1");

            aff.Delete(admin);
        }
Exemplo n.º 17
0
        public void TestSetCryptoSuite()
        {
            HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null);

            CryptoPrimitives testcrypt = new CryptoPrimitives();

            client.CryptoSuite = testcrypt;
            Assert.AreEqual(testcrypt, client.CryptoSuite);
        }
Exemplo n.º 18
0
        public void TestAddCAToURL()
        {
            string     url    = "http://localhost:99";
            HFCAClient client = HFCAClient.Create("ca1", url, null);

            client.CryptoSuite = crypto;
            string url2 = client.AddCAToURL(url);

            Assert.AreEqual(url + "?ca=ca1", url2);
        }
Exemplo n.º 19
0
        public void DeleteIdentityNoServerResponse()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = crypto;

            HFCAIdentity ident = client.NewHFCAIdentity("testuser1");

            ident.Delete(admin);
        }
Exemplo n.º 20
0
        public void GetCertificateNoServerResponse()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = crypto;

            HFCACertificateRequest certReq = client.NewHFCACertificateRequest();

            client.GetHFCACertificates(admin, certReq);
        }
Exemplo n.º 21
0
        public void TestRegisterNullRegistrar()
        {
            RegistrationRequest regreq = new RegistrationRequest("name", "affiliation");

            regreq.EnrollmentID = "abc";
            HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null);

            client.CryptoSuite = crypto;
            client.Register(regreq, null);
        }
Exemplo n.º 22
0
        public void TestRevoke1NullUser()
        {
            HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null);

            client.CryptoSuite = crypto;
            KeyPair     keypair    = crypto.KeyGen();
            IEnrollment enrollment = new X509Enrollment(keypair, "abc");

            client.Revoke(null, enrollment, "keyCompromise");
        }
Exemplo n.º 23
0
 public HFCAAffiliation(string name, HFCAClient client)
 {
     ValidateAffiliationNames(name);
     if (client.CryptoSuite == null)
     {
         throw new ArgumentException("Crypto primitives not set.");
     }
     Name        = name;
     this.client = client;
 }
Exemplo n.º 24
0
        public void TestHFCACertificateNewInstance()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = crypto;
            HFCACertificateRequest certReq = client.NewHFCACertificateRequest();

            Assert.IsNotNull(certReq);
            Assert.AreEqual(typeof(HFCACertificateRequest).Name, certReq.GetType().Name);
        }
Exemplo n.º 25
0
        public void TestHFCAIdentityNewInstance()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = crypto;
            HFCAAffiliation aff = client.NewHFCAAffiliation("org1");

            Assert.IsNotNull(aff);
            Assert.AreSame(typeof(HFCAAffiliation), aff.GetType());
        }
Exemplo n.º 26
0
        public void TestHFCAIdentityNewInstance()
        {
            HFCAClient client = HFCAClient.Create("http://localhost:99", null);

            client.CryptoSuite = crypto;
            HFCAIdentity ident = client.NewHFCAIdentity("testid");

            Assert.IsNotNull(ident);
            Assert.AreSame(typeof(HFCAIdentity), ident.GetType());
            Assert.AreEqual(ident.EnrollmentId, "testid");
        }
Exemplo n.º 27
0
        public void TestEnrollmentNoServerResponse()
        {
            ICryptoSuite cryptoSuite = Factory.Instance.GetCryptoSuite();

            EnrollmentRequest req    = new EnrollmentRequest("profile 1", "label 1", null);
            HFCAClient        client = HFCAClient.Create("client", "http://localhost:99", null);

            client.CryptoSuite = cryptoSuite;

            client.Enroll(TEST_ADMIN_NAME, TEST_ADMIN_NAME, req);
        }
Exemplo n.º 28
0
 public HFCAIdentity(string enrollmentID, HFCAClient client)
 {
     if (string.IsNullOrEmpty(enrollmentID))
     {
         throw new ArgumentException("EnrollmentID cannot be null or empty");
     }
     if (client.CryptoSuite == null)
     {
         throw new ArgumentException("Client's crypto primitives not set");
     }
     EnrollmentId = enrollmentID;
     this.client  = client;
 }
Exemplo n.º 29
0
        public void TestRegisterNoServerResponse()
        {
            Properties testProps = new Properties();
            HFCAClient client    = HFCAClient.Create("client", "https://localhost:99", testProps);

            CryptoPrimitives testcrypt = new CryptoPrimitives();

            client.CryptoSuite = testcrypt;

            RegistrationRequest regreq = new RegistrationRequest("name", "affiliation");

            client.Register(regreq, admin);
        }
Exemplo n.º 30
0
        public void TestIdemixMissingMSPID()
        {
            HFCAClient client = HFCAClient.Create("client", "http://localhost:99", null);

            client.CryptoSuite = crypto;
            var gen         = new ECKeyPairGenerator();
            var keyGenParam = new KeyGenerationParameters(new SecureRandom(), 256);

            gen.Init(keyGenParam);
            KeyPair     pair       = KeyPair.Create(gen.GenerateKeyPair());
            IEnrollment enrollment = new X509Enrollment(pair, "");

            client.IdemixEnroll(enrollment, null);
        }