2016-06-22 17:49:16 +02:00
|
|
|
|
// ***************************************************************************
|
|
|
|
|
//
|
|
|
|
|
// Delphi MVC Framework
|
|
|
|
|
//
|
2023-01-17 08:52:26 +01:00
|
|
|
|
// Copyright (c) 2010-2023 Daniele Teti and the DMVCFramework Team
|
2016-06-22 17:49:16 +02:00
|
|
|
|
//
|
|
|
|
|
// https://github.com/danieleteti/delphimvcframework
|
|
|
|
|
//
|
2017-03-23 18:51:25 +01:00
|
|
|
|
// Collaborators with this file: Ezequiel Juliano M<>ller (ezequieljuliano@gmail.com)
|
|
|
|
|
//
|
2016-06-22 17:49:16 +02:00
|
|
|
|
// ***************************************************************************
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
//
|
|
|
|
|
// ***************************************************************************
|
2016-06-16 22:18:18 +02:00
|
|
|
|
|
2015-06-15 18:57:46 +02:00
|
|
|
|
unit MVCFramework.Server;
|
|
|
|
|
|
2017-03-23 18:51:25 +01:00
|
|
|
|
{$I dmvcframework.inc}
|
|
|
|
|
|
2015-06-15 18:57:46 +02:00
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
System.SysUtils,
|
2016-06-16 22:13:35 +02:00
|
|
|
|
System.Classes,
|
2015-06-15 18:57:46 +02:00
|
|
|
|
System.Generics.Collections,
|
2018-12-09 23:03:06 +01:00
|
|
|
|
MVCFramework.Commons, MVCFramework;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
2015-12-22 12:17:37 +01:00
|
|
|
|
EMVCServerException = class(Exception);
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
IMVCListenerProperties = interface
|
|
|
|
|
['{82721C88-A308-4B2E-B94A-8E7CEEC4721F}']
|
|
|
|
|
function GetName: string;
|
|
|
|
|
function SetName(const AValue: string): IMVCListenerProperties;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
function GetPort: Integer;
|
|
|
|
|
function SetPort(AValue: Integer): IMVCListenerProperties;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
function GetMaxConnections: Integer;
|
|
|
|
|
function SetMaxConnections(AValue: Integer): IMVCListenerProperties;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
function GetWebModuleClass: TComponentClass;
|
|
|
|
|
function SetWebModuleClass(AValue: TComponentClass): IMVCListenerProperties;
|
2019-12-19 10:39:13 +01:00
|
|
|
|
|
|
|
|
|
function GetSSLOptions(out SSLCertFile, SSLRootCertFile, SSLKeyFile, SSLPassword: String): Boolean;
|
|
|
|
|
function SetSSLOptions(const SSLCertFile, SSLRootCertFile, SSLKeyFile, SSLPassword: String): IMVCListenerProperties;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
end;
|
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
IMVCListener = interface
|
|
|
|
|
['{127A5E5D-D968-4409-BE9A-8D3AE08E6009}']
|
|
|
|
|
function GetActive: Boolean;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
procedure Start;
|
|
|
|
|
procedure Stop;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2015-12-22 12:17:37 +01:00
|
|
|
|
property Active: Boolean read GetActive;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
end;
|
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
IMVCListenersContext = interface
|
|
|
|
|
['{9EA6BBDB-B5C1-462E-BBF4-AA30A4317F54}']
|
|
|
|
|
function Add(const AName: string; AListener: IMVCListener): IMVCListenersContext; overload;
|
|
|
|
|
function Add(AProperties: IMVCListenerProperties): IMVCListenersContext; overload;
|
|
|
|
|
function Remove(const AListenerName: string): IMVCListenersContext;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
procedure StartAll;
|
|
|
|
|
procedure StopAll;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
function FindByName(const AListenerName: string): IMVCListener;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
procedure ForEach(AProc: TProc<string, IMVCListener>);
|
|
|
|
|
function Count: Integer;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
end;
|
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
TMVCRequestDelegate = reference to procedure(const AControllerQualifiedClassName, AActionName: string;
|
|
|
|
|
var AAuthenticationRequired: Boolean);
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
TMVCAuthenticationDelegate = reference to procedure(const AUserName, APassword: string; AUserRoles: TList<string>;
|
|
|
|
|
var IsValid: Boolean; const ASessionData: TDictionary<String, String>);
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
TMVCAuthorizationDelegate = reference to procedure(AUserRoles: TList<string>; const AControllerQualifiedClassName: string;
|
|
|
|
|
const AActionName: string; var IsAuthorized: Boolean);
|
2015-06-15 18:57:46 +02:00
|
|
|
|
|
2016-06-16 22:13:35 +02:00
|
|
|
|
IMVCDefaultAuthenticationHandler = interface(IMVCAuthenticationHandler)
|
|
|
|
|
['{0B292EEF-B871-4FA9-81AC-FED633C3A238}']
|
|
|
|
|
function SetOnRequest(AMethod: TMVCRequestDelegate): IMVCDefaultAuthenticationHandler;
|
|
|
|
|
function SetOnAuthentication(AMethod: TMVCAuthenticationDelegate): IMVCDefaultAuthenticationHandler;
|
|
|
|
|
function SetOnAuthorization(AMethod: TMVCAuthorizationDelegate): IMVCDefaultAuthenticationHandler;
|
2015-06-15 18:57:46 +02:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
end.
|