%
Sub Main
' Create 'Scripting.Dictionary' object
' to hold the arguments we will supply
' to the 'Ucam_Webauth' object.
Set args = CreateObject("Scripting.Dictionary")
' Add the different arguments to the 'args'
' associative array as name/value pairs.
' Both name and value must be strings
' so integers must be added as "x", eg. "60".
' 'auth_service' is the WLS authentication server.
' The following line gives the the demo Raven testing server:
' args.Add "auth_service", "https://demo.raven.cam.ac.uk/auth/authenticate.html"
' We're testing with our Dummy Raven WLS server so use that:
' args.Add "auth_service", "http://www2.careers.cam.ac.uk:11812"
' 'hostname' must be a domain name and perhaps a
' port but nothing more.
args.Add "hostname", "localhost:81"
' 'log_file' is the location of the logfile
' which must be read/writable by the webserver.
args.Add "log_file", "C:/wamp/www/raven_asp/logs/vbscriptlog.txt"
' 'key_dir' is the directory holding the
' public key certificate.
args.Add "key_dir", "C:/wamp/www/raven_asp/certificates"
' 'cookie_key' is the key used to generate
' hash values of the authentication cookie.
' Ideally it should be changed on a regular basis
' but not during sessions.
args.Add "cookie_key", "Random string"
' Create new instance of 'Ucam_Webauth'
' and supply arguments.
' We do not need to include 'Request' and 'Response'
' variables (as in C# version), in order to get/set
' cookies and server variables and perform redirects
' as these variables are globally accessible to ASP class.
Set oUcam_Webauth = New Ucam_Webauth
Call oUcam_Webauth(args)
' For the purposes of testing, we provide
' a 'Logout' link that removes the local
' authentication cookie and then displays
' a link to easily logout the Raven WLS.
' So we check to see if this 'Action=Logout'
' link has been called and logout/display
' link accordingly.
If (Request.ServerVariables("QUERY_STRING") = "Action=Logout") Then
oUcam_Webauth.ResetState()
Response.Write("Logged out of Raven (local)
")
Response.Write("Logout Raven (remote)
" & _
"Access Raven authenticated page")
Exit Sub
End If
' When you first access this page
' the 'Authenticate' function will be called.
' This will typically be called three times
' in total to successfully authenticate the
' user. In the first two iterations of
' 'Authenticate', it will return
' 'AUTHENTICATE_INCOMPLETE' while it
' redirects the user's browser first to
' the Raven WLS and then back to this page.
' On the third iteration of 'Authenticate', it
' will return 'AUTHENTICATE_COMPLETE_AUTHENTICATED'
' or 'AUTHENTICATE_COMPLETE_NOT_AUTHENTICATED'
' if the authentication process has fully
' completed without error.
Select Case oUcam_Webauth.Authenticate()
Case oUcam_Webauth.AUTHENTICATE_INCOMPLETE
' 'Authenticate' still redirecting pages
' so don't do anything else.
Exit Sub
Case oUcam_Webauth.AUTHENTICATE_COMPLETE_AUTHENTICATED
' Success so display the 'principal', ie. the user id.
Response.Write("SUCCESS. You are " & oUcam_Webauth.principal() & "
")
' Also display the 'ptags' parameter indicating
' whether the user is 'current' or not.
Response.Write("Ptags = " & oUcam_Webauth.ptags() & "
")
' Display any 'GET variables' to check they
' have carried through from the original
' page request.
For Each item In Request.QueryString()
Response.Write item & "=" & Request.QueryString()(item) & "
"
Next
' Display a 'Logout' link to make it easy to
' test authentication repeatedly.
Response.Write("Logout Raven (local)")
Case Else
' Either there was an error or a failed
' authentication so print out the result either way.
Response.Write("FAIL - " & oUcam_Webauth.status() & ": " & oUcam_Webauth.msg())
' Also log the error for debugging purposes.
oUcam_Webauth.write_log("FAIL - " & oUcam_Webauth.status() & ": " & oUcam_Webauth.msg())
End Select
End Sub
Call Main
%>