[Home] [Help]
PACKAGE BODY: APPS.POS_ANON_PKG
Source
1 PACKAGE BODY pos_anon_pkg AS
2 /* $Header: POSANONB.pls 120.0 2005/06/01 17:34:16 appldev noship $ */
3
4 g_log_module_name VARCHAR2(30) := 'pos.plsql.POSANONB';
5
6 FUNCTION make_anonymous_login(p_registration_key IN VARCHAR2,
7 x_session_id OUT NOCOPY NUMBER,
8 x_transaction_id OUT NOCOPY NUMBER)
9 RETURN VARCHAR2
10 IS
11 l_validate BOOLEAN;
12 l_url VARCHAR2(4000);
13 l_dbc VARCHAR2(240);
14 l_language_code VARCHAR2(30);
15 l_region VARCHAR2(30);
16 l_access_key VARCHAR2(2000);
17 l_admin_mode VARCHAR2(2000);
18 BEGIN
19 l_region := 'My Region';
20 IF NOT icx_sec.validateSession(c_validate_only => 'Y')
21 THEN
22 x_session_id := icx_sec.createSession(
23 p_user_id => 6,
24 c_mode_code => '115X');
25 l_validate := icx_sec.validateSessionPrivate(
26 c_session_id => x_session_id,
27 c_validate_only => 'Y');
28 -- owa_util.mime_header('text/html',FALSE);
29 -- icx_sec.sendsessioncookie(l_session_id);
30
31 x_transaction_id := icx_sec.createTransaction(
32 p_session_id => x_session_id,
33 p_resp_appl_id => 178,
34 p_responsibility_id => 20873,
35 p_security_group_id => 0);
36
37 icx_sec.updateSessionContext(
38 p_application_id =>178,
39 p_responsibility_id =>20873,
40 p_security_group_id => 0,
41 p_session_id => x_session_id,
42 p_transaction_id => x_transaction_id);
43 ELSE
44
45 BEGIN
46
47 SELECT max(transaction_id)
48 INTO x_transaction_id
49 FROM icx_transactions
50 WHERE session_id = icx_sec.g_session_id
51 AND responsibility_id = icx_sec.g_responsibility_id
52 AND security_group_id = icx_sec.g_security_group_id
53 AND function_id = icx_sec.g_function_id
54 GROUP BY transaction_id;
55
56 EXCEPTION
57 WHEN NO_DATA_FOUND THEN
58
59 SELECT icx_transactions_s.nextval
60 INTO x_transaction_id
61 FROM dual;
62
63 END;
64 END IF;
65
66 l_url := fnd_web_config.trail_slash(fnd_profile.value('APPS_FRAMEWORK_AGENT'));
67 fnd_profile.get(
68 name => 'APPS_DATABASE_ID',
69 val => l_dbc);
70
71 IF l_dbc IS null
72 THEN
73 l_dbc := FND_WEB_CONFIG.DATABASE_ID;
74 END IF;
75
76 l_url := l_url || 'OA_HTML/OA.jsp?page=/oracle/apps/pos/registration/webui/UsrRegMainPG' ||
77 '&'||'akRegionApplicationId=177'||'&'||'dbc=' || l_dbc ||
78 '&'||'transaction_id=' || x_transaction_id ||
79 '&'||'registrationKey=' || p_registration_key;
80
81 return l_url;
82 END make_anonymous_login;
83
84 -- Check to see if the POS_SUPPLIER_GUEST_USER responsibility has the right value
85 -- of APPS_FRAMEWORK_AGENT profile_option. If not, set it based on external url.
86 PROCEDURE check_guest_resp_fwk_agent IS
87 CURSOR l_hier_cur IS
88 SELECT resp_enabled_flag,
89 hierarchy_type
90 FROM fnd_profile_options
91 WHERE profile_option_name = 'APPS_FRAMEWORK_AGENT'
92 AND Nvl(start_date_active, Sysdate) <= Sysdate
93 AND Nvl(end_date_active, sysdate) >= sysdate;
94
95 l_hier_rec l_hier_cur%ROWTYPE;
96
97 CURSOR l_resp_cur IS
98 SELECT responsibility_id, application_id
99 FROM fnd_responsibility
100 WHERE responsibility_key = 'POS_SUPPLIER_GUEST_USER'
101 AND application_id =
102 (SELECT application_id FROM fnd_application WHERE application_short_name = 'POS');
103
104 l_resp_rec l_resp_cur%ROWTYPE;
105
106 l_value fnd_profile_option_values.profile_option_value%TYPE;
107
108 l_result BOOLEAN;
109
110 BEGIN
111
112 OPEN l_hier_cur;
113 FETCH l_hier_cur INTO l_hier_rec;
114 IF l_hier_cur%notfound THEN
115 CLOSE l_hier_cur;
116 RETURN; -- something is wrong, but we do nothing
117 END IF;
118 CLOSE l_hier_cur;
119
120 -- dbms_output.put_line('resp enable ' || l_hier_rec.resp_enabled_flag );
121 -- dbms_output.put_line('hier type ' || l_hier_rec.hierarchy_type );
122
123 IF l_hier_rec.resp_enabled_flag = 'Y' AND
124 l_hier_rec.hierarchy_type = 'SECURITY' THEN
125
126 OPEN l_resp_cur;
127 FETCH l_resp_cur INTO l_resp_rec;
128 IF l_resp_cur%notfound THEN
129 CLOSE l_resp_cur;
130 RETURN; -- unlikely to happen
131 END IF;
132 CLOSE l_resp_cur;
133
134 l_value := pos_url_pkg.get_external_url;
135
136 --dbms_output.put_line('value ' || l_value);
137
138 IF l_value IS NULL OR
139 l_value = fnd_profile.value_specific
140 (name => 'APPS_FRAMEWORK_AGENT',
141 user_id => NULL,
142 responsibility_id => l_resp_rec.responsibility_id,
143 application_id => l_resp_rec.application_id,
144 org_id => NULL,
145 server_id => NULL
146 ) THEN
147 NULL;
148 ELSE
149 -- dbms_output.put_line('setting');
150 l_result := fnd_profile.save
151 (x_name => 'APPS_FRAMEWORK_AGENT',
152 x_value => l_value,
153 x_level_name => 'RESP',
154 x_level_value => l_resp_rec.responsibility_id,
155 x_level_value_app_id => l_resp_rec.application_id
156 );
157 END IF;
158
159 END IF;
160 END check_guest_resp_fwk_agent;
161
162 PROCEDURE confirm_has_resp(
163 p_responsibility_key IN VARCHAR2)
164 IS
165 l_assignment_exists BOOLEAN;
166 l_app_id NUMBER;
167 l_resp_id NUMBER;
168 l_start_date DATE;
169 l_end_date DATE;
170 l_found_in_view BOOLEAN;
171 l_user_name FND_USER.USER_NAME%TYPE;
172 lv_proc_name VARCHAR2(30) := 'confirm_has_resp';
173
174 CURSOR l_user_cur
175 IS
176 SELECT user_name
177 FROM FND_USER
178 WHERE user_id = 6
179 AND start_date < sysdate
180 AND (end_date IS NULL OR end_date > sysdate);
181
182 CURSOR l_resp_cur
183 IS
184 SELECT application_id, responsibility_id
185 FROM FND_RESPONSIBILITY
186 WHERE responsibility_key = p_responsibility_key
187 AND start_date < sysdate
188 AND (end_date IS NULL OR end_date > sysdate);
189
190 CURSOR l_assignment_cur
191 IS
192 SELECT end_date, start_date
193 FROM FND_USER_RESP_GROUPS_DIRECT
194 WHERE user_id = 6
195 AND responsibility_id = l_resp_id;
196
197 BEGIN
198
199 OPEN l_user_cur;
200 FETCH l_user_cur INTO l_user_name;
201 IF l_user_cur%NOTFOUND THEN
202 -- the user has been end-dated
203 CLOSE l_user_cur;
204 IF ( fnd_log.level_exception >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
205 fnd_log.string(fnd_log.level_exception, g_log_module_name || '.' || lv_proc_name, 'GUEST user has been end-dated');
206 END IF;
207 RETURN;
208 END IF;
209 CLOSE l_user_cur;
210
211 OPEN l_resp_cur;
212 FETCH l_resp_cur INTO l_app_id, l_resp_id;
213 IF l_resp_cur%NOTFOUND THEN
214 -- there is no such responsibility or the responsibility has been
215 -- end-dated. do not assign the responsibility in this case
216 -- should have end-dated the assignment too. but presumably, there is
217 -- no such assignment (because Form prevents the assignment...)
218 CLOSE l_resp_cur;
219 IF ( fnd_log.level_exception >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
220 fnd_log.string(fnd_log.level_exception, g_log_module_name || '.' || lv_proc_name, 'guest responsibility has been end-dated');
221 END IF;
222 RETURN;
223 END IF;
224 CLOSE l_resp_cur;
225
226 l_assignment_exists :=
227 fnd_user_resp_groups_api.assignment_exists
228 (user_id => 6,
229 responsibility_id => l_resp_id,
230 responsibility_application_id => l_app_id,
231 security_group_id => 0
232 );
233
234 IF l_assignment_exists = FALSE THEN
235 FND_USER_RESP_GROUPS_API.insert_assignment
236 ( user_id => 6,
237 responsibility_id => l_resp_id,
238 responsibility_application_id => l_app_id,
239 security_group_id => 0,
240 start_date => sysdate,
241 end_date => NULL,
242 description => p_responsibility_key);
243 --RETURN;
244 ELSE
245 -- assignment already exists here
246 OPEN l_assignment_cur;
247 FETCH l_assignment_cur INTO l_end_date, l_start_date;
248 l_found_in_view := l_assignment_cur%found;
249 CLOSE l_assignment_cur;
250
251 IF NOT (l_found_in_view AND
252 (l_end_date IS NULL OR l_end_date > Sysdate) AND
253 (l_start_date IS NULL OR l_start_date <= Sysdate)) THEN
254
255 IF l_start_date IS NULL OR l_start_date > Sysdate THEN
256 l_start_date := Sysdate;
257 END IF;
258
259 -- assignment exists here but it is not active now
260 -- due to start date or end_date
261 fnd_user_resp_groups_api.update_assignment
262 ( user_id => 6,
263 responsibility_id => l_resp_id,
264 responsibility_application_id => l_app_id,
265 security_group_id => 0,
266 start_date => l_start_date,
267 end_date => NULL,
268 description => p_responsibility_key);
269 END IF;
270 END IF;
271
272 -- make sure that the guest resp has the right fwk agent
273 -- when not using server profile option
274 check_guest_resp_fwk_agent;
275
276 END confirm_has_resp;
277
278 PROCEDURE get_various_login_info(
279 p_raw_session_id IN VARCHAR2,
280 p_raw_transaction_id IN VARCHAR2,
281 p_responsibility_key IN VARCHAR2,
282 x_dbc_name OUT NOCOPY VARCHAR2,
283 x_enc_session_id OUT NOCOPY VARCHAR2,
284 x_enc_transaction_id OUT NOCOPY VARCHAR2,
285 x_application_id OUT NOCOPY VARCHAR2,
286 x_responsibility_id OUT NOCOPY VARCHAR2)
287 IS
288 l_has_resp NUMBER;
289 BEGIN
290 x_enc_session_id := icx_call.encrypt3(p_raw_session_id);
291 x_enc_transaction_id := icx_call.encrypt3(p_raw_transaction_id);
292 fnd_profile.get(
293 name => 'APPS_DATABASE_ID',
294 val => x_dbc_name);
295 IF x_dbc_name IS NULL
296 THEN
297 x_dbc_name := FND_WEB_CONFIG.DATABASE_ID;
298 END IF;
299
300 SELECT application_id, responsibility_id
301 INTO x_application_id, x_responsibility_id
302 FROM FND_RESPONSIBILITY
303 WHERE responsibility_key = p_responsibility_key;
304
305 END get_various_login_info;
306
307 PROCEDURE get_various_session_info(
308 x_session_cookie_name OUT NOCOPY VARCHAR2,
309 x_session_cookie_domain OUT NOCOPY VARCHAR2)
310 IS
311 l_cookie_name icx_parameters.session_cookie_name%TYPE;
312 l_cookie_domain icx_parameters.session_cookie_domain%TYPE;
313 BEGIN
314
315 SELECT session_cookie_name, session_cookie_domain
316 INTO l_cookie_name, l_cookie_domain
317 FROM icx_parameters;
318
319 x_session_cookie_name := l_cookie_name;
320 x_session_cookie_domain := l_cookie_domain;
321
322 END get_various_session_info;
323
324 END pos_anon_pkg;