Beispiel #1
0
    public Dictionary <string, string> Configure(ISynapseDalConfig conifg)
    {
        if (conifg != null && conifg.Config != null)
        {
            string       s    = YamlHelpers.Serialize(conifg.Config);
            UriDalConfig fsds = YamlHelpers.Deserialize <UriDalConfig>(s);

            _planPath = fsds.PlanFolderPath;
            _histPath = fsds.HistoryFolderPath;
            _splxPath = fsds.Security.FilePath;

            EnsurePaths();

            ProcessPlansOnSingleton   = fsds.ProcessPlansOnSingleton;
            ProcessActionsOnSingleton = fsds.ProcessActionsOnSingleton;

            LoadSuplex();

            if (fsds.CloudPlatform == CloudPlatform.Azure)
            {
                AzureUriDalConfig azureConfig = YamlHelpers.Deserialize <AzureUriDalConfig>(s);
                cloudUriHandler = new AzureCloudUriHandler(azureConfig);
            }
            else
            {
                AWSUriDalConfig awsConfig = YamlHelpers.Deserialize <AWSUriDalConfig>(s);
                cloudUriHandler = new AWSCloudUriHandler(awsConfig);
            }
            EncryptionHelper.Configure(fsds);

            if (_splxDal == null && fsds.Security.IsRequired)
            {
                throw new Exception($"Security is required.  Could not load security file: {_splxPath}.");
            }

            if (_splxDal != null)
            {
                _splxDal.LdapRoot = conifg.LdapRoot;
                _splxDal.GlobalExternalGroupsCsv = fsds.Security.GlobalExternalGroupsCsv;
            }
        }
        else
        {
            ConfigureDefaults();
        }

        Dictionary <string, string> props = new Dictionary <string, string>();
        string name = nameof(UriDal);

        props.Add(name, CurrentPath);
        props.Add($"{name} Plan path", _planPath);
        props.Add($"{name} History path", _histPath);
        props.Add($"{name} Security path", _splxPath);
        return(props);
    }
Beispiel #2
0
    public Dictionary <string, string> Configure(ISynapseDalConfig conifg)
    {
        if (conifg != null)
        {
            string s = YamlHelpers.Serialize(conifg.Config);
            FileSystemDalConfig fsds = YamlHelpers.Deserialize <FileSystemDalConfig>(s);

            _planPath = fsds.PlanFolderPath;
            _histPath = fsds.HistoryFolderPath;
            _splxPath = fsds.Security.FilePath;

            EnsurePaths();

            ProcessPlansOnSingleton   = fsds.ProcessPlansOnSingleton;
            ProcessActionsOnSingleton = fsds.ProcessActionsOnSingleton;

            LoadSuplex();

            if (_splxDal == null && fsds.Security.IsRequired)
            {
                throw new Exception($"Security is required.  Could not load security file: {_splxPath}.");
            }

            if (_splxDal != null)
            {
                _splxDal.LdapRoot = conifg.LdapRoot;
                _splxDal.GlobalExternalGroupsCsv = fsds.Security.GlobalExternalGroupsCsv;
            }
        }
        else
        {
            ConfigureDefaults();
        }

        string name = nameof(FileSystemDal);
        Dictionary <string, string> props = new Dictionary <string, string>
        {
            { name, CurrentPath },
            { $"{name} Plan path", _planPath },
            { $"{name} History path", _histPath },
            { $"{name} Security path", _splxPath }
        };

        return(props);
    }
Beispiel #3
0
    public Dictionary <string, string> Configure(ISynapseDalConfig conifg)
    {
        if (conifg != null)
        {
            string         s    = YamlHelpers.Serialize(conifg.Config);
            AwsS3DalConfig fsds = YamlHelpers.Deserialize <AwsS3DalConfig>(s);

            _region = Amazon.RegionEndpoint.USEast1.ToString();

            if (string.IsNullOrWhiteSpace(fsds.AwsAccessKey) || string.IsNullOrWhiteSpace(fsds.AwsSecretAccessKey))
            {
                _awsClient = new zf.AwsClient(Amazon.RegionEndpoint.USEast1);
                _s3Client  = new Amazon.S3.AmazonS3Client(Amazon.RegionEndpoint.USEast1);
            }
            else
            {
                _awsClient = new zf.AwsClient(fsds.AwsAccessKey, fsds.AwsSecretAccessKey, Amazon.RegionEndpoint.USEast1);
                _s3Client  = new Amazon.S3.AmazonS3Client(fsds.AwsAccessKey, fsds.AwsSecretAccessKey, Amazon.RegionEndpoint.USEast1);
            }

            _bucketName = fsds.DefaultBucketName;

            _planPath            = fsds.PlanFolderPath;
            _histPath            = fsds.HistoryFolderPath;
            _histAsJson          = fsds.WriteHistoryAs == HistorySerializationFormat.FormattedJson || fsds.WriteHistoryAs == HistorySerializationFormat.CompressedJson;
            _histAsFormattedJson = fsds.WriteHistoryAs == HistorySerializationFormat.FormattedJson;
            _histExt             = _histAsJson ? ".json" : ".yaml";
            _splxPath            = fsds.Security.FilePath;

            EnsurePaths();

            ProcessPlansOnSingleton   = fsds.ProcessPlansOnSingleton;
            ProcessActionsOnSingleton = fsds.ProcessActionsOnSingleton;

            LoadSuplex();

            if (_splxDal == null && fsds.Security.IsRequired)
            {
                throw new Exception($"Security is required.  Could not load security file: {_splxPath}.");
            }

            if (_splxDal != null)
            {
                _splxDal.LdapRoot = conifg.LdapRoot;
                _splxDal.GlobalExternalGroupsCsv = fsds.Security.GlobalExternalGroupsCsv;
            }
        }
        else
        {
            ConfigureDefaults();
        }

        string name = nameof(AwsS3Dal);
        Dictionary <string, string> props = new Dictionary <string, string>
        {
            { name, CurrentPath },
            { $"{name} AWS Region", _region },
            { $"{name} S3 Default Bucket", _bucketName },
            { $"{name} Plan path", _planPath },
            { $"{name} History path", _histPath },
            { $"{name} Security path", _splxPath }
        };

        return(props);
    }
Beispiel #4
0
 public Dictionary <string, string> Configure(ISynapseDalConfig conifg)
 {
     throw new NotImplementedException();
 }
 public Dictionary <string, string> Configure(ISynapseDalConfig conifg)
 {
     return(null);
 }
Beispiel #6
0
    public Dictionary <string, string> Configure(ISynapseDalConfig conifg)
    {
        ComponentizedDalConfig cdc = null;

        if (conifg != null)
        {
            string s = YamlHelpers.Serialize(conifg.Config);
            cdc = YamlHelpers.Deserialize <ComponentizedDalConfig>(s);
        }
        else
        {
            cdc = (ComponentizedDalConfig)GetDefaultConfig();
        }

        Dictionary <string, string> secProps = new Dictionary <string, string>();
        ComponentizedDalItem        cdi      = cdc.DalComponents.SingleOrDefault(r => r.Key.Equals(cdc.SecurityProviderKey, StringComparison.OrdinalIgnoreCase));

        if (cdi != null)
        {
            _planSecurityProvider = AssemblyLoader.Load <IPlanSecurityProvider>(cdi.Type, string.Empty);
            secProps = _planSecurityProvider.Configure(new ConfigWrapper {
                Config = cdi.Config, Type = cdi.Type
            });
        }
        else
        {
            throw new TypeLoadException($"Could not load {cdi.Key}/{cdi.Type} for {nameof( IPlanSecurityProvider )}");
        }

        Dictionary <string, string> execProps = new Dictionary <string, string>();

        cdi = cdc.DalComponents.SingleOrDefault(r => r.Key.Equals(cdc.ExecuteReaderKey, StringComparison.OrdinalIgnoreCase));
        if (cdi != null)
        {
            _planExecuteReader = AssemblyLoader.Load <IPlanExecuteReader>(cdi.Type, string.Empty);
            execProps          = _planExecuteReader.Configure(new ConfigWrapper {
                Config = cdi.Config, Type = cdi.Type
            });
        }
        else
        {
            throw new TypeLoadException($"Could not load {cdi.Key}/{cdi.Type} for {nameof( IPlanExecuteReader )}");
        }

        Dictionary <string, string> histProps = new Dictionary <string, string>();

        cdi = cdc.DalComponents.SingleOrDefault(r => r.Key.Equals(cdc.HistoryWriterKey, StringComparison.OrdinalIgnoreCase));
        if (cdi != null)
        {
            _planHistoryWriter = AssemblyLoader.Load <IPlanHistoryWriter>(cdi.Type, string.Empty);
            histProps          = _planHistoryWriter.Configure(new ConfigWrapper {
                Config = cdi.Config, Type = cdi.Type
            });
        }
        else
        {
            throw new TypeLoadException($"Could not load {cdi.Key}/{cdi.Type} for {nameof( IPlanHistoryWriter )}");
        }


        string name = nameof(ComponentizedDal);
        Dictionary <string, string> props = new Dictionary <string, string>
        {
            { $"{name} ExecuteReaderKey", cdc.ExecuteReaderKey },
            { $"{name} HistoryWriterKey", cdc.HistoryWriterKey },
            { $"{name} SecurityProviderKey", cdc.SecurityProviderKey }
        };

        props.AddRange(execProps);
        props.AddRange(histProps);
        props.AddRange(secProps);
        return(props);
    }