josso-client 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+ require 'defaultDriver.rb'
3
+
4
+ endpoint_url = ARGV.shift
5
+ obj = SSOIdentityManager.new(endpoint_url)
6
+
7
+ # run ruby with -d to see SOAP wiredumps.
8
+ obj.wiredump_dev = STDERR if $DEBUG
9
+
10
+ # SYNOPSIS
11
+ # findUser(in0)
12
+ #
13
+ # ARGS
14
+ # in0 String - {http://www.w3.org/2001/XMLSchema}string
15
+ #
16
+ # RETURNS
17
+ # findUserReturn SSOUser - {http://josso.org/gateway/identity/service/ws/impl}SSOUser
18
+ #
19
+ # RAISES
20
+ # # fault NoSuchUserException - {http://josso.org/gateway/identity/service/ws/impl}NoSuchUserException, # fault SSOIdentityException - {http://josso.org/gateway/identity/service/ws/impl}SSOIdentityException
21
+ #
22
+ in0 = nil
23
+ puts obj.findUser(in0)
24
+
25
+ # SYNOPSIS
26
+ # findUserInSession(in0)
27
+ #
28
+ # ARGS
29
+ # in0 String - {http://www.w3.org/2001/XMLSchema}string
30
+ #
31
+ # RETURNS
32
+ # findUserInSessionReturn SSOUser - {http://josso.org/gateway/identity/service/ws/impl}SSOUser
33
+ #
34
+ # RAISES
35
+ # # fault NoSuchUserException - {http://josso.org/gateway/identity/service/ws/impl}NoSuchUserException, # fault SSOIdentityException - {http://josso.org/gateway/identity/service/ws/impl}SSOIdentityException
36
+ #
37
+ in0 = nil
38
+ puts obj.findUserInSession(in0)
39
+
40
+ # SYNOPSIS
41
+ # findRolesByUsername(in0)
42
+ #
43
+ # ARGS
44
+ # in0 String - {http://www.w3.org/2001/XMLSchema}string
45
+ #
46
+ # RETURNS
47
+ # findRolesByUsernameReturn ArrayOfSSORole - {http://josso.org/gateway/identity/service/ws/impl}ArrayOfSSORole
48
+ #
49
+ # RAISES
50
+ # # fault SSOIdentityException - {http://josso.org/gateway/identity/service/ws/impl}SSOIdentityException
51
+ #
52
+ in0 = nil
53
+ puts obj.findRolesByUsername(in0)
54
+
55
+ # SYNOPSIS
56
+ # userExists(in0)
57
+ #
58
+ # ARGS
59
+ # in0 String - {http://www.w3.org/2001/XMLSchema}string
60
+ #
61
+ # RETURNS
62
+ # N/A
63
+ #
64
+ # RAISES
65
+ # # fault NoSuchUserException - {http://josso.org/gateway/identity/service/ws/impl}NoSuchUserException, # fault SSOIdentityException - {http://josso.org/gateway/identity/service/ws/impl}SSOIdentityException
66
+ #
67
+ in0 = nil
68
+ puts obj.userExists(in0)
69
+
70
+ # SYNOPSIS
71
+ # initialize
72
+ #
73
+ # ARGS
74
+ # N/A
75
+ #
76
+ # RETURNS
77
+ # N/A
78
+ #
79
+
80
+ puts obj.initialize
81
+
82
+
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+ require 'defaultDriver.rb'
3
+
4
+ endpoint_url = ARGV.shift
5
+ obj = SSOIdentityProvider.new(endpoint_url)
6
+
7
+ # run ruby with -d to see SOAP wiredumps.
8
+ obj.wiredump_dev = STDERR if $DEBUG
9
+
10
+ # SYNOPSIS
11
+ # assertIdentityWithSimpleAuthentication(in0, in1)
12
+ #
13
+ # ARGS
14
+ # in0 String - {http://www.w3.org/2001/XMLSchema}string
15
+ # in1 String - {http://www.w3.org/2001/XMLSchema}string
16
+ #
17
+ # RETURNS
18
+ # assertIdentityWithSimpleAuthenticationReturn String - {http://www.w3.org/2001/XMLSchema}string
19
+ #
20
+ # RAISES
21
+ # # fault IdentityProvisioningException - {http://josso.org/gateway/identity/service/ws/impl}IdentityProvisioningException
22
+ #
23
+ in0 = in1 = nil
24
+ puts obj.assertIdentityWithSimpleAuthentication(in0, in1)
25
+
26
+ # SYNOPSIS
27
+ # resolveAuthenticationAssertion(in0)
28
+ #
29
+ # ARGS
30
+ # in0 String - {http://www.w3.org/2001/XMLSchema}string
31
+ #
32
+ # RETURNS
33
+ # resolveAuthenticationAssertionReturn String - {http://www.w3.org/2001/XMLSchema}string
34
+ #
35
+ # RAISES
36
+ # # fault AssertionNotValidException - {http://josso.org/gateway/session/service/ws/impl}AssertionNotValidException, # fault IdentityProvisioningException - {http://josso.org/gateway/identity/service/ws/impl}IdentityProvisioningException
37
+ #
38
+ in0 = nil
39
+ puts obj.resolveAuthenticationAssertion(in0)
40
+
41
+ # SYNOPSIS
42
+ # globalSignoff(in0)
43
+ #
44
+ # ARGS
45
+ # in0 String - {http://www.w3.org/2001/XMLSchema}string
46
+ #
47
+ # RETURNS
48
+ # N/A
49
+ #
50
+ # RAISES
51
+ # # fault IdentityProvisioningException - {http://josso.org/gateway/identity/service/ws/impl}IdentityProvisioningException
52
+ #
53
+ in0 = nil
54
+ puts obj.globalSignoff(in0)
55
+
56
+
@@ -0,0 +1,41 @@
1
+ require 'xsd/qname'
2
+
3
+ # {http://josso.org/gateway/identity/service/ws/impl}SSOIdentityException
4
+ class SSOIdentityException
5
+ @@schema_type = "SSOIdentityException"
6
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
7
+ @@schema_element = []
8
+
9
+ def initialize
10
+ end
11
+ end
12
+
13
+ # {http://josso.org/gateway/identity/service/ws/impl}IdentityProvisioningException
14
+ class IdentityProvisioningException < ::StandardError
15
+ @@schema_type = "IdentityProvisioningException"
16
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
17
+ @@schema_element = []
18
+
19
+ def initialize
20
+ end
21
+ end
22
+
23
+ # {http://josso.org/gateway/session/service/ws/impl}AssertionException
24
+ class AssertionException
25
+ @@schema_type = "AssertionException"
26
+ @@schema_ns = "http://josso.org/gateway/session/service/ws/impl"
27
+ @@schema_element = []
28
+
29
+ def initialize
30
+ end
31
+ end
32
+
33
+ # {http://josso.org/gateway/session/service/ws/impl}AssertionNotValidException
34
+ class AssertionNotValidException < ::StandardError
35
+ @@schema_type = "AssertionNotValidException"
36
+ @@schema_ns = "http://josso.org/gateway/session/service/ws/impl"
37
+ @@schema_element = []
38
+
39
+ def initialize
40
+ end
41
+ end
@@ -0,0 +1,108 @@
1
+ require 'wsdl_classes.rb'
2
+
3
+ require 'soap/rpc/driver'
4
+
5
+ class SSOIdentityManager < ::SOAP::RPC::Driver
6
+ DefaultEndpointUrl = "http://fuo.bj.finalist.com:8888/josso/services/SSOIdentityManager"
7
+ MappingRegistry = ::SOAP::Mapping::Registry.new
8
+
9
+ MappingRegistry.set(
10
+ SSOUser,
11
+ ::SOAP::SOAPStruct,
12
+ ::SOAP::Mapping::Registry::TypedStructFactory,
13
+ { :type => XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "SSOUser") }
14
+ )
15
+ MappingRegistry.set(
16
+ ArrayOfSSONameValuePair,
17
+ ::SOAP::SOAPArray,
18
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
19
+ { :type => XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "SSONameValuePair") }
20
+ )
21
+ MappingRegistry.set(
22
+ ArrayOfSSORole,
23
+ ::SOAP::SOAPArray,
24
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
25
+ { :type => XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "SSORole") }
26
+ )
27
+ MappingRegistry.set(
28
+ SSONameValuePair,
29
+ ::SOAP::SOAPStruct,
30
+ ::SOAP::Mapping::Registry::TypedStructFactory,
31
+ { :type => XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "SSONameValuePair") }
32
+ )
33
+ MappingRegistry.set(
34
+ SSORole,
35
+ ::SOAP::SOAPStruct,
36
+ ::SOAP::Mapping::Registry::TypedStructFactory,
37
+ { :type => XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "SSORole") }
38
+ )
39
+
40
+ Methods = [
41
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "findUser"),
42
+ "",
43
+ "findUser",
44
+ [ ["in", "in0", ["::SOAP::SOAPString"]],
45
+ ["retval", "findUserReturn", ["SSOUser", "http://josso.org/gateway/identity/service/ws/impl", "SSOUser"]] ],
46
+ { :request_style => :rpc, :request_use => :encoded,
47
+ :response_style => :rpc, :response_use => :encoded }
48
+ ],
49
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "findUserInSession"),
50
+ "",
51
+ "findUserInSession",
52
+ [ ["in", "in0", ["::SOAP::SOAPString"]],
53
+ ["retval", "findUserInSessionReturn", ["SSOUser", "http://josso.org/gateway/identity/service/ws/impl", "SSOUser"]] ],
54
+ { :request_style => :rpc, :request_use => :encoded,
55
+ :response_style => :rpc, :response_use => :encoded }
56
+ ],
57
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "findRolesByUsername"),
58
+ "",
59
+ "findRolesByUsername",
60
+ [ ["in", "in0", ["::SOAP::SOAPString"]],
61
+ ["retval", "findRolesByUsernameReturn", ["SSORole[]", "http://josso.org/gateway/identity/service/ws/impl", "SSORole"]] ],
62
+ { :request_style => :rpc, :request_use => :encoded,
63
+ :response_style => :rpc, :response_use => :encoded }
64
+ ],
65
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "userExists"),
66
+ "",
67
+ "userExists",
68
+ [ ["in", "in0", ["::SOAP::SOAPString"]] ],
69
+ { :request_style => :rpc, :request_use => :encoded,
70
+ :response_style => :rpc, :response_use => :encoded }
71
+ ],
72
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "initialize"),
73
+ "",
74
+ "initialize",
75
+ [],
76
+ { :request_style => :rpc, :request_use => :encoded,
77
+ :response_style => :rpc, :response_use => :encoded }
78
+ ]
79
+ ]
80
+
81
+ def initialize(endpoint_url = nil)
82
+ endpoint_url ||= DefaultEndpointUrl
83
+ super(endpoint_url, nil)
84
+ self.mapping_registry = MappingRegistry
85
+ init_methods
86
+ end
87
+
88
+ private
89
+
90
+ def init_methods
91
+ Methods.each do |definitions|
92
+ opt = definitions.last
93
+ if opt[:request_style] == :document
94
+ add_document_operation(*definitions)
95
+ else
96
+ add_rpc_operation(*definitions)
97
+ qname = definitions[0]
98
+ name = definitions[2]
99
+ if qname.name != name and qname.name.capitalize == name.capitalize
100
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
101
+ __send__(name, *arg)
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+
@@ -0,0 +1,63 @@
1
+ require 'identity_provider_exceptions.rb'
2
+
3
+ require 'soap/rpc/driver'
4
+
5
+ class SSOIdentityProvider < ::SOAP::RPC::Driver
6
+ DefaultEndpointUrl = "http://fuo.bj.finalist.com:8888/josso/services/SSOIdentityProvider"
7
+ MappingRegistry = ::SOAP::Mapping::Registry.new
8
+
9
+ Methods = [
10
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "assertIdentityWithSimpleAuthentication"),
11
+ "",
12
+ "assertIdentityWithSimpleAuthentication",
13
+ [ ["in", "in0", ["::SOAP::SOAPString"]],
14
+ ["in", "in1", ["::SOAP::SOAPString"]],
15
+ ["retval", "assertIdentityWithSimpleAuthenticationReturn", ["::SOAP::SOAPString"]] ],
16
+ { :request_style => :rpc, :request_use => :encoded,
17
+ :response_style => :rpc, :response_use => :encoded }
18
+ ],
19
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "resolveAuthenticationAssertion"),
20
+ "",
21
+ "resolveAuthenticationAssertion",
22
+ [ ["in", "in0", ["::SOAP::SOAPString"]],
23
+ ["retval", "resolveAuthenticationAssertionReturn", ["::SOAP::SOAPString"]] ],
24
+ { :request_style => :rpc, :request_use => :encoded,
25
+ :response_style => :rpc, :response_use => :encoded }
26
+ ],
27
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "globalSignoff"),
28
+ "",
29
+ "globalSignoff",
30
+ [ ["in", "in0", ["::SOAP::SOAPString"]] ],
31
+ { :request_style => :rpc, :request_use => :encoded,
32
+ :response_style => :rpc, :response_use => :encoded }
33
+ ]
34
+ ]
35
+
36
+ def initialize(endpoint_url = nil)
37
+ endpoint_url ||= DefaultEndpointUrl
38
+ super(endpoint_url, nil)
39
+ self.mapping_registry = MappingRegistry
40
+ init_methods
41
+ end
42
+
43
+ private
44
+
45
+ def init_methods
46
+ Methods.each do |definitions|
47
+ opt = definitions.last
48
+ if opt[:request_style] == :document
49
+ add_document_operation(*definitions)
50
+ else
51
+ add_rpc_operation(*definitions)
52
+ qname = definitions[0]
53
+ name = definitions[2]
54
+ if qname.name != name and qname.name.capitalize == name.capitalize
55
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
56
+ __send__(name, *arg)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
@@ -0,0 +1,80 @@
1
+ require 'xsd/qname'
2
+
3
+ # {http://josso.org/gateway/identity/service/ws/impl}SSONameValuePair
4
+ class SSONameValuePair
5
+ @@schema_type = "SSONameValuePair"
6
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
7
+ @@schema_element = [["name", ["SOAP::SOAPString", XSD::QName.new(nil, "name")]], ["value", ["SOAP::SOAPString", XSD::QName.new(nil, "value")]]]
8
+
9
+ attr_accessor :name
10
+ attr_accessor :value
11
+
12
+ def initialize(name = nil, value = nil)
13
+ @name = name
14
+ @value = value
15
+ end
16
+ end
17
+
18
+ # {http://josso.org/gateway/identity/service/ws/impl}ArrayOfSSONameValuePair
19
+ class ArrayOfSSONameValuePair < ::Array
20
+ @@schema_type = "SSONameValuePair"
21
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
22
+ @@schema_element = [["item", ["SSONameValuePair", XSD::QName.new(nil, "item")]]]
23
+ end
24
+
25
+ # {http://josso.org/gateway/identity/service/ws/impl}SSOUser
26
+ class SSOUser
27
+ @@schema_type = "SSOUser"
28
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
29
+ @@schema_element = [["name", ["SOAP::SOAPString", XSD::QName.new(nil, "name")]], ["properties", ["ArrayOfSSONameValuePair", XSD::QName.new(nil, "properties")]], ["sessionId", ["SOAP::SOAPString", XSD::QName.new(nil, "sessionId")]]]
30
+
31
+ attr_accessor :name
32
+ attr_accessor :properties
33
+ attr_accessor :sessionId
34
+
35
+ def initialize(name = nil, properties = nil, sessionId = nil)
36
+ @name = name
37
+ @properties = properties
38
+ @sessionId = sessionId
39
+ end
40
+ end
41
+
42
+ # {http://josso.org/gateway/identity/service/ws/impl}SSOIdentityException
43
+ class SSOIdentityException < ::StandardError
44
+ @@schema_type = "SSOIdentityException"
45
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
46
+ @@schema_element = []
47
+
48
+ def initialize
49
+ end
50
+ end
51
+
52
+ # {http://josso.org/gateway/identity/service/ws/impl}NoSuchUserException
53
+ class NoSuchUserException < ::StandardError
54
+ @@schema_type = "NoSuchUserException"
55
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
56
+ @@schema_element = []
57
+
58
+ def initialize
59
+ end
60
+ end
61
+
62
+ # {http://josso.org/gateway/identity/service/ws/impl}SSORole
63
+ class SSORole
64
+ @@schema_type = "SSORole"
65
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
66
+ @@schema_element = [["name", ["SOAP::SOAPString", XSD::QName.new(nil, "name")]]]
67
+
68
+ attr_accessor :name
69
+
70
+ def initialize(name = nil)
71
+ @name = name
72
+ end
73
+ end
74
+
75
+ # {http://josso.org/gateway/identity/service/ws/impl}ArrayOfSSORole
76
+ class ArrayOfSSORole < ::Array
77
+ @@schema_type = "SSORole"
78
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
79
+ @@schema_element = [["item", ["SSORole", XSD::QName.new(nil, "item")]]]
80
+ end
@@ -0,0 +1,49 @@
1
+ require 'sso_identity_manager.rb'
2
+ require 'sso_identity_provider.rb'
3
+
4
+ class Jossoagent
5
+
6
+ def initialize(sso_identity_manager_endpoint_url = nil,sso_identity_provider_endpoint_url = nil)
7
+ @agent_identity_manager = SSOIdentityManager.new(sso_identity_manager_endpoint_url)
8
+ @sso_identity_provider = SSOIdentityProvider.new(sso_identity_provider_endpoint_url)
9
+ end
10
+
11
+ def find_roles_by_username(username)
12
+ @agent_identity_manager.findRolesByUsername(username)
13
+ end
14
+
15
+ def find_user(username)
16
+ begin
17
+ @roles = @agent_identity_manager.findUser(username)
18
+ rescue SOAP::FaultError
19
+ return nil
20
+ else
21
+ return @roles
22
+ end
23
+ end
24
+
25
+ def find_user_in_session(josso_session_id)
26
+ begin
27
+ @sso_user = @agent_identity_manager.findUserInSession(josso_session_id)
28
+ rescue SOAP::FaultError
29
+ return nil
30
+ else
31
+ return @sso_user
32
+ end
33
+ end
34
+
35
+ def get_josso_session_id(josso_assertionid)
36
+ begin
37
+ @josso_session_id = @sso_identity_provider.resolveAuthenticationAssertion(josso_assertionid)
38
+ rescue SOAP::FaultError
39
+ return nil
40
+ else
41
+ return @josso_session_id
42
+ end
43
+ end
44
+
45
+ def logout(josso_session_id)
46
+ @sso_identity_provider.globalSignoff(josso_session_id)
47
+ end
48
+
49
+ end
data/lib/main.rb ADDED
@@ -0,0 +1,110 @@
1
+ require 'josso_agent.rb'
2
+
3
+ module Main
4
+ APP_CONFIG = YAML.load_file(RAILS_ROOT + '/config/josso_config.yml')[RAILS_ENV]
5
+
6
+ def self.included(base_class)
7
+ base_class.extend(ClassMethods)
8
+ end
9
+
10
+ # All the methods In this subModule JossoRorAgent::ClassMethods are static methods for the extended target.
11
+ module ClassMethods
12
+ # PlugIn entry
13
+ def inject_josso_agent
14
+ before_filter :authorize
15
+ end
16
+
17
+ # look up roles for user
18
+ def get_roles
19
+ jossoagent = Jossoagent.new(APP_CONFIG['josso_root'] + 'services/SSOIdentityManager', APP_CONFIG['josso_root'] + 'services/SSOIdentityProvider')
20
+ user = jossoagent.find_user_in_session(session[:josso_session_id])
21
+
22
+ if user.nil?
23
+ return nil
24
+ end
25
+
26
+ return jossoagent.find_roles_by_username(user)
27
+ end
28
+ end
29
+
30
+ private
31
+ # Check the user's authority
32
+ def authorize
33
+ begin
34
+ partner_application_entry_url = request.url
35
+ puts partner_application_entry_url
36
+ if (session[:username].nil?)
37
+ login(partner_application_entry_url, params[:josso_assertion_id])
38
+ else
39
+ is_josso_session_expire(partner_application_entry_url)
40
+ end
41
+ end
42
+ end
43
+
44
+ def login(partner_application_entry_url, josso_assertion_id)
45
+ begin
46
+ if (josso_assertion_id.nil?)
47
+ redirect_to APP_CONFIG['josso_root'] + "signon/login.do?josso_back_to=" + partner_application_entry_url
48
+ else
49
+ jossoagent = Jossoagent.new(APP_CONFIG['josso_root'] + 'services/SSOIdentityManager', APP_CONFIG['josso_root'] + 'services/SSOIdentityProvider')
50
+ josso_session_id = jossoagent.get_josso_session_id(josso_assertion_id)
51
+ if (josso_session_id.nil?)
52
+ reset_session
53
+ redirect_to APP_CONFIG['josso_root'] + "signon/login.do?josso_back_to=" + partner_application_entry_url
54
+ # login_error('Sorry! Generate josso_session_id error.')
55
+ return false
56
+ end
57
+ session[:josso_session_id] = josso_session_id
58
+ sso_user = jossoagent.find_user_in_session(josso_session_id)
59
+ if (sso_user.nil?)
60
+ reset_session
61
+ redirect_to APP_CONFIG['josso_root'] + "signon/login.do?josso_back_to=" + partner_application_entry_url
62
+ # login_error('Sorry! Fetching sso_user error.')
63
+ return false
64
+ else
65
+ session[:username] = sso_user.name
66
+ session[:session_timer_at] = Time.now.to_i
67
+ end
68
+ redirect_to partner_application_entry_url
69
+ end
70
+ rescue Exception => e
71
+ #redirect to unique error page of rece system
72
+ puts e
73
+ end
74
+ end
75
+
76
+ # Judge the expiry of the session
77
+ def is_josso_session_expire(partner_application_entry_url)
78
+ begin
79
+ puts 30.minutes.to_i
80
+ if(((Time.now.to_i - session[:session_timer_at].to_i) > 1800))
81
+ logout()
82
+ else
83
+ session[:session_timer_at] = Time.now.to_i
84
+ end
85
+ end
86
+ end
87
+
88
+
89
+
90
+ # Logout from the Josso
91
+ def logout()
92
+ begin
93
+ if(!session[:josso_session_id].nil?)
94
+ jossoagent = Jossoagent.new(APP_CONFIG['josso_root'] + 'services/SSOIdentityManager', APP_CONFIG['josso_root'] + 'services/SSOIdentityProvider')
95
+ jossoagent.logout(session[:josso_session_id])
96
+ end
97
+ rescue Exception => e
98
+ puts e
99
+ ensure
100
+ #redirect to unique error page of rece system
101
+ reset_session
102
+ redirect_to APP_CONFIG['partner_application_entry_url']
103
+ end
104
+ end
105
+
106
+ def login_error(error_message)
107
+ flash[:error_login] = error_message
108
+ @redirect_to_url = APP_CONFIG['josso_root'] + 'signon/login.do'
109
+ end
110
+ end
@@ -0,0 +1,108 @@
1
+ require 'sso_identity_manager_classes.rb'
2
+
3
+ require 'soap/rpc/driver'
4
+
5
+ class SSOIdentityManager < ::SOAP::RPC::Driver
6
+ DefaultEndpointUrl = "http://localhost:8080/josso/services/SSOIdentityManager"
7
+ MappingRegistry = ::SOAP::Mapping::Registry.new
8
+
9
+ MappingRegistry.set(
10
+ SSOUser,
11
+ ::SOAP::SOAPStruct,
12
+ ::SOAP::Mapping::Registry::TypedStructFactory,
13
+ { :type => XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "SSOUser") }
14
+ )
15
+ MappingRegistry.set(
16
+ ArrayOfSSONameValuePair,
17
+ ::SOAP::SOAPArray,
18
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
19
+ { :type => XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "SSONameValuePair") }
20
+ )
21
+ MappingRegistry.set(
22
+ ArrayOfSSORole,
23
+ ::SOAP::SOAPArray,
24
+ ::SOAP::Mapping::Registry::TypedArrayFactory,
25
+ { :type => XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "SSORole") }
26
+ )
27
+ MappingRegistry.set(
28
+ SSONameValuePair,
29
+ ::SOAP::SOAPStruct,
30
+ ::SOAP::Mapping::Registry::TypedStructFactory,
31
+ { :type => XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "SSONameValuePair") }
32
+ )
33
+ MappingRegistry.set(
34
+ SSORole,
35
+ ::SOAP::SOAPStruct,
36
+ ::SOAP::Mapping::Registry::TypedStructFactory,
37
+ { :type => XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "SSORole") }
38
+ )
39
+
40
+ Methods = [
41
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "findUser"),
42
+ "",
43
+ "findUser",
44
+ [ ["in", "in0", ["::SOAP::SOAPString"]],
45
+ ["retval", "findUserReturn", ["SSOUser", "http://josso.org/gateway/identity/service/ws/impl", "SSOUser"]] ],
46
+ { :request_style => :rpc, :request_use => :encoded,
47
+ :response_style => :rpc, :response_use => :encoded }
48
+ ],
49
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "findUserInSession"),
50
+ "",
51
+ "findUserInSession",
52
+ [ ["in", "in0", ["::SOAP::SOAPString"]],
53
+ ["retval", "findUserInSessionReturn", ["SSOUser", "http://josso.org/gateway/identity/service/ws/impl", "SSOUser"]] ],
54
+ { :request_style => :rpc, :request_use => :encoded,
55
+ :response_style => :rpc, :response_use => :encoded }
56
+ ],
57
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "findRolesByUsername"),
58
+ "",
59
+ "findRolesByUsername",
60
+ [ ["in", "in0", ["::SOAP::SOAPString"]],
61
+ ["retval", "findRolesByUsernameReturn", ["SSORole[]", "http://josso.org/gateway/identity/service/ws/impl", "SSORole"]] ],
62
+ { :request_style => :rpc, :request_use => :encoded,
63
+ :response_style => :rpc, :response_use => :encoded }
64
+ ],
65
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "userExists"),
66
+ "",
67
+ "userExists",
68
+ [ ["in", "in0", ["::SOAP::SOAPString"]] ],
69
+ { :request_style => :rpc, :request_use => :encoded,
70
+ :response_style => :rpc, :response_use => :encoded }
71
+ ],
72
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "initialize"),
73
+ "",
74
+ "initialize",
75
+ [],
76
+ { :request_style => :rpc, :request_use => :encoded,
77
+ :response_style => :rpc, :response_use => :encoded }
78
+ ]
79
+ ]
80
+
81
+ def initialize(endpoint_url = nil)
82
+ endpoint_url ||= DefaultEndpointUrl
83
+ super(endpoint_url, nil)
84
+ self.mapping_registry = MappingRegistry
85
+ init_methods
86
+ end
87
+
88
+ private
89
+
90
+ def init_methods
91
+ Methods.each do |definitions|
92
+ opt = definitions.last
93
+ if opt[:request_style] == :document
94
+ add_document_operation(*definitions)
95
+ else
96
+ add_rpc_operation(*definitions)
97
+ qname = definitions[0]
98
+ name = definitions[2]
99
+ if qname.name != name and qname.name.capitalize == name.capitalize
100
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
101
+ __send__(name, *arg)
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+
@@ -0,0 +1,80 @@
1
+ require 'xsd/qname'
2
+
3
+ # {http://josso.org/gateway/identity/service/ws/impl}SSONameValuePair
4
+ class SSONameValuePair
5
+ @@schema_type = "SSONameValuePair"
6
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
7
+ @@schema_element = [["name", ["SOAP::SOAPString", XSD::QName.new(nil, "name")]], ["value", ["SOAP::SOAPString", XSD::QName.new(nil, "value")]]]
8
+
9
+ attr_accessor :name
10
+ attr_accessor :value
11
+
12
+ def initialize(name = nil, value = nil)
13
+ @name = name
14
+ @value = value
15
+ end
16
+ end
17
+
18
+ # {http://josso.org/gateway/identity/service/ws/impl}ArrayOfSSONameValuePair
19
+ class ArrayOfSSONameValuePair < ::Array
20
+ @@schema_type = "SSONameValuePair"
21
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
22
+ @@schema_element = [["item", ["SSONameValuePair", XSD::QName.new(nil, "item")]]]
23
+ end
24
+
25
+ # {http://josso.org/gateway/identity/service/ws/impl}SSOUser
26
+ class SSOUser
27
+ @@schema_type = "SSOUser"
28
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
29
+ @@schema_element = [["name", ["SOAP::SOAPString", XSD::QName.new(nil, "name")]], ["properties", ["ArrayOfSSONameValuePair", XSD::QName.new(nil, "properties")]], ["sessionId", ["SOAP::SOAPString", XSD::QName.new(nil, "sessionId")]]]
30
+
31
+ attr_accessor :name
32
+ attr_accessor :properties
33
+ attr_accessor :sessionId
34
+
35
+ def initialize(name = nil, properties = nil, sessionId = nil)
36
+ @name = name
37
+ @properties = properties
38
+ @sessionId = sessionId
39
+ end
40
+ end
41
+
42
+ # {http://josso.org/gateway/identity/service/ws/impl}SSOIdentityException
43
+ class SSOIdentityException < ::StandardError
44
+ @@schema_type = "SSOIdentityException"
45
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
46
+ @@schema_element = []
47
+
48
+ def initialize
49
+ end
50
+ end
51
+
52
+ # {http://josso.org/gateway/identity/service/ws/impl}NoSuchUserException
53
+ class NoSuchUserException < ::StandardError
54
+ @@schema_type = "NoSuchUserException"
55
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
56
+ @@schema_element = []
57
+
58
+ def initialize
59
+ end
60
+ end
61
+
62
+ # {http://josso.org/gateway/identity/service/ws/impl}SSORole
63
+ class SSORole
64
+ @@schema_type = "SSORole"
65
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
66
+ @@schema_element = [["name", ["SOAP::SOAPString", XSD::QName.new(nil, "name")]]]
67
+
68
+ attr_accessor :name
69
+
70
+ def initialize(name = nil)
71
+ @name = name
72
+ end
73
+ end
74
+
75
+ # {http://josso.org/gateway/identity/service/ws/impl}ArrayOfSSORole
76
+ class ArrayOfSSORole < ::Array
77
+ @@schema_type = "SSORole"
78
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
79
+ @@schema_element = [["item", ["SSORole", XSD::QName.new(nil, "item")]]]
80
+ end
@@ -0,0 +1,63 @@
1
+ require 'sso_identity_provider_classes.rb'
2
+
3
+ require 'soap/rpc/driver'
4
+
5
+ class SSOIdentityProvider < ::SOAP::RPC::Driver
6
+ DefaultEndpointUrl = "http://localhost:8080/josso/services/SSOIdentityProvider"
7
+ MappingRegistry = ::SOAP::Mapping::Registry.new
8
+
9
+ Methods = [
10
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "assertIdentityWithSimpleAuthentication"),
11
+ "",
12
+ "assertIdentityWithSimpleAuthentication",
13
+ [ ["in", "in0", ["::SOAP::SOAPString"]],
14
+ ["in", "in1", ["::SOAP::SOAPString"]],
15
+ ["retval", "assertIdentityWithSimpleAuthenticationReturn", ["::SOAP::SOAPString"]] ],
16
+ { :request_style => :rpc, :request_use => :encoded,
17
+ :response_style => :rpc, :response_use => :encoded }
18
+ ],
19
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "resolveAuthenticationAssertion"),
20
+ "",
21
+ "resolveAuthenticationAssertion",
22
+ [ ["in", "in0", ["::SOAP::SOAPString"]],
23
+ ["retval", "resolveAuthenticationAssertionReturn", ["::SOAP::SOAPString"]] ],
24
+ { :request_style => :rpc, :request_use => :encoded,
25
+ :response_style => :rpc, :response_use => :encoded }
26
+ ],
27
+ [ XSD::QName.new("http://josso.org/gateway/identity/service/ws/impl", "globalSignoff"),
28
+ "",
29
+ "globalSignoff",
30
+ [ ["in", "in0", ["::SOAP::SOAPString"]] ],
31
+ { :request_style => :rpc, :request_use => :encoded,
32
+ :response_style => :rpc, :response_use => :encoded }
33
+ ]
34
+ ]
35
+
36
+ def initialize(endpoint_url = nil)
37
+ endpoint_url ||= DefaultEndpointUrl
38
+ super(endpoint_url, nil)
39
+ self.mapping_registry = MappingRegistry
40
+ init_methods
41
+ end
42
+
43
+ private
44
+
45
+ def init_methods
46
+ Methods.each do |definitions|
47
+ opt = definitions.last
48
+ if opt[:request_style] == :document
49
+ add_document_operation(*definitions)
50
+ else
51
+ add_rpc_operation(*definitions)
52
+ qname = definitions[0]
53
+ name = definitions[2]
54
+ if qname.name != name and qname.name.capitalize == name.capitalize
55
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
56
+ __send__(name, *arg)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
@@ -0,0 +1,41 @@
1
+ require 'xsd/qname'
2
+
3
+ # {http://josso.org/gateway/identity/service/ws/impl}SSOIdentityException
4
+ class SSOIdentityException
5
+ @@schema_type = "SSOIdentityException"
6
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
7
+ @@schema_element = []
8
+
9
+ def initialize
10
+ end
11
+ end
12
+
13
+ # {http://josso.org/gateway/identity/service/ws/impl}IdentityProvisioningException
14
+ class IdentityProvisioningException < ::StandardError
15
+ @@schema_type = "IdentityProvisioningException"
16
+ @@schema_ns = "http://josso.org/gateway/identity/service/ws/impl"
17
+ @@schema_element = []
18
+
19
+ def initialize
20
+ end
21
+ end
22
+
23
+ # {http://josso.org/gateway/session/service/ws/impl}AssertionException
24
+ class AssertionException
25
+ @@schema_type = "AssertionException"
26
+ @@schema_ns = "http://josso.org/gateway/session/service/ws/impl"
27
+ @@schema_element = []
28
+
29
+ def initialize
30
+ end
31
+ end
32
+
33
+ # {http://josso.org/gateway/session/service/ws/impl}AssertionNotValidException
34
+ class AssertionNotValidException < ::StandardError
35
+ @@schema_type = "AssertionNotValidException"
36
+ @@schema_ns = "http://josso.org/gateway/session/service/ws/impl"
37
+ @@schema_element = []
38
+
39
+ def initialize
40
+ end
41
+ end
@@ -0,0 +1,6 @@
1
+ require 'test/unit'
2
+
3
+ class JossoClientTest < Test::Unit::TestCase
4
+ # Replace this with your real tests.
5
+
6
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: josso-client
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ version: "0.1"
9
+ platform: ruby
10
+ authors:
11
+ - Peter C Peterson
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2010-10-14 00:00:00 -06:00
17
+ default_executable:
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: rails
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 3
30
+ - 5
31
+ version: 2.3.5
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: JOSSO client for Rails
35
+ email: peter@saborgato.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - lib/bak_identity_provider_exceptions.rb
44
+ - lib/bak_sso_identity_manager.rb
45
+ - lib/bak_sso_identity_provider.rb
46
+ - lib/bak_wsdl_classes.rb
47
+ - lib/josso_agent.rb
48
+ - lib/main.rb
49
+ - lib/sso_identity_manager.rb
50
+ - lib/sso_identity_manager_classes.rb
51
+ - lib/sso_identity_provider.rb
52
+ - lib/sso_identity_provider_classes.rb
53
+ - lib/SSOIdentityManagerServiceClient.rb
54
+ - lib/SSOIdentityProviderServiceClient.rb
55
+ - test/josso_cllient_test.rb
56
+ has_rdoc: true
57
+ homepage: http://engineersatlarge.com
58
+ licenses: []
59
+
60
+ post_install_message:
61
+ rdoc_options: []
62
+
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ segments:
79
+ - 0
80
+ version: "0"
81
+ requirements: []
82
+
83
+ rubyforge_project:
84
+ rubygems_version: 1.3.7
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: JOSSO client for Rails
88
+ test_files: []
89
+