Skip to content

Commit bf5326b

Browse files
committedMar 9, 2025·
codefactor fixes
1 parent 4c6868b commit bf5326b

File tree

4 files changed

+61
-59
lines changed

4 files changed

+61
-59
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using Microsoft.IdentityModel.Tokens;
2+
3+
namespace WopiHost.Validator.Infrastructure;
4+
5+
public class NonSecureSecurityToken : SecurityToken
6+
{
7+
private readonly string _id;
8+
private readonly string _userName;
9+
private readonly DateTime _effectiveTime;
10+
11+
public NonSecureSecurityToken(string userName)
12+
{
13+
_userName = userName;
14+
_id = userName;// Guid.NewGuid().ToString("N");
15+
_effectiveTime = DateTime.UtcNow;
16+
}
17+
18+
public override string Id
19+
{
20+
get { return _id; }
21+
}
22+
23+
public override DateTime ValidFrom
24+
{
25+
get { return _effectiveTime; }
26+
}
27+
28+
public override DateTime ValidTo
29+
{
30+
// Never expire
31+
get { return DateTime.MaxValue; }
32+
}
33+
34+
public string UserName
35+
{
36+
get { return _userName; }
37+
}
38+
39+
public override string Issuer => throw new NotImplementedException();
40+
41+
public override SecurityKey SecurityKey => throw new NotImplementedException();
42+
43+
public override SecurityKey SigningKey { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
44+
}

‎sample/WopiHost.Validator/Infrastructure/WopiSecurityHandler.cs

-41
Original file line numberDiff line numberDiff line change
@@ -60,44 +60,3 @@ public Task<bool> IsAuthorized(ClaimsPrincipal principal, IWopiAuthorizationRequ
6060
/// </summary>
6161
public string WriteToken(SecurityToken token) => token.Id;
6262
}
63-
64-
public class NonSecureSecurityToken : SecurityToken
65-
{
66-
private readonly string _id;
67-
private readonly string _userName;
68-
private readonly DateTime _effectiveTime;
69-
70-
public NonSecureSecurityToken(string userName)
71-
{
72-
_userName = userName;
73-
_id = userName;// Guid.NewGuid().ToString("N");
74-
_effectiveTime = DateTime.UtcNow;
75-
}
76-
77-
public override string Id
78-
{
79-
get { return _id; }
80-
}
81-
82-
public override DateTime ValidFrom
83-
{
84-
get { return _effectiveTime; }
85-
}
86-
87-
public override DateTime ValidTo
88-
{
89-
// Never expire
90-
get { return DateTime.MaxValue; }
91-
}
92-
93-
public string UserName
94-
{
95-
get { return _userName; }
96-
}
97-
98-
public override string Issuer => throw new NotImplementedException();
99-
100-
public override SecurityKey SecurityKey => throw new NotImplementedException();
101-
102-
public override SecurityKey SigningKey { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
103-
}

‎src/WopiHost.Core/Controllers/EcosystemController.cs

+17-17
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ namespace WopiHost.Core.Controllers;
2222
public class EcosystemController(
2323
IWopiStorageProvider storageProvider) : ControllerBase
2424
{
25-
/// <summary>
26-
/// The GetRootContainer operation returns the root container. A WOPI client can use this operation to get a reference to the root container, from which the client can call EnumerateChildren (containers) to navigate a container hierarchy.
27-
/// Specification: https://learn.microsoft.com/microsoft-365/cloud-storage-partner-program/rest/ecosystem/getrootcontainer
28-
/// Example URL: GET /wopi/ecosystem/root_container_pointer
29-
/// </summary>
30-
/// <returns></returns>
31-
[HttpGet("root_container_pointer")]
32-
[Produces(MediaTypeNames.Application.Json)]
33-
public RootContainerInfo GetRootContainer() //TODO: fix the path
34-
{
35-
var root = storageProvider.GetWopiContainer(@".\");
36-
var rc = new RootContainerInfo
37-
{
38-
ContainerPointer = new ChildContainer(root.Name, Url.GetWopiUrl(WopiResourceType.Container, root.Identifier))
39-
};
40-
return rc;
41-
}
25+
/// <summary>
26+
/// The GetRootContainer operation returns the root container. A WOPI client can use this operation to get a reference to the root container, from which the client can call EnumerateChildren (containers) to navigate a container hierarchy.
27+
/// Specification: https://learn.microsoft.com/microsoft-365/cloud-storage-partner-program/rest/ecosystem/getrootcontainer
28+
/// Example URL: GET /wopi/ecosystem/root_container_pointer
29+
/// </summary>
30+
/// <returns></returns>
31+
[HttpGet("root_container_pointer")]
32+
[Produces(MediaTypeNames.Application.Json)]
33+
public RootContainerInfo GetRootContainer() //TODO: fix the path
34+
{
35+
var root = storageProvider.GetWopiContainer(@".\");
36+
var rc = new RootContainerInfo
37+
{
38+
ContainerPointer = new ChildContainer(root.Name, Url.GetWopiUrl(WopiResourceType.Container, root.Identifier))
39+
};
40+
return rc;
41+
}
4242

4343
/// <summary>
4444
/// The CheckEcosystem operation is similar to the the CheckFileInfo operation, but does not require a file or container ID.

‎src/WopiHost.Url/WopiUrlBuilder.cs

-1
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,4 @@ public partial class WopiUrlBuilder(IDiscoverer discoverer, WopiUrlSettings? url
6161
}
6262
return null;
6363
}
64-
6564
}

0 commit comments

Comments
 (0)
Please sign in to comment.