diff --git a/web/documentserver-example/csharp-mvc/Helpers/DocumentConverter.cs b/web/documentserver-example/csharp-mvc/Helpers/DocumentConverter.cs index b5d4a83d..9a225a58 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/DocumentConverter.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/DocumentConverter.cs @@ -130,7 +130,7 @@ namespace OnlineEditorsExampleMVC.Helpers var payloadToken = JwtManager.Encode(payload); // encode the payload object to the payload token var bodyToken = JwtManager.Encode(body); // encode the body object to the body token // create header token - string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; + string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; request.Headers.Add(JWTheader, "Bearer " + payloadToken); body.Add("token", bodyToken); diff --git a/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs b/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs index 0e4c97fb..8e167190 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs @@ -55,7 +55,7 @@ namespace OnlineEditorsExampleMVC.Helpers // check if the document token is enabled if (JwtManager.Enabled) { - string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; + string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; string token = null; @@ -92,7 +92,7 @@ namespace OnlineEditorsExampleMVC.Helpers // file saving process public static int processSave(Dictionary fileData, string fileName, string userAddress) { - if (fileData["url"].Equals(null)) { + if (string.IsNullOrEmpty((string)fileData["url"])) { throw new Exception("DownloadUrl is null"); } var downloadUri = (string)fileData["url"]; @@ -169,7 +169,7 @@ namespace OnlineEditorsExampleMVC.Helpers // file force saving process public static int processForceSave(Dictionary fileData, string fileName, string userAddress) { - if (fileData["url"].Equals(null)) { + if ( string.IsNullOrEmpty((string)fileData["url"])) { throw new Exception("DownloadUrl is null"); } var downloadUri = (string)fileData["url"]; @@ -228,7 +228,7 @@ namespace OnlineEditorsExampleMVC.Helpers fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress); } forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false); - if (forcesavePath.Equals("")) // create forcesave path if it doesn't exist + if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist { forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, true); } @@ -279,7 +279,7 @@ namespace OnlineEditorsExampleMVC.Helpers var payloadToken = JwtManager.Encode(payload); // encode a payload object into a header token var bodyToken = JwtManager.Encode(body); // encode body into a body token - string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; + string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; request.Headers.Add(JWTheader, "Bearer " + payloadToken); // add a header Authorization with a header token and Authorization prefix in it body.Add("token", bodyToken); diff --git a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs index 794559c7..188faa18 100644 --- a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs @@ -463,13 +463,13 @@ namespace OnlineEditorsExampleMVC if (JwtManager.Enabled && isEmbedded == null) { - string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; + string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase)) { var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length); string token = JwtManager.Decode(headerToken); - if (token == null || token.Equals("")) + if (string.IsNullOrEmpty(token)) { context.Response.StatusCode = (int)HttpStatusCode.Forbidden; context.Response.Write("JWT validation failed"); @@ -479,7 +479,7 @@ namespace OnlineEditorsExampleMVC } var filePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false); // get the path to the force saved document version - if (filePath.Equals("")) + if (string.IsNullOrEmpty(filePath)) { filePath = DocManagerHelper.StoragePath(fileName, userAddress); // or to the original document } @@ -520,14 +520,14 @@ namespace OnlineEditorsExampleMVC if (JwtManager.Enabled) { - string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; + string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase)) { var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length); string token = JwtManager.Decode(headerToken); - if (token == null || token.Equals("")) + if (string.IsNullOrEmpty(token)) { context.Response.StatusCode = (int)HttpStatusCode.Forbidden; context.Response.Write("JWT validation failed"); diff --git a/web/documentserver-example/csharp/DocumentConverter.cs b/web/documentserver-example/csharp/DocumentConverter.cs index 2cb0dd4e..1844c1b6 100644 --- a/web/documentserver-example/csharp/DocumentConverter.cs +++ b/web/documentserver-example/csharp/DocumentConverter.cs @@ -132,7 +132,7 @@ namespace ASC.Api.DocumentConverter var payloadToken = JwtManager.Encode(payload); // encode the payload object to the payload token var bodyToken = JwtManager.Encode(body); // encode the body object to the body token // create header token - string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; + string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; request.Headers.Add(JWTheader, "Bearer " + payloadToken); // and add it to the request headers with the Bearer prefix body.Add("token", bodyToken); diff --git a/web/documentserver-example/csharp/TrackManager.cs b/web/documentserver-example/csharp/TrackManager.cs index 145b60f9..69192d0a 100644 --- a/web/documentserver-example/csharp/TrackManager.cs +++ b/web/documentserver-example/csharp/TrackManager.cs @@ -57,7 +57,7 @@ namespace OnlineEditorsExample // check if the document token is enabled if (JwtManager.Enabled) { - string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; + string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; string token = null; @@ -76,7 +76,7 @@ namespace OnlineEditorsExample context.Response.Write("{\"error\":1,\"message\":\"JWT expected\"}"); } - if (token != null && !token.Equals("")) // invalid signature error + if (!string.IsNullOrEmpty(token)) // invalid signature error { fileData = jss.Deserialize>(token); if (fileData.ContainsKey("payload")) @@ -160,7 +160,7 @@ namespace OnlineEditorsExample File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file string forcesavePath = _Default.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version - if (!forcesavePath.Equals("")) // if the forcesaved file version exists + if (!string.IsNullOrEmpty(forcesavePath)) // if the forcesaved file version exists { File.Delete(forcesavePath); // remove it } @@ -231,7 +231,7 @@ namespace OnlineEditorsExample } forcesavePath = _Default.ForcesavePath(fileName, userAddress, false); - if (forcesavePath.Equals("")) // create forcesave path if it doesn't exist + if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist { forcesavePath = _Default.ForcesavePath(fileName, userAddress, true); } @@ -282,7 +282,7 @@ namespace OnlineEditorsExample var payloadToken = JwtManager.Encode(payload); // encode a payload object into a header token var bodyToken = JwtManager.Encode(body); // encode body into a body token - string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; + string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; request.Headers.Add(JWTheader, "Bearer " + payloadToken); // add a header Authorization with a header token and Authorization prefix in it body.Add("token", bodyToken); diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index 50ba23bb..d24cf407 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -283,14 +283,14 @@ namespace OnlineEditorsExample if (JwtManager.Enabled && isEmbedded == null) { - string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; + string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase)) { var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length); string token = JwtManager.Decode(headerToken); - if (token == null || token.Equals("")) + if (string.IsNullOrEmpty(token)) { context.Response.StatusCode = (int)HttpStatusCode.Forbidden; context.Response.Write("JWT validation failed"); @@ -300,7 +300,7 @@ namespace OnlineEditorsExample } var filePath = _Default.ForcesavePath(fileName, userAddress, false); // get the path to the force saved document version - if (filePath.Equals("")) + if (string.IsNullOrEmpty(filePath)) { filePath = _Default.StoragePath(fileName, userAddress); // or to the original document } @@ -340,14 +340,14 @@ namespace OnlineEditorsExample if (JwtManager.Enabled) { - string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; + string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"]; if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase)) { var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length); string token = JwtManager.Decode(headerToken); - if (token == null || token.Equals("")) + if (string.IsNullOrEmpty(token)) { context.Response.StatusCode = (int)HttpStatusCode.Forbidden; context.Response.Write("JWT validation failed");