Add LUKS key management to tdehwmanager
parent
e89d9e5e16
commit
9556cd9e69
@ -0,0 +1,115 @@
|
||||
/* This file is part of TDE
|
||||
Copyright (C) 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include <config.h>
|
||||
|
||||
#include <tqradiobutton.h>
|
||||
#include <tqpushbutton.h>
|
||||
#include <tqvalidator.h>
|
||||
#include <tqlineedit.h>
|
||||
#include <tqiconset.h>
|
||||
#include <tqlabel.h>
|
||||
#include <tqtabwidget.h>
|
||||
#include <tqgroupbox.h>
|
||||
#include <tqlayout.h>
|
||||
#include <tqslider.h>
|
||||
#include <tqpainter.h>
|
||||
#include <tqstyle.h>
|
||||
#include <tqfile.h>
|
||||
#include <tqinternal_p.h>
|
||||
#undef Unsorted // Required for --enable-final (tqdir.h)
|
||||
#include <tqfiledialog.h>
|
||||
|
||||
#include <kpassdlg.h>
|
||||
#include <kbuttonbox.h>
|
||||
#include <kcombobox.h>
|
||||
#include <tdelocale.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kurlrequester.h>
|
||||
#include <tdeapplication.h>
|
||||
#include <klineedit.h>
|
||||
#include <kpushbutton.h>
|
||||
#include <kstdguiitem.h>
|
||||
#include <tdemessagebox.h>
|
||||
|
||||
#include "cryptpassworddlg.h"
|
||||
|
||||
CryptPasswordDialog::CryptPasswordDialog(TQWidget *parent, TQString passwordPrompt, TQString caption)
|
||||
: KDialogBase(Plain, ((caption == "")?i18n("Enter Password"):caption), Ok|Cancel, Ok, parent, 0L, true, true)
|
||||
{
|
||||
m_base = new CryptPasswordDialogBase(plainPage());
|
||||
|
||||
TQGridLayout *mainGrid = new TQGridLayout(plainPage(), 1, 1, 0, spacingHint());
|
||||
mainGrid->setRowStretch(1, 1);
|
||||
mainGrid->addWidget(m_base, 0, 0);
|
||||
|
||||
m_base->passwordPrompt->setText(passwordPrompt);
|
||||
m_base->passwordIcon->setPixmap(SmallIcon("password.png"));
|
||||
|
||||
connect(m_base->textPasswordButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts()));
|
||||
connect(m_base->filePasswordButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts()));
|
||||
connect(m_base->textPasswordEntry, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(processLockouts()));
|
||||
connect(m_base->filePasswordURL, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(processLockouts()));
|
||||
|
||||
m_base->textPasswordEntry->setFocus();
|
||||
|
||||
processLockouts();
|
||||
}
|
||||
|
||||
CryptPasswordDialog::~CryptPasswordDialog()
|
||||
{
|
||||
}
|
||||
|
||||
TQByteArray CryptPasswordDialog::password() {
|
||||
if (m_base->textPasswordButton->isOn() == true) {
|
||||
m_password.duplicate(m_base->textPasswordEntry->password(), strlen(m_base->textPasswordEntry->password()));
|
||||
}
|
||||
else {
|
||||
m_password = TQFile(m_base->filePasswordURL->url()).readAll();
|
||||
}
|
||||
|
||||
return m_password;
|
||||
}
|
||||
|
||||
void CryptPasswordDialog::processLockouts() {
|
||||
if (m_base->textPasswordButton->isOn() == true) {
|
||||
m_base->textPasswordEntry->setEnabled(true);
|
||||
m_base->filePasswordURL->setEnabled(false);
|
||||
if (strlen(m_base->textPasswordEntry->password()) > 0) {
|
||||
enableButtonOK(true);
|
||||
}
|
||||
else {
|
||||
enableButtonOK(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_base->textPasswordEntry->setEnabled(false);
|
||||
m_base->filePasswordURL->setEnabled(true);
|
||||
if (TQFile(m_base->filePasswordURL->url()).exists()) {
|
||||
enableButtonOK(true);
|
||||
}
|
||||
else {
|
||||
enableButtonOK(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CryptPasswordDialog::virtual_hook( int id, void* data )
|
||||
{ KDialogBase::virtual_hook( id, data ); }
|
||||
|
||||
#include "cryptpassworddlg.moc"
|
@ -0,0 +1,61 @@
|
||||
/* This file is part of TDE
|
||||
Copyright (C) 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef __cryptpassworddlg_h__
|
||||
#define __cryptpassworddlg_h__
|
||||
|
||||
#include <kdialogbase.h>
|
||||
|
||||
#include "cryptpassworddlgbase.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* Dialog to enter LUKS passwords or password files
|
||||
*
|
||||
* @version 0.1
|
||||
* @author Timothy Pearson <kb9vqf@pearsoncomputing.net>
|
||||
*/
|
||||
|
||||
class TDEUI_EXPORT CryptPasswordDialog : public KDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Create a dialog that allows a user to enter LUKS passwords or password files
|
||||
* @param parent Parent widget
|
||||
*/
|
||||
CryptPasswordDialog(TQWidget *parent, TQString passwordPrompt, TQString caption=TQString::null);
|
||||
virtual ~CryptPasswordDialog();
|
||||
|
||||
TQByteArray password();
|
||||
|
||||
protected:
|
||||
virtual void virtual_hook( int id, void* data );
|
||||
|
||||
private slots:
|
||||
void processLockouts();
|
||||
|
||||
private:
|
||||
CryptPasswordDialogBase* m_base;
|
||||
TQByteArray m_password;
|
||||
|
||||
class CryptPasswordDialogPrivate;
|
||||
CryptPasswordDialogPrivate* d;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,132 @@
|
||||
<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
|
||||
<class>CryptPasswordDialogBase</class>
|
||||
<widget class="TQWidget">
|
||||
<property name="name">
|
||||
<cstring>CryptPasswordDialogBase</cstring>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQLabel" row="0" column="0" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>passwordIcon</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>4</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQLabel" row="0" column="1" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>passwordPrompt</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQGroupBox" row="1" column="0" colspan="2">
|
||||
<property name="name">
|
||||
<cstring>passwordProps</cstring>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Password Source</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="TQButtonGroup" row="0" column="0" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>enabledBox</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>5</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Plain</enum>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string></string>
|
||||
</property>
|
||||
<property name="exclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="radioButtonExclusive">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="TQRadioButton" row="0" column="0" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>textPasswordButton</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Text:</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KPasswordEdit" row="0" column="1" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>textPasswordEntry</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="TQRadioButton" row="1" column="0" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>filePasswordButton</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="KURLRequester" row="1" column="1" colspan="1">
|
||||
<property name="name">
|
||||
<cstring>filePasswordURL</cstring>
|
||||
</property>
|
||||
<property name="filter">
|
||||
<cstring>*</cstring>
|
||||
</property>
|
||||
<property name="mode">
|
||||
<number>17</number>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">CryptPasswordDialogBase.ui.h</include>
|
||||
</includes>
|
||||
<Q_SLOTS>
|
||||
<slot>enableSupport_toggled(bool)</slot>
|
||||
</Q_SLOTS>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">kdialog.h</include>
|
||||
</includes>
|
||||
<layoutdefaults spacing="3" margin="6"/>
|
||||
<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
|
||||
</UI>
|
Loading…
Reference in New Issue