def __init__(self, session):
		self.auth = PamAuth()
		self.__authenticated = False
		self.username = None
		self.password = None
		self.userdn = None
		self.ip = None
class PAMAuthenticatedUser(object):
	implements(User)

	@property
	def user(self):
		# TODO: cache
		return get_user_object(self.userdn, self.password)

	def __init__(self, session):
		self.auth = PamAuth()
		self.__authenticated = False
		self.username = None
		self.password = None
		self.userdn = None
		self.ip = None

	def is_authenticated(self):
		if not self.__authenticated:
			raise NotAuthenticated()
		return True

	def authenticate(self, username, password):
		try:
			self.auth.authenticate(username, password)
		except:
			raise
		else:
			self.authenticated(username, password)

	def change_expired_password(self, username, old_password, new_password):
		self.auth.change_expired_password(username, old_password, new_password)
		self.authenticated(username, new_password)

	def authenticated(self, username, password):
		self.__authenticated = True
		self.username = username
		self.password = password
		self._init_user()

	def _init_user(self):
		self.userdn = get_userdn_by_username(self.username)