rmobio 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/rmobio/cas.rb +119 -16
  2. metadata +14 -14
data/lib/rmobio/cas.rb CHANGED
@@ -1,24 +1,127 @@
1
- #
1
+ #
2
2
  # Copyright (C) 2007 Mobio Networks, Inc.
3
- #
4
- # This program is free software: you can redistribute it and/or modify
5
- # it under the terms of the GNU General Public License as published by
6
- # the Free Software Foundation, either version 3 of the License, or
7
- # (at your option) any later version.
8
- #
9
- # This program is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- # GNU General Public License for more details.
13
- #
14
- # You should have received a copy of the GNU General Public License
15
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- #
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify it under
5
+ # the terms of the GNU General Public License as published by the Free Software
6
+ # Foundation, either version 3 of the License, or (at your option) any later
7
+ # version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
+ # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
+ # details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along with
15
+ # this program. If not, see <http://www.gnu.org/licenses/>.
16
+ #
17
+
18
+ #
19
+ # This module contains custom wrapper logic on the rubycas client. Namely, we
20
+ # need to enhance parsing of the serviceResponse:
21
+ #
22
+ # <cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
23
+ # <cas:authenticationSuccess
24
+ # <cas:uuid>someid</cas:uuid>
25
+ # <cas:user>someuser</cas:user>
26
+ # </cas:authenticationSuccess>
27
+ # </cas:serviceResponse>
28
+ #
29
+ # In order to use this validation, we need to modify the rubycas client filter
30
+ # as well as the casclient itself.
31
+ #
32
+
33
+ require 'rubycas-client'
34
+ require 'casclient/frameworks/rails/filter'
35
+ require 'casclient'
17
36
 
18
37
  module Rmobio
19
38
  module Cas
20
- class MobioServiceTicketValidator < CAS::ServiceTicketValidator
39
+ class Client < CASClient::Client
40
+ attr_accessor :xml_response
41
+
42
+ # Override service ticket validation so we use our XmlResponse
43
+ def validate_service_ticket(st)
44
+ RAILS_DEFAULT_LOGGER.debug 'CAS: Starting to validate service ticket...' unless not defined? RAILS_DEFAULT_LOGGER
45
+ uri = URI.parse(validate_url)
46
+ h = uri.query ? query_to_hash(uri.query) : {}
47
+ h['service'] = st.service
48
+ h['ticket'] = st.ticket
49
+ h['renew'] = 1 if st.renew
50
+ h['pgtUrl'] = proxy_callback_url if proxy_callback_url
51
+ uri.query = hash_to_query(h)
52
+
53
+ st.response = request_cas_response(uri, MobioValidationResponse)
54
+ @xml_response = st.response
55
+ return st
56
+ end
57
+ end
58
+
59
+ class MobioValidationResponse < CASClient::ValidationResponse
60
+ attr_reader :uuid
61
+
62
+ # Parse out our custom attributes
63
+ def initialize(raw_text)
64
+ super(raw_text)
65
+ parse_uuid(raw_text)
66
+ end
67
+
68
+ def parse_uuid(raw_text)
69
+ raise BadResponseException,
70
+ "CAS response is empty/blank." if raw_text.blank?
71
+
72
+ @xml = check_and_parse_xml(raw_text)
73
+
74
+ if is_success?
75
+ @uuid = @xml.elements["cas:uuid"].text.strip if @xml.elements["cas:uuid"]
76
+ RAILS_DEFAULT_LOGGER.info 'CAS: Successfully authenticated user ' + @uuid.to_s +
77
+ '...' unless not defined? RAILS_DEFAULT_LOGGER
78
+ else
79
+ # this should never happen, since the response should already have
80
+ # been recognized as invalid
81
+ raise BadResponseException, "BAD CAS RESPONSE:\n#{raw_text.inspect}\n\nXML DOC:\n#{doc.inspect}"
82
+ end
83
+ end
84
+ end
85
+
86
+ class MobioCasFilter < CASClient::Frameworks::Rails::Filter
21
87
 
88
+ # Override configure so we use our cas client
89
+ def self.configure(config)
90
+ @@config = config
91
+ @@config[:logger] = RAILS_DEFAULT_LOGGER unless @@config[:logger]
92
+ @@client = Rmobio::Cas::Client.new(config)
93
+ @@log = client.log
94
+ end
95
+
96
+ def self.filter(controller)
97
+
98
+ RAILS_DEFAULT_LOGGER.debug 'CAS: Starting filter...' unless not defined? RAILS_DEFAULT_LOGGER
99
+
100
+ # Call filter on the base class
101
+ CASClient::Frameworks::Rails::Filter.filter(controller)
102
+
103
+ @handset_id = controller.params[:handsetid]
104
+
105
+ # Use the overloaded cas client to retrieve uuid. This should only
106
+ # happen after service ticket validation.
107
+ if not @@client.xml_response.nil?
108
+ @uuid = @@client.xml_response.uuid
109
+ end
110
+
111
+ # Setup the uuid and handset_id session variables
112
+ if not @uuid.nil? and not @uuid == '' and not @handset_id.nil? and not @handset_id == ''
113
+ controller.session[:uuid] = @uuid
114
+ controller.session[:handset_id] = @handset_id
115
+ RAILS_DEFAULT_LOGGER.debug 'CAS: Stored cas uuid: ' + @uuid + ' and handset_id: ' + @handset_id +
116
+ ' into the session.' unless not defined? RAILS_DEFAULT_LOGGER
117
+ return true
118
+ else
119
+ # Should only happen on initial redirect
120
+ RAILS_DEFAULT_LOGGER.debug 'CAS: MobioCasFilter cannot read the uuid/handset_id ' +
121
+ 'attributes for the user!' unless not defined? RAILS_DEFAULT_LOGGER
122
+ return false
123
+ end
124
+ end
22
125
  end
23
126
  end
24
127
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmobio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Blum
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-03-13 00:00:00 -07:00
12
+ date: 2008-03-19 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,30 +30,30 @@ extensions: []
30
30
  extra_rdoc_files: []
31
31
 
32
32
  files:
33
- - lib/rmobio.rb
34
33
  - lib/rmobio
35
- - lib/rmobio/webservices.rb
34
+ - lib/rmobio.rb
35
+ - lib/rmobio/ads
36
36
  - lib/rmobio/ads.rb
37
- - lib/rmobio/utils.rb
38
- - lib/rmobio/webservices
39
37
  - lib/rmobio/auth.rb
40
- - lib/rmobio/ads
41
38
  - lib/rmobio/cas.rb
39
+ - lib/rmobio/client_info.rb
42
40
  - lib/rmobio/config_manager.rb
43
41
  - lib/rmobio/raketasks.rb
44
- - lib/rmobio/client_info.rb
42
+ - lib/rmobio/utils.rb
43
+ - lib/rmobio/webservices
44
+ - lib/rmobio/webservices.rb
45
+ - lib/rmobio/ads/ad_mobs.rb
46
+ - lib/rmobio/ads/ad_sense.rb
47
+ - lib/rmobio/ads/m_khoj.rb
48
+ - lib/rmobio/ads/smaato.rb
45
49
  - lib/rmobio/webservices/rest
46
50
  - lib/rmobio/webservices/soap
47
- - lib/rmobio/webservices/soap/registration.rb
48
- - lib/rmobio/webservices/soap/rss.rb
49
51
  - lib/rmobio/webservices/soap/drivers.rb
50
52
  - lib/rmobio/webservices/soap/geocode.rb
51
53
  - lib/rmobio/webservices/soap/messaging.rb
52
54
  - lib/rmobio/webservices/soap/platform.rb
53
- - lib/rmobio/ads/m_khoj.rb
54
- - lib/rmobio/ads/smaato.rb
55
- - lib/rmobio/ads/ad_sense.rb
56
- - lib/rmobio/ads/ad_mobs.rb
55
+ - lib/rmobio/webservices/soap/registration.rb
56
+ - lib/rmobio/webservices/soap/rss.rb
57
57
  has_rdoc: false
58
58
  homepage: http://test01.mobio.net/svn/platform/trunk/rails/rmobio
59
59
  post_install_message: