text
stringlengths 0
234
|
|---|
while Node /= null loop
|
if Node.all in EL_Node_Type'Class then
|
E := EL_Node_Type'Class (Node.all)'Access;
|
if E.Value.Get_Expression = Pattern (First .. Pos) then
|
Parent := Node;
|
Node := Node.Children;
|
Found := True;
|
exit;
|
end if;
|
end if;
|
Node := Node.Next_Route;
|
end loop;
|
if not Found then
|
E := new EL_Node_Type;
|
E.Value := EL.Expressions.Create_Expression (Pattern (First .. Pos), ELContext);
|
Insert (Parent, E.all'Access, MAYBE_MATCH);
|
Parent := E.all'Access;
|
end if;
|
Function Definition: procedure Set_Permission_Manager (Filter : in out Auth_Filter;
|
Function Body: Manager : in Policies.Policy_Manager_Access) is
|
begin
|
Filter.Manager := Manager;
|
end Set_Permission_Manager;
|
-- ------------------------------
|
-- Filter the request to make sure the user is authenticated.
|
-- Invokes the <b>Do_Login</b> procedure if there is no user.
|
-- If a permission manager is defined, check that the user has the permission
|
-- to view the page. Invokes the <b>Do_Deny</b> procedure if the permission
|
-- is denied.
|
-- ------------------------------
|
overriding
|
procedure Do_Filter (F : in Auth_Filter;
|
Request : in out Servlet.Requests.Request'Class;
|
Response : in out Servlet.Responses.Response'Class;
|
Chain : in out Servlet.Core.Filter_Chain) is
|
use Ada.Strings.Unbounded;
|
use Policies.URLs;
|
use type Policies.Policy_Manager_Access;
|
Session : Servlet.Sessions.Session;
|
SID : Unbounded_String;
|
AID : Unbounded_String;
|
Auth : Servlet.Principals.Principal_Access;
|
pragma Unreferenced (SID);
|
procedure Fetch_Cookie (Cookie : in Servlet.Cookies.Cookie);
|
-- ------------------------------
|
-- Collect the AID and SID cookies.
|
-- ------------------------------
|
procedure Fetch_Cookie (Cookie : in Servlet.Cookies.Cookie) is
|
Name : constant String := Servlet.Cookies.Get_Name (Cookie);
|
begin
|
if Name = SID_COOKIE then
|
SID := To_Unbounded_String (Servlet.Cookies.Get_Value (Cookie));
|
elsif Name = AID_COOKIE then
|
AID := To_Unbounded_String (Servlet.Cookies.Get_Value (Cookie));
|
end if;
|
end Fetch_Cookie;
|
Context : aliased Contexts.Security_Context;
|
begin
|
Request.Iterate_Cookies (Fetch_Cookie'Access);
|
-- Get a session but avoid creating it.
|
Session := Request.Get_Session (Create => False);
|
if Session.Is_Valid then
|
Auth := Session.Get_Principal;
|
end if;
|
-- If the session does not have a principal, try to authenticate the user with
|
-- the auto-login cookie.
|
if Auth = null and then Length (AID) > 0 then
|
Auth_Filter'Class (F).Authenticate (Request, Response, Session, To_String (AID), Auth);
|
if Auth /= null then
|
-- Now we must make sure we have a valid session and create it if necessary.
|
if not Session.Is_Valid then
|
Session := Request.Get_Session (Create => True);
|
end if;
|
Session.Set_Principal (Auth);
|
end if;
|
end if;
|
-- A permission manager is installed, check that the user can display the page.
|
if F.Manager /= null then
|
if Auth = null then
|
Context.Set_Context (F.Manager, null);
|
else
|
Context.Set_Context (F.Manager, Auth.all'Access);
|
end if;
|
declare
|
Servlet : constant String := Request.Get_Servlet_Path;
|
URL : constant String := Servlet & Request.Get_Path_Info;
|
Perm : constant Policies.URLs.URL_Permission (URL'Length)
|
:= URL_Permission '(Len => URL'Length, URL => URL);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.