 |  |  |
 |
-- Package which sets the context for the Application
create or replace package body cms_ctx as
-- sets a default context used by login trigger
procedure set_default_ctx is
v_u_id number;
v_g_list varchar2(255);
begin
select u_id into v_u_id from cms_users
where loginName='guest';
v_g_list := '|';
for c in (select g_id from cms_user_group where u_id=v_u_id) loop
v_g_list := v_g_list||to_char(c.g_id)||'|';
end loop;
dbms_session.set_context('cms_context','user_id',v_u_id);
dbms_session.set_context('cms_context','group_list',v_g_list);
end set_default_ctx;
-- sets the user s context
-- Parameters:
-- p_loginName: login name used by the user, this login name is asked by the
-- browser authentication screen
-- This authentication step will be implemented using DBPrism
-- perPackage authentication
-- p_pass: password entered by the user
procedure set_user_ctx(p_loginName varchar2, p_pass varchar2) is
v_u_id number;
v_g_list varchar2(255);
begin
select u_id into v_u_id from cms_users
where loginName=p_loginName and password=p_pass;
v_g_list := '|';
for c in (select g_id from cms_user_group
where u_id=v_u_id) loop
v_g_list := v_g_list||to_char(c.g_id)||'|';
end loop;
-- user_id contains a number id of the user logged in
dbms_session.set_context('cms_context','user_id',v_u_id);
-- group_list is a string representation of the groups ids of the user
-- separated by verticals bars, for example |1|2|
dbms_session.set_context('cms_context','group_list',v_g_list);
end set_user_ctx;
end cms_ctx;
|  |
 |  |  |
|