Class: Castanet::Responses::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/castanet/responses/proxy.rb

Overview

A parsed representation of responses from /proxy.

The code in this class implements a state machine generated by Ragel. The state machine definition is in proxy.rl.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

._proxy_actionsObject

Returns the value of attribute _proxy_actions.



193
194
195
# File 'lib/castanet/responses/proxy.rb', line 193

def _proxy_actions
  @_proxy_actions
end

._proxy_index_offsetsObject

Returns the value of attribute _proxy_index_offsets.



343
344
345
# File 'lib/castanet/responses/proxy.rb', line 343

def _proxy_index_offsets
  @_proxy_index_offsets
end

._proxy_key_offsetsObject

Returns the value of attribute _proxy_key_offsets.



202
203
204
# File 'lib/castanet/responses/proxy.rb', line 202

def _proxy_key_offsets
  @_proxy_key_offsets
end

._proxy_range_lengthsObject

Returns the value of attribute _proxy_range_lengths.



309
310
311
# File 'lib/castanet/responses/proxy.rb', line 309

def _proxy_range_lengths
  @_proxy_range_lengths
end

._proxy_single_lengthsObject

Returns the value of attribute _proxy_single_lengths.



275
276
277
# File 'lib/castanet/responses/proxy.rb', line 275

def _proxy_single_lengths
  @_proxy_single_lengths
end

._proxy_trans_actionsObject

Returns the value of attribute _proxy_trans_actions.



442
443
444
# File 'lib/castanet/responses/proxy.rb', line 442

def _proxy_trans_actions
  @_proxy_trans_actions
end

._proxy_trans_keysObject

Returns the value of attribute _proxy_trans_keys.



236
237
238
# File 'lib/castanet/responses/proxy.rb', line 236

def _proxy_trans_keys
  @_proxy_trans_keys
end

._proxy_trans_targsObject

Returns the value of attribute _proxy_trans_targs.



377
378
379
# File 'lib/castanet/responses/proxy.rb', line 377

def _proxy_trans_targs
  @_proxy_trans_targs
end

.proxy_en_mainObject

Returns the value of attribute proxy_en_main.



520
521
522
# File 'lib/castanet/responses/proxy.rb', line 520

def proxy_en_main
  @proxy_en_main
end

.proxy_errorObject

Returns the value of attribute proxy_error.



515
516
517
# File 'lib/castanet/responses/proxy.rb', line 515

def proxy_error
  @proxy_error
end

.proxy_first_finalObject

Returns the value of attribute proxy_first_final.



511
512
513
# File 'lib/castanet/responses/proxy.rb', line 511

def proxy_first_final
  @proxy_first_final
end

.proxy_startObject

Returns the value of attribute proxy_start.



507
508
509
# File 'lib/castanet/responses/proxy.rb', line 507

def proxy_start
  @proxy_start
end

Instance Attribute Details

#failure_codeString?

On ticket issuance failure, contains the code identifying the nature of the failure.

On success, is nil.

Returns:

  • (String, nil)

See Also:



38
39
40
# File 'lib/castanet/responses/proxy.rb', line 38

def failure_code
  @failure_code
end

#failure_reasonString?

On ticket issuance failure, contains the failure reason.

On success, is nil.

Returns:

  • (String, nil)

See Also:



47
48
49
# File 'lib/castanet/responses/proxy.rb', line 47

def failure_reason
  @failure_reason
end

#okBoolean Also known as: ok?

Whether or not a proxy ticket could be issued.

Returns:

  • (Boolean)


18
19
20
# File 'lib/castanet/responses/proxy.rb', line 18

def ok
  @ok
end

#ticketString?

The proxy ticket issued by the CAS server.

If #ok is false, this will be nil.

Returns:

  • (String, nil)


28
29
30
# File 'lib/castanet/responses/proxy.rb', line 28

def ticket
  @ticket
end

Class Method Details

.from_cas(response) ⇒ Proxy

Generates a Castanet::Responses::Proxy object from a CAS response.

Parameters:

  • response (String)

    the CAS response

Returns:



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/castanet/responses/proxy.rb', line 54

def self.from_cas(response)
  data = response.strip.unpack('U*')
  buffer = ''

  
begin
	p ||= 0
	pe ||= data.length
	cs = proxy_start
end


  new.tap do |r|
    
begin
	_klen, _trans, _keys, _acts, _nacts = nil
	_goto_level = 0
	_resume = 10
	_eof_trans = 15
	_again = 20
	_test_eof = 30
	_out = 40
	while true
	_trigger_goto = false
	if _goto_level <= 0
	if p == pe
		_goto_level = _test_eof
		next
	end
	if cs == 0
		_goto_level = _out
		next
	end
	end
	if _goto_level <= _resume
	_keys = _proxy_key_offsets[cs]
	_trans = _proxy_index_offsets[cs]
	_klen = _proxy_single_lengths[cs]
	_break_match = false
	
	begin
	  if _klen > 0
  _lower = _keys
  _upper = _keys + _klen - 1

  loop do
     break if _upper < _lower
     _mid = _lower + ( (_upper - _lower) >> 1 )

     if data[p] < _proxy_trans_keys[_mid]
        _upper = _mid - 1
     elsif data[p] > _proxy_trans_keys[_mid]
        _lower = _mid + 1
     else
        _trans += (_mid - _keys)
        _break_match = true
        break
     end
  end # loop
  break if _break_match
  _keys += _klen
  _trans += _klen
	  end
	  _klen = _proxy_range_lengths[cs]
	  if _klen > 0
  _lower = _keys
  _upper = _keys + (_klen << 1) - 2
  loop do
     break if _upper < _lower
     _mid = _lower + (((_upper-_lower) >> 1) & ~1)
     if data[p] < _proxy_trans_keys[_mid]
       _upper = _mid - 2
     elsif data[p] > _proxy_trans_keys[_mid+1]
       _lower = _mid + 2
     else
       _trans += ((_mid - _keys) >> 1)
       _break_match = true
       break
     end
  end # loop
  break if _break_match
  _trans += _klen
	  end
	end while false
	cs = _proxy_trans_targs[_trans]
	if _proxy_trans_actions[_trans] != 0
		_acts = _proxy_trans_actions[_trans]
		_nacts = _proxy_actions[_acts]
		_acts += 1
		while _nacts > 0
			_nacts -= 1
			_acts += 1
			case _proxy_actions[_acts - 1]
when 0 then
		begin
 buffer << data[p] 		end
when 1 then
		begin
 r.failure_code = buffer; buffer = '' 		end
when 2 then
		begin
 r.failure_reason = buffer.strip; buffer = '' 		end
when 3 then
		begin
 r.ticket = buffer; buffer = '' 		end
when 4 then
		begin
 r.ok = true 		end
			end # action switch
		end
	end
	if _trigger_goto
		next
	end
	end
	if _goto_level <= _again
	if cs == 0
		_goto_level = _out
		next
	end
	p += 1
	if p != pe
		_goto_level = _resume
		next
	end
	end
	if _goto_level <= _test_eof
	end
	if _goto_level <= _out
		break
	end
	end
	end

  end
end