Class: NcsNavigator::Authorization::Core::Authority
- Inherits:
-
Object
- Object
- NcsNavigator::Authorization::Core::Authority
- Defined in:
- lib/ncs_navigator/authorization/core/authority.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#staff_portal_password ⇒ Object
readonly
Returns the value of attribute staff_portal_password.
-
#staff_portal_uri ⇒ Object
readonly
Returns the value of attribute staff_portal_uri.
-
#staff_portal_user ⇒ Object
readonly
Returns the value of attribute staff_portal_user.
Instance Method Summary collapse
- #amplify!(user) ⇒ Object
- #find_users(*criteria) ⇒ Object
-
#initialize(options = {}) ⇒ Authority
constructor
A new instance of Authority.
- #user(user) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Authority
Returns a new instance of Authority.
9 10 11 12 13 14 15 16 17 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 9 def initialize( = {}) @logger = [:logger] || Logger.new($stderr) @staff_portal_uri = [:staff_portal_uri] || NcsNavigator.configuration.staff_portal_uri @staff_portal_user = [:staff_portal_user] || "psc_application" @staff_portal_password = [:staff_portal_password] || NcsNavigator.configuration.staff_portal['psc_user_password'] @groups = {} @portal = :NCSNavigator end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 4 def logger @logger end |
#staff_portal_password ⇒ Object (readonly)
Returns the value of attribute staff_portal_password.
7 8 9 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 7 def staff_portal_password @staff_portal_password end |
#staff_portal_uri ⇒ Object (readonly)
Returns the value of attribute staff_portal_uri.
5 6 7 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 5 def staff_portal_uri @staff_portal_uri end |
#staff_portal_user ⇒ Object (readonly)
Returns the value of attribute staff_portal_user.
6 7 8 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 6 def staff_portal_user @staff_portal_user end |
Instance Method Details
#amplify!(user) ⇒ Object
19 20 21 22 23 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 19 def amplify!(user) base = user(user) return user unless base user.merge!(base) end |
#find_users(*criteria) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 51 def find_users(*criteria) return [] unless criteria.empty? result = [] if users = get_users users.each do |u| next if u["username"].blank? au = Aker::User.new(u["username"]) au.identifiers[:staff_id] = u["staff_id"] au.first_name = u["first_name"] au.last_name = u["last_name"] result << au end end result end |
#user(user) ⇒ Object
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 |
# File 'lib/ncs_navigator/authorization/core/authority.rb', line 25 def user(user) staff = get_staff(user) if staff u = Aker::User.new(user.username) u.portals << @portal attributes = ["first_name", "last_name", "email"] attributes.each do |a| setter = "#{a}=" if u.respond_to?(setter) u.send(setter, staff[a]) end end u.identifiers[:staff_id] = staff["staff_id"] groups = staff['roles'].collect do |role| role['name'] end if groups u.group_memberships(@portal).concat(load_group_memberships(@portal, groups)) end u else nil end end |