libzypp: zypp::media::CredentialManager Class Reference

libzypp 17.25.10

Classes | Public Types | Public Member Functions | Private Attributes | List of all members
zypp::media::CredentialManager Class Reference

`#include <CredentialManager.h>`

## Classes
struct | Impl

## Public Types
typedef std::set< AuthData_Ptr, AuthDataComparator > | CredentialSet
typedef CredentialSet::size_type | CredentialSize
typedef CredentialSet::const_iterator | CredentialIterator

## Public Member Functions
| CredentialManager (const CredManagerOptions &opts=CredManagerOptions())
| ~CredentialManager ()
AuthData_Ptr | getCred (const Url &url)
| Get credentials for the specified url. More...
AuthData_Ptr | getCredFromFile (const Pathname &file)
| Read credentials from a file. More...
void | addGlobalCred (const AuthData &cred)
| Add new global credentials. More...
void | addUserCred (const AuthData &cred)
| Add new user credentials. More...
void | addCred (const AuthData &cred)
| Add new credentials with user callbacks. More...
void | save ()
| Saves any unsaved credentials added via addUserCred() or addGlobalCred() methods. More...
void | saveInGlobal (const AuthData &cred)
| Saves given cred to global credentials file. More...
void | saveInUser (const AuthData &cred)
| Saves given cred to user's credentials file. More...
void | saveInFile (const AuthData &, const Pathname &credFile)
| Saves given cred to user specified credentials file. More...
void | clearAll (bool global=false)
| Remove all global or user credentials from memory and disk. More...
CredentialIterator | credsGlobalBegin () const
CredentialIterator | credsGlobalEnd () const
CredentialSize | credsGlobalSize () const
bool | credsGlobalEmpty () const
CredentialIterator | credsUserBegin () const
CredentialIterator | credsUserEnd () const
CredentialSize | credsUserSize () const
bool | credsUserEmpty () const

## Private Attributes
RW_pointer< Impl > | _pimpl

## Detailed Description

Todo:

  better method names

  delete(AuthData) method

Definition at line 62 of file CredentialManager.h.

## Member Typedef Documentation

## ◆ CredentialSet

typedef std::set<AuthData_Ptr, AuthDataComparator> zypp::media::CredentialManager::CredentialSet

Definition at line 65 of file CredentialManager.h.

## ◆ CredentialSize

typedef CredentialSet::size_type zypp::media::CredentialManager::CredentialSize

Definition at line 66 of file CredentialManager.h.

## ◆ CredentialIterator

typedef CredentialSet::const_iterator zypp::media::CredentialManager::CredentialIterator

Definition at line 67 of file CredentialManager.h.

## Constructor & Destructor Documentation

## ◆ CredentialManager()

zypp::media::CredentialManager::CredentialManager | ( | const CredManagerOptions & | opts = `CredManagerOptions()` | ) |

Definition at line 287 of file CredentialManager.cc.

## ◆ ~CredentialManager()

zypp::media::CredentialManager::~CredentialManager | ( |  | ) |
| inline

Definition at line 72 of file CredentialManager.h.

## Member Function Documentation

## ◆ getCred()

AuthData_Ptr zypp::media::CredentialManager::getCred | ( | const Url & | url | ) |

Get credentials for the specified url.

If the URL contains also username, it will be used to find the match for this user (in case mutliple are available).

Parameters

  url | URL to find credentials for.

Returns
  Pointer to retrieved authentication data on success or an empty AuthData_Ptr otherwise.

Todo:
  return a copy instead?

Definition at line 292 of file CredentialManager.cc.

## ◆ getCredFromFile()

AuthData_Ptr zypp::media::CredentialManager::getCredFromFile | ( | const Pathname & | file | ) |

Read credentials from a file.

Definition at line 301 of file CredentialManager.cc.

## ◆ addGlobalCred()

void zypp::media::CredentialManager::addGlobalCred | ( | const AuthData & | cred | ) |

Add new global credentials.

Definition at line 316 of file CredentialManager.cc.

## ◆ addUserCred()

void zypp::media::CredentialManager::addUserCred | ( | const AuthData & | cred | ) |

Add new user credentials.

Definition at line 332 of file CredentialManager.cc.

## ◆ addCred()

void zypp::media::CredentialManager::addCred | ( | const AuthData & | cred | ) |

Add new credentials with user callbacks.

If the cred->url() contains 'credentials' query parameter, the credentials will be automatically saved to the specified file using the saveInFile() method.

Otherwise a callback will be called asking whether to save to custom file, or to global or user's credentials catalog.

Todo:
  Currently no callback is called, credentials are automatically saved to user's credentials.cat if no 'credentials' parameter has been specified

Todo:
  ask user where to store these creds. saving to user creds for now

Definition at line 305 of file CredentialManager.cc.

## ◆ save()

void zypp::media::CredentialManager::save | ( |  | ) |

Saves any unsaved credentials added via addUserCred() or addGlobalCred() methods.

Definition at line 348 of file CredentialManager.cc.

## ◆ saveInGlobal()

void zypp::media::CredentialManager::saveInGlobal | ( | const AuthData & | cred | ) |

Saves given cred to global credentials file.

Note
  Use this method to add just one piece of credentials. To add multiple items at once, use addGlobalCred() followed by save()

Definition at line 359 of file CredentialManager.cc.

## ◆ saveInUser()

void zypp::media::CredentialManager::saveInUser | ( | const AuthData & | cred | ) |

Saves given cred to user's credentials file.

Note
  Use this method to add just one piece of credentials. To add multiple items at once, use addUserCred() followed by save()

Definition at line 366 of file CredentialManager.cc.

## ◆ saveInFile()

void zypp::media::CredentialManager::saveInFile | ( | const AuthData & | cred,
|  | const Pathname & | credFile
| ) |  |

Saves given cred to user specified credentials file.

If the credFile path is absolute, it will be saved at that precise location. If credFile is just a filename, it will be saved in CredManagerOptions::customCredFileDir. Otherwise the current working directory will be prepended to the file path.

Todo:
  figure out the reason(?), call back to user

Definition at line 373 of file CredentialManager.cc.

## ◆ clearAll()

void zypp::media::CredentialManager::clearAll | ( | bool | global = `false` | ) |

Remove all global or user credentials from memory and disk.

Parameters

  global | Whether to remove global or user credentials.

Definition at line 396 of file CredentialManager.cc.

## ◆ credsGlobalBegin()

CredentialManager::CredentialIterator zypp::media::CredentialManager::credsGlobalBegin | ( |  | ) | const

Definition at line 415 of file CredentialManager.cc.

## ◆ credsGlobalEnd()

CredentialManager::CredentialIterator zypp::media::CredentialManager::credsGlobalEnd | ( |  | ) | const

Definition at line 418 of file CredentialManager.cc.

## ◆ credsGlobalSize()

CredentialManager::CredentialSize zypp::media::CredentialManager::credsGlobalSize | ( |  | ) | const

Definition at line 421 of file CredentialManager.cc.

## ◆ credsGlobalEmpty()

bool zypp::media::CredentialManager::credsGlobalEmpty | ( |  | ) | const

Definition at line 424 of file CredentialManager.cc.

## ◆ credsUserBegin()

CredentialManager::CredentialIterator zypp::media::CredentialManager::credsUserBegin | ( |  | ) | const

Definition at line 428 of file CredentialManager.cc.

## ◆ credsUserEnd()

CredentialManager::CredentialIterator zypp::media::CredentialManager::credsUserEnd | ( |  | ) | const

Definition at line 431 of file CredentialManager.cc.

## ◆ credsUserSize()

CredentialManager::CredentialSize zypp::media::CredentialManager::credsUserSize | ( |  | ) | const

Definition at line 434 of file CredentialManager.cc.

## ◆ credsUserEmpty()

bool zypp::media::CredentialManager::credsUserEmpty | ( |  | ) | const

Definition at line 437 of file CredentialManager.cc.

## Member Data Documentation

## ◆ _pimpl

RW_pointer<Impl> zypp::media::CredentialManager::_pimpl
| private

Definition at line 174 of file CredentialManager.h.

The documentation for this class was generated from the following files:

- zypp/media/CredentialManager.h
- zypp/media/CredentialManager.cc