text
stringlengths
0
234
end Start;
-- ------------------------------
-- Stop the event manager.
-- ------------------------------
procedure Stop (Manager : in out Event_Manager) is
use type AWA.Events.Dispatchers.Dispatcher_Access;
begin
Log.Info ("Stopping the event manager");
-- Stop the dispatchers.
for I in Manager.Dispatchers'Range loop
exit when Manager.Dispatchers (I) = null;
Manager.Dispatchers (I).Stop;
end loop;
end Stop;
-- ------------------------------
-- Get the application associated with the event manager.
-- ------------------------------
function Get_Application (Manager : in Event_Manager) return Application_Access is
begin
return Manager.Application;
end Get_Application;
-- ------------------------------
-- Finalize the queue dispatcher releasing the dispatcher memory.
-- ------------------------------
procedure Finalize (Object : in out Queue_Dispatcher) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => AWA.Events.Dispatchers.Dispatcher'Class,
Name => AWA.Events.Dispatchers.Dispatcher_Access);
begin
Free (Object.Dispatcher);
end Finalize;
-- ------------------------------
-- Finalize the event queues and the dispatchers.
-- ------------------------------
procedure Finalize (Object : in out Event_Queues) is
begin
loop
declare
Pos : constant Queue_Dispatcher_Lists.Cursor := Object.Queues.First;
begin
exit when not Queue_Dispatcher_Lists.Has_Element (Pos);
Object.Queues.Update_Element (Position => Pos,
Process => Finalize'Access);
Object.Queues.Delete_First;
Function Definition: function Has_Permission (Handler : in Entity_Controller;
Function Body: Context : in Security.Contexts.Security_Context'Class;
Permission : in Security.Permissions.Permission'Class)
return Boolean is
use AWA.Permissions.Services;
use AWA.Users.Principals;
use type ADO.Identifier;
use type ADO.Entity_Type;
Manager : constant Permission_Manager_Access := Get_Permission_Manager (Context);
User_Id : constant ADO.Identifier := Get_User_Identifier (Context.Get_User_Principal);
Entity_Id : ADO.Identifier;
begin
-- If there is no permission manager, permission is denied.
if Manager = null or else User_Id = ADO.NO_IDENTIFIER then
return False;
end if;
-- If the user is not logged, permission is denied.
if Manager = null or else User_Id = ADO.NO_IDENTIFIER then
Log.Info ("No user identifier in the security context. Permission is denied");
return False;
end if;
if not (Permission in Entity_Permission'Class) then
Log.Info ("Permission {0} denied because the entity is not given.",
Security.Permissions.Permission_Index'Image (Permission.Id));
return False;
end if;
Entity_Id := Entity_Permission'Class (Permission).Entity;
-- If the security context does not contain the entity identifier, permission is denied.
if Entity_Id = ADO.NO_IDENTIFIER then
Log.Info ("No entity identifier in the security context. Permission is denied");
return False;
end if;
declare
function Get_Session return ADO.Sessions.Session;
-- ------------------------------
-- Get a database session from the AWA application.
-- There is no guarantee that a AWA.Services.Contexts be available.
-- But if we are within a service context, we must use the current session so
-- that we are part of the current transaction.
-- ------------------------------
function Get_Session return ADO.Sessions.Session is
package ASC renames AWA.Services.Contexts;
use type ASC.Service_Context_Access;