def findSessionRecordInDatabase(self, record):
        logging.info("Inside findSessionRecordInDatabase ")

        doesRecordExists = MongoReads.MongoReads().findOneRecord(
            record, self.session_validation_collection)
        logging.debug("Does Record Exists %s", doesRecordExists)
        return doesRecordExists
Example #2
0
    def findOneRecord(self, record, collection):
        logging.info("Inside findOneRecord")

        collectionToBeChecked = self.mongoConnection.return_collection(collection)
        existingRecord = self.mongoConnection.find_one(record, collectionToBeChecked)
        logging.debug("Existing Record %s", existingRecord)
        return existingRecord
    def findSignInRecordInDatabase(self, record):
        logging.info("Inside findSignInRecordInDatabase ")

        doesRecordExists = MongoReads.MongoReads().findOneRecord(
            record, self.registered_users_collection)
        logging.debug("Does Record Exists %s", doesRecordExists)
        return doesRecordExists
    def logOut(self, logout_records):

        logging.info("Inside MongoWrites.logOut")

        collection = self.mongo_connection.return_collection(
            self.session_validation_collection)
        deletion_result = self.mongo_connection.delete_one(
            logout_records, collection)
        if deletion_result.deleted_count != 1:
            logging.critical("Error in Deletion %s", logout_records)
    def signIn(self, session_records):

        logging.info("Inside MongoWrites.signIn")

        collection = self.mongo_connection.return_collection(
            self.session_validation_collection)
        insertion_result = self.mongo_connection.insert(
            session_records, collection)
        if insertion_result.acknowledged == False:
            logging.critical("Error in Insertion %s", session_records)
    def signUp(self, signup_requests):

        logging.info("Inside MongoWrites.signUp")

        collection = self.mongo_connection.return_collection(
            self.registered_users_collection)
        insertion_result = self.mongo_connection.insert(
            signup_requests, collection)
        if insertion_result.acknowledged == False:
            logging.critical("Error in Insertion %s", signup_requests)
Example #7
0
    def validateSession(self):
        """ Function to validate user sessions"""
        logging.info("Inside validateSession")

        usersSessionDetailsToVerify = self.request["param"]
        usersSessionDetailsVerificationStatus = DataBaseInterface.DataBaseInterface(
        ).findSessionRecordInDatabase(usersSessionDetailsToVerify)
        if (usersSessionDetailsVerificationStatus) != "":
            logging.debug("Valid Session Details")
            return {"status": True}
        else:
            logging.debug("Invalid Session Details")
            return {"status": False}
Example #8
0
    def logOut(self):

        logging.info("Inside logOut")
        userToBeLoggedOut = self.request["param"]
        producer = KafkaProducer(
            bootstrap_servers=['localhost:9092'],
            key_serializer=lambda x: x.encode('utf-8'),
            value_serializer=lambda x: dumps(x).encode('utf-8'))

        data_to_placed_in_the_stream = userToBeLoggedOut
        result = producer.send('authentication',
                               key=self.request["task"],
                               value=data_to_placed_in_the_stream)
        sleep(5)
        if (result.is_done):
            logging.debug("Successfully logged out")
            return ({"status": True})
        else:
            logging.debug("Error in logout")
            return ({"status": False})
Example #9
0
    def signUp(self):
        """ Function to submit the signup request to the kafka stream """
        logging.info("Inside signUp")

        producer = KafkaProducer(
            bootstrap_servers=['localhost:9092'],
            key_serializer=lambda x: x.encode('utf-8'),
            value_serializer=lambda x: dumps(x).encode('utf-8'))

        data_to_placed_in_the_stream = self.request["data"]

        result = producer.send('authentication',
                               key=self.request["task"],
                               value=data_to_placed_in_the_stream)
        sleep(5)
        if (result.is_done):
            logging.debug("Successfully pushed to the stream")
            return ({"status": True})
        else:
            logging.debug("Failed to push to the stream")
            return ({"status": False})
Example #10
0
    def signIn(self):

        logging.info("Inside signIn")

        loginCredentialsToBeVerified = self.request["data"]
        login_credentials_verification_status = DataBaseInterface.DataBaseInterface(
        ).findSignInRecordInDatabase(loginCredentialsToBeVerified)
        if (login_credentials_verification_status) != "":
            randomKey = self.generateRandomKey()

            # record preparation for producing kafka event begins

            duplicatedLoginCredentials = self.request["data"]
            del duplicatedLoginCredentials["password"]
            duplicatedLoginCredentials[self.sessionId] = randomKey

            # put the record in the kafka stream so that it can be consumed by other consumers

            producer = KafkaProducer(
                bootstrap_servers=['localhost:9092'],
                key_serializer=lambda x: x.encode('utf-8'),
                value_serializer=lambda x: dumps(x).encode('utf-8'))

            data_to_placed_in_the_stream = duplicatedLoginCredentials
            result = producer.send('authentication',
                                   key=self.request["task"],
                                   value=data_to_placed_in_the_stream)
            sleep(5)
            if (result.is_done):
                logging.debug("Successfully pushed to the stream")
                return ({"status": True, self.sessionId: randomKey})
            else:
                logging.debug("Failed to push to the stream")
                return ({"status": False})
        else:
            logging.debug("Invalid Login Credentials")
            return ({"status": False})
Example #11
0
def catch_all(path):
    transformed_request = request_preparation(request, path)
    logging.info("Transformed Request From Web %s", transformed_request)
    service = ServiceInterface.ServiceInterface(transformed_request)
    logging.info("Response  %s", service.result)
    return jsonify(service.result)