[Home] [Help]
PACKAGE BODY: APPS.AMW_SECURITY_UTILS_PVT
Source
1 PACKAGE BODY AMW_SECURITY_UTILS_PVT AS
2 /*$Header: amwsutlb.pls 120.0 2005/05/31 21:07:54 appldev noship $*/
3
4
5 procedure give_dependant_grants (p_grant_guid IN raw,
6 p_parent_obj_name in varchar2,
7 p_parent_role in varchar2,
8 p_parent_pk1 in varchar2,
9 p_parent_pk2 in varchar2,
10 p_parent_pk3 in varchar2,
11 p_parent_pk4 in varchar2,
12 p_parent_pk5 in varchar2,
13 p_grantee_type in varchar2,
14 p_grantee_key in varchar2,
15 p_start_date in date,
16 p_end_date in date,
17 x_success OUT NOCOPY VARCHAR, /* Boolean */
18 x_errorcode OUT NOCOPY NUMBER)
19 is
20
21
22 l_api_name constant varchar2(30) := 'give_dependant_grants';
23
24
25
26 l_grant_guid fnd_grants.grant_guid%type;
27
28
29
30 l_default_name constant varchar2(80) := 'AMW_AUTOMATIC_DEPENDANT_GRANT';
31 l_default_description constant varchar2(240) := 'Dependant instance set based grant on child object';
32
33 cursor c is (select parent_role_name, child_obj_name,
34 child_role_name, child_instance_set_id
35 from amw_security_role_mappings where parent_obj_name = p_parent_obj_name
36 and (parent_role_name = p_parent_role or parent_role_name = 'ANY'));
37
38
39 type t_c is table of c%rowtype;
40 t_ctbl t_c;
41
42 l_start_date date;
43 l_child_role_name amw_security_role_mappings.child_role_name%type;
44
45
46 begin
47
48
49 if p_start_date is null
50 then l_start_date := sysdate;
51 else l_start_date := p_start_date;
52 end if;
53
54
55 open c;
56 fetch c bulk collect into t_ctbl;
57 close c;
58
59 if t_ctbl.exists(1) then
60 for ctr in t_ctbl.first .. t_ctbl.last loop
61 if (t_ctbl(ctr).parent_role_name = 'ANY' and t_ctbl(ctr).child_role_name = 'SAME')
62 then
63 l_child_role_name := p_parent_role;
64 else
65 l_child_role_name := t_ctbl(ctr).child_role_name;
66 end if;
67
68
69 fnd_grants_pkg.grant_function(p_api_version => g_api_version,
70 p_menu_name => l_child_role_name,
71 p_object_name => t_ctbl(ctr).child_obj_name,
72 p_instance_type => 'SET',
73 p_instance_set_id => t_ctbl(ctr).child_instance_set_id,
74 p_grantee_type => p_grantee_type,
75 p_grantee_key => p_grantee_key,
76 p_start_date => l_start_date,
77 p_end_date => p_end_date,
78 p_parameter1 => p_parent_pk1,
79 p_parameter2 => p_parent_pk2,
80 p_parameter3 => p_parent_pk3,
81 p_parameter4 => p_parent_pk4,
82 p_parameter5 => p_parent_pk5,
83 p_parameter10 => p_grant_guid, --store a pointer to parent grant
84 p_name => l_default_name,
85 p_description => l_default_description,
86 x_success => x_success, /* Boolean */
87 x_errorcode => x_errorcode,
88 x_grant_guid => l_grant_guid);
89
90
91
92
93
94
95
96
97 end loop;
98 end if;
99
100 exception
101 when OTHERS then
102
103 x_success := FND_API.G_FALSE ;
104 x_errorcode:=-1;
105
106
107 end give_dependant_grants;
108
109 procedure update_dependant_grants(p_grant_guid in raw,
110 p_new_start_date in date,
111 p_new_end_date in date,
112 x_success OUT NOCOPY VARCHAR /* Boolean */)
113 is
114 l_api_name constant varchar2(30) := 'update_dependant_grants';
115
116
117
118
119 l_start_date date;
120
121
122
123 l_grant_guid fnd_grants.grant_guid%type;
124 type t_guid is table of fnd_grants.grant_guid%type;
125 guid_tbl t_guid;
126
127 cursor c_guid
128 is select grant_guid from fnd_grants where
129 parameter10 = p_grant_guid;
130
131
132
133 begin
134
135
136 if p_new_start_date is null
137 then l_start_date := sysdate;
138 else l_start_date := p_new_start_date;
139 end if;
140
141
142
143
144
145 open c_guid;
146 fetch c_guid bulk collect into guid_tbl;
147 close c_guid;
148
149 if guid_tbl.exists(1) then
150 for i in guid_tbl.first .. guid_tbl.last loop
151
152
153 fnd_grants_pkg.update_grant(p_api_version => g_api_version,
154 p_grant_guid => guid_tbl(i),
155 p_start_date => l_start_date,
156 p_end_date => p_new_end_date,
157 x_success => x_success);
158
159 end loop;
160 end if;
161
162
163 exception
164 when OTHERS then
165 x_success := FND_API.G_FALSE ;
166
167 end update_dependant_grants;
168
169 procedure revoke_dependant_grants(p_grant_guid in raw,
170 x_success OUT NOCOPY VARCHAR2, /* Boolean */
171 x_errorcode OUT NOCOPY NUMBER)
172 is
173 l_api_name constant varchar2(30) := 'revoke_dependant_grants';
174
175
176 l_grant_guid fnd_grants.grant_guid%type;
177 type t_guid is table of fnd_grants.grant_guid%type;
178 guid_tbl t_guid;
179
180 cursor c_guid
181 is select grant_guid from fnd_grants where
182 parameter10 = p_grant_guid;
183
184
185 begin
186
187 open c_guid;
188 fetch c_guid bulk collect into guid_tbl;
189 close c_guid;
190
191 if guid_tbl.exists(1) then
192 for i in guid_tbl.first .. guid_tbl.last loop
193
194
195 fnd_grants_pkg.revoke_grant(p_api_version => g_api_version,
196 p_grant_guid => guid_tbl(i),
197 x_success => x_success,
198 x_errorcode => x_errorcode);
199
200 end loop;
201 end if;
202
203
204 exception
205 when OTHERS then
206 x_success := FND_API.G_FALSE ;
207 x_errorcode := -1;
208 end revoke_dependant_grants;
209
210 FUNCTION get_party_id return number
211
212 is
213
214 l_party_id number;
215
216 begin
217 select party_id into l_party_id
218 from amw_employees_current_v
219 where employee_id = (select employee_id from fnd_user where user_name = FND_GLOBAL.user_name)
220 and rownum = 1;
221
222 return l_party_id;
223
224 exception
225 when others then
226 return null;
227
228
229 end get_party_id;
230
231
232 FUNCTION check_function
233 (
234 p_function IN VARCHAR2,
235 p_object_name IN VARCHAR2,
236 p_instance_pk1_value IN VARCHAR2,
237 p_instance_pk2_value IN VARCHAR2,
238 p_instance_pk3_value IN VARCHAR2,
239 p_instance_pk4_value IN VARCHAR2,
240 p_instance_pk5_value IN VARCHAR2
241 )
242 RETURN VARCHAR2 IS
243
244 l_data_security_switch varchar2(1);
245 l_user_name varchar2(80);
246 l_party_id number;
247
248 BEGIN
249
250 if (fnd_global.user_name is null) then
251 raise FND_API.G_EXC_UNEXPECTED_ERROR;
252 end if;
253
254 l_data_security_switch := fnd_profile.value('AMW_DATA_SECURITY_SWITCH');
255
256
257 if(l_data_security_switch is null or l_data_security_switch = 'N') then
258 return 'T';
259 else
260 l_party_id := get_party_id;
261
262 if(l_party_id is null) then
263 l_user_name := FND_GLOBAL.user_name;
264 else
265 l_user_name := 'HZ_PARTY:' || l_party_id;
266 end if;
267
268 return FND_DATA_SECURITY.check_function( p_api_version => g_api_version
269 ,p_function => p_function
270 ,p_object_name => p_object_name
271 ,p_instance_pk1_value => p_instance_pk1_value
272 ,p_instance_pk2_value => p_instance_pk2_value
273 ,p_instance_pk3_value => p_instance_pk3_value
274 ,p_instance_pk4_value => p_instance_pk4_value
275 ,p_instance_pk5_value => p_instance_pk5_value
276 ,p_user_name => l_user_name);
277 end if;
278
279 exception
280 when others then
281 raise FND_API.G_EXC_UNEXPECTED_ERROR;
282
283 END;
284
285
286 end AMW_SECURITY_UTILS_PVT;