CredentialManager.h

Go to the documentation of this file.
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     static const url::ViewOption vopt;
00052     bool operator()(const AuthData_Ptr & lhs, const AuthData_Ptr & rhs);
00053   };
00054 
00056   //
00057   // CLASS NAME : CredentialManager
00058   //
00063   class CredentialManager
00064   {
00065   public:
00066     typedef std::set<AuthData_Ptr, AuthDataComparator> CredentialSet;
00067     typedef CredentialSet::size_type                   CredentialSize;
00068     typedef CredentialSet::const_iterator              CredentialIterator;
00069 
00070 
00071     CredentialManager(const CredManagerOptions & opts = CredManagerOptions());
00072 
00073     ~CredentialManager()
00074     {}
00075 
00076   public:
00088     AuthData_Ptr getCred(const Url & url);
00089 
00093     AuthData_Ptr getCredFromFile(const Pathname & file);
00094 
00098     void addGlobalCred(const AuthData & cred);
00099 
00103     void addUserCred(const AuthData & cred);
00104 
00119     void addCred(const AuthData & cred);
00120 
00125     void save();
00126 
00134     void saveInGlobal(const AuthData & cred);
00135 
00143     void saveInUser(const AuthData & cred);
00144 
00153     void saveInFile(const AuthData &, const Pathname & credFile);
00154 
00160     void clearAll(bool global = false);
00161 
00162 
00163     CredentialIterator credsGlobalBegin() const;
00164     CredentialIterator credsGlobalEnd()   const;
00165     CredentialSize     credsGlobalSize()  const;
00166     bool               credsGlobalEmpty() const;
00167 
00168     CredentialIterator credsUserBegin() const;
00169     CredentialIterator credsUserEnd()   const;
00170     CredentialSize     credsUserSize()  const;
00171     bool               credsUserEmpty() const;
00172 
00173     class Impl;
00174   private:
00175     RW_pointer<Impl> _pimpl;
00176   };
00178 
00179 
00181   } // media
00184 } // zypp
00186 
00187 #endif /* ZYPP_MEDIA_CREDENTIALMANAGER_H */
00188 

doxygen