Skip to content

Commit

Permalink
Merge branch 'feature/Authentication' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ktekinay committed Feb 14, 2015
2 parents 8412637 + 60dddcf commit 5a3f93f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 48 additions & 1 deletion Kaju Classes/Kaju/HTTPSSocket.xojo_code
Original file line number Diff line number Diff line change
@@ -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 )
Expand Down Expand Up @@ -107,22 +124,52 @@ 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
else
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 is nil then
Username = ""
Password = ""
else
Username = DecodeURLComponent( match.SubExpressionString( 1 ) )
Password = DecodeURLComponent( match.SubExpressionString( 2 ) )
url = match.SubExpressionString( 3 )
end if

End Sub
#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

#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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,5 @@ 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:[email protected]".
- Added Kaju.Version constant.

0 comments on commit 5a3f93f

Please sign in to comment.