Class: Devise::W3Adapter::IBMEmployee

Inherits:
Struct
  • Object
show all
Defined in:
lib/devise_w3_authenticatable/w3_adapter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#countryObject

Returns the value of attribute country

Returns:

  • (Object)

    the current value of country



16
17
18
# File 'lib/devise_w3_authenticatable/w3_adapter.rb', line 16

def country
  @country
end

#departmentObject

Returns the value of attribute department

Returns:

  • (Object)

    the current value of department



16
17
18
# File 'lib/devise_w3_authenticatable/w3_adapter.rb', line 16

def department
  @department
end

#logonObject

Returns the value of attribute logon

Returns:

  • (Object)

    the current value of logon



16
17
18
# File 'lib/devise_w3_authenticatable/w3_adapter.rb', line 16

def logon
  @logon
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



16
17
18
# File 'lib/devise_w3_authenticatable/w3_adapter.rb', line 16

def name
  @name
end

#serialObject

Returns the value of attribute serial

Returns:

  • (Object)

    the current value of serial



16
17
18
# File 'lib/devise_w3_authenticatable/w3_adapter.rb', line 16

def serial
  @serial
end

#uidObject

Returns the value of attribute uid

Returns:

  • (Object)

    the current value of uid



16
17
18
# File 'lib/devise_w3_authenticatable/w3_adapter.rb', line 16

def uid
  @uid
end

#workplaceObject

Returns the value of attribute workplace

Returns:

  • (Object)

    the current value of workplace



16
17
18
# File 'lib/devise_w3_authenticatable/w3_adapter.rb', line 16

def workplace
  @workplace
end

Class Method Details

.find_by_mail(mail) ⇒ Object



36
37
38
# File 'lib/devise_w3_authenticatable/w3_adapter.rb', line 36

def find_by_mail(mail)
  parse_from_bluepages("http://bluepages.ibm.com/BpHttpApisv3/slaphapi?ibmperson/mail=#{mail}.list/byxml")
end

.parse_from_bluepages(bluepages_url) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/devise_w3_authenticatable/w3_adapter.rb', line 18

def parse_from_bluepages(bluepages_url)
  begin
    entry = Nokogiri::XML(open(bluepages_url)).css("entry").first

    uid        = entry.attributes["dn"].to_s
    logon      = entry.css("attr[name='mail'] value").children.first.to_s
    name       = entry.css("attr[name='cn'] value").children.first.to_s
    serial     = entry.css("attr[name='serialnumber'] value").children.first.to_s
    department = entry.css("attr[name='dept'] value").children.first.to_s
    country    = entry.css("attr[name='co'] value").children.first.to_s
    workplace  = entry.css("attr[name='physicaldeliveryofficename'] value").children.first.to_s

    new(uid, logon, name, serial, department, country, workplace)
  rescue
    nil
  end
end