Qt 4.8
Classes | Functions
qnetworkaccessauthenticationmanager.cpp File Reference
#include "qnetworkaccessmanager.h"
#include "qnetworkaccessmanager_p.h"
#include "qnetworkaccessauthenticationmanager_p.h"
#include "QtCore/qbuffer.h"
#include "QtCore/qurl.h"
#include "QtCore/qvector.h"
#include "QtCore/QMutexLocker"
#include "QtNetwork/qauthenticator.h"

Go to the source code of this file.

Classes

class  QNetworkAuthenticationCache
 

Functions

static QByteArray authenticationKey (const QUrl &url, const QString &realm)
 
static QByteArray proxyAuthenticationKey (const QNetworkProxy &proxy, const QString &realm)
 

Function Documentation

◆ authenticationKey()

static QByteArray authenticationKey ( const QUrl url,
const QString realm 
)
inlinestatic

Definition at line 141 of file qnetworkaccessauthenticationmanager.cpp.

Referenced by QNetworkAccessAuthenticationManager::cacheCredentials(), and QNetworkAccessAuthenticationManager::fetchCachedCredentials().

142 {
143  QUrl copy = url;
144  copy.setFragment(realm);
146 }
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
void setFragment(const QString &fragment)
Sets the fragment of the URL to fragment.
Definition: qurl.cpp:5669
QByteArray toEncoded(FormattingOptions options=None) const
Returns the encoded representation of the URL if it's valid; otherwise an empty QByteArray is returne...
Definition: qurl.cpp:5949

◆ proxyAuthenticationKey()

static QByteArray proxyAuthenticationKey ( const QNetworkProxy proxy,
const QString realm 
)
static

Definition at line 102 of file qnetworkaccessauthenticationmanager.cpp.

Referenced by QNetworkAccessAuthenticationManager::cacheProxyCredentials(), and QNetworkAccessAuthenticationManager::fetchCachedProxyCredentials().

103 {
104  QUrl key;
105 
106  switch (proxy.type()) {
108  key.setScheme(QLatin1String("proxy-socks5"));
109  break;
110 
113  key.setScheme(QLatin1String("proxy-http"));
114  break;
115 
117  key.setScheme(QLatin1String("proxy-ftp"));
118  break;
119 
122  // shouldn't happen
123  return QByteArray();
124 
125  // no default:
126  // let there be errors if a new proxy type is added in the future
127  }
128 
129  if (key.scheme().isEmpty())
130  // proxy type not handled
131  return QByteArray();
132 
133  key.setUserName(proxy.user());
134  key.setHost(proxy.hostName());
135  key.setPort(proxy.port());
136  key.setFragment(realm);
137  return "auth:" + key.toEncoded();
138 }
QNetworkProxy::ProxyType type() const
Returns the proxy type for this instance.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
void setHost(const QString &host)
Sets the host of the URL to host.
Definition: qurl.cpp:4821
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setFragment(const QString &fragment)
Sets the fragment of the URL to fragment.
Definition: qurl.cpp:5669
QByteArray toEncoded(FormattingOptions options=None) const
Returns the encoded representation of the URL if it's valid; otherwise an empty QByteArray is returne...
Definition: qurl.cpp:5949
QString scheme() const
Returns the scheme of the URL.
Definition: qurl.cpp:4550
void setPort(int port)
Sets the port of the URL to port.
Definition: qurl.cpp:4897
int key
quint16 port() const
Returns the port of the proxy host.
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
Definition: qurl.cpp:4533
QString user() const
Returns the user name used for authentication.
void setUserName(const QString &userName)
Sets the URL's user name to userName.
Definition: qurl.cpp:4648
QString hostName() const
Returns the host name of the proxy host.