EBS MO_GLOBAL包的分析

概述

整个MOAC流程的核心都是在MO_GLOBAL中完成的,包括对mo_glob_org_access_tmp记录的插入,访问模式的设置,默认OU的获取,对VPD的支持(提供ORG_SECURITY验证方法),在该节将会对这些概念进行理解,在此基础上对MO_global pakage进行分析。

访问模式(Access Mode)

在MOAC的实现中,采用Access Mode来控制当前是Mutil org还是Single org。常见的有三种模式:

简称全称说明
SSingle单OU模式
MMutil多OU模式
AAll预留将来使用
X阻止从同义词返回任何数据

值的产生逻辑:
访问模式值生成逻辑是在mo_global.set_org_access中实现的,它有三个参数

参数说明
p_org_id_charThe operating unit ID for the current session
p_sp_id_charThe security profile id for the current session
p_appl_short_nameApplication owner for the current module or session
PROCEDURE set_org_access(p_org_id_char     VARCHAR2,
p_sp_id_char      VARCHAR2,
p_appl_short_name VARCHAR2)

该方法中调用了populate_orgs和set_org_context方法,其中populate_orgs的作用和逻辑在EBS mo_glob_org_access_tmp表的分析 中已经阐述,但该方法中需要使用到populate_orgs中设置的一些全局变量和一些返回值。set_org_context方法主要是对Access Mode进行付值。

该方法的伪代码:

<1> IF 当前的数据库实例不是multi-org数据库实例 THEN
RETURN;
END IF;
<2> IF “MO: Security Profile”预制文件和”MO: Operating Unit”预制文件都没有设置 THEN
抛出异常
<3> ELSIF 应用简称为空 THEN
抛出异常
END IF;
<4> 获取当前应用是否支持Mutil-org的标示

SELECT nvl(mpi.status, 'N')
INTO l_access_ctrl_enabled
FROM fnd_mo_product_init mpi
WHERE mpi.application_short_name = p_appl_short_name; 

<5> 删除表mo_glob_org_access_tmp中的数据
delete_orgs;
<6> IF 支持Mutil-org THEN
<6.1> IF 当前环境设置了安全性配置文件 THEN
“MO: Operating Unit”值被覆盖;
END IF;
<6.2> opulate_orgs(l_org_id,
l_security_profile_id,
l_current_org_id,
l_view_all_orgs);
判断当前是否有多个OU
<6.3> F OU个数为0 THEN
RAISE NO_ORG_ACCESS_FOUND;
<6.4> ELSIF OU个数为1 THEN
设置Access MODE为’S’,且org_id为当前唯一的org_id
set_policy_context(‘S’, l_current_org_id);
<6.5> ELSE OU个数>1 THEN
<6.5.1> IF 访问所有OU标示= ‘Y’ THEN
设置Access MODE为’A’
set_policy_context(‘A’,”);
<6.5.2>ELSE
设置Access MODE为’M’
set_policy_context(‘M’,”);
END IF;
END IF;
<7>ELSE 当前应用不支持多OU
<7.1> IF 已经设置了”MO: Operating Unit”预制文件 THEN

<7.1.1> populate_orgs(l_org_id,
null,
l_current_org_id,
l_view_all_orgs);
<7.2> 设置Access MODE为’S’,且org_id为预制文件的Org_id
set_policy_context(‘S’,l_org_id);
END IF;
END IF;
<8> commit;

在该方法中共产生了三种访问模式,但这些访问模式是怎样赋值和被VPD所使用的呢?这就需要另一个知识点 Application context……

应用程序上下文(Application context)的理解

介绍:应用程序上下文,其实就是个环境变量,在SESSION的生命周期内有效。oracle官方的资料如下:
Application context can be useful for the following purposes:
1.Enforcing fine-grained access control
2.Preserving user identity across multitier environments
3.Serving as a secure data cache for attributes needed by an application for fine-grained auditing or for use in PL/SQL conditional statements or loops
This cache saves the repeated overhead of querying the database each time such attributes are needed.
4.Serving as a holding area for attribute-value pairs that an application can define, modify, and access
Three types of application context are defined, differentiated by where the context data is stored and by how updates can be done:
1.Secure session-based application contexts, for which data is stored in the database user session (UGA) in a namespace specified by an SQL command (CREATE CONTEXT).
2.The client session-based application context, using only the CLIENTCONTEXT namespace, updatable by any OCI client or by the existing DBMS_SESSION API for application context. No privilege or package security check is done.
3.Nonsession-based (global) application contexts, for which data is stored in the shared area (SGA).

创建语法:

CREATE CONTEXT cux_context_name USING apps.cux_vpd_global

cux_context_name 是应用程序上下文的名称(namespace)
apps.cux_vpd_global是可以对这个namespace进行变量的创建和删除的package
相关DB对象:
dba_context,sys.context c,sys.obj

在MOAC中的使用:
在MOAC中我们是用的是第二种类型的client session-based应用上下文
赋值:使用DBMS_SESSION.set_context方法操作

procedure set_context(namespace varchar2, 
attribute varchar2, value varchar2,
username varchar2 default null, 
client_id varchar2 default null);
参数说明
namespaceName of the namespace to use for the application context
attributeName of the attribute to be set
valueValue to be set

Eg:dbms_session.set_context(‘multi_org’, ‘access_mode’, p_access_mode);
取值:使用sys_context(namespace, attribute)
Eg:sys_context(‘multi_org2’,’current_org_id’)
为了获取在MO_GLOBAL中使用的context,可以根据定义使用语句:

SELECT *
  FROM dba_context dc
 WHERE package = 'MO_GLOBAL'

这里写图片描述

在MO_GLOBAL中对这两个值的使用在mo_global.set_policy_context方法中
**multi_org的access_mode属性存放的是当前的访问模式.
multi_org2的current_org_id属性存放的是当前的org_id.**

两参数的信息:

参数类型说明
multi_orgaccess_modeS=Single, M=Multiple, A=All, X=None
multi_org2current_org_idOperating unit org id, only applicable if access mode is Single

其中access_mode和current_org_id的值在mo_global.set_org_access方法中已经获取到了,但access_mode=’A’或’M’时current_org_id为空,否则current_org_id值为当前的唯一Org_id;经过上面一系列的讨论,可以得到mo_global.set_policy_context的付值是多OU产生阶段的最后一个步骤,接下来我们解析一下这个逻辑,

mo_global.set_policy_context伪代码
1 IF 当前的access_mode和org_id未发生改变 THEN
返回(状态没有变,不需要设置);
2 ELSIF 参数access_mode=’S’ THEN
2.1 IF 当前的access_mode为空 or 当前的access_mode<>’S’ THEN
-设置access_mode Context的值
dbms_session.set_context(‘multi_org’, ‘access_mode’, p_access_mode);
g_access_mode := p_access_mode;
END IF;
2.2 IF (当前的org_id为空 or 当前的org_id<>参数org_id or
上下文中的org_id <> 参数org_id – Bug4916086
OR 上下文中的org_id为空) THEN
设置current_org_id context的值
dbms_session.set_context(‘multi_org2’, ‘current_org_id’, p_org_id);
g_current_org_id := p_org_id;
END IF;

3 ELSIF (参数access_mode = ‘M’) THEN
3.1 IF 当前的access_mode为空 or 当前的access_mode<>’M’ THEN
–设置access_mode Context的值
dbms_session.set_context(‘multi_org’, ‘access_mode’, p_access_mode);
g_access_mode := p_access_mode;
END IF;
3.2 IF (当前的org_id不为空 ) THEN
将current_org_id Context的值清空
dbms_session.set_context(‘multi_org2’, ‘current_org_id’, ”);
g_current_org_id := NULL;
END IF;

4 ELSIF (参数access_mode = ‘A’) and g_init_access_mode = ‘A’ THEN
4.1 IF 当前的access_mode为空 or 当前的access_mode<>’A’ THEN
-设置access_mode Context的值
dbms_session.set_context(‘multi_org’, ‘access_mode’, p_access_mode);
g_access_mode := p_access_mode;
END IF;
4.2 IF (当前的org_id不为空 ) THEN
将current_org_id Context的值清空
dbms_session.set_context(‘multi_org2’, ‘current_org_id’, ”);
g_current_org_id := NULL;
END IF;

5 ELSIF (参数access_mode in (‘X’,’B’)) THEN
5.2 IF 上下文中的org_id is not null then
将current_org_id Context的值清空
dbms_session.set_context(‘multi_org2’, ‘current_org_id’, ”);
end if;
设置access_mode CONTEXT的值
dbms_session.set_context(‘multi_org’, ‘access_mode’, p_access_mode);
g_current_org_id := NULL;
g_access_mode := p_access_mode;

6 ELSIF (参数access_mode为空) THEN
6.1 IF (g_access_mode IS NOT NULL) THEN
设置access_mode CONTEXT的值
dbms_session.set_context(‘multi_org’, ‘access_mode’, p_access_mode);
g_access_mode := p_access_mode;
END IF;
6.2 IF (当前org_id不为空) THEN
将current_org_id Context的值清空
dbms_session.set_context(‘multi_org2’, ‘current_org_id’, ”);
g_current_org_id := NULL;
END IF;
END IF;

7 获取当前用户和职责的信息,用以验证MO设置是否完成

g_old_user_id:=sys_context('FND','USER_ID');
  g_old_resp_id:=sys_context('FND','RESP_ID');

mo_global 流程理解

到了这一步,我们已经分别将值放到了mo_glob_org_access_tmp和context中,但是系统是怎么实现这个功能的呢?它的出发点在什么地方呢,在oracle ETRM上查询引用在这个包的数据库对象,有706个,真正使用mo_global.init的入口包是哪个,我不能确定,但我们只要理解它从mo_global.init这个口进入后的流程也就能理解了MOAC的Org_id安全机制了。
mo_global主要流程图
¬—— by mingwei.liu on 2012/6/13 注释:下图中po_glob_org_access_tmp应为mo_glob_org_access_tmp。
这里写图片描述
该流程图展示了系统设置Organization Security Policy的整个流程,通过该流程,系统将MO的Org_id放入session 临时表mo_glob_org_access_tmp表中,将Access mode值存储到Application context multi_orgaccess_mode attribute中,将当前默认的org_id存入到Application context multi_org2current_org_idattribute中,我们可以在程序中使用
sys_context(‘multi_org2’,’current_org_id’) 获取当前的org_id,使用sys_context(‘multi_org’, ‘access_mode’)获取当前的访问模式。
这两个值是我们多OU访问判断的关键,在VPD中会阐述怎么使用这两个值进行多OU的安全性策略控制。

总结

在这一节中讨论到MO_GLOBAL包在生成MO的OU信息,同时理解了Access mode 和application context这两个概念,但我们只是涉及到了对MO的设置,并没有解决同义词没有值的问题,我们也知道了需要使用我们设置的Access mode 和application context,但系统到底是怎使用的呢?在使用这两个值的过程中需要引入新的概念VPD…
详见:EBS VPD介绍和使用实例

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值