/
authenticator.rb
49 lines (43 loc) · 1.64 KB
/
authenticator.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require "ruby_plsql"
module OracleEbsAuthentication
class Authenticator
FND_RESPONSIBILITY_QUERY = 'SELECT r.responsibility_name
FROM apps.fnd_user_resp_groups_all ur, apps.fnd_responsibility_vl r
WHERE ur.user_id = :p_user_id
AND TRUNC(SYSDATE) BETWEEN NVL(ur.start_date,TRUNC(SYSDATE)) AND NVL(ur.end_date, TRUNC(SYSDATE))
AND ur.responsibility_id = r.responsibility_id'
def initialize
@security = OracleEbsAuthentication::Security.new
end
def get_fnd_password(username, password)
username &&= username.upcase
result = plsql.apps.fnd_security_pkg.fnd_encrypted_pwd(username, nil, nil, nil)
if result[:p_password]
@security.decrypt(username + "/" + password, result[:p_password], false)
end
rescue OCIError => e
if e.message.include?("ORA-20001: Your account does not exist or has expired.")
nil
else
raise e
end
end
def get_fnd_user_id(username)
username &&= username.upcase
plsql.apps.fnd_security_pkg.fnd_encrypted_pwd(username, nil, nil, nil)[:p_user_id]
end
def get_fnd_responsibilities(username)
user_id = get_fnd_user_id(username)
if user_id
plsql.select(:all, OracleEbsAuthentication::Authenticator::FND_RESPONSIBILITY_QUERY, user_id).map{|row| row[:responsibility_name]}
else
[]
end
end
def validate_user_password(username, password)
if username && password
!! get_fnd_password(username, password)
end
end
end
end