10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/warden/strategy.rb', line 10
def authenticate!
config = Rails.configuration
handler = Identity::ConnectionHandler.new config.identity_key, config.identity_key_password, config.identity_certificate, config.identity_truststore
@provider = Identity::Provider::IdentityServiceProvider.new handler
if session[:identity_username_key].nil? && session[:identity_display_items].nil?
pretext = @provider.pre_authenticate params["username"], request.ip
if pretext.result['content'] == 'SUCCESS'
session[:identity_username_key] = pretext.name
session[:identity_display_items] = pretext.display_items
else
fail! pretext.result['message']
end
elsif !session[:identity_display_items].nil?
parameters = {}
session[:identity_display_items].each do |display_item|
key = display_item['name']
Rails.logger.debug "looking for #{key}"
parameters[key] = params[key]
end
context = @provider.authenticate session[:identity_username_key], request.ip, parameters
case context.result['content']
when 'CONTINUE'
session[:identity_display_items] = context.display_items
flash[:notice] = context.result['message']
when 'RESET'
session[:identity_username_key] = nil
session[:identity_display_items] = nil
when 'SUCCESS'
username = context.name
session[:identity_username_key] = nil
session[:identity_display_items] = nil
user = User.new(:username => username)
success! user
else
fail! context.result['message']
end
end
end
|