Class: RackCAS::ServiceValidationResponse
- Inherits:
-
Object
- Object
- RackCAS::ServiceValidationResponse
- Defined in:
- lib/rack-cas/service_validation_response.rb
Defined Under Namespace
Classes: AuthenticationFailure, RequestInvalidError, ServiceInvalidError, TicketInvalidError
Constant Summary collapse
- REQUEST_HEADERS =
{ 'Accept' => '*/*' }
Instance Method Summary collapse
- #extra_attributes ⇒ Object
-
#initialize(url) ⇒ ServiceValidationResponse
constructor
A new instance of ServiceValidationResponse.
- #user ⇒ Object
Constructor Details
#initialize(url) ⇒ ServiceValidationResponse
Returns a new instance of ServiceValidationResponse.
10 11 12 |
# File 'lib/rack-cas/service_validation_response.rb', line 10 def initialize(url) @url = URL.parse(url) end |
Instance Method Details
#extra_attributes ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rack-cas/service_validation_response.rb', line 31 def extra_attributes attrs = {} raise AuthenticationFailure, unless success? # Jasig style if attr_node = xml.at('//serviceResponse/authenticationSuccess/attributes') attrs = parse_user_info(attr_node) # RubyCas-Server style else xml.at('//serviceResponse/authenticationSuccess').children.each do |node| if node.is_a? Nokogiri::XML::Element if !node.namespace || !node.namespace.prefix == 'cas' # TODO: support JSON encoding attrs[node.name] = YAML.load node.text.strip end end end end attrs end |
#user ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rack-cas/service_validation_response.rb', line 14 def user if success? xml.at('//serviceResponse/authenticationSuccess/user').text else case failure_code when 'INVALID_REQUEST' raise RequestInvalidError, when 'INVALID_TICKET' raise TicketInvalidError, when 'INVALID_SERVICE' raise ServiceInvalidError, else raise AuthenticationFailure, end end end |