Esempio n. 1
0
    def open_wallet_callback(self):
        print('open wallet callback called')
        if ui_test_mode:
            notary_app.sm.current = "landingpage"
            return
        from notary_client import NotaryClient, NotaryException
        import simplecrypt
        password_value = self.ids.password.text
        if password_value is None:
            popup = Popup(title='Wrong Password',
                          content=Label(text='Wrong password'),
                          size_hint=(None, None),
                          size=(400, 200))
            popup.open()
            return
        if len(password_value) is 0:
            popup = Popup(title='Wrong Password',
                          content=Label(text='Wrong password'),
                          size_hint=(None, None),
                          size=(400, 200))
            popup.open()
            return

        try:
            notary_app.notary_obj = NotaryClient("notaryconfig.ini",
                                                 password_value)
            account = notary_app.notary_obj.get_account()
            notary_app.sm.current = 'landingpage'
        except NotaryException as e:
            print("Code %s " % e.error_code)
            print(e.message)
            if e.error_code == 404:
                notary_app.sm.current = 'registerwallet'
            elif e.error_code == 403:
                notary_app.sm.current = 'confirmemail'
        except ValueError as e:
            print("ValueError ")
            print(e.message)
            popup = Popup(title='Confirmation',
                          content=Label(text='Not yet confirmed. Try again.'),
                          size_hint=(None, None),
                          size=(400, 200))
            popup.open()
            notary_app.sm.current = 'confirmemail'
        except simplecrypt.DecryptionException as e:
            print e.message
            popup = Popup(title='Wrong Password',
                          content=Label(text='Wrong password'),
                          size_hint=(None, None),
                          size=(400, 200))
            popup.open()
Esempio n. 2
0
 def create_wallet_callback(self):
     print('create wallet callback called')
     if ui_test_mode:
         notary_app.sm.current = "registerwallet"
         return
     from notary_client import NotaryClient
     password_value = self.ids.password.text
     retyped_value = self.ids.retype_password.text
     if password_value == retyped_value:
         notary_app.notary_obj = NotaryClient("notaryconfig.ini",
                                              password_value)
         notary_app.sm.current = 'registerwallet'
     else:
         popup = Popup(title='Password Mismatch',
                       content=Label(text='Passwords does not match'),
                       size_hint=(None, None),
                       size=(400, 200))
         popup.open()
import test_data
from notary_client import NotaryClient, NotaryException

try:
    notary_client = NotaryClient('./notaryconfig.ini', 'foobar')
    message = notary_client.register_user(test_data.email_address)
    print(message)
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)
import test_data
from notary_client import NotaryClient, NotaryException

try:
    notary_client = NotaryClient('./notaryconfig.ini', 'foobar')
    message = notary_client.download_file(test_data.document_hash,
                                          test_data.storing_file_name)
    print(message)
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)
from notary_client import NotaryClient, NotaryException

try:
    notary_client = NotaryClient('./notaryconfig.ini', 'foobar')
    message = notary_client.get_notarizations()
    if len(message) > 0:
        for notarization in message:
            print(notarization)
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)
Esempio n. 6
0
import test_data
from notary_client import NotaryClient, NotaryException

try:
    notary_client = NotaryClient('./notaryconfig.ini', 'foobar')
    message = notary_client.notarize_file(test_data.notary_file_name, test_data.getMetaData())
    print(message)
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)
from notary_client import NotaryClient, NotaryException

notary_client = NotaryClient('./notaryconfig.ini', 'foobar')
try:
    cookies = notary_client.authenticate()
    print(cookies)
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)
Esempio n. 8
0
from notary_client import NotaryClient, NotaryException

try:
    notary_client = NotaryClient('./notaryconfig.ini', 'foobar')
    message = notary_client.get_account()
    print(message['email'])
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)
import test_data
from notary_client import NotaryClient, NotaryException

try:
    notary_client = NotaryClient('./notaryconfig.ini', 'foobar')
    message = notary_client.get_server_pubkey()
    print(message)
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)
Esempio n. 10
0
import test_data
from notary_client import NotaryClient, NotaryException

try:
    notary_client = NotaryClient('./notaryconfig.ini', 'foobar')
    message = notary_client.upload_file(test_data.notary_file_name)
    print(message)
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)
Esempio n. 11
0
def do_sale(buyer, seller, houseinfo):
    '''Calls client class to record sale.'''
    privkeyfile = _get_private_keyfile(KEY_NAME)
    client = NotaryClient(base_url=DEFAULT_URL, key_file=privkeyfile)
    response = client.sale(buyer, seller, houseinfo)
    print("Sale transaction response: {}".format(response))
Esempio n. 12
0
def main_method(cmd_str=None):
    '''
       main method of notary.
    Parameters
    ----------
    cmd_str  takes the command line input.

    Returns
    -------

    '''
    global notary
    parser = argparse.ArgumentParser()
    parser.add_argument("command", choices=[ 'register', 'confirm', 'notarize', 'login', 'notarystatus',
                                            'uploadfile', 'downloadfile'],
                        help="Name of the command.")
    parser.add_argument("-password", type=str, help="the password used to access the wallet.")
    parser.add_argument("-email", type=str, help="the email address of the registered user.")
    parser.add_argument("-file", type=str, help="Fully qualified name of the file.")
    parser.add_argument("-metadata", type=str, help="File containing metadata of the file to notarize.")
    parser.add_argument("-confirm_url", type=str, help="Confirmation URL to confirm an account.")
    parser.add_argument("-document_hash", type=str, help="Document hash  of a document")

    if cmd_str is None:
        args = parser.parse_args()
    else:
        args = parser.parse_args(cmd_str)
    if not args.password:
        print("Password is required!")
        return

    if notary is None:
        notary = NotaryClient("./notaryconfig.ini", args.password)

    command = args.command

    print "Running " + command + " command"

    if command == "register":
        if not args.email:
            print "register command needs email address"
        else:
            print args.email
            result = notary.register_user(args.email)
            print result
            return result
    elif command == "notarize":
        if not args.metadata:
            print "notarize command needs metadata file"
            return

        if not args.file:
            print "notarize command needs file"
            return
        # print args.file
        # print args.metadata
        metadata = json.loads(args.metadata)
        return notary.notarize_file(args.file,
                                    metadata)
    elif command == "uploadfile":

        if not args.file:
            print "upload command needs file"
            return
        # print args.file
        return notary.upload_file(args.file)

    elif command == "downloadfile":

        if not args.document_hash:
            print "download command needs document hash value"
            return
        if not args.file:
            print "download command needs file"
            return
        # print args.file
        return notary.download_file(args.document_hash,args.file)

    elif command == "login":
        return notary.authenticate()
    elif command == "notarystatus":
        if not args.document_hash:
            print "confirm command needs document_hash"
        else:
            print args.document_hash
            status = notary.get_notarization_status(args.document_hash)
            print "The Document status is"
            print status
            return status
    else:
        print "no command"
Esempio n. 13
0
from notary_client import NotaryClient,NotaryException
import simplecrypt
from client_wallet import ClientWallet
import test_data

# create a wallet
notary_obj = NotaryClient(test_data.config_file_name, "test123")

#try to authenticate without anything.
print "try to authenticate without anything"
try:
    print notary_obj.authenticate()
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)
# load wallet with wrong password


try:
    notary_obj = NotaryClient(test_data.config_file_name, "tessfsdft123")
except simplecrypt.DecryptionException as e:
    print e.message
# test wallet exists are not.
client_wallet_obj = ClientWallet("somepassword")
print "wallet exists"
print client_wallet_obj.wallet_exists()
#test wallet is registered or not.
#test wallet is confirmed or not.
#test register to server.
print "registering wallet"
try:
Esempio n. 14
0
import test_data
from notary_client import NotaryClient, NotaryException

try:
    notary_client = NotaryClient('./notaryconfig.ini', 'foobar')
    message = notary_client.download_file(test_data.document_hash, test_data.storing_file_name)
    print(message)
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)
import test_data
from notary_client import NotaryClient, NotaryException

try:
    notary_client = NotaryClient('./notaryconfig.ini', 'foobar')
    message = notary_client.get_notarization_status(test_data.document_hash)
    print(message)
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)
Esempio n. 16
0
import test_data
from notary_client import NotaryClient, NotaryException

try:
    notary_client = NotaryClient('./notaryconfig.ini', 'foobar')
    message = notary_client.notarize_file(test_data.notary_file_name,
                                          test_data.getMetaData())
    print(message)
except NotaryException as e:
    print("Code %s " % e.error_code)
    print(e.message)