Now HTTP_AUTHORIZATION acceps READABLE_STRING_GENERAL for username and password argument.

This commit is contained in:
Jocelyn Fiat
2017-09-21 10:45:40 +02:00
parent 20a90db2e3
commit ab507d543a

View File

@@ -76,13 +76,13 @@ feature -- Initialization
a_http_authorization /= Void implies http_authorization /= Void a_http_authorization /= Void implies http_authorization /= Void
end end
make_basic_auth (u: READABLE_STRING_32; p: READABLE_STRING_32) make_basic_auth (u: READABLE_STRING_GENERAL; p: READABLE_STRING_GENERAL)
-- Create a Basic authentication. -- Create a Basic authentication.
do do
make_custom_auth (u, p, Basic_auth_type) make_custom_auth (u, p, Basic_auth_type)
end end
make_custom_auth (u: READABLE_STRING_32; p: READABLE_STRING_32; a_type: READABLE_STRING_8) make_custom_auth (u: READABLE_STRING_GENERAL; p: READABLE_STRING_GENERAL; a_type: READABLE_STRING_8)
-- Create a custom `a_type' authentication. -- Create a custom `a_type' authentication.
require require
a_type_accepted: a_type.is_case_insensitive_equal (Basic_auth_type) a_type_accepted: a_type.is_case_insensitive_equal (Basic_auth_type)
@@ -90,15 +90,20 @@ feature -- Initialization
local local
t: STRING_8 t: STRING_8
utf: UTF_CONVERTER utf: UTF_CONVERTER
s: STRING_32
do do
login := u create login.make_from_string_general (u)
password := p create password.make_from_string_general (p)
create t.make_from_string (a_type) create t.make_from_string (a_type)
t.left_adjust; t.right_adjust t.left_adjust; t.right_adjust
type := t type := t
if t.is_case_insensitive_equal (Basic_auth_type) then if t.is_case_insensitive_equal (Basic_auth_type) then
type := Basic_auth_type type := Basic_auth_type
create http_authorization.make_from_string ("Basic " + (create {BASE64}).encoded_string (utf.string_32_to_utf_8_string_8 (u + {STRING_32} ":" + p))) create s.make_from_string_general (u)
s.extend (':')
s.append_string_general (p)
create http_authorization.make_from_string ("Basic " + (create {BASE64}).encoded_string (utf.string_32_to_utf_8_string_8 (s)))
elseif t.is_case_insensitive_equal (Digest_auth_type) then elseif t.is_case_insensitive_equal (Digest_auth_type) then
type := Digest_auth_type type := Digest_auth_type
to_implement ("HTTP Authorization %""+ t +"%", not yet implemented") to_implement ("HTTP Authorization %""+ t +"%", not yet implemented")
@@ -115,9 +120,9 @@ feature -- Access
type: READABLE_STRING_8 type: READABLE_STRING_8
login: detachable READABLE_STRING_32 login: detachable IMMUTABLE_STRING_32
password: detachable READABLE_STRING_32 password: detachable IMMUTABLE_STRING_32
feature -- Status report feature -- Status report