All Downloads are FREE. Search and download functionalities are using the official Maven repository.

runtime.csharp.IRT.Transport.Authorization.AuthApiKey.cs Maven / Gradle / Ivy


using System;

namespace IRT.Transport.Authorization {
    class AuthApiKey: AuthMethod {
        public string ApiKey;

        public AuthApiKey(string apiKey = null) {
            ApiKey = apiKey;
        }

        public override bool FromValue(string value) {
            var lower = value.ToLower();
            if (value.StartsWith("api-key ", StringComparison.Ordinal)) {
                ApiKey = value.Substring(8);
                return true;
            }

            if (value.StartsWith("apikey ", StringComparison.Ordinal)) {
                ApiKey = value.Substring(7);
                return true;
            }

            return false;
        }

        public override string ToValue() {
            return "Api-Key " + ApiKey;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy