protected override string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError) { parsingError = null; if (string.IsNullOrEmpty(relativeUri.ToString())) { return(baseUri.ToString()); } string keypath = Path.GetDirectoryName(GetKey(baseUri)); if (keypath == null) { keypath = ""; } return(string.Format("s3://{0}/{1}", GetBucketName(baseUri), Path.Combine(keypath, relativeUri.ToString()).TrimStart('/'))); }
/// <summary> /// Acquires a `<see cref="Token"/>` from the authority via an non-interactive user logon. /// <para/> /// Returns the acquired `<see cref="Token"/>` if successful; otherwise `<see langword="null"/>`. /// </summary> /// <param name="targetUri">Uniform resource indicator of the resource access tokens are being requested for.</param> /// <param name="clientId">Identifier of the client requesting the token.</param> /// <param name="resource">Identifier of the target resource that is the recipient of the requested token.</param> /// <param name="redirectUri">Address to return to upon receiving a response from the authority.</param> public async Task <Token> NoninteractiveAcquireToken(TargetUri targetUri, string clientId, string resource, Uri redirectUri) { if (targetUri is null) { throw new ArgumentNullException(nameof(targetUri)); } if (string.IsNullOrWhiteSpace(clientId)) { throw new ArgumentNullException(nameof(clientId)); } if (string.IsNullOrWhiteSpace(resource)) { throw new ArgumentNullException(nameof(resource)); } if (redirectUri is null) { throw new ArgumentNullException(nameof(redirectUri)); } if (!redirectUri.IsAbsoluteUri) { var inner = new UriFormatException("Uri is not absolute when an absolute Uri is required."); throw new ArgumentException(inner.Message, nameof(redirectUri), inner); } Token token = null; try { var authResult = await Adal.AcquireTokenAsync(AuthorityHostUrl, resource, clientId); if (Guid.TryParse(authResult.TenantId, out Guid tentantId)) { token = new Token(authResult.AccessToken, tentantId, TokenType.AzureAccess); Trace.WriteLine($"token acquisition for authority host URL = '{AuthorityHostUrl}' succeeded."); } } catch (AuthenticationException) { Trace.WriteLine($"token acquisition for authority host URL = '{AuthorityHostUrl}' failed."); } return(token); }
public async Task Should_return_internal_server_error_result_when_non_video_api_exception_thrown() { var exception = new UriFormatException("Test format is invalid"); _bookingsApiClientMock .Setup(x => x.GetCaseTypesAsync()) .ThrowsAsync(exception); var result = await _controller.Health(); var typedResult = (ObjectResult)result; typedResult.StatusCode.Should().Be((int)HttpStatusCode.InternalServerError); var response = (Models.HealthCheckResponse)typedResult.Value; response.BookingsApiHealth.Successful.Should().BeFalse(); response.BookingsApiHealth.ErrorMessage.Should().NotBeNullOrWhiteSpace(); }
public void TestInvalidInput2() { var uriData = new ValidUriModel0 { Base = null }; UriFormatException e = null; try { var uri = uriData.ToUri(); } catch (UriFormatException exception) { e = exception; } Assert.That(e, Is.Not.Null); Assert.That(e.Message, Is.EqualTo("The object's Base URI Property Base was null.")); }
protected override void InitializeAndValidate(Uri uri, out UriFormatException parsingError) { AmazonS3Uri amazonS3Uri = GetAmazonS3Uri(uri); if (amazonS3Uri != null) { parsingError = null; return; } Match match = PathStyleRegEx.Match(uri.OriginalString); if (!match.Success) { parsingError = new UriFormatException("S3 Uri could not be parsed"); return; } parsingError = null; }
static void SendHeartBeat() { HeartbeatData data = new HeartbeatData(HeartbeatServerUrl); if (!RaiseHeartbeatSendingEvent(data, HeartbeatServerUrl)) { return; } try { heartBeatRequest = CreateRequest(data.CreateUri()); } catch (Exception UriFormatException) { Logger.Log(LogType.Debug, UriFormatException.ToString()); return; } var state = new HeartbeatRequestState(heartBeatRequest, data); heartBeatRequest.BeginGetResponse(ResponseCallback, state); }
public TargetUri(Uri queryUri, Uri proxyUri) { if (queryUri is null) { throw new ArgumentNullException(nameof(queryUri)); } if (!queryUri.IsAbsoluteUri) { var inner = new UriFormatException("Uri must be absolute."); throw new ArgumentException(inner.Message, nameof(queryUri), inner); } if (proxyUri != null && !proxyUri.IsAbsoluteUri) { var inner = new UriFormatException("Uri must be absolute."); throw new ArgumentException(inner.Message, nameof(proxyUri), inner); } _proxyUri = proxyUri; _queryUri = queryUri; }
///------------------------------------------------------------------------------------------------- /// <summary> /// Called by Uri constructors and Uri.TryCreate() to resolve a relative URI. /// </summary> /// /// <remarks> /// Joey Brock <*****@*****.**>, 4/19/2013. /// </remarks> /// /// <param name="baseUri"> /// System.Uri. /// </param> /// <param name="relativeUri"> /// System.Uri. /// </param> /// <param name="parsingError"> /// System.UriFormatException. /// </param> /// /// <returns> /// The string of the resolved relative Uri. /// </returns> ///------------------------------------------------------------------------------------------------- protected virtual string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError) { // Uri constructors and Uri.TryCreate() use Resolve to construct a URI from baseUri and relativeUri. // If a parsing error occurs, the returned string for the resolved relative Uri is null. string strResolvedUri = ""; parsingError = new UriFormatException(); try { if (relativeUri != null) { // Resolving was a success strResolvedUri = baseUri.OriginalString; } else { // Resolving failed //__DEBUG__.DebugForm. return(parsingError.Message); } } catch (UriFormatException ex) { MessageBox.Show("Error : " + ex.Message, "Resolving Uri", MessageBoxButtons.OK); } return(strResolvedUri); }
public new string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError) => base.Resolve(baseUri, relativeUri, out parsingError);
public new void InitializeAndValidate(Uri uri, out UriFormatException parsingError) => base.InitializeAndValidate(uri, out parsingError);
protected override string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError) { return(base.Resolve(baseUri, relativeUri, out parsingError)); }
public new void InitializeAndValidate(Uri uri, out UriFormatException parsingError) => base.InitializeAndValidate(uri, out parsingError);
public string _Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parserError) { return(base.Resolve(baseUri, relativeUri, out parserError)); }
protected internal virtual void InitializeAndValidate(Uri uri, out UriFormatException parsingError) { // bad boy, it should check null arguments. if ((uri.Scheme != scheme_name) && (scheme_name != "*")) // Here .NET seems to return "The Authority/Host could not be parsed", but it does not make sense. parsingError = new UriFormatException("The argument Uri's scheme does not match"); else parsingError = null; }
protected override void InitializeAndValidate(Uri uri, out UriFormatException parsingError) { parsingError = null; }
public void DangerousExposed_InitializeAndValidate(Uri uri, out UriFormatException parsingError) { InitializeAndValidate(uri, out parsingError); }
///------------------------------------------------------------------------------------------------- /// <summary> /// Initialize the state of the parser and validate the URI. /// </summary> /// /// <remarks> /// Joey Brock <*****@*****.**>, 4/19/2013. /// </remarks> /// /// <param name="uri"> /// The T:System.Uri to validate. /// </param> /// <param name="parsingError"> /// Validation errors, if any. /// </param> ///------------------------------------------------------------------------------------------------- protected virtual void InitializeAndValidate(Uri uri, out UriFormatException parsingError) { // The InitializeAndValidate method is called every time a Uri is instantiated parsingError = new UriFormatException(); }
protected virtual string Resolve(Uri baseUri, Uri relativeUri, ref UriFormatException parsingError) { throw new NotImplementedException(); }
public new string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError) => base.Resolve(baseUri, relativeUri, out parsingError);
protected override void InitializeAndValidate(Uri uri, out UriFormatException parsingError) { throw new NotImplementedException(); // base.InitializeAndValidate (uri, out parsingError); }
public void DenyUnrestricted() { // can we call everything without a SecurityException ? UriFormatException ufe = new UriFormatException(); }
protected override string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError) { throw new OutOfMemoryException(); // return base.Resolve (baseUri, relativeUri, out parsingError); }
private LogOn.FormInfo ValidateForm() { string value; HtmlInputControl htmlInputControl; LogOn.FormInfo formInfo = new LogOn.FormInfo(); LogOn.ValidateCharactersInString(this.userNameTextBox.Value); LogOn.ValidateCharactersInString(this.passwordTextBox.Value); LogOn.ValidateCharactersInString(this.altUserNameTextBox.Value); LogOn.ValidateCharactersInString(this.passwordTextBox.Value); LogOn.ValidateCharactersInString(this.connectionUriTextBox.Value); LogOn.ValidateCharactersInString(this.targetNodeTextBox.Value); LogOn.ValidateCharactersInString(this.configurationNameTextBox.Value); LogOn.ValidateCharactersInString(this.applicationNameTextBox.Value); formInfo.UserName = PswaHelper.TranslateLocalAccountName(this.userNameTextBox.Value); formInfo.Password = this.passwordTextBox.Value; LogOn.FormInfo formInfo1 = formInfo; if (this.altUserNameTextBox.Value.Length > 0) { value = this.altUserNameTextBox.Value; } else { value = formInfo.UserName; } formInfo1.DestinationUserName = value; if (this.altPasswordTextBox.Value.Length > 0) { htmlInputControl = this.altPasswordTextBox; } else { htmlInputControl = this.passwordTextBox; } char[] charArray = htmlInputControl.Value.ToCharArray(); formInfo.DestinationPassword = new SecureString(); for (int i = 0; i < (int)charArray.Length; i++) { formInfo.DestinationPassword.AppendChar(charArray[i]); charArray[i] = '*'; } formInfo.IsUriConnection = string.Compare(this.connectionTypeSelection.Value, "connection-uri", StringComparison.OrdinalIgnoreCase) == 0; if (!formInfo.IsUriConnection) { formInfo.ComputerName = this.targetNodeTextBox.Value; formInfo.UseSsl = this.useSslSelection.Value == "1"; if (this.portTextBox.Value.Length != 0) { if (!int.TryParse(this.portTextBox.Value, out formInfo.Port)) { throw PowwaException.CreateValidationErrorException(Resources.LogonError_InvalidPort); } } else { formInfo.Port = 0x1761; } formInfo.ApplicationName = this.applicationNameTextBox.Value; } else { try { formInfo.ConnectionUri = new Uri(this.connectionUriTextBox.Value); } catch (UriFormatException uriFormatException1) { UriFormatException uriFormatException = uriFormatException1; object[] message = new object[1]; message[0] = uriFormatException.Message; throw PowwaException.CreateValidationErrorException(string.Format(CultureInfo.CurrentUICulture, Resources.LogonError_InvalidUri, message)); } formInfo.AllowRedirection = this.allowRedirectionSelection.Value == "1"; } formInfo.ConfigurationName = this.configurationNameTextBox.Value; string str = this.authenticationTypeSelection.Value; string str1 = str; if (str != null) { if (str1 == "0") { formInfo.AuthenticationType = AuthenticationMechanism.Default; } else if (str1 == "1") { formInfo.AuthenticationType = AuthenticationMechanism.Basic; } else if (str1 == "2") { formInfo.AuthenticationType = AuthenticationMechanism.Negotiate; } else if (str1 == "4") { formInfo.AuthenticationType = AuthenticationMechanism.Credssp; } else if (str1 == "5") { formInfo.AuthenticationType = AuthenticationMechanism.Digest; } else if (str1 == "6") { formInfo.AuthenticationType = AuthenticationMechanism.Kerberos; } else { throw PowwaException.CreateValidationErrorException(Resources.InternalError_InvalidAuthenticationMechanism); } return(formInfo); } throw PowwaException.CreateValidationErrorException(Resources.InternalError_InvalidAuthenticationMechanism); }
protected virtual void InitializeAndValidate(Uri uri, ref UriFormatException parsingError) { throw new NotImplementedException(); }
public bool IniProxy(string sURL, string sUserName, string sPassword, string sDomain, ref string sServer, ref string sCode, bool bMsgBox = true) { bool result = false; try { try { if (sURL.StartsWith("http")) { this.__Proxy = new WebProxy(new Uri(sURL)); } else { this.__Proxy = new WebProxy(sURL); } } catch (UriFormatException expr_2E) { ProjectData.SetProjectError(expr_2E); UriFormatException ex = expr_2E; if (bMsgBox) { MessageBox.Show("URI Format is wrong for proxy address, please fix it!\r\nFormat: address_or_IP:port\r\n" + ex.Message, "URI format is wrong", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); } result = false; ProjectData.ClearProjectError(); return(result); } this.__Proxy.BypassProxyOnLocal = false; bool flag = false; if (false == (string.IsNullOrEmpty(sUserName) & string.IsNullOrEmpty(sPassword) & string.IsNullOrEmpty(sDomain))) { this.__Proxy.Credentials = new NetworkCredential(sUserName, sPassword, sDomain); } else if (flag == (string.IsNullOrEmpty(sUserName) & string.IsNullOrEmpty(sPassword))) { this.__Proxy.Credentials = new NetworkCredential(sUserName, sPassword); } if (this.TestOK(this.__Proxy, ref sServer, ref sCode)) { this.__Enable = true; } else { this.__Enable = false; } result = this.__Enable; } catch (WebException expr_ED) { ProjectData.SetProjectError(expr_ED); WebException ex2 = expr_ED; if (bMsgBox) { MessageBox.Show(ex2.ToString()); } ProjectData.ClearProjectError(); } return(result); }
protected internal virtual string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError) { // used by Uri.ctor and Uri.TryCreate throw new NotImplementedException(); }
protected override void InitializeAndValidate(Uri uri, out UriFormatException parsingError) { base.InitializeAndValidate(uri, out parsingError); }
public void _InitializeAndValidate(Uri uri, out UriFormatException parserError) { base.InitializeAndValidate(uri, out parserError); }
//[MonoTODO] protected internal virtual string Resolve(Uri baseUri, Uri relativeUri, out UriFormatException parsingError) { // used by Uri.ctor and Uri.TryCreate throw new NotImplementedException(); }