Skip to content

Commit

Permalink
[auth system] basic, pki paths, pkcs12, and identity certificate plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
dakcarto committed Sep 21, 2015
1 parent 95214e9 commit e13be21
Show file tree
Hide file tree
Showing 26 changed files with 2,813 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ADD_SUBDIRECTORY(core)
ADD_SUBDIRECTORY(analysis)
ADD_SUBDIRECTORY(ui)
ADD_SUBDIRECTORY(gui)
ADD_SUBDIRECTORY(auth)
ADD_SUBDIRECTORY(providers)
ADD_SUBDIRECTORY(crssync)

Expand Down
18 changes: 18 additions & 0 deletions src/auth/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Authentication method plugins
# (similar to how data provider plugin libs are structured and loaded)
# see current auth method plugins for example implementation

# core/auth/QgsAuthMethod.h is the abstract base class for the method
# gui/auth/QgsAuthMethodEdit.h is the abstract base class for the method's edit widget

# override default path where built files are put to allow running qgis without installing
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR})
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR})

# NOTE: the plugin's file name must follow this pattern to be found during auth method registry loading:
# (.*)authmethod\.(so|dll)

ADD_SUBDIRECTORY(basic)
ADD_SUBDIRECTORY(identcert)
ADD_SUBDIRECTORY(pkipaths)
ADD_SUBDIRECTORY(pkipkcs12)
40 changes: 40 additions & 0 deletions src/auth/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
SET(AUTH_BASIC_SRCS
qgsauthbasicmethod.cpp
qgsauthbasicedit.cpp
)

SET(AUTH_BASIC_HDRS
qgsauthbasicmethod.h
qgsauthbasicedit.h
)

SET(AUTH_BASIC_MOC_HDRS
qgsauthbasicmethod.h
qgsauthbasicedit.h
)

SET(AUTH_BASIC_UIS qgsauthbasicedit.ui)

INCLUDE_DIRECTORIES (
../../core
../../core/auth
${QCA_INCLUDE_DIR}
../../gui
../../gui/auth
${CMAKE_CURRENT_BINARY_DIR}
)

QT4_WRAP_UI (AUTH_BASIC_UIS_H ${AUTH_BASIC_UIS})

QT4_WRAP_CPP(AUTH_BASIC_MOC_SRCS ${AUTH_BASIC_MOC_HDRS})

ADD_LIBRARY (basicauthmethod MODULE ${AUTH_BASIC_SRCS} ${AUTH_BASIC_HDRS} ${AUTH_BASIC_MOC_SRCS} ${AUTH_BASIC_UIS_H})

TARGET_LINK_LIBRARIES (basicauthmethod
qgis_core
qgis_gui
)

INSTALL(TARGETS basicauthmethod
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
87 changes: 87 additions & 0 deletions src/auth/basic/qgsauthbasicedit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/***************************************************************************
qgsauthbasicedit.cpp
---------------------
begin : September 1, 2015
copyright : (C) 2015 by Boundless Spatial, Inc. USA
author : Larry Shaffer
email : lshaffer at boundlessgeo dot 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsauthbasicedit.h"
#include "ui_qgsauthbasicedit.h"


QgsAuthBasicEdit::QgsAuthBasicEdit( QWidget *parent )
: QgsAuthMethodEdit( parent )
, mValid( 0 )
{
setupUi( this );
}

QgsAuthBasicEdit::~QgsAuthBasicEdit()
{
}

bool QgsAuthBasicEdit::validateConfig()
{
bool curvalid = !leUsername->text().isEmpty();
if ( mValid != curvalid )
{
mValid = curvalid;
emit validityChanged( curvalid );
}
return curvalid;
}

QgsStringMap QgsAuthBasicEdit::configMap() const
{
QgsStringMap config;
config.insert( "username", leUsername->text() );
config.insert( "password", lePassword->text() );
config.insert( "realm", leRealm->text() );

return config;
}

void QgsAuthBasicEdit::loadConfig( const QgsStringMap &configmap )
{
clearConfig();

mConfigMap = configmap;
leUsername->setText( configmap.value( "username" ) );
lePassword->setText( configmap.value( "password" ) );
leRealm->setText( configmap.value( "realm" ) );

validateConfig();
}

void QgsAuthBasicEdit::resetConfig()
{
loadConfig( mConfigMap );
}

void QgsAuthBasicEdit::clearConfig()
{
leUsername->clear();
lePassword->clear();
leRealm->clear();
chkPasswordShow->setChecked( false );
}

void QgsAuthBasicEdit::on_leUsername_textChanged( const QString &txt )
{
Q_UNUSED( txt );
validateConfig();
}

void QgsAuthBasicEdit::on_chkPasswordShow_stateChanged( int state )
{
lePassword->setEchoMode(( state > 0 ) ? QLineEdit::Normal : QLineEdit::Password );
}
56 changes: 56 additions & 0 deletions src/auth/basic/qgsauthbasicedit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/***************************************************************************
qgsauthbasicedit.h
---------------------
begin : September 1, 2015
copyright : (C) 2015 by Boundless Spatial, Inc. USA
author : Larry Shaffer
email : lshaffer at boundlessgeo dot 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSAUTHBASICEDIT_H
#define QGSAUTHBASICEDIT_H

#include <QWidget>
#include "qgsauthmethodedit.h"
#include "ui_qgsauthbasicedit.h"

#include "qgsauthconfig.h"


class GUI_EXPORT QgsAuthBasicEdit : public QgsAuthMethodEdit, private Ui::QgsAuthBasicEdit
{
Q_OBJECT

public:
explicit QgsAuthBasicEdit( QWidget *parent = 0 );
virtual ~QgsAuthBasicEdit();

bool validateConfig() override;

QgsStringMap configMap() const override;

public slots:
void loadConfig( const QgsStringMap &configmap ) override;

void resetConfig() override;

void clearConfig() override;

private slots:
void on_leUsername_textChanged( const QString& txt );

void on_chkPasswordShow_stateChanged( int state );

private:
QgsStringMap mConfigMap;
bool mValid;
};

#endif // QGSAUTHBASICEDIT_H
117 changes: 117 additions & 0 deletions src/auth/basic/qgsauthbasicedit.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsAuthBasicEdit</class>
<widget class="QWidget" name="QgsAuthBasicEdit">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item row="2" column="1">
<widget class="QLineEdit" name="leRealm">
<property name="placeholderText">
<string>Optional</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leUsername">
<property name="placeholderText">
<string>Required</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lblRealm">
<property name="text">
<string>Realm</string>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>173</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QLineEdit" name="lePassword">
<property name="text">
<string/>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="placeholderText">
<string>Optional</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkPasswordShow">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Show</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblUsername">
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lblPassword">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>leUsername</tabstop>
<tabstop>lePassword</tabstop>
<tabstop>leRealm</tabstop>
<tabstop>chkPasswordShow</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
Loading

0 comments on commit e13be21

Please sign in to comment.