DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_SESSION_UTILITIES

Source


1 package body FND_SESSION_UTILITIES as
2 /* $Header: AFICXSUB.pls 120.1.12010000.2 2010/05/19 11:23:21 stadepal ship $ */
3 
4   function SessionID_to_XSID(p_session_id in number) return varchar2
5   is
6     l_XSID varchar2(32);
7   begin
8     select XSID
9     into   l_XSID
10     from   ICX_SESSIONS
11     where  SESSION_ID = p_session_id;
12     if l_XSID is null
13     then
14       l_XSID := icx_call.encrypt3(p_session_id);
15     end if;
16 
17     return l_XSID;
18 
19   exception
20     when no_data_found then
21       l_XSID := NULL;
22       return l_XSID;
23   end SessionID_to_XSID;
24 
25   function XSID_to_SessionID(p_XSID in varchar2) return number
26   is
27     l_SessionID number;
28   begin
29     -- if substrb(p_XSID,-2,2) <> ':S'
30     -- New method to generate XSID (NewXSID) always generates XSID
31     -- of length 26. Whereas the old method (encrypt3) always generates
32     -- the value in lengths of multiple of 16 (ex: 16,32,64)
33     if length(p_XSID) <> 26
34     then
35       l_SessionID := icx_call.decrypt3(p_XSID);
36     else
37       select SESSION_ID
38       into   l_SessionID
39       from   ICX_SESSIONS
40       where  XSID = p_XSID;
41     end if;
42 
43     return l_SessionID;
44 
45   exception
46     when no_data_found then
47       l_SessionID := NULL;
48       return l_SessionID;
49   end XSID_to_SessionID;
50 
51   function TransactionID_to_XTID(p_transaction_id in number) return varchar2
52   is
53   -- l_XTID varchar2(32);
54   begin
55 
56     return p_transaction_id;
57 
58   end TransactionID_to_XTID;
59 
60 
61   function XTID_to_TransactionID(p_XTID in varchar2) return number
62   is
63     l_TransactionID number;
64   begin
65 
66     -- nlbarlow, have to still support backward compatibility.
67     begin
68 
69   if (translate(p_XTID, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
70         'xxxxxxxxxxxxxxxxxxxxxxxxxx') <> p_XTID)
71        then
72      l_TransactionID := icx_call.decrypt3(p_XTID);
73 
74    else
75 
76       select TRANSACTION_ID
77       into   l_TransactionID
78       from   ICX_TRANSACTIONS
79       where  TRANSACTION_ID = p_XTID;
80 
81   end if;
82 
83 /*
84 
85     exception
86       when no_data_found then
87         l_TransactionID := NULL;
88       when others then
89         l_TransactionID := icx_call.decrypt3(p_XTID);
90 */
91 
92 
93      exception
94      when no_data_found then
95       l_TransactionID := NULL;
96 
97     end;
98 
99     return l_TransactionID;
100 
101   end XTID_to_TransactionID;
102 
103 
104 
105 
106 
107 
108 
109   function MAC(p_source in varchar2,
110                p_session_id in number) return varchar2 is
111     l_source raw(2000);
112     l_key    raw(20);
113     l_mac    raw(16);
114   begin
115 
116     l_source := utl_raw.cast_to_raw(p_source);
117 
118     select MAC_KEY
119     into   l_key
120     from   ICX_SESSIONS
121     where  SESSION_ID = p_session_id;
122 
123     l_mac := fnd_crypto.mac(source => l_source,
124                             mac_type => fnd_crypto.HMAC_MD5,
125                             key => l_key);
126 
127     return fnd_crypto.encode(source => l_mac,
128                              fmt_type => fnd_crypto.ENCODE_URL);
129 
130    exception
131      when no_data_found then
132      l_mac := NULL;
133      return l_mac;
134 
135   end;
136 
137 end FND_SESSION_UTILITIES;