DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_SSO_MANAGER

Source


1 package body FND_SSO_MANAGER as
2 /* $Header: fndssob.pls 120.5.12000000.1 2007/01/18 13:43:27 appldev ship $ */
3 
4 G_MODULE_SOURCE  constant varchar2(80) := 'fnd.plsql.sso.fnd_sso_manager.';
5 
6 -- The parameters errCode and errText can
7 -- be manually added to the Login url for additional processing.
8 --
9 -- we no longer use this method. Please refer bug 4043786
10 -- Instead we use the function with 3 parameters */
11 --function getLoginUrl(requestUrl    in      varchar2 ,
12 --               cancelUrl     in      varchar2 )
13 --return varchar2 is
14 -- l_requestUrl          varchar2(2024);
15 -- l_cancelUrl          varchar2(2024);
16 -- cs_anchor                varchar2(2000);
17 -- cj_anchor                varchar2(2000);
18 --begin
19 --
20 --	fnd_profile.get(name => 'APPS_SERVLET_AGENT',
21 --                     val => cs_anchor);
22 --	fnd_profile.get(name => 'APPS_FRAMEWORK_AGENT',
23 --                     val => cj_anchor);
24 --	l_requestUrl := requestUrl;
25 --	l_cancelUrl := cancelUrl;
26 --
27 --	if l_requestUrl is NULL then
28 --		l_requestUrl := 'APPSHOMEPAGE';
29 --	end if;
30 --
31 --	if l_cancelUrl is NULL then
32 --		l_cancelUrl := FND_WEB_CONFIG.trail_slash(cs_anchor)|| 'oracle.apps.fnd.sso.AppsLogin' ;
33 --	end if;
34 --
35 --	return FND_WEB_CONFIG.trail_slash(cs_anchor)|| 'oracle.apps.fnd.sso.AppsLogin?requestUrl=' || wfa_html.conv_special_url_chars(l_requestUrl) || '&' || 'cancelUrl=' || wfa_html.conv_special_url_chars(l_cancelUrl);
36 --
37 --end;
38 
39 procedure synch_user_from_LDAP(p_user_name in fnd_user.user_name%type) is
40   l_module_source   varchar2(256);
41   l_result  pls_integer;
42   l_user_name fnd_user.user_name%type;
43 begin
44   l_module_source := G_MODULE_SOURCE || 'synch_user_from_LDAP';
45 
46   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
47   then
48     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
49   end if;
50 
51   l_user_name  := p_user_name;
52   fnd_ldap_wrapper.synch_user_from_LDAP(p_user_name => l_user_name,
53                                        p_result => l_result);
54 
55   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
56   then
57     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'l_result: '||l_result);
58   end if;
59 
60   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
61   then
62     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
63   end if;
64 
65 exception
66  when others then
67  raise;
68  if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
69  then
70   fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
71 end if;
72 end synch_user_from_LDAP;
73 
74 /*
75  API returns true if profile APPS_SSO_USER_CREATE_UPDATE is ENABLED
76 */
77 function isUserCreateUpdateAllowed
78   return boolean is
79 
80   l_apps_sso_user_create_update  varchar2(10);
81   l_module_source   varchar2(256);
82   l_returnVal boolean;
83 
84 begin
85   l_returnVal := false;
86   l_module_source := G_MODULE_SOURCE || 'isUserCreateUpdateAllowed: ';
87 
88   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
89   then
90     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
91   end if;
92 
93   fnd_profile.get(name => 'APPS_SSO_USER_CREATE_UPDATE',
94                    val => l_apps_sso_user_create_update);
95 
96   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
97   then
98     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source,
99            'APPS_SSO_USER_CREATE_UPDATE: ' || l_apps_sso_user_create_update);
100   end if;
101 
102  if (l_apps_sso_user_create_update = 'N')
103   then
104     l_returnVal := FALSE;
105   else
106     l_returnVal := TRUE;
107   end if;
108 
109   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
110   then
111     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
112   end if;
113 
114   return l_returnVal;
115 
116 exception
117   when others then
118     if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
119     then
120       fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, sqlerrm);
121     end if;
122     return false;
123 end;
124 
125 /*
126  Overloaded getLoginUrl function with an additional parameter
127  of langCode
128  */
129 function getLoginUrl(requestUrl    in      varchar2 ,
130                cancelUrl     in      varchar2,
131 	       langCode in varchar2)
132 return varchar2 is
133  l_requestUrl          varchar2(2024);
134  l_cancelUrl          varchar2(2024);
135  l_langCode          varchar2(2024);
136  cs_anchor                varchar2(2000);
137  cj_anchor                varchar2(2000);
138 begin
139 
140 	fnd_profile.get(name => 'APPS_SERVLET_AGENT',
141                      val => cs_anchor);
142 	fnd_profile.get(name => 'APPS_FRAMEWORK_AGENT',
143                      val => cj_anchor);
144 	l_requestUrl := requestUrl;
145 	l_cancelUrl := cancelUrl;
146 	l_langCode := langCode;
147 
148 	if l_requestUrl is NULL then
149 		l_requestUrl := 'APPSHOMEPAGE';
150 	end if;
151 
152 	if l_cancelUrl is NULL then
153 		-- Bug 5369045: user servlet name
154 		l_cancelUrl := FND_WEB_CONFIG.trail_slash(cs_anchor)|| 'AppsLogin' ;
155 	end if;
156 
157 	if l_langCode is NOT NULL then
158 		-- Bug 5369045: user servlet name
159 		return FND_WEB_CONFIG.trail_slash(cs_anchor)|| 'AppsLogin?requestUrl=' || wfa_html.conv_special_url_chars(l_requestUrl) || '&' || 'cancelUrl=' || wfa_html.conv_special_url_chars(l_cancelUrl) ||
160 		'&' || 'langCode=' || wfa_html.conv_special_url_chars(l_langCode);
161 	end if;
162 
163 		-- Bug 5369045: user servlet name
164 	return FND_WEB_CONFIG.trail_slash(cs_anchor)|| 'AppsLogin?requestUrl=' || wfa_html.conv_special_url_chars(l_requestUrl) || '&' || 'cancelUrl=' || wfa_html.conv_special_url_chars(l_cancelUrl);
165 
166 end;
167 
168 function getLogoutUrl(returnUrl	in	varchar2 )
169 return varchar2 is
170 cs_anchor                varchar2(2000);
171 l_returnUrl		 varchar2(2000);
172 l_audit_level      VARCHAR2(1);
173 l_login_id        NUMBER;
174 l_session_id      NUMBER;
175 begin
176 
177  -- fix for bug 3241092
178          l_session_id := icx_sec.getsessioncookie; ---get session_id from the cookie
179 
180          select login_id into l_login_id
181          from  ICX_SESSIONS
182          where  SESSION_ID = l_session_id;
183 
184          l_audit_level:=fnd_profile.value('SIGNONAUDIT:LEVEL');
185          if (l_audit_level is not null) and ( l_login_id is not null)
186          then
187               fnd_signon.audit_end(l_login_id); -- end audit session and resps.
188          end if;
189  --
190 	l_returnUrl := returnUrl;
191 	fnd_profile.get(name => 'APPS_SERVLET_AGENT',
192                      val => cs_anchor);
193 	if l_returnUrl is NULL then
194 		-- Bug 5369045: user servlet name
195 		return FND_WEB_CONFIG.trail_slash(cs_anchor)|| 'AppsLogout';
196 	end if;
197 
198 		-- Bug 5369045: user servlet name
199 	return FND_WEB_CONFIG.trail_slash(cs_anchor)|| 'AppsLogout?returnUrl=' || wfa_html.conv_special_url_chars(l_returnUrl);
200 
201 end;
202 
203 
204 function modplsql_currentURL return varchar2 is
205 l_urlrequested          varchar2(2024);
206 begin
207       l_urlrequested :=
208       lower(owa_util.get_cgi_env('REQUEST_PROTOCOL'))||'://'||
209       owa_util.get_cgi_env('SERVER_NAME')||':'||
210       owa_util.get_cgi_env('SERVER_PORT')||
211       owa_util.get_cgi_env('SCRIPT_NAME')||
212       owa_util.get_cgi_env('PATH_INFO');
213       if owa_util.get_cgi_env('QUERY_STRING') is not null then
214         l_urlrequested := l_urlrequested  ||'?'|| owa_util.get_cgi_env('QUERY_STRING');
215       end if;
216 
217       return l_urlrequested;
218 end;
219 
220 function isPasswordChangeable(username in varchar2) return boolean
221 is
222 pValue varchar2(50);
223 p_user_id number;
224 l_profile_defined boolean;
225 -- userNotFound exception;  Bug4420380 Changed exception from local to global
226 begin
227 
228 	select user_id into p_user_id from fnd_user where user_name = username;
229 	FND_PROFILE.GET_SPECIFIC(name_z => 'APPS_SSO_LOCAL_LOGIN',
230                              user_id_z =>           p_user_id,
231                              val_z => pValue,
232                              defined_z => l_profile_defined);
233 
234 	IF pValue is null then
235 		return true;
236 	elsif pvalue = 'LOCAL' then
237 		return true;
238 	elsif pvalue = 'BOTH' then
239 		return true;
240 	elsif pvalue = 'SSO' then
241 		return false;
242 	end if;
243 
244 	return true;
245 
246 	exception
247 	when no_data_found  THEN
248 		raise userNotFound;
249 
250 end;
251 
252 function get_ldap_user_name(p_user_name in fnd_user.user_name%type)
253 return varchar2 is
254 
255  l_module_source   varchar2(256);
256  l_result  varchar2(4000);
257 begin
258  l_module_source := G_MODULE_SOURCE || 'get_ldap_user_name';
259 
260   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
261   then
262     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
263   end if;
264 
265   l_result :=  fnd_ldap_wrapper.get_ldap_user_name(p_user_name => p_user_name);
266 
267   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
268   then
269     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'l_result: '||l_result);
270   end if;
271 
272   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
273   then
274     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'End');
275   end if;
276 	return l_result;
277 end get_ldap_user_name;
278 
279 end FND_SSO_MANAGER;