@@ -31,9 +31,8 @@ def initialize(overrides = {}, keep_security_attributes = false)
3131
3232 # IdP Data
3333 attr_accessor :idp_entity_id
34-
35- attr_accessor :idp_sso_service_url
36- attr_accessor :idp_slo_service_url
34+ attr_writer :idp_sso_service_url
35+ attr_writer :idp_slo_service_url
3736 attr_accessor :idp_slo_response_service_url
3837 attr_accessor :idp_cert
3938 attr_accessor :idp_cert_fingerprint
@@ -43,8 +42,10 @@ def initialize(overrides = {}, keep_security_attributes = false)
4342 attr_accessor :idp_name_qualifier
4443 attr_accessor :valid_until
4544 # SP Data
45+ attr_writer :sp_entity_id
4646 attr_accessor :assertion_consumer_service_url
47- attr_accessor :assertion_consumer_service_binding
47+ attr_reader :assertion_consumer_service_binding
48+ attr_writer :single_logout_service_url
4849 attr_accessor :sp_name_qualifier
4950 attr_accessor :name_identifier_format
5051 attr_accessor :name_identifier_value
@@ -54,7 +55,7 @@ def initialize(overrides = {}, keep_security_attributes = false)
5455 attr_accessor :compress_response
5556 attr_accessor :double_quote_xml_attribute_values
5657 attr_accessor :passive
57- attr_accessor :protocol_binding
58+ attr_reader :protocol_binding
5859 attr_accessor :attributes_index
5960 attr_accessor :force_authn
6061 attr_accessor :certificate
@@ -67,104 +68,99 @@ def initialize(overrides = {}, keep_security_attributes = false)
6768 # Work-flow
6869 attr_accessor :security
6970 attr_accessor :soft
70- # Compability
71+ # Deprecated
7172 attr_accessor :assertion_consumer_logout_service_url
72- attr_accessor :assertion_consumer_logout_service_binding
73+ attr_reader :assertion_consumer_logout_service_binding
7374 attr_accessor :issuer
7475 attr_accessor :idp_sso_target_url
7576 attr_accessor :idp_slo_target_url
7677
7778 # @return [String] IdP Single Sign On Service URL
7879 #
7980 def idp_sso_service_url
80- val = nil
81- if @idp_sso_service_url . nil?
82- if @idp_sso_target_url
83- val = @idp_sso_target_url
84- end
85- else
86- val = @idp_sso_service_url
87- end
88- val
81+ @idp_sso_service_url || @idp_sso_target_url
8982 end
9083
9184 # @return [String] IdP Single Logout Service URL
9285 #
9386 def idp_slo_service_url
94- val = nil
95- if @idp_slo_service_url . nil?
96- if @idp_slo_target_url
97- val = @idp_slo_target_url
98- end
99- else
100- val = @idp_slo_service_url
101- end
102- val
87+ @idp_slo_service_url || @idp_slo_target_url
88+ end
89+
90+ # @return [String] IdP Single Sign On Service Binding
91+ #
92+ def idp_sso_service_binding
93+ @idp_sso_service_binding || idp_binding_from_embed_sign
94+ end
95+
96+ # Setter for IdP Single Sign On Service Binding
97+ # @param value [String, Symbol].
98+ #
99+ def idp_sso_service_binding = ( value )
100+ @idp_sso_service_binding = get_binding ( value )
101+ end
102+
103+ # @return [String] IdP Single Logout Service Binding
104+ #
105+ def idp_slo_service_binding
106+ @idp_slo_service_binding || idp_binding_from_embed_sign
107+ end
108+
109+ # Setter for IdP Single Logout Service Binding
110+ # @param value [String, Symbol].
111+ #
112+ def idp_slo_service_binding = ( value )
113+ @idp_slo_service_binding = get_binding ( value )
103114 end
104115
105116 # @return [String] SP Entity ID
106117 #
107118 def sp_entity_id
108- val = nil
109- if @sp_entity_id . nil?
110- if @issuer
111- val = @issuer
112- end
113- else
114- val = @sp_entity_id
115- end
116- val
119+ @sp_entity_id || @issuer
117120 end
118121
119- # Setter for SP Entity ID.
120- # @param val [String].
122+ # Setter for SP Protocol Binding
123+ # @param value [String, Symbol ].
121124 #
122- def sp_entity_id = ( val )
123- @sp_entity_id = val
125+ def protocol_binding = ( value )
126+ @protocol_binding = get_binding ( value )
124127 end
125128
126- # @return [String] Single Logout Service URL.
129+ # Setter for SP Assertion Consumer Service Binding
130+ # @param value [String, Symbol].
127131 #
128- def single_logout_service_url
129- val = nil
130- if @single_logout_service_url . nil?
131- if @assertion_consumer_logout_service_url
132- val = @assertion_consumer_logout_service_url
133- end
134- else
135- val = @single_logout_service_url
136- end
137- val
132+ def assertion_consumer_service_binding = ( value )
133+ @assertion_consumer_service_binding = get_binding ( value )
138134 end
139135
140- # Setter for the Single Logout Service URL.
141- # @param url [String].
136+ # @return [String] Single Logout Service URL.
142137 #
143- def single_logout_service_url = ( url )
144- @single_logout_service_url = url
138+ def single_logout_service_url
139+ @single_logout_service_url || @assertion_consumer_logout_service_url
145140 end
146141
147142 # @return [String] Single Logout Service Binding.
148143 #
149144 def single_logout_service_binding
150- val = nil
151- if @single_logout_service_binding . nil?
152- if @assertion_consumer_logout_service_binding
153- val = @assertion_consumer_logout_service_binding
154- end
155- else
156- val = @single_logout_service_binding
157- end
158- val
145+ @single_logout_service_binding || @assertion_consumer_logout_service_binding
159146 end
160147
161148 # Setter for Single Logout Service Binding.
162149 #
163150 # (Currently we only support "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect")
164- # @param url [String]
151+ # @param value [String, Symbol ]
165152 #
166- def single_logout_service_binding = ( url )
167- @single_logout_service_binding = url
153+ def single_logout_service_binding = ( value )
154+ @single_logout_service_binding = get_binding ( value )
155+ end
156+
157+ # @deprecated Setter for legacy Single Logout Service Binding parameter.
158+ #
159+ # (Currently we only support "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect")
160+ # @param value [String, Symbol]
161+ #
162+ def assertion_consumer_logout_service_binding = ( value )
163+ @assertion_consumer_logout_service_binding = get_binding ( value )
168164 end
169165
170166 # Calculates the fingerprint of the IdP x509 certificate.
@@ -252,9 +248,19 @@ def get_sp_key
252248
253249 private
254250
251+ def idp_binding_from_embed_sign
252+ security [ :embed_sign ] ? Utils ::BINDINGS [ :post ] : Utils ::BINDINGS [ :redirect ]
253+ end
254+
255+ def get_binding ( value )
256+ return unless value
257+
258+ Utils ::BINDINGS [ value . to_sym ] || value
259+ end
260+
255261 DEFAULTS = {
256- :assertion_consumer_service_binding => "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" . freeze ,
257- :single_logout_service_binding => "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" . freeze ,
262+ :assertion_consumer_service_binding => Utils :: BINDINGS [ :post ] ,
263+ :single_logout_service_binding => Utils :: BINDINGS [ :redirect ] ,
258264 :idp_cert_fingerprint_algorithm => XMLSecurity ::Document ::SHA1 ,
259265 :compress_request => true ,
260266 :compress_response => true ,
@@ -268,7 +274,7 @@ def get_sp_key
268274 :want_assertions_encrypted => false ,
269275 :want_name_id => false ,
270276 :metadata_signed => false ,
271- :embed_sign => false ,
277+ :embed_sign => false , # Deprecated
272278 :digest_method => XMLSecurity ::Document ::SHA1 ,
273279 :signature_method => XMLSecurity ::Document ::RSA_SHA1 ,
274280 :check_idp_cert_expiration => false ,
0 commit comments