Class: Rmobio::Cas::MobioCasFilter

Inherits:
CASClient::Frameworks::Rails::Filter
  • Object
show all
Defined in:
lib/rmobio/cas.rb

Class Method Summary collapse

Class Method Details

.configure(config) ⇒ Object

Override configure so we use our cas client



129
130
131
132
133
134
# File 'lib/rmobio/cas.rb', line 129

def self.configure(config)
  @@config = config
  @@config[:logger] = RAILS_DEFAULT_LOGGER unless @@config[:logger]
  @@client = Rmobio::Cas::Client.new(config)
  @@log = client.log
end

.filter(controller) ⇒ Object

Here’s where we override the filter



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/rmobio/cas.rb', line 137

def self.filter(controller)
  RAILS_DEFAULT_LOGGER.debug 'CAS: Starting filter...' unless not defined? RAILS_DEFAULT_LOGGER
  
  @handset_id = controller.params[:handsetid]
  
  # handsetid gets appended to request uri, we need to remove it for 
  # service validation to work
  controller.params.delete('handsetid')
  
  # Call filter on the base class
  CASClient::Frameworks::Rails::Filter.filter(controller)  
  
  # Now let's put the handsetid back into the request in case we do a redirect
  controller.params[:handsetid] = @handset_id
  
  # Use the overloaded cas client to retrieve uuid. This should only
  # happen after service ticket validation.
  if not @@client.xml_response.nil?
    @uuid = @@client.xml_response.uuid
  end
  
  # Setup the uuid and handset_id session variables
  if not @uuid.nil? and not @uuid == '' and not @handset_id.nil? and not @handset_id == ''
    controller.session[:uuid] = @uuid
    controller.session[:handset_id] = @handset_id
    RAILS_DEFAULT_LOGGER.debug 'CAS: Stored cas uuid: ' + @uuid + ' and handset_id: ' + @handset_id +
      ' into the session.' unless not defined? RAILS_DEFAULT_LOGGER
    return true
  else
    # Should only happen on initial redirect
    RAILS_DEFAULT_LOGGER.debug 'CAS: MobioCasFilter cannot read the uuid/handset_id ' +
      'attributes for the user!' unless not defined? RAILS_DEFAULT_LOGGER
    return false
  end
end