mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-23 17:34:17 +03:00
deed329102
* Centered on parent all forms (by code) * Some minor corrections
143 lines
5.7 KiB
C#
143 lines
5.7 KiB
C#
//
|
|
// Copyright (c) 2012 Virtual Cable S.L.
|
|
// All rights reserved.
|
|
//
|
|
// Redistribution and use in source and binary forms, with or without modification,
|
|
// are permitted provided that the following conditions are met:
|
|
//
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
// this list of conditions and the following disclaimer.
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
// and/or other materials provided with the distribution.
|
|
// * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
|
// may be used to endorse or promote products derived from this software
|
|
// without specific prior written permission.
|
|
//
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
// author: Adolfo Gómez, dkmaster at dkmon dot com
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace UdsAdmin.forms
|
|
{
|
|
public partial class AuthenticatorForm : Form
|
|
{
|
|
string _id;
|
|
xmlrpc.GuiField[] _flds;
|
|
xmlrpc.GuiFieldValue[] _fldValues;
|
|
string _authenticatorName;
|
|
string _authenticatorType;
|
|
|
|
public AuthenticatorForm(string providerName, string providerType, Icon icon)
|
|
{
|
|
InitializeComponent();
|
|
_fldValues = null;
|
|
_id = null;
|
|
_flds = null;
|
|
_authenticatorName = providerName;
|
|
_authenticatorType = providerType;
|
|
Icon = icon;
|
|
Text = Strings.titleAuthenticator;
|
|
}
|
|
|
|
public void setData(string name, string comments, string id, xmlrpc.GuiFieldValue[] data)
|
|
{
|
|
this.name.Text = name;
|
|
this.comments.Text = comments;
|
|
this._id = id;
|
|
this.priority.Value = Convert.ToInt32(xmlrpc.GuiFieldValue.getData(data, "priority"));
|
|
_fldValues = data;
|
|
}
|
|
|
|
private void Authenticator_Load(object sender, EventArgs e)
|
|
{
|
|
_flds = xmlrpc.UdsAdminService.GetAuthenticatorGui(_authenticatorType);
|
|
Size sz = gui.DinamycFieldsManager.PutFields(dataPanel, _flds, _fldValues);
|
|
groupData.Size = new Size(sz.Width, 32 + sz.Height);
|
|
Size wSize = new Size();
|
|
wSize.Width = Size.Width;
|
|
int w = groupData.Location.X + groupData.Size.Width + 48;
|
|
if (wSize.Width < w)
|
|
wSize.Width = w;
|
|
wSize.Height = groupData.Location.Y + tableLayoutPanel1.Size.Height + groupData.Size.Height + 48;
|
|
Size = MinimumSize = MaximumSize = wSize;
|
|
|
|
if (_flds.Length == 0)
|
|
groupData.Visible = false;
|
|
Text = _authenticatorName;
|
|
|
|
this.Location = MainForm.centerLocation(this);
|
|
//this.Location = System.Windows.Forms.Cursor.Position;
|
|
}
|
|
|
|
private void accept_Click(object sender, EventArgs e)
|
|
{
|
|
if (name.Text.Trim().Length == 0)
|
|
{
|
|
gui.UserNotifier.notifyError(Strings.nameRequired);
|
|
return;
|
|
}
|
|
xmlrpc.GuiFieldValue[] data;
|
|
try {
|
|
data = gui.DinamycFieldsManager.ReadFields(dataPanel, _flds);
|
|
}
|
|
catch (gui.DinamycFieldsManager.ValidationError err)
|
|
{
|
|
gui.UserNotifier.notifyValidationException(err);
|
|
return;
|
|
}
|
|
|
|
try {
|
|
if (_id == null)
|
|
xmlrpc.UdsAdminService.CreateAuthenticator(name.Text, comments.Text, _authenticatorType, Convert.ToInt32(priority.Value), data);
|
|
else
|
|
{
|
|
xmlrpc.UdsAdminService.ModifyAuthenticator(name.Text, comments.Text, Convert.ToInt32(priority.Value), _id, data);
|
|
}
|
|
DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
}
|
|
catch (CookComputing.XmlRpc.XmlRpcFaultException ex)
|
|
{
|
|
gui.UserNotifier.notifyRpcException(ex);
|
|
}
|
|
|
|
}
|
|
|
|
private void test_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
xmlrpc.GuiFieldValue[] data = gui.DinamycFieldsManager.ReadFields(dataPanel, _flds);
|
|
xmlrpc.ResultTest res = xmlrpc.UdsAdminService.TestAuthenticator(_authenticatorType, data);
|
|
gui.UserNotifier.notifyTestResult(res);
|
|
}
|
|
catch (CookComputing.XmlRpc.XmlRpcFaultException ex)
|
|
{
|
|
gui.UserNotifier.notifyRpcException(ex);
|
|
}
|
|
catch (gui.DinamycFieldsManager.ValidationError ex)
|
|
{
|
|
gui.UserNotifier.notifyValidationException(ex);
|
|
}
|
|
}
|
|
}
|
|
}
|