Class: Cbac::CbacPristine::GenericPristineFile
- Inherits:
-
AbstractPristineFile
- Object
- ActiveRecord::Base
- AbstractPristineFile
- Cbac::CbacPristine::GenericPristineFile
- Defined in:
- lib/cbac/cbac_pristine/pristine_file.rb
Instance Attribute Summary
Attributes inherited from AbstractPristineFile
Instance Method Summary collapse
Methods inherited from AbstractPristineFile
#initialize, #is_pristine_permission_line?, #parse, #parse_privilege_set_name, #permission_set
Constructor Details
This class inherits a constructor from Cbac::CbacPristine::AbstractPristineFile
Instance Method Details
#parse_role(line, line_number, use_db = true) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/cbac/cbac_pristine/pristine_file.rb', line 160 def parse_role(line, line_number, use_db = true) # generic pristine files differ, because they create generic roles when needed # but those generic roles should be re-used if one with that name already exists if generic_role= line.match(/^.*GenericRole\(\s*([A-Za-z0-9_]+)\s*\)/) @generic_roles.each do |generic_cbac_role| if generic_cbac_role.name == generic_role.captures[0] return generic_cbac_role end end role = use_db ? PristineRole.where(role_type: PristineRole.ROLE_TYPES[:generic], name: generic_role.captures[0]).first : nil if role.nil? role = PristineRole.new do |role| role.role_id = @generic_roles.length + 2 role.role_type = PristineRole.ROLE_TYPES[:generic] role.name = generic_role.captures[0] end role.save if use_db end @generic_roles.push(role) return role end raise SyntaxError, "Error: GenericRole expected, but found: \"#{line}\" on line #{(line_number + 1).to_s}" end |