nextcloud-desktop/src/creds/abstractcredentials.cpp
Daniel Molkentin ccb45bfea6 Move code from HTTPCredentials to more generic locations
This is a preparation to make them usable from the Shibboleth
credentials class.
2014-02-06 13:02:01 +01:00

42 lines
1.1 KiB
C++

/*
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include <QString>
#include <QDebug>
#include "creds/abstractcredentials.h"
namespace Mirall
{
QString AbstractCredentials::keychainKey(const QString &url, const QString &user)
{
QString u(url);
if( u.isEmpty() ) {
qDebug() << "Empty url in keyChain, error!";
return QString::null;
}
if( user.isEmpty() ) {
qDebug() << "Error: User is emty!";
return QString::null;
}
if( !u.endsWith(QChar('/')) ) {
u.append(QChar('/'));
}
QString key = user+QLatin1Char(':')+u;
return key;
}
} // ns Mirall