CSimpleLoginComp.h
Go to the documentation of this file.
1 #ifndef iauth_CSimpleLoginComp_included
2 #define iauth_CSimpleLoginComp_included
3 
4 
5 // ACF includes
6 #include "icomp/CComponentBase.h"
7 #include "imod/TModelWrap.h"
8 #include "iser/ISerializable.h"
9 #include "iser/CArchiveTag.h"
10 
11 // ACF-Solutions includes
12 #include "iauth/ILogin.h"
13 #include "iauth/IRightsProvider.h"
14 #include "iauth/CUser.h"
15 
16 
17 namespace iauth
18 {
19 
20 
22  public icomp::CComponentBase,
23  public ILogin,
24  public IRightsProvider,
25  public iser::ISerializable
26 {
27 public:
29 
30  I_BEGIN_COMPONENT(CSimpleLoginComp);
31  I_REGISTER_INTERFACE(ILogin);
32  I_REGISTER_INTERFACE(IRightsProvider);
33  I_REGISTER_INTERFACE(iser::ISerializable);
34  I_ASSIGN_MULTI_0(m_userLevelsIfPtr, "UserLevels", "User levels", true);
35  I_ASSIGN_MULTI_0(m_defaultUsersAttrPtr, "DefaultUsers", "DefaultUsers", false);
36  I_ASSIGN_MULTI_0(m_defaultUserPasswordsAttrPtr, "DefaultUserPasswords", "DefaultUserPasswords", false);
37  I_ASSIGN_MULTI_0(m_defaultUserLevelsAttrPtr, "DefaultUserLevels", "DefaultUserLevels", false);
38  I_END_COMPONENT;
39 
41 
42  virtual int GetUsersCount() const;
43  virtual CUser& GetUser(int index) const;
44  virtual int FindUserIndex(const QString& name) const;
45  virtual bool AddUser(const CUser& user);
46 
47  // reimplemented (iauth::ILogin)
48  virtual CUser* GetLoggedUser() const;
49  virtual bool Login(const QString& userName, const QString& password);
50  virtual bool Logout();
51 
52  // reimplemented (iauth::IRightsProvider)
53  virtual bool HasRight(
54  const QByteArray& operationId,
55  bool beQuiet = false) const;
56 
57  // reimplemented (iser::ISerializable)
58  virtual bool Serialize(iser::IArchive& archive);
59 
60 protected:
61  // reimplemented (icomp::CComponentBase)
62  virtual void OnComponentCreated();
63 
64 private:
65  I_MULTIREF(IRightsProvider, m_userLevelsIfPtr);
66  I_MULTIATTR(QString, m_defaultUsersAttrPtr);
67  I_MULTIATTR(QString, m_defaultUserPasswordsAttrPtr);
68  I_MULTIATTR(int, m_defaultUserLevelsAttrPtr);
69 
70  typedef QVector<CUser> Users;
71  Users m_users;
72 
73  int m_loggedUserIndex;
74 };
75 
76 
77 } // namespace iauth
78 
79 
80 #endif // !iauth_CSimpleLoginComp_included
81 
82 
virtual CUser & GetUser(int index) const
virtual CUser * GetLoggedUser() const
Returns the currently logged on user.
virtual bool Login(const QString &userName, const QString &password)
Log in user.
virtual int FindUserIndex(const QString &name) const
virtual int GetUsersCount() const
virtual bool HasRight(const QByteArray &operationId, bool beQuiet=false) const
Checks if user has rights for specific operation.
virtual void OnComponentCreated()
virtual bool Logout()
Log in user.
virtual bool Serialize(iser::IArchive &archive)
virtual bool AddUser(const CUser &user)
icomp::CComponentBase BaseClass

© 2007-2011 Witold Gantzke and Kirill Lepskiy