Skip to content

Commit

Permalink
Set default user login
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeide committed Jan 22, 2014
1 parent bb3a427 commit d9669a0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
6 changes: 4 additions & 2 deletions poortego/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 33,7 @@ class Dispatcher(Cmd):
#
def __init__(self):
Cmd.__init__(self)
self.namespace = 'poortego'
self.prompt = 'poortego> '
self.do_poortego_reinitialize('')

Expand All @@ -56,7 57,7 @@ def do_poortego_login(self, arg):
self.stdout.write("\n Password: ")
password_string = (self.stdin.readline()).replace('\n','')
attempted_user = User(username_string, password_string)
if (attempted_user.is_authenticated):
if (attempted_user.authenticate()):
self.my_session.user = attempted_user

#
Expand Down Expand Up @@ -161,6 162,7 @@ def do_import(self, arg, opts=None):
fn = arg
# TODO
elif opts.stix:
# TODO
fn = arg
(stix_package, stix_package_binding_obj) = STIXPackage.from_xml(fn)
stix_dict = stix_package.to_dict() # parse to dictionary
Expand Down Expand Up @@ -201,7 203,7 @@ def do_poortego_purge(self, arg):
"""Command to delete EVERYTHING from GraphDB"""
self.stdout.write("This will delete EVERYTHING from the GraphDB!!! Are you sure you want to do this [Y/N]: ")
response = (self.stdin.readline()).replace('\n','')
if (response == 'Y'):
if response == 'Y' or response == 'y':
self.my_graph.PURGE()
self.stdout.write("Database purged.\n")
self.do_poortego_reinitialize('')
Expand Down
13 changes: 0 additions & 13 deletions poortego/poortego_passwd.txt

This file was deleted.

19 changes: 11 additions & 8 deletions poortego/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 7,32 @@

import time

from .user import User

class Session:
"""Used for tracking Poortego session state"""
def __init__(self):
self.username = "" # TODO
self.user = User('guest','guest')
self.user.authenticate()
self.home_node_id = -1
self.current_node_id = -1
now_string = time.strftime("%Y-%m-%d %H:%M:%S")
self.default_node_meta = {
"created_by":self.username,
"created_by":self.user.username,
"created_at":now_string,
"creation_method":"Poortego shell",
"last_accessed_by":self.username,
"last_accessed_by":self.user.username,
"last_accessed_at":now_string,
"last_modified_by":self.username,
"last_modified_by":self.user.username,
"last_modified_at":now_string
}
self.default_link_meta = {
"created_by":self.username,
"created_by":self.user.username,
"created_at":now_string,
"creation_method":"Poortego shell",
"last_accessed_by":self.username,
"last_accessed_by":self.user.username,
"last_accessed_at":now_string,
"last_modified_by":self.username,
"last_modified_by":self.user.username,
"last_modified_at":now_string
}

Expand All @@ -45,6 48,6 @@ def update_link_meta(self):
def display(self):
print "Session Info:"
print "-------------"
print " Username: " str(self.username)
print " Username: " str(self.user.username)
print " Home Node Id: " str(self.home_node_id)
print " Current Node Id: " str(self.current_node_id)
4 changes: 3 additions & 1 deletion poortego/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 10,7 @@
class User:
"""Used for tracking Poortego user"""
def __init__(self, username, password):
self.password_file = 'poortego_passwd.txt'
self.username = username
self.password = password
self.authenticated = False
Expand All @@ -18,7 19,7 @@ def __init__(self, username, password):
def authenticate(self):
"""Stupid/basic authentication against a file - update before using in production"""
# TODO - improve authentication
with open('poortego_passwd.txt', 'r') as users_file:
with open(self.password_file, 'r') as users_file:
userreader = csv.reader(users_file, delimiter=':')
for row in userreader:
if len(row) == 3:
Expand Down Expand Up @@ -47,4 48,5 @@ def authenticate(self):
#user = User('guest', 'guest')
#user = User('analyst','analyst')
user = User('admin', 'admin')
user.password_file = "../" user.password_file
user.authenticate()

0 comments on commit d9669a0

Please sign in to comment.