Esempio n. 1
0
def create_connection():
    try:
     cnx = MySQLdb.connect(host = "localhost", user = "******", passwd = "Team5", db = "testDB")
     cur = cnx.cursor()
     wsLogging.audit_logging("CRUD", "String created")
     return cur
    except:
        wsLogging.error_logging("CRUD","Error during Connection")
Esempio n. 2
0
        def service_login(self,username, password,search):

            if auth_kinit(username, password) == True:
                audit_logging("webService", "Login successful")
                #Send Json token with permissions
                return return_jwt(username)
            else:
                audit_logging("webService", "Login Failed")
                #Send message with failure
                return "Failed to connect to service"
Esempio n. 3
0
def send_to(Message):
    try:
        channel.basic_publish(exchange='',
                      routing_key="FirstQ",
                      body=str(Message))
        #Logs process
        audit_logging("RabbitSend","Sent to queue")
        connection.close()
    except:
        # Logs Process
        error_logging("RabbitSend","Couldn't Send")
Esempio n. 4
0
        def service_login(self, username, password):

            if auth_kinit(username, password) == True:
                audit_logging("webService", "Login successful")
                #Send Json token with permissions

            else:
                audit_logging("webService", "Login Failed")
                #Send message with failure

                return False
Esempio n. 5
0
def return_jwt(username):
    try:
        # Create connection to DB
        con = create_connection()

        #Get user and their services and parse out the dict taht is sent back
        user_service_array = get_user(con, username)
        user_service_tuple = user_service_array[0]
        service_unpacked = user_service_tuple[0]
        encoded = jwt.encode({'user_service': service_unpacked},'secret', algorithm='HS256')
        wsLogging.audit_logging("Create_Token", "Toek was created")
        return encoded
    except:
        wsLogging.error_logging("Create_Token","Error when creating token")
Esempio n. 6
0
import pika
from wsLogging import error_logging, audit_logging

try:
    # Creates connection we can specify an ipAddress later
    connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))

    # Sets up connection
    channel = connection.channel()

    channel.queue_declare(queue='FirstQ')

    # Logs
    audit_logging("Rabbit Send", "Connected to Queue")
except:
    error_logging("RabbitSend","Couldn't Create connection")

def send_to(Message):
    try:
        channel.basic_publish(exchange='',
                      routing_key="FirstQ",
                      body=str(Message))
        #Logs process
        audit_logging("RabbitSend","Sent to queue")
        connection.close()
    except:
        # Logs Process
        error_logging("RabbitSend","Couldn't Send")


Esempio n. 7
0
 def test_audit_logger_create(self):
     log = wsLogging.audit_logging("UnitTest","audit")
     self.assertFalse(log)
Esempio n. 8
0
def start_consume():
    try:
        audit_logging("Rabbit Recieve", "started consume")
        channel.start_consuming()
    except:
        error_logging("Rabbit Receive", "Error running CallBack")
Esempio n. 9
0
import pika
from wsLogging import error_logging, audit_logging

connection = pika.BlockingConnection(pika.ConnectionParameters(
        host='localhost'))
channel = connection.channel()


channel.queue_declare(queue='FirstQ')


def callback(ch, method, properties, body):
    print " [x] Received %r" % (body,)

try:
    channel.basic_consume(callback,
                          queue='FirstQ',
                          no_ack=True)
    audit_logging("Rabbit Receive", "Basic consume")
except:
    error_logging("Rabbit Receive", "Error running CallBack")

def start_consume():
    try:
        audit_logging("Rabbit Recieve", "started consume")
        channel.start_consuming()
    except:
        error_logging("Rabbit Receive", "Error running CallBack")