-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccessSystem.py
More file actions
96 lines (88 loc) · 3.9 KB
/
AccessSystem.py
File metadata and controls
96 lines (88 loc) · 3.9 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from datetime import datetime, time
ROLES = ["Regular_Client", "Premium_Client", "Teller", "Investment_Analyst", "Financial_Advisor", "Financial_Planner", "Compliance_Officer", "Technical_Support"]
def checkAccess(userRole):
"""
Check if a user has access into the system based on their role.
@param userRole: the role of the user.
@return true if they have access, false otherwise.
"""
# if the user is a teller, check if they have access
if(userRole.lower() == "teller"):
currentTime = datetime.now().time()
startTime = time(9, 0)
endTime = time(17, 0)
return (startTime <= currentTime and currentTime < endTime)
# if the user's role is a valid role, besides a teller, grant them access
else:
for role in ROLES:
if(userRole.lower() == role.lower()):
return True
return False # if the user role is invalid, deny access
def getAccessControlMatrix():
"""
Get the access control matrix.
@return a two-dimensional array of each role's permissions.
"""
acm = []
acm.append(["ROLE", "AccBalanceAccess", "PortAccess", "FinAdrContactAccess", "FinPlrContactAccess", "InvAnlContactAccess", "CltAccAccess", "CltAccBlcAccess", "CltPortAccess", "DervTradAccess", "IntInstrumentAccess", "MnyMktInstrumentAccess", "PrvConsInstrumentAccess", "VldPortMod"])
for role in ROLES:
acm.append(getRoleAccess(role))
return acm
def getRoleAccess(role):
"""
Get the permissions allowed for each role.
@param role: the role to get permissions for.
@return an array of the role's permissions.
"""
# all the default permissions for clients
accountBalanceAccess = "-"
portfolioAccess = "-"
financialAdvisorContactAccess = "-"
financialPlannerContactAccess = "-"
investmentAnalystContactAccess = "-"
# all the default permissions for employees
clientAccountAccess = "-"
clientAccountBalanceAccess = "-"
clientPortfolioAccess = "-"
derivativesTradingAccess = "-"
interestInstrumentAccess = "-"
moneyMarketInstrumentAccess = "-"
privateConsumerInstrumentAccess = "-"
validatePortfolioModification = "-"
# modify the permissions based on their role
if(role == "Regular_Client"):
accountBalanceAccess = "r"
portfolioAccess = "r"
financialAdvisorContactAccess = "r"
elif(role == "Premium_Client"):
accountBalanceAccess = "r"
portfolioAccess = "rw"
financialAdvisorContactAccess = "r"
financialPlannerContactAccess = "r"
investmentAnalystContactAccess = "r"
elif(role == "Compliance_Officer"):
clientAccountBalanceAccess = "r"
clientPortfolioAccess = "r"
validatePortfolioModification = "x"
elif(role == "Financial_Advisor"):
clientAccountBalanceAccess = "r"
clientPortfolioAccess = "rw"
privateConsumerInstrumentAccess = "r"
elif(role == "Financial_Planner"):
clientAccountBalanceAccess = "r"
clientPortfolioAccess = "rw"
moneyMarketInstrumentAccess = "r"
privateConsumerInstrumentAccess = "r"
elif(role == "Investment_Analyst"):
clientAccountBalanceAccess = "r"
clientPortfolioAccess = "rw"
derivativesTradingAccess = "r"
interestInstrumentAccess = "r"
moneyMarketInstrumentAccess = "r"
privateConsumerInstrumentAccess = "r"
elif(role == "Technical_Support"):
clientAccountAccess = "rx"
elif(role == "Teller"):
clientAccountBalanceAccess = "r"
clientPortfolioAccess = "r"
return [role, accountBalanceAccess, portfolioAccess, financialAdvisorContactAccess, financialPlannerContactAccess, investmentAnalystContactAccess, clientAccountAccess, clientAccountBalanceAccess, clientPortfolioAccess, derivativesTradingAccess, interestInstrumentAccess, moneyMarketInstrumentAccess, privateConsumerInstrumentAccess, validatePortfolioModification]