Class: OmniAuth::Strategies::CAS::ServiceTicketValidator
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::CAS::ServiceTicketValidator
show all
- Defined in:
- lib/cul_omniauth.rb
Instance Method Summary
collapse
Instance Method Details
#defunct_parse ⇒ Object
10
|
# File 'lib/cul_omniauth.rb', line 10
alias defunct_parse parse_user_info
|
#defunct_success ⇒ Object
11
|
# File 'lib/cul_omniauth.rb', line 11
alias defunct_success find_authentication_success
|
#find_authentication_success(body) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/cul_omniauth.rb', line 38
def find_authentication_success(body)
return nil if body.nil? || body == ''
begin
doc = Nokogiri::XML(body)
begin
doc.xpath('/cas:serviceResponse/cas:authenticationSuccess')
rescue Nokogiri::XML::XPath::SyntaxError
doc.xpath('/serviceResponse/authenticationSuccess')
end
rescue Nokogiri::XML::XPath::SyntaxError
nil
end
end
|
#parse_user_info(node) ⇒ Object
turns an ‘<cas:authenticationSuccess>` node into a Hash; returns nil if given nil
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/cul_omniauth.rb', line 14
def parse_user_info(node)
return nil if node.nil?
{}.tap do |hash|
node.children.each do |e|
node_name = e.name.sub(/^cas:/, '')
unless e.kind_of?(Nokogiri::XML::Text) || node_name == 'proxies'
if e.element_children.count == 0
hash[node_name] = e.content
elsif e.element_children.count
if node_name == 'attributes'
hash.merge!(parse_user_info(e))
elsif node_name == 'affiliations'
hash.merge!(affiliations: e.xpath('cas:affil',NS).collect {|x| x.text})
else
hash[node_name] = [] if hash[node_name].nil?
hash[node_name].push(parse_user_info(e))
end
end
end
end
end
end
|