コード例 #1
0
    def __init__(self, sock):
        self.sock = sock
        self.auction_manager = AuctionManagerEntity()

        # Create the Public key and Private key
        rsa_kg = RSAKGen()

        # Check for the existence of the directory
        if check_directory(self._server_path):
            try:
                self.auction_manager.private_key, self.auction_manager.public_key = rsa_kg.load_key_servers(
                    self._server_path,self._server_password)
                self.auction_manager.public_repository_key = rsa_kg.load_public_key(os.getcwd()+"/server",
                                                                                    "repository_server.pem")
            except ValueError:
                print("The password is incorrect!"
                      "All information has been deleted and the server will now become instable")
                sys.exit(0)

        else:
            os.mkdir(self._server_path)
            self.auction_manager.private_key, self.auction_manager.public_key = rsa_kg.generate_key_pair_server()
            rsa_kg.save_keys_server(self._server_path, self._server_password)

        # Create the sessionKey with the other Repository
        self.create_session_key_server()
コード例 #2
0
ファイル: Auction.py プロジェクト: jpribeiro7/SIO
    def __init__(self,
                 auction_time,
                 auction_type,
                 auction_user_key,
                 auction_user,
                 auction_name=None,
                 description=None,
                 auction_max_number_bids=10,
                 auction_min_number_bids=10,
                 auction_allowed_bidders=None,
                 auction_threshold=None):
        self.auction_user_key = auction_user_key
        self.auction_user = auction_user
        self.description = description
        self.auction_name = auction_name
        self.id = uuid.uuid1()
        self.auction_time = auction_time
        self.type = auction_type
        self.auction_max_number_bids = int(auction_max_number_bids)
        self.auction_min_number_bids = int(auction_min_number_bids)
        self.blockchain = []
        self.begin_date = datetime.datetime.now()
        self.max_date = datetime.datetime(year=self.begin_date.year,
                                          month=self.begin_date.month,
                                          day=self.begin_date.day,
                                          hour=self.begin_date.hour +
                                          int(auction_time))

        self.open = True
        # Assymetric key pair to cipher the bid's information
        rsa_kg = RSAKGen()
        self.auction_private_key, self.auction_public_key = rsa_kg.generate_key_pair_server(
        )
コード例 #3
0
    def __init__(self, sock):
        # Create the Entity and socket
        self.auction_repository = AuctionRepositoryEntity()
        self.sock = sock

        # Create the Public key and Private key
        rsa_kg = RSAKGen()

        # Check for the existence of the directory
        if check_directory(self._server_path):

            try:
                # Get the keys from the folders
                self.auction_repository.private_key, self.auction_repository.public_key = rsa_kg.load_key_servers(
                    self._server_path, self._server_password)

                # Get the server public key
                self.auction_repository.manager_public = rsa_kg.load_public_key(
                    self._server_path, "manager_server.pem")
            except ValueError:
                # Exits
                sys.exit(
                    "The password is incorrect! All information has been deleted and the server will"
                    "now become unstable")

        else:
            # Since it doesn't exist, we create the folders
            os.mkdir(self._server_path)
            os.mkdir(os.getcwd() + "/Clients")
            self.auction_repository.private_key, self.auction_repository.public_key = rsa_kg.generate_key_pair_server(
            )
            rsa_kg.save_keys_server(self._server_path, self._server_password)