def authenticate_user(self):
# we should check to see if we are already authenticated before blindly
# doing it again
if CoprHDCLIDriver.AUTHENTICATED is False:
utils.COOKIE = None
objauth = auth.Authentication(
self.coprhdhost,
self.port)
cookiedir = self.cookiedir
if( (self.coprhdcli_security_file is not '')
and (self.coprhdcli_security_file is not None)):
from Crypto.Cipher import ARC4
import getpass
objarc = ARC4.new(getpass.getuser())
security_file = open(self.coprhdcli_security_file, 'r')
cipher_text = security_file.readline().rstrip()
self.username = objarc.decrypt(cipher_text)
cipher_text = security_file.readline().rstrip()
self.password = objarc.decrypt(cipher_text)
security_file.close()
objauth.authenticate_user(self.username,
self.password,
cookiedir,
None)
CoprHDCLIDriver.AUTHENTICATED = True
评论列表
文章目录