//---------------------------------------------------------------------------------------// private bool Authorised(AuthHeader authHeader) { bool ok = true; if (Global.allowedCallers.IsAuthenticating == true) { // // Check if caller is specified // if (authHeader == null || authHeader.identifier == null || authHeader.passKey == null) { // Caller is not specified ok = false; Logfile.Write(STRLOG_AccessDenied); } // // Check if access is authorised for this caller // else { // Get the caller's name string lsName = Global.allowedCallers.Authentication(authHeader.identifier, authHeader.passKey); // // Check if caller is allowed access to this web service // if (lsName == null) { // Caller is not allowed access to this Web Method ok = false; Logfile.Write(STRLOG_UnauthorisedAccess); } } } return(ok); }
//---------------------------------------------------------------------------------------// public EquipmentService() { this.authHeader = new AuthHeader(); }
//---------------------------------------------------------------------------------------// private bool Authorised(AuthHeader authHeader) { bool ok = true; if (Global.allowedCallers.IsAuthenticating == true) { // // Check if caller is specified // if (authHeader == null || authHeader.identifier == null || authHeader.passKey == null) { // Caller is not specified ok = false; Logfile.Write(STRLOG_AccessDenied); } // // Check if access is authorised for this caller // else { // Get the caller's name string lsName = Global.allowedCallers.Authentication(authHeader.identifier, authHeader.passKey); // // Check if caller is allowed access to this web service // if (lsName == null) { // Caller is not allowed access to this Web Method ok = false; Logfile.Write(STRLOG_UnauthorisedAccess); } } } return ok; }
//================================================================================================================// private bool Authenticate(AuthHeader authHeader) { /* * Assume this will fail */ bool success = false; try { if (Global.configProperties.Authenticating == true) { /* * Check that the AuthHeader is specified */ if (authHeader == null) { throw new ArgumentNullException(String.Format(STRERR_NotSpecified_arg, STRERR_AuthHeader)); } /* * Verify the LabServer Guid */ if (authHeader.Identifier == null) { throw new ArgumentException(String.Format(STRERR_NotSpecified_arg, STRERR_LabServerGuid)); } if (Global.configProperties.LabServerGuid.Equals(authHeader.Identifier, StringComparison.OrdinalIgnoreCase) == false) { throw new ArgumentException(String.Format(STRERR_Invalid_arg, STRERR_LabServerGuid)); } /* * Verify the passkey */ if (authHeader.Passkey == null) { throw new ArgumentException(String.Format(STRERR_NotSpecified_arg, STRERR_Passkey)); } if (Global.configProperties.LabServerPasskey.Equals(authHeader.Passkey, StringComparison.OrdinalIgnoreCase) == false) { throw new ArgumentException(String.Format(STRERR_Invalid_arg, STRERR_Passkey)); } } /* * Successfully authenticated */ success = true; } catch (Exception ex) { String message = String.Format(STRERR_AccessDenied_arg, ex.Message); Logfile.WriteError(message); /* * Throw SoapException back to the caller */ throw new SoapException(message, SoapException.ClientFaultCode); } return success; }