Ejemplo n.º 1
0
    public IProfile?GetProfile(string name)
    {
        byte[]? data;

        try
        {
            data = _storage.Get(name);
        }
        catch
        {
            return(null);
        }

        if (data == null)
        {
            return(null);
        }

        IProfile profile = _serializer.Deserialize <Profile>(data);

        //Check if the we have the right protector
        string?protector = profile.GetTag("Protector");

        string profileProtector = protector ?? string.Empty;
        string userProtector    = _protector != null?_protector.GetType().Name : string.Empty;

        if (!string.Equals(profileProtector, userProtector, StringComparison.OrdinalIgnoreCase))
        {
            throw new S3Exception($"The access key is protected with '{protector}' but it was not available");
        }

        return(profile);
    }
Ejemplo n.º 2
0
        public IProfile GetProfile(string name)
        {
            byte[] data;

            try
            {
                data = _storage.Get(name);
            }
            catch
            {
                return(null);
            }

            if (data == null)
            {
                return(null);
            }

            IProfile profile = _serializer.Deserialize <Profile>(data);

            //Check if the we have the right protector
            string protector = profile.GetTag("Protector");

            if (!string.IsNullOrEmpty(protector))
            {
                if (_protector == null || !protector.Equals(_protector.GetType().Name, StringComparison.OrdinalIgnoreCase))
                {
                    throw new Exception("The access key is protected with " + protector + " but it was not available");
                }
            }

            return(profile);
        }