Exemple #1
0
 def decrypt_data(self, data):
     if not self.encrypt:
         return data
     try:
         return cryptotool.decrypt_scalarizr(self.crypto_algo, data, self.crypto_key)
     except:
         raise InvalidRequestError('Failed to decrypt data. Error:%s' % helper.exc_info())
Exemple #2
0
 def decrypt_data(self, data):
     if not self.encrypt:
         return data
     try:
         return cryptotool.decrypt_scalarizr(self.crypto_algo, data,
                                             self.crypto_key)
     except:
         raise InvalidRequestError('Failed to decrypt data. Error:%s' %
                                   helper.exc_info())
Exemple #3
0
def answer(environ, start_response):
    server_id = environ['HTTP_X_SERVER_ID']
    data = environ['wsgi.input'].readline()
    crypto_key = lib.world.server_properties[server_id]['scalarizr.key']
    msg = cryptotool.decrypt_scalarizr(CRYPTO_ALGO, data, cryptotool.decrypt_key(crypto_key))
    if msg != 'Carrot':
        start_response('400 NOT OK', [('Content-Type', 'text/html')])
    else:
        time.sleep(0.4)
        start_response('201 OK', [('Content-Type', 'text/html')])
    yield '<b>Hello world!</b>\n'
Exemple #4
0
def answer(environ, start_response):
    server_id = environ['HTTP_X_SERVER_ID']
    data = environ['wsgi.input'].readline()
    crypto_key = lib.world.server_properties[server_id]['scalarizr.key']
    msg = cryptotool.decrypt_scalarizr(CRYPTO_ALGO, data,
                                       cryptotool.decrypt_key(crypto_key))
    if msg != 'Carrot':
        start_response('400 NOT OK', [('Content-Type', 'text/html')])
    else:
        time.sleep(0.4)
        start_response('201 OK', [('Content-Type', 'text/html')])
    yield '<b>Hello world!</b>\n'
Exemple #5
0
def answer(environ, start_response):
    try:
        data = environ['wsgi.input'].readline()
        key = cryptotool.decrypt_key(scalrpytests.scalarizr_key)
        msg = cryptotool.decrypt_scalarizr(scalrpytests.crypto_algo, data, key)
        if msg == '400':
            start_response('400 NOT OK', [('Content-Type', 'text/html')])
        else:
            time.sleep(random.randint(3, 40) / 10.0)
            start_response('201 OK', [('Content-Type', 'text/html')])
        yield '<b>Hello world!</b>\n'
    except:
        LOG.exception('Answer exception')