From 510a5029d72d50e1ef184a7f72e2f64e5cf5e342 Mon Sep 17 00:00:00 2001 From: Kem Tekinay Date: Wed, 11 Feb 2015 12:44:39 -0500 Subject: [PATCH 01/10] UpdateChecker: Added Socket As Kaju.HTTPSSocket property --- Kaju Classes/Kaju/UpdateChecker.xojo_code | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Kaju Classes/Kaju/UpdateChecker.xojo_code b/Kaju Classes/Kaju/UpdateChecker.xojo_code index 949c57e..66b0f02 100644 --- a/Kaju Classes/Kaju/UpdateChecker.xojo_code +++ b/Kaju Classes/Kaju/UpdateChecker.xojo_code @@ -534,6 +534,10 @@ Protected Class UpdateChecker ServerPublicRSAKey As String #tag EndProperty + #tag Property, Flags = &h0 + Socket As Kaju.HTTPSSocket + #tag EndProperty + #tag Property, Flags = &h0 UpdateURL As String #tag EndProperty From ca00f21a9aa47a83f4f7f0a94e0a32a07cecea8c Mon Sep 17 00:00:00 2001 From: Kem Tekinay Date: Wed, 11 Feb 2015 12:45:15 -0500 Subject: [PATCH 02/10] UpdateChecker: Will use the given Socket if provided --- Kaju Classes/Kaju/UpdateChecker.xojo_code | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Kaju Classes/Kaju/UpdateChecker.xojo_code b/Kaju Classes/Kaju/UpdateChecker.xojo_code index 66b0f02..4d39472 100644 --- a/Kaju Classes/Kaju/UpdateChecker.xojo_code +++ b/Kaju Classes/Kaju/UpdateChecker.xojo_code @@ -80,7 +80,12 @@ Protected Class UpdateChecker // dim url as string = self.UpdateURL if AllowRedirection then - dim redirector as new Kaju.HTTPSSocket + dim redirector as Kaju.HTTPSSocket + if Socket is nil then + redirector = new Kaju.HTTPSSocket + else + redirector = Socket + end if url = redirector.GetRedirectAddress( url, 5 ) end if @@ -89,7 +94,12 @@ Protected Class UpdateChecker // do - dim http as new Kaju.HTTPSSocket + dim http as Kaju.HTTPSSocket + if Socket is nil then + http = new Kaju.HTTPSSocket + else + http = Socket + end if dim raw as string = http.Get( url, 5 ) if http.HTTPStatusCode = 404 then // Not found From f2f356b3fc780a5688505b883a9407f586649b13 Mon Sep 17 00:00:00 2001 From: Kem Tekinay Date: Wed, 11 Feb 2015 12:45:49 -0500 Subject: [PATCH 03/10] HTTPSSocket: Added Username and Password properties --- Kaju Classes/Kaju/HTTPSSocket.xojo_code | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Kaju Classes/Kaju/HTTPSSocket.xojo_code b/Kaju Classes/Kaju/HTTPSSocket.xojo_code index 828e89f..abe0d51 100644 --- a/Kaju Classes/Kaju/HTTPSSocket.xojo_code +++ b/Kaju Classes/Kaju/HTTPSSocket.xojo_code @@ -123,6 +123,14 @@ Inherits HTTPSecureSocket ForceSecure As Boolean #tag EndProperty + #tag Property, Flags = &h21 + Private Password As String + #tag EndProperty + + #tag Property, Flags = &h21 + Private Username As String + #tag EndProperty + #tag Constant, Name = kDefaultMaximumIterations, Type = Double, Dynamic = False, Default = \"5", Scope = Private #tag EndConstant From e66f7666121a3b65417043ebf5bd612cbf862c5d Mon Sep 17 00:00:00 2001 From: Kem Tekinay Date: Wed, 11 Feb 2015 12:46:11 -0500 Subject: [PATCH 04/10] HTTPSSocket: Custom event for AuthenticationRequired --- Kaju Classes/Kaju/HTTPSSocket.xojo_code | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Kaju Classes/Kaju/HTTPSSocket.xojo_code b/Kaju Classes/Kaju/HTTPSSocket.xojo_code index abe0d51..06d17b8 100644 --- a/Kaju Classes/Kaju/HTTPSSocket.xojo_code +++ b/Kaju Classes/Kaju/HTTPSSocket.xojo_code @@ -119,6 +119,11 @@ Inherits HTTPSecureSocket #tag EndMethod + #tag Hook, Flags = &h0 + Event AuthenticationRequired(Realm As String, Headers As InternetHeaders, ByRef Name As String, ByRef Password As String) As Boolean + #tag EndHook + + #tag Property, Flags = &h0 ForceSecure As Boolean #tag EndProperty From 9fa2a77f91eb3e559a45cb1998917e9a0fa8c382 Mon Sep 17 00:00:00 2001 From: Kem Tekinay Date: Wed, 11 Feb 2015 12:47:09 -0500 Subject: [PATCH 05/10] HTTPSSocket: SetSecure will parse the url for the username and password --- Kaju Classes/Kaju/HTTPSSocket.xojo_code | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Kaju Classes/Kaju/HTTPSSocket.xojo_code b/Kaju Classes/Kaju/HTTPSSocket.xojo_code index 06d17b8..3f1cb59 100644 --- a/Kaju Classes/Kaju/HTTPSSocket.xojo_code +++ b/Kaju Classes/Kaju/HTTPSSocket.xojo_code @@ -107,7 +107,7 @@ Inherits HTTPSecureSocket #tag EndMethod #tag Method, Flags = &h21 - Private Sub SetSecure(url As String) + Private Sub SetSecure(ByRef url As String) if ForceSecure or url.Trim.Left( 8 ) = "https://" then self.Secure = true self.Port = 443 @@ -115,6 +115,22 @@ Inherits HTTPSecureSocket self.Secure = false self.Port = 80 end if + + // + // See if the username and password has been specified + // + dim rx as new RegEx + rx.SearchPattern = "^(?:https?://)([^:/\x20@]+):([^:/\x20@]*)@(.*)" + dim match as RegExMatch = rx.Search( url ) + if match IsA RegExMatch then + Username = DecodeURLComponent( match.SubExpressionString( 1 ) ) + Password = DecodeURLComponent( match.SubExpressionString( 2 ) ) + url = match.SubExpressionString( 3 ) + else + Username = "" + Password = "" + end if + End Sub #tag EndMethod From 678c233cda234727a45683545d513c84ab0be6d2 Mon Sep 17 00:00:00 2001 From: Kem Tekinay Date: Wed, 11 Feb 2015 12:47:27 -0500 Subject: [PATCH 06/10] HTTPSSocket: Implemented AuthenticationRequired event --- Kaju Classes/Kaju/HTTPSSocket.xojo_code | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Kaju Classes/Kaju/HTTPSSocket.xojo_code b/Kaju Classes/Kaju/HTTPSSocket.xojo_code index 3f1cb59..794215c 100644 --- a/Kaju Classes/Kaju/HTTPSSocket.xojo_code +++ b/Kaju Classes/Kaju/HTTPSSocket.xojo_code @@ -1,6 +1,23 @@ #tag Class Protected Class HTTPSSocket Inherits HTTPSecureSocket + #tag Event + Function AuthenticationRequired(Realm As String, Headers As InternetHeaders, ByRef Name As String, ByRef Password As String) As Boolean + if RaiseEvent AuthenticationRequired( Realm, Headers, Name, Password ) then + return true + end if + + if Username <> "" then + Name = Username + Password = self.Password + return true + else + return false + end if + End Function + #tag EndEvent + + #tag Method, Flags = &h0 Sub Get(url As String) SetSecure( url ) From c6d81d9b107117272a0272f65d9c1285d19c5878 Mon Sep 17 00:00:00 2001 From: Kem Tekinay Date: Wed, 11 Feb 2015 12:52:59 -0500 Subject: [PATCH 07/10] UpdateChecker: Removed Socket property --- Kaju Classes/Kaju/UpdateChecker.xojo_code | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/Kaju Classes/Kaju/UpdateChecker.xojo_code b/Kaju Classes/Kaju/UpdateChecker.xojo_code index 4d39472..949c57e 100644 --- a/Kaju Classes/Kaju/UpdateChecker.xojo_code +++ b/Kaju Classes/Kaju/UpdateChecker.xojo_code @@ -80,12 +80,7 @@ Protected Class UpdateChecker // dim url as string = self.UpdateURL if AllowRedirection then - dim redirector as Kaju.HTTPSSocket - if Socket is nil then - redirector = new Kaju.HTTPSSocket - else - redirector = Socket - end if + dim redirector as new Kaju.HTTPSSocket url = redirector.GetRedirectAddress( url, 5 ) end if @@ -94,12 +89,7 @@ Protected Class UpdateChecker // do - dim http as Kaju.HTTPSSocket - if Socket is nil then - http = new Kaju.HTTPSSocket - else - http = Socket - end if + dim http as new Kaju.HTTPSSocket dim raw as string = http.Get( url, 5 ) if http.HTTPStatusCode = 404 then // Not found @@ -544,10 +534,6 @@ Protected Class UpdateChecker ServerPublicRSAKey As String #tag EndProperty - #tag Property, Flags = &h0 - Socket As Kaju.HTTPSSocket - #tag EndProperty - #tag Property, Flags = &h0 UpdateURL As String #tag EndProperty From 3a9462dcf9451656b9a15fc9309149edb8760592 Mon Sep 17 00:00:00 2001 From: Kem Tekinay Date: Wed, 11 Feb 2015 12:59:25 -0500 Subject: [PATCH 08/10] HTTPSSocket: Cleaned up some code for readability --- Kaju Classes/Kaju/HTTPSSocket.xojo_code | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Kaju Classes/Kaju/HTTPSSocket.xojo_code b/Kaju Classes/Kaju/HTTPSSocket.xojo_code index 794215c..fe036a6 100644 --- a/Kaju Classes/Kaju/HTTPSSocket.xojo_code +++ b/Kaju Classes/Kaju/HTTPSSocket.xojo_code @@ -138,14 +138,15 @@ Inherits HTTPSecureSocket // dim rx as new RegEx rx.SearchPattern = "^(?:https?://)([^:/\x20@]+):([^:/\x20@]*)@(.*)" + dim match as RegExMatch = rx.Search( url ) - if match IsA RegExMatch then + if match is nil then + Username = "" + Password = "" + else Username = DecodeURLComponent( match.SubExpressionString( 1 ) ) Password = DecodeURLComponent( match.SubExpressionString( 2 ) ) url = match.SubExpressionString( 3 ) - else - Username = "" - Password = "" end if End Sub From 8a0bdc9148cbeb52be8da50d4c1e2d3e598ed45e Mon Sep 17 00:00:00 2001 From: Kem Tekinay Date: Wed, 11 Feb 2015 13:01:42 -0500 Subject: [PATCH 09/10] Updated README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3613939..f6c593a 100644 --- a/README.md +++ b/README.md @@ -369,3 +369,4 @@ Add a translation for each, then submit a pull request as outlined above. - Added /g switch to XCOPY in Windows script. - When the app relaunches after an update or failed update, will get command-line switches telling it what happened. Added Kaju methods to report. +- URL's for both the update information and the downloads can specify a username and password in the form "http://un:pw@theurl.com". From 60dddcff6eeae1ba572e303d32c46f35e6e5a933 Mon Sep 17 00:00:00 2001 From: Kem Tekinay Date: Sat, 14 Feb 2015 10:44:45 -0500 Subject: [PATCH 10/10] Updated README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f6c593a..10fabad 100644 --- a/README.md +++ b/README.md @@ -370,3 +370,4 @@ Add a translation for each, then submit a pull request as outlined above. - Added /g switch to XCOPY in Windows script. - When the app relaunches after an update or failed update, will get command-line switches telling it what happened. Added Kaju methods to report. - URL's for both the update information and the downloads can specify a username and password in the form "http://un:pw@theurl.com". +- Added Kaju.Version constant.