本文整理汇总了Python中pyasm.security.Login类的典型用法代码示例。如果您正苦于以下问题:Python Login类的具体用法?Python Login怎么用?Python Login使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Login类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
def execute(my):
# Since this is not called with Command.execute_cmd
my.check()
web = WebContainer.get_web()
reset_on = my.kwargs.get('reset') == True
if reset_on:
security = WebContainer.get_security()
#Batch()
login = Login.get_by_login(my.login)
if not login:
web.set_form_value(ResetPasswordWdg.MSG, 'This user [%s] does not exist or has been disabled. Please contact the Administrator.'%my.login)
return
email = login.get_value('email')
if not email:
web.set_form_value(ResetPasswordWdg.MSG, 'This user [%s] does not have an email entry for us to email you the new password. Please contact the Administrator.'%my.login)
return
# auto pass generation
unique_code = ''.join([ random.choice('abcdefghijklmno12345') for i in xrange(0, 5)])
auto_password = unique_code
msg = ResetPasswordWdg.RESET_MSG
# send the email
try:
from pyasm.command import EmailTriggerTestCmd
admin = Login.get_by_login('admin')
if admin:
sender_email = admin.get_value('email')
else:
sender_email = '[email protected]'
recipient_emails = [email]
email_msg = 'Your TACTIC password has been reset. The new password is:\n%s\nYou can change your password once you log in by going to Edit My Account at the top right corner.'%auto_password
email_cmd = EmailTriggerTestCmd(sender_email=sender_email, recipient_emails=recipient_emails, msg= email_msg, subject='TACTIC password change')
email_cmd.execute()
except TacticException, e:
msg = "Failed to send an email for your new password. Reset aborted."
web.set_form_value(ResetPasswordWdg.MSG, msg)
raise
else:
encrypted = hashlib.md5(auto_password).hexdigest()
login.set_value('password', encrypted)
login.commit()
web.set_form_value(ResetPasswordWdg.MSG, 'A new password has been sent to your email address. Please check your email.')
# handle windows domains
#if my.domain:
# my.login = "%s\\%s" % (my.domain, my.login)
web.set_form_value(ResetPasswordWdg.MSG, msg)
示例2: verify
def verify(my, login_name, password):
# replace cn=attribute with cn={login} in the config ldap_path
# e.g. cn={login},o=organization,ou=server,dc=domain
path = Config.get_value("security", "ldap_path")
server = Config.get_value("security", "ldap_server")
assert path, server
my.login_name = login_name
my.internal = True
path = path.replace("{login}", login_name)
#import ldap
try:
l = ldap.open(server)
l.simple_bind_s(path, password)
l.unbind()
return True
except:
login = Login.get_by_login(login_name)
# check if it's an external account and verify with standard approach
if login and login.get_value('location', no_exception=True) == 'external':
auth_class = "pyasm.security.TacticAuthenticate"
authenticate = Common.create_from_class_path(auth_class)
is_authenticated = authenticate.verify(login_name, password)
if is_authenticated == True:
my.internal = False
return True
elif login:
auth_class = "pyasm.security.TacticAuthenticate"
authenticate = Common.create_from_class_path(auth_class)
is_authenticated = authenticate.verify(login_name, password)
if is_authenticated == True:
my.internal = False
return True
raise SecurityException("Login/Password combination incorrect")
示例3: get_to
def get_to(my):
from tactic_client_lib import TacticServerStub
from pyasm.common import Environment
recipients = set()
to = '[email protected]'
login_obj = Environment.get_login()
login = login_obj.get_login()
server = TacticServerStub.get()
eq = my.sobject
wo_code = eq.get_value('work_order_code')
if wo_code not in [None,'']:
wo = server.eval("@SOBJECT(twog/work_order['code','%s'])" % wo_code)
if wo:
wo = wo[0]
if wo.get('login') != login:
the_obj = Login.get_by_code(wo.get('login'))
if the_obj:
recipients.add(the_obj)
# creator_login_obj = server.eval("@SOBJECT(sthpw/login['login','%s'])" % wo.get('login'))
# if creator_login_obj:
# creator_login_obj = creator_login_obj[0]
# #to = creator_login_obj.get('email')
# to = creator_login_obj
print "RETURN Recipients: %s" % recipients
return recipients
示例4: add_user_to_group
def add_user_to_group(self):
web = WebContainer.get_web()
user_name = web.get_form_value("user_to_add")
group_name = web.get_form_value("group_name")
login = Login.get_by_login(user_name)
login.add_to_group(group_name)
self.description = "Added User '%s' to Group '%s'" \
% (user_name,group_name)
示例5: remove_user_from_group
def remove_user_from_group(self):
web = WebContainer.get_web()
users_to_remove = web.get_form_values("users_to_remove")
group_name = web.get_form_value("group_name")
for user_name in users_to_remove:
login = Login.get_by_login(user_name)
login.remove_from_group(group_name)
self.description = "Removed User '%s' to Group '%s'" \
% ( ", ".join(users_to_remove), group_name)
示例6: init
def init(my):
assert my.task
super(TaskExtraInfoWdg, my).init()
# create the visible element
icon = IconWdg('Time Card', icon=IconWdg.TIME)
my.add(icon)
my.add(HtmlElement.b(my.task.get_process()))
my.time_card = TimecardWdg()
my.time_card.set_task(my.task)
from pyasm.security import Login
# create the content
content = DivWdg()
content.add_style('width','46em')
# customize the extra info widget
my.set_class('timecard_main')
my.set_content(content)
my.set_mouseout_flag(False)
my.login = Login.get_by_login(my.task.get_assigned())
title = FloatDivWdg()
login_name = 'unassigned'
my.is_other = False
if my.login:
login_name = my.login.get_full_name()
if my.login.get_login() == Environment.get_login().get_login():
icon = IconWdg(icon=IconWdg.REFRESH)
icon.add_class('hand')
icon.add_event('onclick', my.time_card.get_refresh_script())
title.add(icon)
else:
my.is_other = True
title.add("Time card - %s" % login_name)
content.add(title)
content.add(CloseWdg(my.get_off_script()))
content.add(HtmlElement.br(2))
content.add(my.time_card, 'time')
if not my.login:
div = DivWdg(HtmlElement.b('Time card cannot be entered for unassigned task.'))
content.set_widget(div, 'time')
my.height = 60
elif my.is_other:
div = DivWdg(HtmlElement.b('Time card cannot be entered for other users [%s].'\
%login_name))
content.set_widget(div, 'time')
my.height = 60
示例7: get_to
def get_to(my):
# add the assigned user to the list of users sent.
recipients = super(TaskAssignEmailHandler, my).get_to()
task = my.sobject
assigned = task.get_value("assigned")
login = Login.get_by_login(assigned)
if not login:
Environment.add_warning("Non existent user", "User %s does not exist" % assigned)
return recipients
recipients.add(login)
return recipients
示例8: verify
def verify(my, login_name, password):
# replace cn=attribute with cn={login} in the config ldap_path
# e.g. cn={login},o=organization,ou=server,dc=domain
path = Config.get_value("security", "ldap_path")
server = Config.get_value("security", "ldap_server")
assert path, server
my.login_name = login_name
my.internal = True
path = path.replace("{login}", login_name)
#import ldap
try:
l = ldap.initialize(server)
# For AD, it may need these before simple_bind_s()
#l.protocol_version = 3
#l.set_option(ldap.OPT_REFERRALS, 0)
l.simple_bind_s(path, password)
my.ldap_info = search_ldap_info(l, login_name)
l.unbind()
print login_name, password
#with open("/tmp/foo", "a") as fh:
#print >> fh, "{0} - {1}".format(login_name, password)
return True
except Exception, e:
login = Login.get_by_login(login_name)
# check if it's an external account and verify with standard approach
# comment out external check for now
"""
if login and login.get_value('location', no_exception=True) == 'external':
auth_class = "pyasm.security.TacticAuthenticate"
authenticate = Common.create_from_class_path(auth_class)
is_authenticated = authenticate.verify(login_name, password)
if is_authenticated == True:
my.internal = False
return True
"""
raise SecurityException("Login/Password combination incorrect. %s" %e.__str__())
示例9: get_display
def get_display(self):
top = DivWdg()
top.add_class("ad_input_top")
name = self.get_name()
text = TextWdg(self.get_input_name())
# get the login
sobject = self.get_current_sobject()
client = sobject.get_value("contact_name")
print "client: ", client
if client:
login_sobj = Login.get_by_code(client)
else:
login_sobj = Environment.get_login()
# build the display_name
login = login_sobj.get_value("login")
display_name = login_sobj.get_value("display_name")
if not display_name:
display_name = "%s %s" % (user.get('first_name'), user.get('last_name'))
display_name = display_name.replace('"', "'")
print "login: ", login
hidden = HiddenWdg(self.get_input_name())
hidden.set_options( self.options.copy() )
hidden.add_class("spt_ad_input")
if login:
hidden.set_value(login)
top.add(hidden)
# copy over some options
#text.set_options( self.options.copy() )
if login:
text.set_value(display_name)
text.set_option("read_only", "true")
text.add_class("spt_ad_display")
top.add(text)
top.add(" ")
groups_str = self.get_option("groups_allowed_to_search")
if groups_str:
stmt = 'groups_list = %s' % groups_str
exec stmt
else:
groups_list = None
allow_search = True
if groups_list:
allow_search = False
login_in_group_list = Search.eval("@SOBJECT(sthpw/login_in_group['login','=','%s'])" % login)
for login_in_group in login_in_group_list:
group = login_in_group.get_value("login_group")
if group in groups_list:
allow_search = True
break
if login == 'admin':
allow_search = True
if allow_search:
button = IconButtonWdg('Search for User', IconWdg.USER)
#button = ButtonWdg()
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
var top = bvr.src_el.getParent('.ad_input_top');
var content = top.getElement('.ad_input_content');
spt.toggle_show_hide(content);
'''
} )
top.add(button)
ad_top = DivWdg()
ad_top.add_class("ad_input_content")
ad_top.add_style("display: none")
ad_top.add_style("position: absolute")
ad_top.add_style("background: #222")
ad_top.add_style("min-width: 300px")
ad_top.add_style("border: solid 1px #000")
ad_top.add_style("padding: 20px")
cbjs_action = '''
var value = bvr.src_el.getAttribute('spt_input_value');
var display_value = bvr.src_el.getAttribute('spt_display_value');
var phone_number = bvr.src_el.getAttribute('spt_phone_number');
var email = bvr.src_el.getAttribute('spt_mail');
var top = bvr.src_el.getParent('.ad_input_top');
#.........这里部分代码省略.........
示例10: _get_login
def _get_login(my, assigned):
return Login.get_by_login(assigned)
示例11: init
def init(my):
my.is_refresh = my.kwargs.get("refresh")
my.search_key = my.kwargs.get("search_key")
my.ticket_key = my.kwargs.get("ticket")
my.parent_key = my.kwargs.get("parent_key")
my.expression = my.kwargs.get("expression")
# This assumed parent can cause errors as it tries to find a
# relationship between to stypes that don't exist ... or worse,
# try to bind them when one stype does not have the sufficent columns
# ie: pipeline_code
#if not my.parent_key:
# project = Project.get()
# my.parent_key = project.get_search_key()
my.code = my.kwargs.get("code")
sobject = None
if my.search_key:
sobject = Search.get_by_search_key(my.search_key)
my.search_id = sobject.get_id()
my.search_type = sobject.get_base_search_type()
if sobject.is_insert():
my.mode = 'insert'
else:
my.mode = 'edit'
elif my.expression:
sobject = Search.eval(my.expression, single=True)
my.search_id = sobject.get_id()
my.search_type = sobject.get_base_search_type()
my.mode = 'edit'
elif my.ticket_key:
from pyasm.security import Ticket, Login
ticket = Ticket.get_by_valid_key(my.ticket_key)
if not ticket:
raise TacticException("No valid ticket")
login_code = ticket.get_value("login")
login = Login.get_by_code(login_code)
my.search_type = "sthpw/login"
my.search_id = login.get_id()
my.mode = 'edit'
elif my.code:
my.search_type = my.kwargs.get("search_type")
search = Search(my.search_type)
search.add_filter("code", my.code)
sobject = search.get_sobject()
my.search_id = sobject.get_id()
my.search_type = sobject.get_base_search_type()
my.mode = 'edit'
else:
my.search_type = my.kwargs.get("search_type")
my.search_id = my.kwargs.get("search_id")
if not my.search_id:
my.search_id = -1
my.search_id = int(my.search_id)
if my.search_id != -1:
my.mode = "edit"
else:
my.mode = "insert"
# explicit override
if my.kwargs.get("mode"):
my.mode = my.kwargs.get("mode")
my.view = my.kwargs.get("view")
if not my.view:
my.view = my.kwargs.get("config_base")
if not my.view:
my.view = "edit"
default_data = my.kwargs.get('default')
if not default_data:
default_data = {}
elif isinstance(default_data, basestring):
try:
default_data = jsonloads(default_data)
except:
#may be it's regular dictionary
try:
default_data = eval(default_data)
except:
print "Warning: Cannot evaluate [%s]" %default_data
default_data = {}
if sobject:
my.set_sobjects([sobject], None)
else:
my.do_search()
#.........这里部分代码省略.........
示例12: alter_search
def alter_search(self, search):
user = Environment.get_user_name()
from pyasm.security import Login
user = Login.get_by_login(user)
search.add_filter("login", user.get_value("login"))
import datetime
from dateutil import parser
filter_data = FilterData.get()
values = filter_data.get_values_by_index("week", 0)
date_string = values.get("calendar")
if date_string:
date = parser.parse(date_string)
else:
date = datetime.datetime.now()
from tactic.ui.report import MMSUtility
#start_wday, end_wday = self.get_week_range(date_string)
start_wday, end_wday = MMSUtility.get_week_range(date)
one_day = datetime.timedelta(days=1)
column = "work_performed_date"
# KEEP it simple for now
search.add_op("begin")
search.add_filter(column, start_wday, op='>=')
search.add_filter(column, end_wday, op='<=')
search.add_op("and")
'''
search.add_op("begin")
search.add_filter(column, start_wday + one_day, op='>=')
search.add_filter(column, end_wday - one_day, op='<=')
search.add_op("and")
search.add_op("begin")
search.add_filter(column, start_wday, op='>=')
search.add_filter(column, start_wday+one_day, op='<=')
search.add_filter("shift", "pm", op='=')
search.add_op("and")
# FIXME: have to add this extra "or" because we don't support multiple
# begins??
search.add_op("or")
search.add_op("begin")
search.add_filter(column, end_wday, op='>=')
search.add_filter(column, end_wday+one_day, op='<=')
search.add_filter("shift", "am", op='=')
search.add_op("and")
search.add_op("or")
'''
search.add_order_by(column)
search.add_order_by("work_start_time")
search.add_order_by("shift")
示例13: Batch
# All Rights Reserved
#
# PROPRIETARY INFORMATION. This software is proprietary to
# Southpaw Technology, and is not to be reproduced, transmitted,
# or disclosed in any way without written permission.
#
#
#
import sys
import os
import tacticenv
from pyasm.security import Batch, Login
from pyasm.search import Search
Batch()
search = Search("sthpw/login")
search.add_filter("login", "admin")
admin = search.get_sobject()
password = Login.get_default_encrypted_password()
admin.set_value("password", password)
admin.commit()
print "Successfully reset admin password. You will be prompted to change it on startup of TACTIC."
raw_input()
示例14: get_display
def get_display(self):
top = DivWdg()
top.add_color("background", "background")
top.add_color("color", "color")
top.add_style("min-width: 600px")
os_name = os.name
top.set_unique_id()
top.add_smart_style("spt_info_title", "background", self.top.get_color("background3"))
top.add_smart_style("spt_info_title", "padding", "3px")
top.add_smart_style("spt_info_title", "font-weight", "bold")
# server
title_div = DivWdg()
top.add(title_div)
title_div.add("Server")
title_div.add_class("spt_info_title")
os_div = DivWdg()
top.add(os_div)
os_info = platform.uname()
try:
os_login = os.getlogin()
except Exception:
os_login = os.environ.get("LOGNAME")
table = Table()
table.add_color("color", "color")
table.add_style("margin: 10px")
os_div.add(table)
for i, title in enumerate(['OS','Node Name','Release','Version','Machine']):
table.add_row()
td = table.add_cell("%s: " % title)
td.add_style("width: 150px")
table.add_cell( os_info[i] )
table.add_row()
table.add_cell("CPU Count: ")
try :
import multiprocessing
table.add_cell( multiprocessing.cpu_count() )
except (ImportError, NotImplementedError):
table.add_cell( "n/a" )
table.add_row()
table.add_cell("Login: ")
table.add_cell( os_login )
# python
title_div = DivWdg()
top.add(title_div)
title_div.add("Python")
title_div.add_class("spt_info_title")
table = Table()
table.add_color("color", "color")
table.add_style("margin: 10px")
top.add(table)
table.add_row()
td = table.add_cell("Version: ")
td.add_style("width: 150px")
table.add_cell( sys.version )
# client
title_div = DivWdg()
top.add(title_div)
title_div.add("Client")
title_div.add_class("spt_info_title")
web = WebContainer.get_web()
user_agent = web.get_env("HTTP_USER_AGENT")
table = Table()
table.add_color("color", "color")
table.add_style("margin: 10px")
top.add(table)
table.add_row()
td = table.add_cell("User Agent: ")
td.add_style("width: 150px")
table.add_cell( user_agent )
table.add_row()
td = table.add_cell("TACTIC User: ")
table.add_cell( web.get_user_name() )
top.add('<br/>')
self.handle_load_balancing(top)
#.........这里部分代码省略.........
示例15: get_display
def get_display(my):
top = my.top
login = my.kwargs.get("login")
if not login or login == "$LOGIN":
login = Environment.get_user_name()
login_sobj = Login.get_by_code(login)
# top.add_style("margin-top: -2px")
# top.add_style("margin-left: -2px")
thumb_div = DivWdg()
thumb_div.add_style("float: left")
thumb_div.add_style("margin-right: 5px")
thumb_div.add_style("margin-bottom: 5px")
thumb_div.add_style("padding-top: 1px")
thumb = ThumbWdg()
thumb.set_sobject(login_sobj)
thumb_div.add(thumb)
thumb.set_icon_size(90)
thumb.set_aspect("height")
full_name = login_sobj.get_full_name()
info_wdg = DivWdg()
top.add(info_wdg)
name_wdg = DivWdg()
info_wdg.add(thumb_div)
info_wdg.add(name_wdg)
name_wdg.add(" " * 3)
name_wdg.add(full_name)
name_wdg.add_style("font-size: 1.5em")
name_wdg.add_style("font-weight: bold")
name_wdg.add_style("padding: 5px")
# name_wdg.add_style("margin-left: -10px")
name_wdg.add_color("background", "background3")
name_wdg.add_style("height: 20px")
name_wdg.add_style("margin-bottom: 0px")
name_wdg.add_border()
info_wdg.add("<br/>")
from tactic.ui.container import TabWdg
# return if the supplied tab view has a config xml
if my.tab_view:
search = Search("config/widget_config")
search.add_filter("category", "TabWdg")
search.add_filter("view", my.tab_view)
config_sobj = search.get_sobject()
if config_sobj:
config_xml = config_sobj.get_value("config")
# replace the variable $login with the login clicked
if login:
config_xml = config_xml.replace("$login", login)
tab = TabWdg(config_xml=config_xml, view=my.tab_view, show_add=False, show_remove=False)
top.add(tab)
return top
config_xml = []
config_xml.append("<config>")
config_xml.append("<tab>")
config_xml.append(
"""
<element name='activity'>
<display class='tactic.ui.widget.ActivityCalendarWdg'>
<login>%s</login>
<cell_width>100px</cell_width>
<cell_height>50px</cell_height>
<show_header>true</show_header>
<show_border>false</show_border>
</display>
</element>
"""
% login
)
config_xml.append(
"""
<element name='schedule'>
<display class='tactic.ui.widget.TaskCalendarWdg'>
<assigned>%s</assigned>
<sobject_display_expr>%s</sobject_display_expr>
<show_header>true</show_header>
<show_border>false</show_border>
</display>
</element>
"""
% (login, my.sobject_display_expr)
)
config_xml.append(
"""
<element name='tasks'>
<display class='tactic.ui.panel.FastTableLayoutWdg'>
<search_type>sthpw/task</search_type>
#.........这里部分代码省略.........