runtime.csharp.IRT.Transport.Server.SystemContext.cs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of idealingua-v1-runtime-rpc-c-sharp_2.13 Show documentation
Show all versions of idealingua-v1-runtime-rpc-c-sharp_2.13 Show documentation
idealingua-v1-runtime-rpc-c-sharp
The newest version!
using IRT.Transport.Authorization;
namespace IRT.Transport.Server {
public class SystemContext {
public AuthMethod Auth;
public bool UpdateAuth(string value) {
if (string.IsNullOrEmpty(value)) {
Auth = null;
return true;
}
if (value.StartsWith("Bearer ")) {
Auth = new AuthToken();
} else
if (value.StartsWith("Basic ")) {
Auth = new AuthBasic();
} else {
var lower = value.ToLowerInvariant();
if (lower.StartsWith("api-key") || lower.StartsWith("apikey")) {
Auth = new AuthApiKey();
} else {
Auth = new AuthCustom();
}
}
return Auth.FromValue(value);
}
}
}