Hello

I'm trying to write my first class. I want to use it as module and build anothers on top of it. I read that default functions attributes are not inherited. Is it that same for constructor? This is how my class (not finished) is looking right now:

class credential
{
        auto accessKey = environment.get["AWS_ACCESS_KEY"];
        auto secretKey = environment.get["AWS_SECRET_KEY"];
}

class sigv4 : credential
{
        public:
                string method;
                string service;
                string host;
                string region;
                string endpoint;
                string request_parameters;
                string payload;

        private:
                const algorithm = "AWS4-HMAC-SHA256";

                auto currentClock = Clock.currTime(UTC());
                auto currentDate = cast(Date)currentClock;
                auto curDateStr = currentDate.toISOString;
                auto currentTime = cast(TimeOfDay)currentClock;
                auto curTimeStr = currentTime.toISOString;
                auto xamztime = curDateStr ~ "T" ~ curTimeStr ~ "Z";

                auto hmac_sha256(ubyte[] key, ubyte[] msg)
                {
                        auto hmac = hmac!SHA256(key);
                        hmac.put(msg);
                        auto digest = hmac.finish;

                        return digest;
                }

auto getSignatureKey(string key, string dateStamp, string regionName, string serviceName)
                {
                        ubyte[] kString = cast(ubyte[])("AWS4" ~ key);
                        auto kDate = sign(kString, cast(ubyte[])dateStamp);
                        auto kRegion = sign(kDate, cast(ubyte[])regionName);
                        auto kService = sign(kRegion,  
cast(ubyte[])serviceName);
                        auto kSigning = sign(kService, 
cast(ubyte[])"aws4_request");

                        return kSigning;
                }

auto getCanonicalRequest(string canonicalURI, string canonicalQueryString, string canonicalHeaderString, string signedHeaders)
                {
                        string payloadHash = sha256Of("").toHexString.toLower;
string canonicalRequest = method ~ "\n" ~ canonicalURI ~ "\n" ~ canonicalQueryString ~ "\n" ~ canonicalHeadersString ~ "\n" ~ signedHeaders ~ "\n" ~ payloadHash;
                }

                this()
                {
                        
                }
}

I need to set all variables by defaults values from "public" and all needed by function "getCanonicalRequest". But if i will use that class to build another should i set defaults again? If yes is there some solution for it?

//holo

Reply via email to