'Return True to allow the request to proceed.
Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean
If req.GetSession.GetAttribute2("logged in", False) = True Then Return True
If req.RequestURI="/ws" Then
Return True
Else
Dim auths As List = req.GetHeaders("Authorization")
If auths.Size = 0 Then
resp.SetHeader("WWW-Authenticate", $"Basic realm="Realm""$)
resp.SendError(401, "authentication required")
Return False
Else
If CheckCredentials(auths.Get(0)) Then
req.GetSession.SetAttribute("logged in", True)
Return True
Else
resp.SendError(401, "authentication required")
Return False
End If
End If
End If
End Sub