Exemplo n.º 1
0
        /// <summary>
        /// Handles the logout timer configuration values retrieval request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>A <see cref="Agatha.Common.Response"/></returns>
        public override Response Handle(GetTimeOutIntervalRequest request)
        {
            var automaticLogoutIntervalMinutesResult = _configurationPropertiesProvider.GetProperty(AutomaticLogoutIntervalMinutes);
            int automaticTimeOutIntervalMinutes;

            if (!int.TryParse(automaticLogoutIntervalMinutesResult, out automaticTimeOutIntervalMinutes))
            {
                throw new ArgumentException("A valid automatic logout time interval could not be obtained from configuration.");
            }

            var warningLogoutIntervalSecondsResult = _configurationPropertiesProvider.GetProperty(WarningLogoutIntervalSeconds);
            int warningTimeOutIntervalSeconds;

            if (!int.TryParse(warningLogoutIntervalSecondsResult, out warningTimeOutIntervalSeconds))
            {
                throw new ArgumentException("A valid warning logout time interval could not be obtained from configuration.");
            }

            var response = CreateTypedResponse();

            response.AutomaticTimeOutIntervalMinutes = automaticTimeOutIntervalMinutes;
            response.WarningTimeOutIntervalSeconds   = warningTimeOutIntervalSeconds;

            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>A <see cref="Agatha.Common.Response"/></returns>
        public override Response Handle(GetAllReportsRequest request)
        {
            var response     = new GetAllReportsResponse();
            var reports      = _reportRepository.GetAllReports().ToList();
            var catalogItems = GetAllReportsFromSsrs();
            var reportDtos   = new List <ReportDto> ();

            for (var index = 0; index < reports.Count; index++)
            {
                ////TODO: Check how this works when report has paramaters.
                var index1 = index; //To avoid Access to modified closure.
                if (catalogItems.Where(ci => ci.Name == reports[index1].ResourceName).Count() > 0)
                {
                    reportDtos.Add(
                        new ReportDto
                    {
                        Key          = reports[index1].Key,
                        Name         = reports[index].Name,
                        Description  = reports[index].Description,
                        ResourceName = reports[index].ResourceName
                    });
                }
                else
                {
                    ////Report entry exists in database, but not present in SSRS.
                    reports.Remove(reports[index]);
                    index--;
                }
            }

            response.Reports        = reportDtos;
            response.ReportsRootUri = _configurationPropertiesProvider.GetProperty(SettingKeyNames.ReportsRootUri);

            return(response);
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="SystemAccountIdentityServiceManager" /> class.
 /// </summary>
 /// <param name="appSettingsConfiguration">The app settings configuration.</param>
 public SystemAccountIdentityServiceManager(IConfigurationPropertiesProvider appSettingsConfiguration)
 {
     _baseAddress =
         new Uri(((FederatedAuthentication.WSFederationAuthenticationModule ?? new WSFederationAuthenticationModule()).Issuer.Replace("issue/wsfed", "")));
     _userName   = appSettingsConfiguration.GetProperty <string> (IdentityServerUserName);
     _password   = appSettingsConfiguration.GetProperty <string> (IdentityServerPassword);
     _expiration = DateTime.MinValue;
 }
        /// <summary>
        ///     Initializes a new instance of the <see cref="SystemAccountIdentityServiceManager" /> class.
        /// </summary>
        /// <param name="appSettingsConfiguration">The app settings configuration.</param>
        public SystemAccountIdentityServiceManager(IConfigurationPropertiesProvider appSettingsConfiguration)
        {
            var issuerUri = new Uri((FederatedAuthentication.WSFederationAuthenticationModule ?? new WSFederationAuthenticationModule()).Issuer);
            var url       = issuerUri.AbsoluteUri.Replace("issue/wsfed", string.Empty);

            if (url.EndsWith("//"))
            {
                url = url.Substring(0, url.Length - 1);
            }
            _baseAddress = new Uri(url);
            _userName    = appSettingsConfiguration.GetProperty <string> (IdentityServerUserName);
            _password    = appSettingsConfiguration.GetProperty <string> (IdentityServerPassword);
            _expiration  = DateTime.MinValue;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Loaders the key from configuration.
        /// </summary>
        public void LoaderKeyFromConfiguration()
        {
            // Retrieve the Keys from Configuration Store
            var key = _configurationPropertiesProvider.GetProperty(MeaningfulUseEncryptionKeyPropertyName);
            var iv  = _configurationPropertiesProvider.GetProperty(MeaningfulUseEncryptionIvPropertyName);

            //TODO: This is not how we want to deal with this beyond Meaningful Use Certification
            Check.IsNotNullOrWhitespace(key, "The Configuration Store did not contain an AES Key for Document Encryption");
            Check.IsNotNullOrWhitespace(iv, "The Configuration Store did not contain an AES IV for Document Encryption");

            KeyCypher = Convert.FromBase64String(key);
            IvCypher  = Convert.FromBase64String(iv);

            _isKeyLoaded = true;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the imap client.
        /// </summary>
        /// <returns>Imap 4 client.</returns>
        public Imap4Client GetImapClient()
        {
            string imapServer = _configurationPropertiesProvider.GetProperty(SettingKeyNames.ImapServer);
            int    imapPort   = _configurationPropertiesProvider.GetPropertyInt(SettingKeyNames.ImapPort);

            // Retrieves the Current User Context
            UserInformationDto info = _userInformationDtoFactory.CreateUserInformationDto();

            // Retrieves the corresponding Staff record for the current user
            Staff staff = _sessionProvider.GetSession().QueryOver <Staff>().Where(s => s.Key == info.StaffKey).SingleOrDefault();

            //string username = "******";
            //string password = "******";

            string username = null;
            string password = null;

            if (staff.DirectAddressCredential.DirectAddress != null)
            {
                username = staff.DirectAddressCredential.DirectAddress.Address;
                password = staff.DirectAddressCredential.DirectAddressPassword;
            }

            if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
            {
                throw new ApplicationException("Username/password are not provided to access IMAP mail server.");
            }

            var imap4Client = new Imap4Client();

            imap4Client.Connect(imapServer, imapPort, username, password);

            return(imap4Client);
        }
Exemplo n.º 7
0
        private void LoadConfiguration()
        {
            var cannedErrorMessage = "Unable to find {0} in the configuration Store";

            var configName           = _configProvider.GetProperty(IdentityServerEndpointConfigName);
            var identityProviderName = _configProvider.GetProperty(IdentityProviderNameConfigName);
            var identityProviderUri  = _configProvider.GetProperty(IdentityProviderUriConfigName);

            _membershipServiceEndpointAddress = Check.IsNotNullOrWhitespaceAndAssign(
                configName, string.Format(cannedErrorMessage, IdentityServerEndpointConfigName));

            _identityProviderName = Check.IsNotNullOrWhitespaceAndAssign(
                identityProviderName, string.Format(cannedErrorMessage, IdentityProviderNameConfigName));

            _identityProviderUri = Check.IsNotNullOrWhitespaceAndAssign(
                identityProviderUri, string.Format(cannedErrorMessage, IdentityProviderUriConfigName));
        }
        /// <summary>
        /// Configures this instance.
        /// </summary>
        /// <returns>A IPersistenceConfigurer object.</returns>
        public IPersistenceConfigurer Configure()
        {
            IPersistenceConfigurer database;

            bool   useTrustedConnection = true;
            string databasePassword     = string.Empty;
            string databaseUsername     = string.Empty;

            string databaseServer = _configurationPropertiesProvider.GetProperty(SettingKeyNames.DatabaseServerName);
            string databaseName   = _configurationPropertiesProvider.GetProperty(SettingKeyNames.DatabaseCatalogName);

            bool.TryParse(_configurationPropertiesProvider.GetProperty(SettingKeyNames.UseTrustedConnection), out useTrustedConnection);

            if (useTrustedConnection)
            {
                database = MsSqlConfiguration.MsSql2008.ConnectionString(
                    c => c
                    .Server(databaseServer)
                    .Database(databaseName)
                    .TrustedConnection())
                           .AdoNetBatchSize(10)
                           .UseOuterJoin()
                           .QuerySubstitutions("true 1, false 0, yes 'Y', no 'N'");
            }
            else
            {
                databasePassword = _configurationPropertiesProvider.GetProperty(SettingKeyNames.DatabasePassword);
                databaseUsername = _configurationPropertiesProvider.GetProperty(SettingKeyNames.DatabaseUsername);

                database = MsSqlConfiguration.MsSql2008.ConnectionString(
                    c => c
                    .Server(databaseServer)
                    .Database(databaseName)
                    .Username(databaseUsername)
                    .Password(databasePassword))
                           .AdoNetBatchSize(10)
                           .UseOuterJoin()
                           .QuerySubstitutions("true 1, false 0, yes 'Y', no 'N'");
            }


            return(database);
        }
Exemplo n.º 9
0
        private string CreateHtmlC32(string c32Xml)
        {
            // TODO: This could be resused somewhere else.

            string stylesheetPath = _configurationPropertiesProvider.GetProperty(SettingKeyNames.C32XsltStylesheet);

            var xmlDoc       = new XmlDocument();
            var stringWriter = new StringWriter();
            var xslTransform = new XslCompiledTransform();

            xmlDoc.LoadXml(c32Xml);
            xslTransform.Load(HttpRuntime.AppDomainAppPath + stylesheetPath);
            xslTransform.Transform(xmlDoc.CreateNavigator(), new XsltArgumentList(), stringWriter);

            string html = stringWriter.ToString();

            return(html);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Sends the specified mail message.
        /// </summary>
        /// <param name="mailMessage">The mail message.</param>
        public void Send(MailMessage <MailMessageHeader> mailMessage)
        {
            Check.IsNotNull(mailMessage, "Mail message cannot be null.");

            var smtpServer = _configurationPropertiesProvider.GetProperty(SettingKeyNames.SmtpServer);
            var smtpPort   = _configurationPropertiesProvider.GetPropertyInt(SettingKeyNames.SmtpPort);

            using (var client = new SmtpClient(smtpServer, smtpPort))
            {
                var message = new MailMessage(
                    new MailAddress(mailMessage.Header.FromAddress, mailMessage.Header.FromName),
                    new MailAddress(mailMessage.Header.ToAddress))
                {
                    Subject = mailMessage.Header.Subject, Body = mailMessage.BodyText
                };

                mailMessage.Attachments.ForEach(
                    p =>
                {
                    if (!string.IsNullOrWhiteSpace(p.FileName))
                    {
                        Attachment smtpAttachment;
                        if (p.ContentBytes != null)
                        {
                            smtpAttachment = CreateAttachmentFromBytes(p.ContentBytes, p.FileName);
                        }
                        else
                        {
                            smtpAttachment = CreateAttachmentFromString(p.ContentString, p.FileName);
                        }
                        message.Attachments.Add(smtpAttachment);
                    }
                }
                    );

                client.Send(message);
            }
        }
Exemplo n.º 11
0
        private void LoadConfiguration()
        {
            _newCropPartnerName    = _configProvider.GetProperty(NewCropConfigurationStoreProperty.PartnerNamePropertyName);
            _newCropUserName       = _configProvider.GetProperty(NewCropConfigurationStoreProperty.UserNamePropertyName);
            _newCropPassword       = _configProvider.GetProperty(NewCropConfigurationStoreProperty.PasswordPropertyName);
            _newCropProductName    = _configProvider.GetProperty(NewCropConfigurationStoreProperty.ProductNamePropertyName);
            _newCropProductVersion = _configProvider.GetProperty(NewCropConfigurationStoreProperty.ProductVersionPropertyName);
            _newCropAccountId      = _configProvider.GetProperty(NewCropConfigurationStoreProperty.AccountIdPropertyName);
            _newCropAccountName    = _configProvider.GetProperty(NewCropConfigurationStoreProperty.AccountNamePropertyName);

            var format = "The Configuration store does not contain a property named {0}";

            Check.IsNotNullOrWhitespace
            (
                _newCropPartnerName,
                string.Format(format, NewCropConfigurationStoreProperty.PartnerNamePropertyName));

            Check.IsNotNullOrWhitespace
            (
                _newCropUserName,
                string.Format(format, NewCropConfigurationStoreProperty.UserNamePropertyName));

            Check.IsNotNullOrWhitespace
            (
                _newCropPassword,
                string.Format(format, NewCropConfigurationStoreProperty.PasswordPropertyName));

            Check.IsNotNullOrWhitespace
            (
                _newCropProductName,
                string.Format(format, NewCropConfigurationStoreProperty.ProductNamePropertyName));

            Check.IsNotNullOrWhitespace
            (
                _newCropProductVersion,
                string.Format(format, NewCropConfigurationStoreProperty.ProductVersionPropertyName));
        }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="C32ToPopHealthPoster"/> class.
 /// </summary>
 /// <param name="c32Builder">The C32 builder.</param>
 /// <param name="configurationPropertiesProvider">The configuration properties provider.</param>
 public C32ToPopHealthPoster(IC32Builder c32Builder, IConfigurationPropertiesProvider configurationPropertiesProvider)
 {
     _c32Builder       = c32Builder;
     _requestUriString = configurationPropertiesProvider.GetProperty(PopHealthServiceAddress);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="C32ToPopHealthPoster"/> class.
 /// </summary>
 /// <param name="c32Builder">The C32 builder.</param>
 /// <param name="configurationPropertiesProvider">The configuration properties provider.</param>
 public C32ToPopHealthPoster( IC32Builder c32Builder, IConfigurationPropertiesProvider configurationPropertiesProvider )
 {
     _c32Builder = c32Builder;
     _requestUriString = configurationPropertiesProvider.GetProperty ( PopHealthServiceAddress );
 }
Exemplo n.º 14
0
 /// <summary>
 /// Gets the service URL.
 /// </summary>
 /// <returns>The service url.</returns>
 protected override string GetServiceUrl()
 {
     return(_configurationPropertiesProvider.GetProperty(SettingKeyNames.ReportExecutionUrl));
 }