예제 #1
0
        public static AuthorizationContext CreateContext()
        {
            var config        = ServiceConfigurationLoader.Load();
            var configuration = config.ConnectionStrings["Authorization"];
            var context       = new AuthorizationContext(ConnectionFactory.Create(configuration));

            context.configuration = configuration;
            return(context);
        }
예제 #2
0
        public static ArcsAuditLogEntities CreateContext()
        {
            var config        = ServiceConfigurationLoader.Load();
            var configuration = config.ConnectionStrings[typeof(ArcsAuditLogEntities).Name];
            var context       = new ArcsAuditLogEntities(ConnectionFactory.Create(configuration));

            context.configuration = configuration;
            return(context);
        }
예제 #3
0
        /// <summary>
        /// PdfDocumentのコンストラクタ
        /// </summary>
        public PdfDocument()
        {
            var config = ServiceConfigurationLoader.Load();

            this.endPoint = config.AppSettings["pdfServiceUrl"].ToString();
            this.maxSize  = int.Parse(config.AppSettings["pdfMaxSize"].ToString());
            this.Service  = new PdfServiceEx()
            {
                Url = this.endPoint
            };
        }
        /// <summary>
        /// 認証処理の初期化を実行します。
        /// </summary>
        /// <param name="app">アプリケーション定義</param>
        public static void ConfigureAuth(IAppBuilder app)
        {
            var configuration = ServiceConfigurationLoader.Load();

            app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
            app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationType = ApplicationCookie,
                LoginPath          = new PathString(GetDefaultLoginPage(configuration)),
                Provider           = new CookieAuthenticationProvider()
            });
        }
예제 #5
0
        /// <summary>
        /// OutputLog
        /// </summary>
        /// <param name="exception"></param>
        private void OutputLog(Exception exception)
        {
            var serviceConfig   = ServiceConfigurationLoader.Load();
            var adapterSettings = LogConfiguration.CreateLogAdapterSetting(serviceConfig.Raw);
            var target          = new Logger(HttpContext.Current.Request.RawUrl, adapterSettings);
            var logData         = new LogData();

            logData.LogName   = "trace";
            logData.User      = HttpContext.Current.User.Identity.Name;
            logData.Message   = exception.Message;
            logData.Exception = exception;
            target.Error(logData);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Context.Request.RawUrl))
            {
                var serviceConfig = ServiceConfigurationLoader.Load();
                var logConfig     = new LogConfiguration(serviceConfig.Raw);
                var target        = new NLogAdapter(logConfig);
                var logData       = new LogData();
                logData.LogId   = Guid.NewGuid();
                logData.LogName = "trace";
                logData.User    = HttpContext.Current.User.Identity.Name;
                logData.Message = "Unauthorized: " + Context.Request.RawUrl;

                target.Error(logData);
            }
            this.refresh.Content = "5;URL=" + RedirectUrl;
        }
        /// <summary>
        /// ルートにアクセスされた際にデフォルトページにリダイレクトする設定
        /// </summary>
        /// <param name="app"><see cref="IAppBuilder"/></param>
        private void UseDefaultPage(IAppBuilder app)
        {
            var defaultPage   = "~/";
            var configuration = ServiceConfigurationLoader.Load();

            if (configuration.Raw.ContainsKey("defaultPage"))
            {
                defaultPage = VirtualPathUtility.ToAbsolute(configuration.Raw["defaultPage"].ToString());
            }

            app.Use(new Func <AppFunc, AppFunc>(next => (async env =>
            {
                var owinContext = new OwinContext(env);

                if (owinContext.Request.Path.Value == "/")
                {
                    owinContext.Response.Redirect(defaultPage);
                    return;
                }
                await next.Invoke(env);
            })));
        }
예제 #8
0
        public IMailSender Create(LogContext logContext)
        {
            var config     = ServiceConfigurationLoader.Load();
            var smtpConfig = config.Raw["smtpMail"].ToObject <SmtpMailConfiguration>();

            if (smtpConfig == null || string.IsNullOrWhiteSpace(smtpConfig.SendType))
            {
                return(null);
            }
            if (smtpConfig.SendType.ToUpper() == "SEND")
            {
                return(new SmtpMailSender(smtpConfig, logContext));
            }
            else if (smtpConfig.SendType.ToUpper() == "FIX")
            {
                return(new FixAddressMailSender(smtpConfig, logContext));
            }
            else if (smtpConfig.SendType.ToUpper() == "FILE")
            {
                return(new FileOutputMailSender(smtpConfig));
            }
            return(null);
        }
        private Employee GetAuthenticatedUserInfo(string userID)
        {
            var config  = ServiceConfigurationLoader.Load();
            var dir     = config.AppSettings["employeeInfoQueryDir"];
            var domains = ((JArray)config.AppSettings["employeeInfoTargetDomains"]).ToList();
            //@archwaytest.local

            var whereClases = domains.Select(d =>
            {
                return(string.Format("LOWER(TUSR001.AML) = LOWER(CONCAT(:UserID/*VARCHAR2(500)*/, '@{0}'))", d.Value <string>()));
            });

            var newQuery = string.Format(sql, string.Join(" OR ", whereClases));

            using (EmployeeInformationEntities context = EmployeeInformationEntities.CreateContext())
            {
                FileSqlDefinitionFactory factory = new FileSqlDefinitionFactory("ServiceUnits/Actos/V1/");
                DataQuery query = new DataQuery(context, factory, logContext).AppendQuery(newQuery);

                query.SetParameter("UserID", userID);

                return(query.GetList <Employee>().FirstOrDefault());
            }
        }
        /// <summary>
        /// 指定されたパスを解析し、結果の <see cref="PathInfo"/> を返します。
        /// </summary>
        /// <param name="path">解析するパス</param>
        /// <returns>解析された情報を保持する <see cref="PathInfo"/></returns>
        public static PathInfo Build(String path)
        {
            var targetPath = path;

            if (string.IsNullOrWhiteSpace(targetPath))
            {
                throw new ArgumentNullException("path");
            }
            targetPath = targetPath.Trim();
            if (targetPath.StartsWith("/"))
            {
                targetPath = targetPath.Substring(1);
            }
            if (targetPath.EndsWith("/"))
            {
                targetPath = targetPath.Substring(0, targetPath.Length - 1);
            }
            if (string.IsNullOrEmpty(targetPath))
            {
                return(null);
                //"ルートのみのパスは許可されません。"
            }

            var uri = new Uri("http://localhost/" + targetPath, UriKind.Absolute);

            var segments = uri.Segments.Skip(1).Select(seg => seg.TrimEnd('/')).ToArray();

            var baseSegments         = segments;
            var specificSegments     = Enumerable.Empty <string>();
            var specificSegmentIndex = baseSegments.FindIndex(s => s == "_");

            if (specificSegmentIndex > -1)
            {
                specificSegments = baseSegments.Skip(specificSegmentIndex + 1);
                if (specificSegments.Count() < 1)
                {
                    return(null);
                    //"URLの末尾が特殊処理URLを表す _ で終わっています。"
                }
                baseSegments = baseSegments.Take(specificSegmentIndex).ToArray();
            }

            if (baseSegments.Length < 3)
            {
                return(null);
                //"URLには処理の指定までが必要です。 {ServiceUnitName}/{Version}/{Role}/{ProcessType}"
            }

            //一覧の設定にない値の場合は ProcessType とみなす処理
            var baseSegmentList     = baseSegments.ToList();
            var specificSegmentList = specificSegments.ToList();

            var config = ServiceConfigurationLoader.Load(baseSegmentList[0], baseSegmentList[1]);

            var result = new PathInfo();

            result.ServiceUnitName = baseSegmentList[0];
            result.Version         = baseSegmentList[1];

            var pos = 1;

            if (config.AvailableRoles.Contains(baseSegmentList[2]))
            {
                if (baseSegments.Length < 4)
                {
                    return(null);
                    //"URLには処理の指定までが必要です。 {ServiceUnitName}/{Version}/{Role}/{ProcessType}"
                }

                result.Role = baseSegmentList[2];
                config      = ServiceConfigurationLoader.Load(baseSegmentList[0], baseSegmentList[1], baseSegmentList[2]);
                pos         = 0;
            }
            result.Path = uri.AbsolutePath;

            result.ProcessType = baseSegmentList[3 - pos];
            result.ProcessPath = "/" + string.Join("/", baseSegmentList.Skip(4 - pos));

            if (specificSegmentList.Count > 0)
            {
                result.SpecificProcessPath = "/" + string.Join("/", specificSegmentList);
            }
            var queries = HttpUtility.ParseQueryString(uri.Query);

            result.Query = queries.AllKeys.Aggregate(new Dictionary <string, string>(), (dic, key) =>
            {
                dic.Add(key, queries.Get(key));
                return(dic);
            });

            return(result);
        }