def get_orderer_org_admin(client): """Loads the admin user for a given orderer org and returns an user object. """ orderer_admin_base_path = os.path.join( os.getcwd(), 'test/fixtures/e2e_cli/crypto-config/ordererOrganizations/' 'example.com/users/[email protected]/msp/') key_path = os.path.join( orderer_admin_base_path, 'keystore/', E2E_CONFIG['test-network']['orderer']['users']['admin']['private_key']) cert_path = os.path.join( orderer_admin_base_path, 'signcerts', E2E_CONFIG['test-network']['orderer']['users']['admin']['cert']) with open(key_path, 'rb') as key: key_pem = key.read() with open(cert_path, 'rb') as cert: cert_pem = cert.read() orderer_admin = User('ordererAdmin', 'example.com', client.state_store) private_key = load_pem_private_key(key_pem, None, default_backend()) enrollment = Enrollment(private_key, cert_pem) orderer_admin.enrollment = enrollment orderer_admin.msp_id = E2E_CONFIG['test-network']['orderer']['mspid'] return orderer_admin
def create_user(self, enrollment_id, org, msp_id, state_store=None): """Returns an instance of a user whose identity is stored in the CouchDBWallet :param enrollment_id: enrollment id :param org: organization :param msp_id: MSP id :param state_store: (Default value = None) :return: a validated user instance """ crypto_suit = ecies() if not self.exists(enrollment_id): raise AttributeError('"user" does not exist') key_pem = self.db[enrollment_id]['PrivateKey'] cert_pem = self.db[enrollment_id]['EnrollmentCert'] private_key = load_pem_private_key(key_pem, None, default_backend()) enrollment = Enrollment(private_key, cert_pem) user = User(enrollment_id, org, state_store) user.enrollment = enrollment user.msp_id = msp_id user.cryptoSuite = crypto_suit return validate(user)
def create_user(self, enrollment_id, org, msp_id, state_store=None): """ Returns an instance of a user whose identity is stored in the InMemoryWallet """ crypto_suit = ecies() if not self.exists(enrollment_id): raise AttributeError('"user" does not exist') user = User(enrollment_id, org, state_store) user.enrollment = self._Map[enrollment_id] user.msp_id = msp_id user.cryptoSuite = crypto_suit return validate(user)
def create_user(self, enrollment_id, org, msp_id, state_store=None): """Returns an instance of a user whose identity is stored in the InMemoryWallet :param enrollment_id: enrollment id :param org: organization :param msp_id: MSP id :param state_store: (Default value = None) :return: a validated user object """ crypto_suit = ecies() if not self.exists(enrollment_id): raise AttributeError('"user" does not exist') user = User(enrollment_id, org, state_store) user.enrollment = self._Map[enrollment_id] user.msp_id = msp_id user.cryptoSuite = crypto_suit return validate(user)
def get_peer_org_admin(client, peer_org): """Loads the admin user for a given peer org and returns a user object. """ peer_admin_base_path = os.path.join( os.getcwd(), 'test/fixtures/e2e_cli/crypto-config/peerOrganizations/{0}' '/users/Admin@{0}/msp/'.format(peer_org)) key_path = os.path.join( peer_admin_base_path, 'keystore/', E2E_CONFIG['test-network'][peer_org]['users']['admin']['private_key']) cert_path = os.path.join( peer_admin_base_path, 'signcerts/', E2E_CONFIG['test-network'][peer_org]['users']['admin']['cert']) with open(key_path, 'rb') as key: key_pem = key.read() with open(cert_path, 'rb') as cert: cert_pem = cert.read() org_admin = User('peer' + peer_org + 'Admin', peer_org, client.state_store) # wrap the key in a 'cryptography' private key object # so that all the methods can be used private_key = load_pem_private_key(key_pem, None, default_backend()) enrollment = Enrollment(private_key, cert_pem) org_admin.enrollment = enrollment org_admin.msp_id = E2E_CONFIG['test-network'][peer_org]['mspid'] return org_admin