Listing F
'##############################################################################
' Author: Kevin Koch
' Description:  This class is used to provide common functionality for
'               authentication, and for creating the security contexts
'               required by Tom's application
'##############################################################################
 
 
 
 
Imports System.Configuration.ConfigurationSettings
 
 
Public Class WSUtil
 
 
    '================================================================================================================================
    ' Authenticates a web service consumer's security context values
    '================================================================================================================================
    Friend Function Authenticate(ByVal SecureCtx As OrderSecurityContext) As Boolean
        Dim Authenticated As Boolean = False
 
 
        If SecureCtx Is Nothing Then Return False
 
 
        Dim ClientDs As DataSet = CType(HttpContext.Current.Application.Item(ClientDb.CLIENT_DS_REF), DataSet)
        If ClientDs Is Nothing Then Return False
 
 
        ClientDs.Tables(0).DefaultView.Sort = ClientDb.FIELD_CLIENT_ID
        If ClientDs.Tables(0).DefaultView.Find(SecureCtx.ClientId) >= 0 Then
            ClientDs.Tables(0).DefaultView.Sort = ClientDb.FIELD_WS_TOKEN
            If ClientDs.Tables(0).DefaultView.Find(SecureCtx.WSToken) >= 0 Then
                Authenticated = True
            End If
        End If
 
 
        Return Authenticated
    End Function
 
 
 
 
    '================================================================================================================================
    ' Authenticates a web service consumer's security context values
    '================================================================================================================================
    Friend Function Authenticate(ByVal SecureCtx As BookSecurityContext) As Boolean
        Dim Authenticated As Boolean = False
 
 
        If SecureCtx Is Nothing Then Return False
 
 
        Dim ClientDs As DataSet = CType(HttpContext.Current.Application.Item(ClientDb.CLIENT_DS_REF), DataSet)
        If ClientDs Is Nothing Then Return False
 
 
        ClientDs.Tables(0).DefaultView.Sort = ClientDb.FIELD_CLIENT_ID
        If ClientDs.Tables(0).DefaultView.Find(SecureCtx.ClientId) >= 0 Then
            ClientDs.Tables(0).DefaultView.Sort = ClientDb.FIELD_WS_TOKEN
            If ClientDs.Tables(0).DefaultView.Find(SecureCtx.WSToken) >= 0 Then
                Authenticated = True
            End If
        End If
 
 
        Return Authenticated
    End Function
 
 
 
 
    Public Shared Function GetOrderSecurityContext() As OrderProxy.OrderSecurityContext
        Dim SecureCtx As New OrderProxy.OrderSecurityContext()
        SecureCtx.WSToken = AppSettings("TomWSToken")
 
 
        Return SecureCtx
    End Function
 
 
End Class