本文整理汇总了Python中authentication.Authentication类的典型用法代码示例。如果您正苦于以下问题:Python Authentication类的具体用法?Python Authentication怎么用?Python Authentication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Authentication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
class LayoutData:
def __init__(self):
self.authentication = Authentication();
self.authentication.session_init();
def getPortal(self):
return Services.getPortalManager().get(portalId)
def getPortals(self):
return Services.getPortalManager().portals
def getPortalName(self):
return self.getPortal().getDescription()
def escapeText(self, text):
return StringEscapeUtils.escapeXml(text)
def md5Hash(self, data):
return md5.new(data).hexdigest()
def capitalise(self, text):
return text[0].upper() + text[1:]
def getTemplate(self, templateName):
portalName = portalId
if not Services.pageService.resourceExists(portalId, templateName, False):
portalName = Services.portalManager.DEFAULT_PORTAL_NAME
return "%s/%s" % (portalName, templateName)
示例2: authenticate_user
def authenticate_user(self):
global AUTHENTICATED
# we should check to see if we are already authenticated before blindly doing it again
if (AUTHENTICATED == False ):
obj = Authentication(self._vipr_info['hostname'], int(self._vipr_info['port']))
cookiedir = '/tmp/vipr_cookie_dir'
cookiefile = 'cookie-' + self._vipr_info['username'] + '-' + str(os.getpid())
obj.authenticate_user(self._vipr_info['username'], self._vipr_info['password'], cookiedir, cookiefile)
AUTHENTICATED = True
示例3: __init__
def __init__(self, username=None, api_key=None, timeout=10, **kwargs):
"""
Accepts keyword arguments for Rackspace Cloud username and api key.
Optionally, you can omit these keywords and supply an
Authentication object using the auth keyword.
@type username: str
@param username: a Rackspace Cloud username
@type api_key: str
@param api_key: a Rackspace Cloud API key
"""
self.connection_args = None
self.connection = None
self.token = None
self.debuglevel = int(kwargs.get('debuglevel', 0))
self.user_agent = kwargs.get('useragent', consts.user_agent)
self.timeout = timeout
self.auth = 'auth' in kwargs and kwargs['auth'] or None
if not self.auth:
authurl = kwargs.get('authurl', consts.us_authurl)
if username and api_key and authurl:
self.auth = Authentication(username, api_key, authurl=authurl,
useragent=self.user_agent)
else:
raise TypeError("Incorrect or invalid arguments supplied")
self._authenticate()
示例4: register
def register(profile_cipher, profile_dict):
profile_type = Authentication.decrypt_profile_type(profile_type)
"""This code block will update info from external service (Facebook,
Linkedin, etc) using token or refresh token"""
if profile_type == "Facebook" and type(profile_dict) is str:
#WILL NEED TO GET TOKEN SOMEHOW/use refresh token
#make facebook api call and put data in dict
FacebookProfile(profile_dict).put()
#return status_code
if profile_type == "Linkedin" and type(profile_dict) is str:
#WILL NEED TO GET TOKEN SOMEHOW/use refresh token
#make linkedin api call and put data in dict
LinkedinProfile(profile_dict).put()
#return status_code
"""This code block will update info from the dictionary sent up
by user. Fields that they changed should now remain static"""
if profile_type == "Facebook" and type(profile_dict) is dict:
#figure out how to not allow fields the user changed to be modifed from external service
FacebookProfile(profile_dict).put()
#return status_code
if profile_type == "Linkedin" and type(profile_dict) is dict:
#figure out how to not allow fields the user changed to be modifed from external service
LinkedinProfile(profile_dict).put()
#return status_code
"""This code block will always update with user's curr app info
since they do not use any external services"""
if profile_type == "BCFrd":
BlueConnectFriend(profile_dict).put()
#return status_code
if profile_type == "BCPro":
BlueConnectProfessional(profile_dict).put()
#return status_code
else: raise TypeError("Invalid Profile Type")
示例5: __init__
def __init__(self):
# init Query
super(Client, self).__init__()
self.token = None
self.server_info = None
self.headers = {}
self.config = Config().get_data()
self.authentication = None
data = 'data' in self.config.keys() and self.config['data'] or None
if data:
self.hostname = 'hostname' in data.keys() and \
data['hostname'] or ''
self.sf_apikey = 'apikey' in data.keys() and \
data['apikey'] or ''
self.username = 'username' in data.keys() and \
data['username'] or ''
self.password = 'password' in data.keys() and \
data['password'] or ''
self.impersonation_username = \
'impersonation_username' in data.keys() and \
data['impersonation_username'] or ''
self.token_life_time = 'token_life_time' in data.keys() and \
data['token_life_time'] or 0
self.handler = Handler(self.config)
self.authentication = Authentication(
hostname=self.hostname,
sf_apikey=self.sf_apikey,
username=self.username,
password=self.password,
impersonation_username=self.impersonation_username)
示例6: __init__
def __init__(self, username=None, api_key=None, **kwargs):
"""
Accepts keyword arguments for Mosso username and api key.
Optionally, you can omit these keywords and supply an
Authentication object using the auth keyword.
@type username: str
@param username: a Mosso username
@type api_key: str
@param api_key: a Mosso API key
"""
self.cdn_enabled = False
self.cdn_args = None
self.connection_args = None
self.cdn_connection = None
self.connection = None
self.token = None
self.debuglevel = int(kwargs.get('debuglevel', 0))
socket.setdefaulttimeout = int(kwargs.get('timeout', 5))
self.auth = kwargs.has_key('auth') and kwargs['auth'] or None
if not self.auth:
authurl = kwargs.get('authurl', consts.default_authurl)
if username and api_key and authurl:
self.auth = Authentication(username, api_key, authurl)
else:
raise TypeError("Incorrect or invalid arguments supplied")
self._authenticate()
示例7: __init__
class LayoutData:
def __init__(self):
self.authentication = Authentication()
self.authentication.session_init()
self.config = JsonConfig()
def getPortal(self):
return Services.getPortalManager().get(portalId)
def getPortals(self):
return Services.getPortalManager().portals
def getPortalName(self):
return self.getPortal().getDescription()
def escapeXml(self, text):
return StringEscapeUtils.escapeXml(text)
def escapeHtml(self, text):
return StringEscapeUtils.escapeHtml(text)
def unescapeHtml(self, text):
return StringEscapeUtils.unescapeHtml(text)
def md5Hash(self, data):
return md5.new(data).hexdigest()
def capitalise(self, text):
return text[0].upper() + text[1:]
def getTemplate(self, templateName):
portalName = portalId
if not Services.pageService.resourceExists(portalId, templateName, False):
portalName = Services.portalManager.DEFAULT_PORTAL_NAME
return "%s/%s" % (portalName, templateName)
def isConfigured(self):
return self.config.isConfigured()
def isNotConfigured(self):
return not self.config.isConfigured()
def isOutdated(self):
return self.config.isOutdated()
def needRestart(self):
return "true" == sessionState.get("need-restart", "false")
示例8: __init__
def __init__(self, username=None, api_key=None, timeout=15, **kwargs):
"""
Accepts keyword arguments for Mosso username and api key.
Optionally, you can omit these keywords and supply an
Authentication object using the auth keyword. Setting the argument
servicenet to True will make use of Rackspace servicenet network.
@type username: str
@param username: a Mosso username
@type api_key: str
@param api_key: a Mosso API key
@type servicenet: bool
@param servicenet: Use Rackspace servicenet to access Cloud Files.
@type cdn_log_retention: bool
@param cdn_log_retention: set logs retention for this cdn enabled
container.
"""
self.cdn_enabled = False
self.cdn_args = None
self.connection_args = None
self.cdn_connection = None
self.connection = None
self.token = None
self.debuglevel = int(kwargs.get('debuglevel', 0))
self.servicenet = kwargs.get('servicenet', False)
self.user_agent = kwargs.get('useragent', consts.user_agent)
self.timeout = timeout
# if the environement variable RACKSPACE_SERVICENET is set (to
# anything) it will automatically set servicenet=True
if not 'servicenet' in kwargs \
and 'RACKSPACE_SERVICENET' in os.environ:
self.servicenet = True
self.auth = 'auth' in kwargs and kwargs['auth'] or None
if not self.auth:
authurl = kwargs.get('authurl', consts.us_authurl)
if username and api_key and authurl and authurl.startswith('hubic|'):
self.auth = HubicAuthentication(username, api_key, authurl,
useragent=self.user_agent, timeout=self.timeout)
elif username and api_key and authurl:
self.auth = Authentication(username, api_key, authurl=authurl,
useragent=self.user_agent, timeout=self.timeout)
else:
raise TypeError("Incorrect or invalid arguments supplied")
self._authenticate()
示例9: __init__
class SearchTreeData:
def __init__(self):
self.authentication = Authentication()
self.authentication.session_init()
self.__search()
def __search(self):
query = formData.get("query")
searchQuery = sessionState.get("searchQuery")
if query is None or query == "":
query = "*:*"
if searchQuery and query == "*:*":
query = searchQuery
elif searchQuery:
query += " AND " + searchQuery
facetField = formData.get("facet.field")
req = SearchRequest(query)
req.setParam("facet", "true")
req.setParam("fl", "id")
req.setParam("rows", "0")
req.setParam("facet.limit", "-1")
req.setParam("facet.field", facetField)
fq = sessionState.get("fq")
if fq is not None:
req.setParam("fq", fq)
req.addParam("fq", 'item_type:"object"')
# Make sure 'fq' has already been set in the session
security_roles = self.authentication.get_roles_list();
security_query = 'security_filter:("' + '" OR "'.join(security_roles) + '")'
req.addParam("fq", security_query)
out = ByteArrayOutputStream()
indexer = Services.getIndexer()
indexer.search(req, out)
result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
self.__facetList = FacetList(facetField, result)
def getFacetList(self):
return self.__facetList
def getFacet(self, value):
return self.__facetList.get(value)
示例10: __init__
def __init__(self):
self.authentication = Authentication()
self.authentication.session_init()
self.writer = response.getPrintWriter("text/html; charset=UTF-8")
if self.authentication.is_logged_in() and self.authentication.is_admin():
self.process()
else:
self.throw_error("Only administrative users can access this feature")
示例11: Application
class Application(tornado.web.Application):
def __init__(self):
settings = dict(
autoreload=False,
compiled_template_cache=False,
static_hash_cache=False,
serve_traceback=True,
gzip=True,
template_path=os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')),
static_path=os.path.abspath(os.path.join(os.path.dirname(__file__), 'static')),
login_url='/login'
)
handlers = [
url(r'/', Domains, name="Domains", kwargs={'title': 'Domains'}),
url('/mailboxes', Mailboxes, name="Mailboxes", kwargs={'title': 'Mailboxes'}),
url('/login', Login, name="Login", kwargs={'title': "Login"}),
url('/logout', Logout, name="Logout"),
url('/set_language', SetLanguage, name="SetLanguage"),
url('/aliases', Aliases, name="Aliases", kwargs={'title': 'Aliases'}),
url('/profile', Profile, name="Profile", kwargs={'title': 'Profile'})
]
self.logger = logging.getLogger("application")
logging.basicConfig(level=logging.DEBUG)
self.app_settings = Settings
self.database = Database(self.app_settings.Database.DatabaseName, {'user': self.app_settings.Database.Username,
'passwd': self.app_settings.Database.Password,
'host': self.app_settings.Database.Address,
'port': self.app_settings.Database.Port})
self.authentication = Authentication(self)
tornado.locale.load_translations(os.path.join(os.path.dirname(__file__), Settings.Language.TranslationFolder))
tornado.locale.set_default_locale(Settings.Language.DefaultLanguage)
if not self.database.is_populated():
self.database.initialise()
self.authentication.create_user("admin", "admin")
tornado.web.Application.__init__(self, handlers, **settings)
示例12: __init__
class DeleteData:
def __init__(self):
self.authentication = Authentication()
self.authentication.session_init()
self.writer = response.getPrintWriter("text/html; charset=UTF-8")
if self.authentication.is_logged_in() and self.authentication.is_admin():
self.process()
else:
self.throw_error("Only administrative users can access this feature")
def process(self):
record = formData.get("record")
try:
Services.storage.removeObject(record)
Services.indexer.remove(record)
self.writer.println(record)
self.writer.close()
except Exception, e:
self.throw_error("Error deleting object: " + e.getMessage())
示例13: __init__
class LayoutData:
def __init__(self):
self.authentication = Authentication();
self.authentication.session_init();
self.config = JsonConfig()
def getPortal(self):
return Services.getPortalManager().get(portalId)
def getPortals(self):
return Services.getPortalManager().portals
def getPortalName(self):
return self.getPortal().getDescription()
def escapeXml(self, text):
return StringEscapeUtils.escapeXml(text)
def escapeHtml(self, text):
return StringEscapeUtils.escapeHtml(text)
def unescapeHtml(self, text):
return StringEscapeUtils.unescapeHtml(text)
def md5Hash(self, data):
return md5.new(data).hexdigest()
def capitalise(self, text):
return text[0].upper() + text[1:]
def getTemplate(self, templateName):
return Services.pageService.resourceExists(portalId, templateName)
def getQueueStats(self):
return Services.getHouseKeepingManager().getQueueStats()
def getSsoProviders(self):
return security.ssoBuildLogonInterface()
示例14: __init__
def __init__(self):
self.authentication = Authentication()
self.authentication.session_init()
if self.authentication.is_logged_in():
if self.authentication.is_admin():
responseMsg = self.authentication.get_name() + ":admin"
else:
responseMsg = self.authentication.get_name() + ":notadmin"
else:
responseMsg = self.authentication.get_error()
response.setStatus(500)
writer = response.getPrintWriter("text/html")
writer.println(responseMsg)
writer.close()
示例15: __init__
def __init__(self, username=None, api_key=None, token=None, tenant_id=None, timeout=10, **kwargs):
"""
Accepts keyword arguments for Rackspace Cloud username and api key.
Optionally, you can omit these keywords and supply an
Authentication object using the auth keyword.
@type username: str
@param username: a Rackspace Cloud username
@type api_key: str
@param api_key: a Rackspace Cloud API key
"""
self.connection_args = None
self.connection = None
self.token = None
self.debuglevel = int(kwargs.get('debuglevel', 0))
self.user_agent = kwargs.get('useragent', consts.user_agent)
self.timeout = timeout
self.auth = 'auth' in kwargs and kwargs['auth'] or None
#Temporary hack - if we already have a token and tenant_id, skip auth process and jump straight to connecting
if token and tenant_id:
#TODO: Make sure token is valid for tenant_id, otherwise, throw back a 401
self.token = token
url = "https://dns.api.rackspacecloud.com/v1.0/%s" % tenant_id
self.connection_args = parse_url(url)
if version_info[0] <= 2 and version_info[1] < 6:
self.conn_class = self.connection_args[3] and THTTPSConnection or \
THTTPConnection
else:
self.conn_class = self.connection_args[3] and HTTPSConnection or \
HTTPConnection
self.http_connect()
else:
if not self.auth:
authurl = kwargs.get('authurl', consts.us_authurl)
if username and api_key and authurl:
self.auth = Authentication(username, api_key, authurl=authurl,
useragent=self.user_agent)
else:
raise TypeError("Incorrect or invalid arguments supplied")
self._authenticate()