DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_LOGIN

Source


1 package body irc_login as
2 /* $Header: irclogin.pkb 120.3 2008/01/21 14:59:30 gaukumar noship $ */
3 --
4 function createExecLink2
5 (p_function_name varchar2
6 ,p_application_short_name varchar2
7 ,p_responsibility_key varchar2
8 ,p_security_group_key varchar2
9 ,p_server_name varchar2
10 ,p_parameters varchar2 default null)
11 return varchar2 is
12   --
13   l_retval varchar2(32767);
14   l_b boolean;
15   l_server_id number := null;
16   --
17   cursor get_func_id is
18   select function_id
19   from fnd_form_functions
20   where function_name=p_function_name;
21   l_function_id fnd_form_functions.function_id%type;
22   --
23   cursor get_user_id is
24   select user_id
25   from fnd_user
26   where user_name=substr(FND_WEB_SEC.GET_GUEST_USERNAME_PWD()
27                         ,0
28                         ,instr(FND_WEB_SEC.GET_GUEST_USERNAME_PWD(),'/')-1);
29   l_user_id fnd_user.user_id%type;
30   --
31   cursor get_resp_id is
32   select responsibility_id
33   from fnd_responsibility
34   where responsibility_key=p_responsibility_key;
35   l_responsibility_id fnd_responsibility.responsibility_id%type;
36   --
37   cursor get_app_id is
38   select application_id
39   from fnd_application
40   where application_short_name=p_application_short_name;
41   l_application_id fnd_application.application_id%type;
42   --
43   cursor get_sec_grp_id is
44   select security_group_id
45   from fnd_security_groups
46   where security_group_key=p_security_group_key;
47   l_security_group_id fnd_security_groups.security_group_id%type;
48   --
49   cursor get_server_id is
50   select node_id
51   from fnd_nodes
52   where lower(node_name)=lower(p_server_name);
53 
54   cursor get_server_id2 is
55   select node_id
56   from fnd_nodes
57   where lower(webhost)=lower(p_server_name);
58   --
59   begin
60   --
61   open get_func_id;
62   fetch get_func_id into l_function_id;
63   close get_func_id;
64   --
65   open get_user_id;
66   fetch get_user_id into l_user_id;
67   close get_user_id;
68   --
69   open get_resp_id;
70   fetch get_resp_id into l_responsibility_id;
71   close get_resp_id;
72   --
73   open get_app_id;
74   fetch get_app_id into l_application_id;
75   close get_app_id;
76   --
77   open get_sec_grp_id;
78   fetch get_sec_grp_id into l_security_group_id;
79   close get_sec_grp_id;
80   --
81   open get_server_id2;
82   fetch get_server_id2 into l_server_id;
83   close get_server_id2;
84   --
85   if l_server_id is null then
86     open get_server_id;
87     fetch get_server_id into l_server_id;
88     close get_server_id;
89   end if;
90   --
91   if l_server_id is null then
92     fnd_global.apps_initialize
93     (user_id          =>l_user_id
94     ,resp_id          => l_responsibility_id
95     ,resp_appl_id     => l_application_id
96     ,security_group_id=>l_security_group_id);
97   else
98     fnd_global.apps_initialize
99     (user_id          =>l_user_id
100     ,resp_id          => l_responsibility_id
101     ,resp_appl_id     => l_application_id
102     ,security_group_id=>l_security_group_id
103     ,server_id        =>l_server_id);
104   end if;
105   --
106   l_retval:=icx_portlet.createExecLink
107   (p_application_id   =>l_application_id
108   ,p_responsibility_id=>l_responsibility_id
109   ,p_security_group_id=>l_security_group_id
110   ,p_function_id      =>l_function_id
111   ,p_parameters       =>p_parameters
112   ,p_link_name        =>''
113   ,p_url_only         =>'Y');
114   --
115   return l_retval;
116 end createExecLink2;
117 --
118 FUNCTION validate_login(
119     p_user    IN VARCHAR2,
120     p_pwd     IN VARCHAR2,
121     p_disable in varchar2) return VARCHAR2 is
122 --
123     user        VARCHAR2(100) := upper(p_user);
124     userID      NUMBER := -1;
125     l_result    varchar2(10) := 'N';
126     l_loginID   number;
127     l_expired   varchar2(10);
128 --
129 begin
130   hr_utility.set_location('calling validate_login user_name='||p_user||' and pwd:'||p_pwd||' and disable='||p_disable,10);
131   l_result := fnd_web_sec.validate_login(p_user => p_user,
132                                          p_pwd  => p_pwd);
133   hr_utility.set_location('result='||l_result,20);
134 
135   if l_result = 'N' and p_disable = 'Y'  then
136     begin
137       hr_utility.set_location('calling disable user',30);
138       select user_id into userID
139       from fnd_user
140       where user_name = user AND
141       user_id <> 6 and
142       (start_date <= sysdate) AND
143       (end_date is null or end_date > sysdate);
144       fnd_web_sec.unsuccessful_login(userID);
145       hr_utility.set_location('called disable user',40);
146       exception
147         when no_data_found then
148         hr_utility.set_location('No data found',10);
149         return 'N';
150     end;
151   end if;
152   if l_result = 'Y' and p_disable = 'Y'then
153     hr_utility.set_location('creating new session loginid='||l_loginID||' expired='||l_expired,10);
154 --    fnd_signon.new_icx_session(userID, l_loginID, l_expired);
155   end if;
156   hr_utility.set_location('final result:='||l_result,40);
157   --
158   return l_result;
159   --
160 end validate_login;
161 --
162 procedure convertSession(p_token in VARCHAR2,
163                          p_username IN VARCHAR2,
164                          p_password IN VARCHAR2) is
165 begin
166   hr_utility.set_location('calling for user_name'||p_username,10);
167   OracleApps.convertSession(
168                c_token => p_token
169               ,i_1     => p_username
170               ,i_2     => p_password);
171   hr_utility.set_location('done calling convertsession'||p_username,20);
172   FND_USER_PKG.UpdateUser (
173                x_user_name       => p_username
174               ,x_owner           => null
175               ,x_last_logon_date => sysdate
176               );
177   hr_utility.set_location('update usre:'||p_username||
178                           ' with date'||to_char(sysdate,'DD-MON-YYYY hh:mm:ss'),30);
179 end convertSession;
180 --
181 end irc_login;