//---------------------------------------------------------------------------------------// private LabServerWebService GetLabServer(sbAuthHeader sbHeader) { const string STRLOG_MethodName = "GetLabServer"; Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName); long couponId = sbHeader.couponID; string couponPasskey = sbHeader.couponPassKey; Logfile.Write(" Coupon Id: " + couponId.ToString()); Logfile.Write(" Coupon Passkey: " + couponPasskey); LabServerWebService labServer = null; try { // // Get settings from Application's configuration file // string labserverId = couponId.ToString(); Logfile.Write(" Labserver Id: " + labserverId); string labServerUrl = Utilities.GetAppSetting(labserverId); string sbGuid = Utilities.GetAppSetting(Consts.STRCFG_ServiceBrokerGuid); string sbToLsPasskey = Utilities.GetAppSetting(Consts.STRCFG_SbToLsPasskey); Logfile.Write(" ServiceBroker Guid: " + sbGuid); Logfile.Write(" Labserver Url: " + labServerUrl); Logfile.Write(" SBtoLS Passkey: " + sbToLsPasskey); // // Create LabServer interface // labServer = new LabServerWebService(); labServer.Url = labServerUrl; // // Create and fill in authorisation information // AuthHeader authHeader = new AuthHeader(); authHeader.identifier = sbGuid; authHeader.passKey = sbToLsPasskey; labServer.AuthHeaderValue = authHeader; } catch (Exception ex) { Trace.WriteLine(ex.Message); throw; } Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName); return(labServer); }
//---------------------------------------------------------------------------------------// public ServiceBrokerService() { const string STRLOG_MethodName = "ServiceBrokerService"; Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName); if (nextExperimentId == 0) { // Initialise the experiment number nextExperimentId = GetNextExperimentID(); } Logfile.Write(" Experiment Id: " + nextExperimentId.ToString()); sbHeader = new sbAuthHeader(); Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName); }
//---------------------------------------------------------------------------------------// private LabServerWebService GetLabServer(sbAuthHeader sbHeader) { const string STRLOG_MethodName = "GetLabServer"; Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName); long couponId = sbHeader.couponID; string couponPasskey = sbHeader.couponPassKey; Logfile.Write(" Coupon Id: " + couponId.ToString()); Logfile.Write(" Coupon Passkey: " + couponPasskey); LabServerWebService labServer = null; try { // // Get settings from Application's configuration file // string labserverId = couponId.ToString(); Logfile.Write(" Labserver Id: " + labserverId); string labServerUrl = Utilities.GetAppSetting(labserverId); string sbGuid = Utilities.GetAppSetting(Consts.STRCFG_ServiceBrokerGuid); string sbToLsPasskey = Utilities.GetAppSetting(Consts.STRCFG_SbToLsPasskey); Logfile.Write(" ServiceBroker Guid: " + sbGuid); Logfile.Write(" Labserver Url: " + labServerUrl); Logfile.Write(" SBtoLS Passkey: " + sbToLsPasskey); // // Create LabServer interface // labServer = new LabServerWebService(); labServer.Url = labServerUrl; // // Create and fill in authorisation information // AuthHeader authHeader = new AuthHeader(); authHeader.identifier = sbGuid; authHeader.passKey = sbToLsPasskey; labServer.AuthHeaderValue = authHeader; } catch (Exception ex) { Trace.WriteLine(ex.Message); throw; } Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName); return labServer; }
//=======================================================================================// private void Authenticate(sbAuthHeader sbHeader) { /* * Check if authenticating */ if (this.configProperties.Authenticating == true) { if (this.configProperties.LogAuthentication == true) { if (sbHeader == null) { Logfile.Write(STRLOG_SbAuthHeaderNull); } else { Logfile.Write(String.Format(STRLOG_CouponIdPasskey_arg2, sbHeader.CouponId, sbHeader.CouponPasskey)); } } try { /* * Check that AuthHeader is specified */ if (sbHeader == null) { throw new ApplicationException(STRERR_SbAuthHeaderNull); } /* * Verify the Coupon Id */ if (sbHeader.CouponId != this.configProperties.CouponId) { throw new ApplicationException(String.Format(STRERR_CouponIdInvalid_arg, sbHeader.CouponId)); } /* * Verify the Coupon Passkey */ if (sbHeader.CouponPasskey == null) { throw new ApplicationException(STRERR_CouponPasskeyNull); } if (sbHeader.CouponPasskey.Equals(this.configProperties.CouponPasskey, StringComparison.OrdinalIgnoreCase) == false) { throw new ApplicationException(String.Format(STRERR_CouponPasskeyInvalid_arg, sbHeader.CouponPasskey)); } } catch (Exception ex) { String message = String.Format(STRERR_AccessDenied_arg, ex.Message); Logfile.WriteError(message); throw new ProtocolException(message); } } }