-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth_client.py
56 lines (41 loc) · 1.29 KB
/
auth_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import json
import random
import signal
import string
import logging
import os.path
from getpass import getpass
import Ice
Ice.loadSlice('iceflix.ice')
# pylint: disable=E0401
# pylint: disable=C0413
import IceFlix
class Client(Ice.Application):
def run(self, argv):
broker = self.communicator()
proxy = broker.stringToProxy(argv[3])
self.authentication = IceFlix.AuthenticatorPrx.checkedCast(proxy)
user = argv[2]
option = argv[1]
if option == "-t":
print("Enter password:")
passwd = getpass()
if passwd == "":
token = self.authentication.refreshAuthorization(user, None)
else :
token = self.authentication.refreshAuthorization(user, passwd)
print(token)
elif option == "-p":
print("Enter password:")
passwd = getpass()
print("Enter new password:")
new_passwd = getpass()
if new_passwd == "":
self.authentication.changePassword(user, None, getpass())
else:
self.authentication.changePassword(user, passwd, new_passwd)
return 0
sys.exit(Client().main(sys.argv))