Initial Commit
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
main.o
|
||||
.qmake.stash
|
||||
RSA-VDI
|
||||
24
.vscode/c_cpp_properties.json
vendored
Normal file
24
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"/usr/include/qt",
|
||||
"/usr/include/qt/QtWidgets",
|
||||
"/usr/include/qt/QtGui",
|
||||
"/usr/include/qt/QtCore",
|
||||
"/usr/lib/qt/mkspecs/linux-g++",
|
||||
"/usr/include/KF5/KSyntaxHighlighting",
|
||||
"/usr/include/KF5/KWallet"
|
||||
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "c++14",
|
||||
"intelliSenseMode": "linux-clang-x64"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
84
.vscode/settings.json
vendored
Normal file
84
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"*.COBOL*": "cobol",
|
||||
"*.COB*": "cobol",
|
||||
"*.COBCOPY*": "cobol",
|
||||
"*.COPYBOOK*": "cobol",
|
||||
"*.COPY*": "cobol",
|
||||
"*.PL1*": "pl1",
|
||||
"*.PLI*": "pl1",
|
||||
"*.INC*": "pl1",
|
||||
"*.INCLUDE*": "pl1",
|
||||
"*.JCL*": "jcl",
|
||||
"*.ASM*": "hlasm",
|
||||
"*.ASSEMBLE*": "hlasm",
|
||||
"*.HLASM*": "hlasm",
|
||||
"*.HLA*": "hlasm",
|
||||
"qapplication": "cpp",
|
||||
"iostream": "cpp",
|
||||
"ostream": "cpp",
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"hash_map": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"chrono": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"ranges": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"valarray": "cpp",
|
||||
"variant": "cpp"
|
||||
}
|
||||
}
|
||||
21
RSA-VDI.pro
Normal file
21
RSA-VDI.pro
Normal file
@ -0,0 +1,21 @@
|
||||
######################################################################
|
||||
# Automatically generated by qmake (3.1) Mon Feb 22 13:07:54 2021
|
||||
######################################################################
|
||||
|
||||
TEMPLATE = app
|
||||
TARGET = RSA-VDI
|
||||
INCLUDEPATH += .
|
||||
|
||||
# You can make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# Please consult the documentation of the deprecated API in order to know
|
||||
# how to port your code away from it.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
QT += core widgets KSyntaxHighlighting
|
||||
LIBS += -lKF5Wallet
|
||||
# Input
|
||||
HEADERS += main.h
|
||||
SOURCES += main.cpp
|
||||
169
main.cpp
Normal file
169
main.cpp
Normal file
@ -0,0 +1,169 @@
|
||||
#include "main.h"
|
||||
|
||||
|
||||
// Main sets up the Application/GUI, and tries to retrieveLogin()
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication app(argc,argv);
|
||||
QWidget *window = new QWidget;
|
||||
|
||||
|
||||
domainLE = new QLineEdit;
|
||||
tokenUsername = new QLineEdit;
|
||||
tokenCode = new QLineEdit;
|
||||
ntUsername = new QLineEdit;
|
||||
ntPassword = new QLineEdit;
|
||||
authSystemLE = new QLineEdit;
|
||||
rememberCredentials = new QCheckBox;
|
||||
vboxLayout = new QVBoxLayout;
|
||||
vdiLoginLayout = new QFormLayout;
|
||||
|
||||
domainLE->setPlaceholderText("Horizon Domain");
|
||||
tokenUsername->setPlaceholderText("Email address");
|
||||
tokenUsername->setMinimumWidth(250);
|
||||
tokenCode->setPlaceholderText("RSA Token code");
|
||||
ntUsername->setPlaceholderText("Windows username");
|
||||
ntPassword->setPlaceholderText("Windows password");
|
||||
ntPassword->setEchoMode(QLineEdit::Password);
|
||||
QPushButton loginBtn("Log In");
|
||||
loginBtn.setToolTip("Click here to log in using the data entered.");
|
||||
authSystemLE->setPlaceholderText("Optional Auth System");
|
||||
// Try to populate form before adding to the layout
|
||||
retrieveLogin();
|
||||
|
||||
vdiLoginLayout->addRow("Domain: ", domainLE);
|
||||
vdiLoginLayout->addRow("Token Username:", tokenUsername);
|
||||
vdiLoginLayout->addRow("RSA Token:", tokenCode);
|
||||
vdiLoginLayout->addRow("NT Username:", ntUsername);
|
||||
vdiLoginLayout->addRow("NT Password:", ntPassword);
|
||||
vdiLoginLayout->addRow("Auth System:", authSystemLE);
|
||||
vdiLoginLayout->addRow("Remember Credentials:", rememberCredentials);
|
||||
|
||||
vboxLayout->addItem(vdiLoginLayout);
|
||||
vboxLayout->addWidget(&loginBtn);
|
||||
|
||||
QObject::connect(&loginBtn, &QPushButton::released, tryLogin);
|
||||
|
||||
|
||||
window->setLayout(vboxLayout);
|
||||
window->show();
|
||||
return app.exec();
|
||||
|
||||
}
|
||||
|
||||
// walletOpen() returns a pointer to the kwallet, or throws an error if the wallet is unable to open.
|
||||
KWallet::Wallet* walletOpen() {
|
||||
KWallet::Wallet *wallet = KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Synchronous);
|
||||
if (wallet->hasFolder(KWallet::Wallet::FormDataFolder())) {
|
||||
if (!wallet->setFolder(KWallet::Wallet::FormDataFolder())) {
|
||||
std::cout << "Wallet folder could not be set." << std::endl;
|
||||
throw -1;
|
||||
}
|
||||
} else {
|
||||
std::cout << "Wallet did not have folder, creating." << std::endl;
|
||||
if(wallet->createFolder(KWallet::Wallet::FormDataFolder())) {
|
||||
if (!wallet->setFolder(KWallet::Wallet::FormDataFolder())) {
|
||||
std::cout << "Wallet folder could not be set." << std::endl;
|
||||
throw -1;
|
||||
}
|
||||
} else {
|
||||
std::cout << "Could not create folder." << std::endl;
|
||||
throw -1;
|
||||
}
|
||||
}
|
||||
return wallet;
|
||||
}
|
||||
|
||||
// retrieve login information from kwallet using walletOpen() or die
|
||||
void retrieveLogin() {
|
||||
try {
|
||||
wallet = walletOpen();
|
||||
} catch (int e) {
|
||||
exit(-1);
|
||||
}
|
||||
QMap<QString, QString> map;
|
||||
if (wallet->readMap("http://rsa-vdi.nightmare.haus/#authInfo", map) == 0) {
|
||||
domainLE->setText(map[QString("domain")]);
|
||||
tokenUsername->setText(map[QString("tokenUsername")]);
|
||||
ntUsername->setText(map[QString("ntUsername")]);
|
||||
ntPassword->setText(map[QString("ntPassword")]);
|
||||
authSystemLE->setText(map[QString("authSystem")]);
|
||||
if (tokenUsername->text().length() > 0) {
|
||||
rememberCredentials->setChecked(true);
|
||||
}
|
||||
} else {
|
||||
std::cout << "Error loading from wallet, is it populated?" << std::endl;
|
||||
}
|
||||
}
|
||||
// save login information to kwallet using walletOpen() or die
|
||||
void saveLogin() {
|
||||
try {
|
||||
wallet = walletOpen();
|
||||
} catch (int e) {
|
||||
exit(-1);
|
||||
}
|
||||
QMap<QString, QString> map;
|
||||
map[QString("domain")] = domainLE->text();
|
||||
map[QString("tokenUsername")] = tokenUsername->text();
|
||||
map[QString("ntUsername")] = ntUsername->text();
|
||||
map[QString("ntPassword")] = ntPassword->text();
|
||||
map[QString("authSystem")] = authSystemLE->text();
|
||||
|
||||
if (!wallet->writeMap("http://rsa-vdi.nightmare.haus/#authInfo", map)) {
|
||||
std::cout << "Error writing to Wallet!" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void tryLogin() {
|
||||
if (rememberCredentials->isChecked()) {
|
||||
saveLogin();
|
||||
}
|
||||
if(debug) {
|
||||
std::cout << "tryLogin()" << std::endl;
|
||||
std::cout << "\tToken Username: " << tokenUsername->text().toStdString() << std::endl;
|
||||
std::cout << "\tToken Code: " << tokenCode->text().toStdString() << std::endl;
|
||||
std::cout << "\tntUsername: " << ntUsername->text().toStdString() << std::endl;
|
||||
std::cout << "\tntPassword Length: " << ntPassword->text().length() << std::endl;
|
||||
std::cout << "\tAuth System: " << authSystemLE->text().toStdString() << std::endl;
|
||||
if (rememberCredentials->isChecked()) {
|
||||
std::cout << "\tRemember creds: true" << std::endl;
|
||||
} else {
|
||||
std::cout << "\tRemember creds: false" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -q, --nonInteractive Connect automatically if enough values are given on the command line.
|
||||
QString command = "vmware-view -q";
|
||||
if (domainLE->text().length() > 0) {
|
||||
// -s, --serverURL=<broker URL> Specify connection broker.
|
||||
command += " -s \'" + domainLE->text() + "\'";
|
||||
}
|
||||
if (authSystemLE->text().length() > 0) {
|
||||
// -d, --domainName=<domain name> Specify domain for password authentication
|
||||
command += " -d \'" + authSystemLE->text() + "\'";
|
||||
}
|
||||
if (tokenUsername->text().length() > 0) {
|
||||
// -t, --tokenUserName=<token user name> Specify user name for RSA or Radius authentication.
|
||||
command += " -t \'" + tokenUsername->text() + "\'";
|
||||
}
|
||||
if (tokenCode->text().length() > 0 ) {
|
||||
// -c, --passcode=<passcode> Specify passcode for RSA or Radius authentication.
|
||||
command += " -c \'" + tokenCode->text() + "\'";
|
||||
}
|
||||
if (ntUsername->text().length() > 0) {
|
||||
// -u, --userName=<user name> Specify user name for password authentication.
|
||||
command += " -u \'" + ntUsername->text() + "\'";
|
||||
}
|
||||
if (ntPassword->text().length() > 0) {
|
||||
//-p, --password=<password> Specify password for password authentication.
|
||||
command += " -p \'" + ntPassword->text() + "\'";
|
||||
}
|
||||
if (debug) {
|
||||
std::cout << command.toStdString() << std::endl;
|
||||
} else {
|
||||
system(command.toStdString().c_str());
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
33
main.h
Normal file
33
main.h
Normal file
@ -0,0 +1,33 @@
|
||||
#include <QApplication>
|
||||
#include <QFormLayout>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QSpinBox>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QStringList>
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <unistd.h>
|
||||
#include <kwallet.h>
|
||||
|
||||
QLineEdit *domainLE;
|
||||
QLineEdit *tokenUsername;
|
||||
QLineEdit *tokenCode;
|
||||
QLineEdit *ntUsername;
|
||||
QLineEdit *ntPassword;
|
||||
QLineEdit *authSystemLE;
|
||||
QCheckBox *rememberCredentials;
|
||||
QVBoxLayout *vboxLayout;
|
||||
QFormLayout *vdiLoginLayout;
|
||||
KWallet::Wallet *wallet;
|
||||
|
||||
bool debug = false;
|
||||
|
||||
|
||||
|
||||
KWallet::Wallet* walletOpen();
|
||||
void saveLogin();
|
||||
void retrieveLogin();
|
||||
void tryLogin();
|
||||
Reference in New Issue
Block a user