Ejemplo n.º 1
0
def on_request(ch, method, props, body):
    message = smessage.unwrap(body)
    #decrypt received message
    print(message)
    ch.basic_publish(
        exchange='',
        routing_key=props.reply_to,
        properties=pika.BasicProperties(correlation_id=props.correlation_id),
        body=smessage.wrap(message))
    #encrypt and send reply message
    ch.basic_ack(delivery_tag=method.delivery_tag)
 def post(self):
     message = smessage.unwrap(self.request.body);         #decrypt accepted message
     print(message);
     self.write(smessage.wrap(message));                #encrypt and send message
Ejemplo n.º 3
0
def on_request(ch, method, props, body):
    message = smessage.unwrap(body); #decrypt received message
    print message;
    ch.basic_publish(exchange='', routing_key=props.reply_to, properties=pika.BasicProperties(correlation_id = props.correlation_id), body=smessage.wrap(message));
    #encrypt and send reply message
    ch.basic_ack(delivery_tag = method.delivery_tag);
 def on_response(self, ch, method, props, body):
     if self.corr_id == props.correlation_id:
         self.response = smessage.unwrap(body)  # decrypt acceptedd message
 def on_response(self, ch, method, props, body):
     if self.corr_id == props.correlation_id:
         self.response = smessage.unwrap(body)  #decrypt acceptedd message
Ejemplo n.º 6
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#echo client for tornado
from pythemis import smessage;
import tornado.ioloop
import tornado.httpclient;

client_priv = b"\x52\x45\x43\x32\x00\x00\x00\x2d\x51\xf4\xaa\x72\x00\x9f\x0f\x09\xce\xbe\x09\x33\xc2\x5e\x9a\x05\x99\x53\x9d\xb2\x32\xa2\x34\x64\x7a\xde\xde\x83\x8f\x65\xa9\x2a\x14\x6d\xaa\x90\x01"

server_pub  = b"\x55\x45\x43\x32\x00\x00\x00\x2d\x75\x58\x33\xd4\x02\x12\xdf\x1f\xe9\xea\x48\x11\xe1\xf9\x71\x8e\x24\x11\xcb\xfd\xc0\xa3\x6e\xd6\xac\x88\xb6\x44\xc2\x9a\x24\x84\xee\x50\x4c\x3e\xa0"

http_client = tornado.httpclient.HTTPClient();
smessage=smessage.smessage(client_priv, server_pub);
try:
    response = http_client.fetch(tornado.httpclient.HTTPRequest("http://127.0.0.1:26260", "POST", None, smessage.wrap(b"This is test message")));
    #decrypt request body(message)
    message = smessage.unwrap(response.body);         #encrypt message
    print(message);                                #send message
    
except tornado.httpclient.HTTPError as e:
    print("Error: " + str(e));
except Exception as e:
    print("Error: " + str(e));
http_client.close();
Ejemplo n.º 7
0
 def post(self):
     message = smessage.unwrap(self.request.body)
     #decrypt accepted message
     print(message)
     self.write(smessage.wrap(message))