KDEUI
qosxkeychain.cpp
Go to the documentation of this file.
127 static OSStatus basicWriteItem( const QByteArray *serviceName, const QByteArray &accountName, const QByteArray &value,
153 kDebug() << "Retrieved reference to default keychain" << (void*) keyChainRef << "in " << keyChainPath;
178 kWarning() << "Error opening keychain '" << n << "' (falling back to default keychain): " << qPrintable(errMsg);
188 kDebug() << "Retrieved reference to keychain" << name << (void*) keyChainRef << "in " << keyChainPath;
217 SecKeychainAttribute attr[] = { { kSecAccountItemAttr, accountName.size(), (void*) accountName.constData() },
221 if( isError( (err = SecKeychainItemModifyAttributesAndData( itemRef, &attrList, 0, NULL )), &errMsg ) ){
222 kWarning() << "OSXKeychain::renameItem(" << currentKey << ") couldn't change name & label to" << accountName
253 if( SecKeychainGetPath( (keychain)? keychain : OSXKeychain().reference(), &plen, pathName ) == errSecSuccess ){
267 kDebug() << "Could not get the status of keychain" << OSXKeychain::Path(keychain) << ":" << qPrintable(errMsg);
301 kDebug() << "Could not unlock the keychain at '" << OSXKeychain::Path(keychain) << "': " << qPrintable(errMsg);
316 kDebug() << "Could not lock the keychain at '" << OSXKeychain::Path(keychain) << "': " << qPrintable(errMsg);
348 SecKeychainAttribute attrs = { kSecAccountItemAttr, accountName.size(), (void*) accountName.constData() };
359 kDebug() << "OSXKeychain::HasItem(" << key << "," << (void*) keychain << "): SecKeychainSearchCreateFromAttributes failed";
380 kDebug() << ((found)? "Found" : "Did not find") << "item '" << key << "' in keychain " << (void*) keychain << ", error=" << err << " " << qPrintable(errMsg);
395 kDebug() << "Error" << err << "retrieving password for '" << accountName << "' :" << qPrintable(errMsg);
439 kDebug() << "OSXKeychain::ReadItem '" << key << "' from keychain " << OSXKeychain::Path(keychain) << ", error=" << err;
456 kDebug() << "Error" << err << "retrieving type for '" << accountName << "' :" << qPrintable(errMsg);
487 kDebug() << "Error: key" << key << "item type retrieved is of size" << attrList->attr[0].length << "!=" << sizeof(EntryType);
502 kDebug() << "OSXKeychain::ItemType '" << key << "' from keychain " << OSXKeychain::Path(keychain) << "=" << OSTStr(etype) << ", error=" << err;
526 const SecKeychainRef keychain, SecKeychainItemRef *itemRef, EntryType *entryType, OSXKeychain *osxKeyChain )
534 // save the "GenericPassword" item using the service name, which appears to be the only way to write
537 // the service (folder!) string will also appear on the "Name" field, which however can be changed
546 // RJVB: the previous implementation was wrong. errSecDuplicateItem means the write failed because of an existing item.
561 SecKeychainAttribute attr = { kSecLabelItemAttr, accountName.size(), (void*) accountName.constData() };
564 if( isError( (err = SecKeychainItemModifyAttributesAndData( theItem, &attrList, 0, NULL )), &errMsg ) ){
565 kWarning() << "OSXKeychain::WriteItem(" << key << ") couldn't set the desired name/label" << accountName
577 if( isError( (err = SecKeychainItemModifyAttributesAndData( theItem, &attrList, 0, NULL )), &errMsg ) ){
578 kWarning() << "OSXKeychain::WriteItem(" << key << ") couldn't set type to" << OSTStr(*entryType)
588 kDebug() << "OSXKeychain::WriteItem '" << key << "' to keychain " << (void*) keychain << ", error=" << err;
593 const QString &comment, const SecKeychainRef keychain, EntryType *entryType, OSXKeychain *osxKeyChain )
599 SecKeychainAttribute attr = { kSecCommentItemAttr, commentString.size(), (void*) commentString.constData() };
602 if( isError( (err = SecKeychainItemModifyAttributesAndData( itemRef, &attrList, 0, NULL )), &errMsg ) ){
613 OSStatus OSXKeychain::ItemList( SecKeychainRef keychain, QStringList &keyList, OSXKeychain *osxKeyChain )
616 bool generateFolderList = ( osxKeyChain && osxKeyChain->isKDEChain && osxKeyChain->generateFolderList );
626 err = SecKeychainSearchCreateFromAttributes( keychain, kSecGenericPasswordItemClass, NULL, &searchRef[0] );
628 if( SecKeychainSearchCreateFromAttributes( keychain, kSecInternetPasswordItemClass, NULL, &searchRef[1] ) ){
637 kDebug() << "OSXKeychain::ItemList(" << (void*) keychain << "): SecKeychainSearchCreateFromAttributes failed" << qPrintable(errMsg);
657 // appear in each folder that has a non-empty name. In other words, we allow a folder without name.
void clear()
QString fromAscii(const char *str, int size)
static OSStatus RemoveItem(const QString &key, const SecKeychainRef keychain)
Definition: qosxkeychain.cpp:506
static OSStatus Destroy(SecKeychainRef *keychain)
Definition: qosxkeychain.cpp:700
static OSStatus basicWriteItem(const QByteArray *serviceName, const QByteArray &accountName, const QByteArray &value, const SecKeychainRef keychain, SecKeychainItemRef *itemRef=NULL)
Definition: qosxkeychain.cpp:127
Definition: qosxkeychain.h:98
int size() const
static bool HasItem(const QString &key, const SecKeychainRef keychain, OSStatus *errReturn, SecKeychainItemRef *itemRef)
use the keychain search functions to find the first matching item, if any, returning True if found...
Definition: qosxkeychain.cpp:343
bool contains(const QString &str, Qt::CaseSensitivity cs) const
Definition: qosxkeychain.h:98
const char * name(StandardAction id)
This will return the internal name of a given standard action.
Definition: kstandardaction.cpp:223
static OSStatus openKeychain(const QString &n, SecKeychainRef *keychain)
Definition: qosxkeychain.cpp:91
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
OSStatus renameItem(const QString ¤tKey, const QString &newKey)
Definition: qosxkeychain.cpp:210
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
void clear()
void append(const T &value)
QString fromUtf8(const char *str, int size)
static OSStatus UnLock(const SecKeychainRef keychain)
Definition: qosxkeychain.cpp:295
static OSStatus Lock(const SecKeychainRef keychain)
Definition: qosxkeychain.cpp:310
static bool IsOpen(const SecKeychainRef keychain)
Definition: qosxkeychain.cpp:261
QString fileName() const
static QString keyChainName(SecKeychainRef keychain, QString *path=NULL)
Definition: qosxkeychain.cpp:74
Definition: qosxkeychain.h:90
static OSStatus WriteItem(const QString &key, const QByteArray &value, const SecKeychainRef keychain, SecKeychainItemRef *itemRef=NULL, EntryType *entryType=NULL, OSXKeychain *osxKeyChain=NULL)
Definition: qosxkeychain.cpp:525
static OSStatus ItemType(const QString &key, EntryType *entryType, const SecKeychainRef keychain)
Definition: qosxkeychain.cpp:443
const char * constData() const
static OSStatus KeychainList(QStringList &theList)
Definition: qosxkeychain.cpp:232
static OSStatus ItemList(const SecKeychainRef keychain, QStringList &keyList, OSXKeychain *osxKeyChain=NULL)
Definition: qosxkeychain.cpp:613
static OSStatus ReadItem(const QString &key, QByteArray *value, const SecKeychainRef keychain, SecKeychainItemRef *itemRef=NULL, OSXKeychain *osxKeyChain=NULL)
Definition: qosxkeychain.cpp:384
int length() const
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QString left(int n) const
int size() const
QByteArray toUtf8() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.