File indexing completed on 2024-12-22 04:57:00

0001 /*
0002     SPDX-FileCopyrightText: 2018 Krzysztof Nowicki <krissn@op.pl>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "ewsjob.h"
0010 
0011 #include <QScopedPointer>
0012 #include <QUrl>
0013 
0014 class QNetworkAccessManager;
0015 class QNetworkReply;
0016 
0017 class EwsPKeyAuthJob : public EwsJob
0018 {
0019     Q_OBJECT
0020 public:
0021     explicit EwsPKeyAuthJob(const QUrl &pkeyUri, const QString &certFile, const QString &keyFile, const QString &keyPassword, QObject *parent);
0022     ~EwsPKeyAuthJob() override;
0023 
0024     const QUrl &resultUri() const;
0025     void start() override;
0026 
0027     [[nodiscard]] QString getAuthHeader();
0028 
0029 private:
0030     [[nodiscard]] QByteArray buildAuthResponse(const QMap<QString, QString> &params);
0031     void sendAuthRequest(const QByteArray &respToken, const QUrl &submitUrl, const QString &context);
0032     void authRequestFinished();
0033 
0034     const QUrl mPKeyUri;
0035     const QString mCertFile;
0036     const QString mKeyFile;
0037     const QString mKeyPassword;
0038 
0039     QScopedPointer<QNetworkAccessManager> mNetworkAccessManager;
0040     QScopedPointer<QNetworkReply> mAuthReply;
0041 
0042     QUrl mResultUri;
0043 };