class SoarSc::Web::Controllers::ConfiguredController

Attributes

configuration[RW]
dependencies[RW]
policies[RW]
smaak_client[RW]

Public Class Methods

new(configuration, policies = nil) click to toggle source
# File lib/soar_sc_mvc/configured_controller.rb, line 15
def initialize(configuration, policies = nil)
  @configuration = configuration
  @policies = policies
  @dependencies = SoarSc::dependencies
  configure_smaak_client if smaak_enabled?
end

Public Instance Methods

auditing() click to toggle source
# File lib/soar_sc_mvc/configured_controller.rb, line 38
def auditing
  SoarAspects::Aspects::auditing
end
body(request) click to toggle source
# File lib/soar_sc_mvc/configured_controller.rb, line 22
def body(request)
  return nil if request.body.nil?
  return request.body.gets if request.body.is_a? Rack::Lint::InputWrapper
  return request.body.string if request.body.is_a? StringIO
  request.body
end
serve(request) click to toggle source
# File lib/soar_sc_mvc/configured_controller.rb, line 29
def serve(request)
  [ 501, "Not implemented" ]
end

Protected Instance Methods

configure_smaak_client() click to toggle source
# File lib/soar_sc_mvc/configured_controller.rb, line 49
def configure_smaak_client
  @smaak_client = ::Smaak::Client.new
  secure_service = SoarSmaak::SecureService.get_instance(@configuration)
  if secure_service.dynamic
    secure_service.trust_store.associations.each do |identifier, association|
      @smaak_client.add_association(identifier, association['public_key'], association['psk'], association['encrypt'])
    end
    @smaak_client.set_identifier(secure_service.dynamic)
    @smaak_client.set_private_key(secure_service.trust_store.associations[secure_service.dynamic]['private_key'])
  else
    @smaak_client.set_identifier(SoarSc::environment['IDENTIFIER'])
    @smaak_client.set_private_key(@configuration['private_key'])
    @configuration['associations'].each do |identifier, association|
      @smaak_client.add_association(identifier, association['public_key'], association['psk'], association['encrypt'])
    end
  end
end
smaak_enabled?() click to toggle source
# File lib/soar_sc_mvc/configured_controller.rb, line 44
def smaak_enabled?
  (@configuration['private_key'] and @configuration['associations']) or
  (@configuration['smaak'] == 'dynamic')
end