libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_MEDIA_CREDENTIALMANAGER_H 00013 #define ZYPP_MEDIA_CREDENTIALMANAGER_H 00014 00015 #include <set> 00016 00017 #include "zypp/Pathname.h" 00018 #include "zypp/media/MediaUserAuth.h" 00019 00021 namespace zypp 00022 { 00023 00024 class Url; 00025 00027 namespace media 00028 { 00029 00030 00032 // 00033 // CLASS NAME : CredManagerOptions 00034 // 00038 struct CredManagerOptions 00039 { 00040 CredManagerOptions(const Pathname & rootdir = ""); 00041 00042 Pathname globalCredFilePath; 00043 Pathname userCredFilePath; 00044 Pathname customCredFileDir; 00045 }; 00047 00048 // comparator for CredentialSet 00049 struct AuthDataComparator 00050 { 00051 bool operator()(const AuthData_Ptr & lhs, const AuthData_Ptr & rhs); 00052 }; 00053 00055 // 00056 // CLASS NAME : CredentialManager 00057 // 00062 class CredentialManager 00063 { 00064 public: 00065 typedef std::set<AuthData_Ptr, AuthDataComparator> CredentialSet; 00066 typedef CredentialSet::size_type CredentialSize; 00067 typedef CredentialSet::const_iterator CredentialIterator; 00068 00069 00070 CredentialManager(const CredManagerOptions & opts = CredManagerOptions()); 00071 00072 ~CredentialManager() 00073 {} 00074 00075 public: 00087 AuthData_Ptr getCred(const Url & url); 00088 00092 AuthData_Ptr getCredFromFile(const Pathname & file); 00093 00097 void addGlobalCred(const AuthData & cred); 00098 00102 void addUserCred(const AuthData & cred); 00103 00118 void addCred(const AuthData & cred); 00119 00124 void save(); 00125 00133 void saveInGlobal(const AuthData & cred); 00134 00142 void saveInUser(const AuthData & cred); 00143 00152 void saveInFile(const AuthData &, const Pathname & credFile); 00153 00159 void clearAll(bool global = false); 00160 00161 00162 CredentialIterator credsGlobalBegin() const; 00163 CredentialIterator credsGlobalEnd() const; 00164 CredentialSize credsGlobalSize() const; 00165 bool credsGlobalEmpty() const; 00166 00167 CredentialIterator credsUserBegin() const; 00168 CredentialIterator credsUserEnd() const; 00169 CredentialSize credsUserSize() const; 00170 bool credsUserEmpty() const; 00171 00172 class Impl; 00173 private: 00174 RW_pointer<Impl> _pimpl; 00175 }; 00177 00178 00180 } // media 00183 } // zypp 00185 00186 #endif /* ZYPP_MEDIA_CREDENTIALMANAGER_H */ 00187