Ejemplo n.º 1
0
        /// <summary>XmlDocumentをLoad</summary>
        /// <param name="filePath">string</param>
        /// <returns>
        /// 真 : ロードできた
        /// 偽 : ロードできなかった
        /// </returns>
        private static bool LoadFromFile(string filePath)
        {
            if (EmbeddedResourceLoader.Exists(filePath, false))
            {
                XmlDocument xMLMSG = new XmlDocument();

                // Load
                xMLMSG.LoadXml(EmbeddedResourceLoader.LoadXMLAsString(filePath));
                // Save
                GetMessage.DicMSG[filePath] = GetMessage.FillDictionary(xMLMSG);

                return(true);
            }
            else if (ResourceLoader.Exists(filePath, false))
            {
                XmlDocument xMLMSG = new XmlDocument();

                // Load
                xMLMSG.Load(PubCmnFunction.BuiltStringIntoEnvironmentVariable(filePath));
                // Save
                GetMessage.DicMSG[filePath] = GetMessage.FillDictionary(xMLMSG);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public static Node NewNode(string ModID, string Path)
        {
            string TargetPath = "res://" + ModID + "/Nodes/" + Path + ".tscn";

            if (!ResourceLoader.Exists(TargetPath))
            {
                return(default);
Ejemplo n.º 3
0
        private static PackedScene LoadPackedScene(String path)
        {
            String full_path = path;

            if (!ResourceLoader.Exists(full_path))
            {
                MDLog.Warn(LOG_CAT, $"Can't find: {full_path}");
            }
            return((PackedScene)ResourceLoader.Load(full_path));
        }
Ejemplo n.º 4
0
    public static AudioStream loadInternalSound(string path, bool loop)
    {
        var stream = ResourceLoader.Exists(path) ? ResourceLoader.Load <AudioStreamOGGVorbis>(path) : null;

        if (stream != null)
        {
            stream.Loop = loop;
        }
        return(stream);
    }
Ejemplo n.º 5
0
 public void ExistsTest(string loadfilepath, bool throwException)
 {
     try
     {
         bool result = ResourceLoader.Exists(loadfilepath, throwException);
         Assert.True(result);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         throw;
     }
 }
Ejemplo n.º 6
0
    // returns location of Dino stats save
    public string GetDinoSaveLocation(Enums.Dinos dinoType)
    {
        string dinoNameNoSpaces = EnumUtils.GetDinoName(dinoType).Replace(" ", string.Empty);
        string userSaveLocation = $"user://{dinoNameNoSpaces}StatsSave.tres";

        // make a savefile in the user:// location if none exists yet
        if (!ResourceLoader.Exists(userSaveLocation))
        {
            string projectStatsLocation = $"res://src/combat/dinos/stats/{dinoNameNoSpaces}.tres";
            ResourceSaver.Save(userSaveLocation, ResourceLoader.Load <DinoInfoResource>(projectStatsLocation, null, true));
        }

        return(userSaveLocation);
    }
        /// <summary>Get</summary>
        /// <param name="fileName">
        /// CurrentUICulture等の拡張子を除くテキスト・ファイル名
        /// </param>
        /// <param name="codePage"></param>
        /// <param name="resourcesString">
        /// テキスト・ファイルが見つからない場合に使用するリソース文字列
        /// </param>
        /// <returns>文字列</returns>
        public static string Get(string fileName, int codePage, string resourcesString)
        {
            CultureInfo currentUICulture = null;
            string      uICultureName    = "";
            string      contentOfLetter  = "";

            // テキスト・ファイル文字列の利用
            do
            {
                if (currentUICulture == null)
                {
                    // 初回
                    currentUICulture = Thread.CurrentThread.CurrentUICulture;
                }
                else
                {
                    // フォールバック
                    currentUICulture = currentUICulture.Parent;
                }

                uICultureName = currentUICulture.Name;

                string path = GetConfigParameter.GetConfigValue("ContentOfLetterFilePath") + "\\" + fileName + string.Format(".{0}.txt", uICultureName);
                if (ResourceLoader.Exists(path, false))
                {
                    contentOfLetter = ResourceLoader.LoadAsString(path, Encoding.GetEncoding(codePage));
                }
            }while (
                !string.IsNullOrEmpty(uICultureName) &&   // フォールバックが終わった。
                string.IsNullOrEmpty(contentOfLetter)     // ファイルを読み取れなかった。
                );

            if (string.IsNullOrEmpty(contentOfLetter)) // 既定(英語)
            {
                string path = GetConfigParameter.GetConfigValue("ContentOfLetterFilePath") + "\\" + fileName + ".txt";
                if (ResourceLoader.Exists(path, false))
                {
                    contentOfLetter = ResourceLoader.LoadAsString(path, Encoding.GetEncoding(codePage));
                }
            }

            // リソース文字列の利用
            if (string.IsNullOrEmpty(contentOfLetter) && !string.IsNullOrEmpty(resourcesString))
            {
                contentOfLetter = resourcesString;
            }

            return(contentOfLetter);
        }
Ejemplo n.º 8
0
 public void ExistsTest1(string filePath, string fileName, bool throwException)
 {
     try
     {
         bool result = ResourceLoader.Exists(filePath, fileName, throwException);
         if (result)
         {
             Assert.True(result);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         throw;
     }
 }
Ejemplo n.º 9
0
    /// <summary>
    ///   Loads a Texture from predefined GUI asset texture folder path.
    /// </summary>
    public static Texture LoadGuiTexture(string file)
    {
        var assumedPath = PathUtils.Join(Constants.ASSETS_GUI_BEVEL_FOLDER, file);

        if (ResourceLoader.Exists(assumedPath, "Texture"))
        {
            return(GD.Load <Texture>(assumedPath));
        }

        // Fail-safe if file itself is the absolute path
        if (ResourceLoader.Exists(file, "Texture"))
        {
            return(GD.Load <Texture>(file));
        }

        return(GD.Load(file) as Texture);
    }
Ejemplo n.º 10
0
    public override void _Ready()
    {
        Instance = this;

        // load player stats; make a new one if none exists from the pre-existing one in the project
        string statsSaveLocation    = "user://PlayerStatsSave.tres";
        string projectStatsLocation = "res://src/resources/PlayerStats.tres";

        if (!ResourceLoader.Exists(statsSaveLocation))
        {
            ResourceSaver.Save(statsSaveLocation, ResourceLoader.Load <PlayerStatsResource>(projectStatsLocation));
        }
        statsResource = ResourceLoader.Load <PlayerStatsResource>("user://PlayerStatsSave.tres", null, true);

        dinosUnlocked = statsResource.dinosUnlocked;
        genesFound    = statsResource.genesFound;
    }
Ejemplo n.º 11
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="mapName"></param>
    public static bool LoadMap(string mapKey, Vector2?triggeredFrom = null)
    {
        //Check distance is OK for all characters
        if (triggeredFrom != null)
        {
            var partyPositions = LocalCharacterManager.GetPartyPositions();
            foreach (Vector2 pcp in partyPositions)
            {
                if (pcp.Dot((Vector2)triggeredFrom) > maxPlayerMapTransitionDistance)
                {
                    return(false);
                }
            }
        }

        //Test map can actually be found and loaded
        if (!(zones.ContainsKey(mapKey) && ResourceLoader.Exists(zones[mapKey])))
        {
            return(false);
        }


        GUIManager.SetLoadables(false);
        GUIManager.WipePartyElements();
        LocalCharacterManager.ResetAll();
        //We'll need another class to persist characters and recreate on the next map

        //Run a screen transition and wipe the current map

        //Reload the new map

        //Setup MCM, Party Icons as needed
        var loaded = ResourceLoader.Load(zones[mapKey]) as PackedScene;

        if (_ml.CurrentMap != null)
        {
            _ml.CurrentMap.QueueFree();
        }

        _ml.GetTree().ChangeSceneTo(loaded);
        //Map will attempt to set itself as current map

        GUIManager.SetLoadables(true);
        return(true);
    }
Ejemplo n.º 12
0
        /// <summary>コンストラクタ</summary>
        public TransactionControl()
        {
            // トランザクション定義をロードする。

            // リソース ローダでチェック(ここで落とすとハンドルされないので落とさない。)
            if (EmbeddedResourceLoader.Exists(
                    GetConfigParameter.GetConfigValue(FxLiteral.XML_TC_DEFINITION), false))
            {
                // トランザクション定義(XmlDocument)のロード
                this.XMLTCD.LoadXml(
                    EmbeddedResourceLoader.LoadXMLAsString(
                        GetConfigParameter.GetConfigValue(FxLiteral.XML_TC_DEFINITION)));
            }
            else if (ResourceLoader.Exists(
                         GetConfigParameter.GetConfigValue(FxLiteral.XML_TC_DEFINITION), false))
            {
                // トランザクション定義(XmlDocument)のロード
                this.XMLTCD.Load(
                    PubCmnFunction.BuiltStringIntoEnvironmentVariable(
                        GetConfigParameter.GetConfigValue(FxLiteral.XML_TC_DEFINITION)));
            }
            else
            {
                // チェック
                if (GetConfigParameter.GetConfigValue(FxLiteral.XML_TC_DEFINITION) == null ||
                    GetConfigParameter.GetConfigValue(FxLiteral.XML_TC_DEFINITION) == "")
                {
                    // 定義が無い(offの扱い)。

                    // トランザクション定義(XmlDocument)を空で初期化
                    this.XMLTCD.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><TCD></TCD>");
                }
                else
                {
                    // 定義が間違っている(エラー)。

                    // エラーをスロー
                    throw new FrameworkException(
                              FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_PATH2[0],
                              String.Format(FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_PATH2[1],
                                            FxLiteral.XML_TC_DEFINITION));
                }
            }
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            // 現在の証明書のJwk
            JObject jwkObject =
                JsonConvert.DeserializeObject <JObject>(
                    RS256_KeyConverter.X509CerToJwkPublicKey(OAuth2AndOIDCParams.RS256Cer));

            // JwkSet.jsonファイルの存在チェック
            if (!ResourceLoader.Exists(OAuth2AndOIDCParams.JwkSetFilePath, false))
            {
                // 新規
                File.Create(OAuth2AndOIDCParams.JwkSetFilePath).Close();
            }
            else
            {
                // 既存?
            }

            // JwkSet.jsonファイルのロード
            JwkSet jwkSetObject = JwkSet.LoadJwkSet(OAuth2AndOIDCParams.JwkSetFilePath);

            // 判定
            if (jwkSetObject == null)
            {
                // 新規
                jwkSetObject = new JwkSet();
                jwkSetObject.keys.Add(jwkObject);
            }
            else
            {
                // 既存

                // kidの重複確認
                JwkSet.AddJwkToJwkSet(jwkSetObject, jwkObject);
            }

            // jwkSetObjectのセーブ
            JwkSet.SaveJwkSet(OAuth2AndOIDCParams.JwkSetFilePath, jwkSetObject);
        }
Ejemplo n.º 14
0
        /// <summary>コンストラクタ</summary>
        /// <remarks>CallController、ServiceInterfaceから利用するので、public</remarks>
        public InProcessNameService()
        {
            // インプロセス呼び出しの名前解決定義をロードする。

            #region  埋め込まれたリソース ローダでチェック(ここで落とすとハンドルされないので落とさない。)

            if (EmbeddedResourceLoader.Exists(
                    GetConfigParameter.GetConfigValue(FxLiteral.XML_TM_INPROCESS_DEFINITION), false))
            {
                // インプロセス呼び出しの名前解決定義(XmlDocument)を[埋め込まれたリソース]で初期化
                this.XMLTMD_InProcess.LoadXml(EmbeddedResourceLoader.LoadXMLAsString(
                                                  GetConfigParameter.GetConfigValue(FxLiteral.XML_TM_INPROCESS_DEFINITION)));

                // 戻す
                return;
            }
            else
            {
                // 何もしない。
            }

            #endregion

            #region リソース ローダでチェック(ここで落とすとハンドルされないので落とさない。)

            if (ResourceLoader.Exists(
                    GetConfigParameter.GetConfigValue(FxLiteral.XML_TM_INPROCESS_DEFINITION), false))
            {
                // インプロセス呼び出しの名前解決定義(XmlDocument)を[リソース]で初期化
                this.XMLTMD_InProcess.Load(
                    PubCmnFunction.BuiltStringIntoEnvironmentVariable(
                        GetConfigParameter.GetConfigValue(FxLiteral.XML_TM_INPROCESS_DEFINITION)));

                // 戻す
                return;
            }
            else
            {
                // 何もしない。
            }

            #endregion

            #region チェック(定義の有無や、定義の誤り)

            if (GetConfigParameter.GetConfigValue(FxLiteral.XML_TM_INPROCESS_DEFINITION) == null ||
                GetConfigParameter.GetConfigValue(FxLiteral.XML_TM_INPROCESS_DEFINITION) == "")
            {
                // 定義が無い(offの扱い)。

                // インプロセス呼び出しの名前解決定義(XmlDocument)を空で初期化
                this.XMLTMD_InProcess.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><TMD></TMD>");
            }
            else
            {
                // 定義が間違っている(エラー)。

                // 例外をスロー
                throw new FrameworkException(
                          FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_PATH2[0],
                          String.Format(FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_PATH2[1],
                                        FxLiteral.XML_TM_INPROCESS_DEFINITION));
            }

            #endregion
        }
Ejemplo n.º 15
0
    public override void _Ready()
    {
        var mesh = new PlaneMesh();

        mesh.Size           = new Vector2(size, size);
        mesh.SubdivideDepth = 3;
        mesh.SubdivideWidth = (int)position.x == 0 ? (int)size : 3;

        var surface_tool = new SurfaceTool();

        surface_tool.CreateFrom(mesh, 0);
        var mesh_tool = new MeshDataTool();

        mesh_tool.CreateFromSurface(surface_tool.Commit(), 0);

        var biome = GetBiome(/*hydro_noise.GetNoise2dv(position / size), */ heat_noise.GetNoise2d(position.x / size / 10.0f, position.y));

        for (int i = 0; i < mesh_tool.GetVertexCount(); ++i)
        {
            var vertex            = mesh_tool.GetVertex(i);
            var vertex_global_pos = position + new Vector2(vertex.x, vertex.z);

            var height_noise_val = height_noise.GetNoise2dv(vertex_global_pos);
            vertex.y = height_noise_val * 20;
            var color_factor = (height_noise_val + 1) / 2.0f;

            var hydro_val = (int)Math.Round(hydro_noise.GetNoise2dv(vertex_global_pos));

            if ((int)vertex.x == 0 && (int)position.x == 0)
            {
                mesh_tool.SetVertexColor(i, new Color(color_factor, color_factor / 2, 0.0f));
            }
            else if (hydro_val == -1)
            {
                mesh_tool.SetVertexColor(i, biome.dry_color * color_factor);
            }
            else if (hydro_val == 1)
            {
                mesh_tool.SetVertexColor(i, biome.humid_color * color_factor);
            }
            else
            {
                mesh_tool.SetVertexColor(i, biome.ground_color * color_factor);
            }
            mesh_tool.SetVertex(i, vertex);
        }

        /*if (base_tree_mesh == null && ResourceLoader.Exists("res://assets/tree.obj"))
         * {
         *      base_tree_mesh = ResourceLoader.Load<Mesh>("res://assets/tree.obj");
         * }
         * if (base_tree_material == null && ResourceLoader.Exists("res://assets/tree.tres"))
         * {
         *      Console.WriteLine("OK");
         *      base_tree_material = ResourceLoader.Load<SpatialMaterial>("res://assets/tree.tres");
         * }
         *
         * MultiMesh trees = new MultiMesh();
         * trees.Mesh = base_tree_mesh;
         * trees.TransformFormat = MultiMesh.TransformFormatEnum.Transform3d;
         *
         * if ((int)position.x == 0)
         * {
         *      var points1 = Utility.UniformPoissonDiskSampler.SampleRectangle(-new Vector2(size, size) / 2, new Vector2(-5, size / 2.0f), biome.tree_spacing);
         *      var points2 = Utility.UniformPoissonDiskSampler.SampleRectangle(new Vector2(5, 0), new Vector2(size, size) / 2, biome.tree_spacing);
         *      trees.InstanceCount = points1.Count + points2.Count;
         *
         *      int i = 0;
         *      foreach (var p in points1)
         *      {
         *              trees.SetInstanceTransform(i, Transform.Identity.Scaled(new Vector3(1, biome.tree_size, 1)).Translated(new Vector3(p.x, height_noise.GetNoise2dv(position + p) * 20, p.y)));
         ++i;
         *      }
         *
         *      foreach (var p in points2)
         *      {
         *              trees.SetInstanceTransform(i, Transform.Identity.Scaled(new Vector3(1, biome.tree_size, 1)).Translated(new Vector3(p.x, height_noise.GetNoise2dv(position + p) * 20, p.y)));
         ++i;
         *      }
         * }
         * else
         * {
         *      var points = Utility.UniformPoissonDiskSampler.SampleRectangle(-new Vector2(size, size) / 2, new Vector2(size, size) / 2, biome.tree_spacing);
         *      trees.InstanceCount = points.Count;
         *      int i = 0;
         *      foreach (var p in points)
         *      {
         *              trees.SetInstanceTransform(i, Transform.Identity.Scaled(new Vector3(1, biome.tree_size, 1)).Translated(new Vector3(p.x, height_noise.GetNoise2dv(position + p) * 20, p.y)));
         ++i;
         *      }
         * }
         *
         * MultiMeshInstance child = new MultiMeshInstance();
         * child.Multimesh = trees;
         * child.MaterialOverride = base_tree_material;
         * AddChild(child);*/

        var array = new ArrayMesh();

        mesh_tool.CommitToSurface(array);
        Mesh = array;

        if (base_shader == null && ResourceLoader.Exists("res://assets/chunk_shader.tres"))
        {
            base_shader = ResourceLoader.Load <ShaderMaterial>("res://assets/chunk_shader.tres");
        }
        var shader = base_shader;

        MaterialOverride = shader;
    }
Ejemplo n.º 16
0
        /// <summary>汎用認証サイトの発行したJWT形式のTokenを検証する。</summary>
        /// <param name="jwtToken">JWT形式のToken</param>
        /// <param name="jwtPayload">
        /// JWS, JWS + JEWの場合があるのでペイロードを返す。
        /// </param>
        /// <returns>検証結果</returns>
        public static bool Verify(string jwtToken, out string jwtPayload)
        {
            jwtPayload = "";

            JWE jwe = null;
            JWS jws = null;

            // 復号化(JWEの場合)
            bool isJWE_FAPI2 = false;

            if (3 < jwtToken.Split('.').Length)
            {
                isJWE_FAPI2 = true;

                // ヘッダ
                JWE_Header jweHeader = JsonConvert.DeserializeObject <JWE_Header>(
                    CustomEncode.ByteToString(CustomEncode.FromBase64UrlString(jwtToken.Split('.')[0]), CustomEncode.UTF_8));

                if (jweHeader.alg == JwtConst.RSA_OAEP)
                {
                    jwe = new JWE_RsaOaepAesGcm_X509(
                        CmnClientParams.RsaPfxFilePath,
                        CmnClientParams.RsaPfxPassword);
                }
                else if (jweHeader.alg == JwtConst.RSA1_5)
                {
                    jwe = new JWE_Rsa15A128CbcHS256_X509(
                        CmnClientParams.RsaPfxFilePath,
                        CmnClientParams.RsaPfxPassword);
                }
                else
                {
                    throw new NotSupportedException(string.Format(
                                                        "This jwe alg of {0} is not supported.", jweHeader.alg));
                }

                jwe.Decrypt(jwtToken, out jwtToken);
            }
            else
            {
                isJWE_FAPI2 = false;
            }

            // 検証
            // ヘッダ
            JWS_Header jwsHeader = JsonConvert.DeserializeObject <JWS_Header>(
                CustomEncode.ByteToString(CustomEncode.FromBase64UrlString(jwtToken.Split('.')[0]), CustomEncode.UTF_8));

            if (jwsHeader.alg == JwtConst.ES256 && isJWE_FAPI2)
            {
            }                                                       // 正常
            else if (jwsHeader.alg == JwtConst.RS256 && !isJWE_FAPI2)
            {
            }                                                             // 正常
            else
            {
                throw new NotSupportedException("Unexpected combination of JWS and JWE.");
            }

            // 証明書を使用するか、Jwkを使用するか判定
            if (string.IsNullOrEmpty(jwsHeader.jku) ||
                string.IsNullOrEmpty(jwsHeader.kid))
            {
                // 旧バージョン(証明書を使用
                if (isJWE_FAPI2)
                {
#if NET45 || NET46
                    throw new NotSupportedException("FAPI2 is not supported in this dotnet version.");
#else
                    jws = new JWS_ES256_X509(CmnClientParams.EcdsaCerFilePath, "");
#endif
                }
                else
                {
                    jws = new JWS_RS256_X509(CmnClientParams.RsaCerFilePath, "");
                }
            }
            else
            {
                // 新バージョン(Jwkを使用
                if (string.IsNullOrEmpty(OAuth2AndOIDCParams.JwkSetFilePath))
                {
                    // jku(jwks_uri)使用のカバレッジ

                    // Client側
                    JObject jwkObject = JwkSetStore.GetInstance().GetJwkObject(jwsHeader.kid);

                    // チェック
                    if (jwkObject == null)
                    {
                        // 書込
                        jwkObject = JwkSetStore.GetInstance().SetJwkSetObject(jwsHeader.jku, jwsHeader.kid);
                    }

                    // チェック
                    if (jwkObject == null)
                    {
                        // 証明書を使用
                        if (isJWE_FAPI2)
                        {
#if NET45 || NET46
                            throw new NotSupportedException("FAPI2 is not supported in this dotnet version.");
#else
                            jws = new JWS_ES256_X509(CmnClientParams.EcdsaCerFilePath, "");
#endif
                        }
                        else
                        {
                            jws = new JWS_RS256_X509(CmnClientParams.RsaCerFilePath, "");
                        }
                    }
                    else
                    {
                        // Jwkを使用
                        if (isJWE_FAPI2)
                        {
#if NET45 || NET46
                            throw new NotSupportedException("FAPI2 is not supported in this dotnet version.");
#else
                            EccPublicKeyConverter epkc = new EccPublicKeyConverter();
                            jws = new JWS_ES256_Param(epkc.JwkToParam(jwkObject), false);
#endif
                        }
                        else
                        {
                            RsaPublicKeyConverter rpkc = new RsaPublicKeyConverter();
                            jws = new JWS_RS256_Param(rpkc.JwkToParam(jwkObject));
                        }
                    }
                }
                else
                {
                    // JwkSet使用のカバレッジ
                    // AuthZ側でClient側テストを行うためのカバレージ
                    JObject jwkObject = null;

                    if (ResourceLoader.Exists(OAuth2AndOIDCParams.JwkSetFilePath, false))
                    {
                        JwkSet jwkSet = JwkSet.LoadJwkSet(OAuth2AndOIDCParams.JwkSetFilePath);
                        jwkObject = JwkSet.GetJwkObject(jwkSet, jwsHeader.kid);
                    }

                    if (jwkObject == null)
                    {
                        // 証明書を使用
                        if (isJWE_FAPI2)
                        {
#if NET45 || NET46
                            throw new NotSupportedException("FAPI2 is not supported in this dotnet version.");
#else
                            jws = new JWS_ES256_X509(CmnClientParams.EcdsaCerFilePath, "");
#endif
                        }
                        else
                        {
                            jws = new JWS_RS256_X509(CmnClientParams.RsaCerFilePath, "");
                        }
                    }
                    else
                    {
                        // Jwkを使用
                        if (isJWE_FAPI2)
                        {
#if NET45 || NET46
                            throw new NotSupportedException("FAPI2 is not supported in this dotnet version.");
#else
                            EccPublicKeyConverter epkc = new EccPublicKeyConverter();
                            jws = new JWS_ES256_Param(epkc.JwkToParam(jwkObject), false);
#endif
                        }
                        else
                        {
                            RsaPublicKeyConverter rpkc = new RsaPublicKeyConverter();
                            jws = new JWS_RS256_Param(rpkc.JwkToParam(jwkObject));
                        }
                    }
                }
            }

            bool ret = jws.Verify(jwtToken);

            if (ret)
            {
                jwtPayload = CustomEncode.ByteToString(
                    CustomEncode.FromBase64UrlString(jwtToken.Split('.')[1]), CustomEncode.us_ascii);
            }

            return(ret);
        }
Ejemplo n.º 17
0
 public static TileSet loadInternalTileset(string path)
 {
     return(ResourceLoader.Exists(path) ? ResourceLoader.Load <TileSet>(path) : null);
 }
Ejemplo n.º 18
0
 public static Texture loadInternalTexture(string path)
 {
     return(ResourceLoader.Exists(path) ? ResourceLoader.Load <Texture>(path) : null);
 }
Ejemplo n.º 19
0
            /// <summary>コンストラクタ</summary>
            /// <remarks>インナークラス</remarks>
            public SharedPropertyManager()
            {
                // 共有情報定義をロードする。
                XmlDocument xMLSP = new XmlDocument();

                if (GetConfigParameter.GetConfigValue(FxLiteral.XML_SP_DEFINITION) == null ||
                    GetConfigParameter.GetConfigValue(FxLiteral.XML_SP_DEFINITION) == "")
                {
                    // 定義が無い(offの扱い)。

                    // 共有情報定義(XmlDocument)を空で初期化
                    xMLSP.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><SPD></SPD>");
                }
                else
                {
                    //// 定義が間違っている(エラー)。

                    //// エラーをスロー
                    //throw new FrameworkException(
                    //    FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_PATH2[0],
                    //    String.Format(FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_PATH2[1],
                    //                    FxLiteral.XML_SP_DEFINITION));

                    #region  埋め込まれたリソース ローダでチェック(ここで落とすとハンドルされないので落とさない。)

                    if (EmbeddedResourceLoader.Exists(
                            GetConfigParameter.GetConfigValue(FxLiteral.XML_SP_DEFINITION), false))
                    {
                        // 共有情報定義(XmlDocument)を[埋め込まれたリソース]で初期化
                        xMLSP.LoadXml(EmbeddedResourceLoader.LoadXMLAsString(
                                          GetConfigParameter.GetConfigValue(FxLiteral.XML_SP_DEFINITION)));

                        //// 戻す
                        //return;
                    }
                    else
                    {
                        // 何もしない。
                    }

                    #endregion

                    #region リソース ローダでチェック(ここで落とすとハンドルされないので落とさない。)

                    if (ResourceLoader.Exists(
                            GetConfigParameter.GetConfigValue(FxLiteral.XML_SP_DEFINITION), false))
                    {
                        // 共有情報定義(XmlDocument)を[リソース]で初期化
                        xMLSP.Load(
                            PubCmnFunction.BuiltStringIntoEnvironmentVariable(
                                GetConfigParameter.GetConfigValue(FxLiteral.XML_SP_DEFINITION)));

                        //// 戻す
                        //return;
                    }
                    else
                    {
                        // 何もしない。
                    }

                    #endregion
                }

                #region すべてのSHAREDPROPタグをDictionary化

                // すべてのSHAREDPROPタグを取得、大文字・小文字は区別する。
                XmlNodeList xmlNodeList = xMLSP.GetElementsByTagName(FxLiteral.XML_SP_TAG_SHARED_PROPERTY);

                foreach (XmlNode xmlNodeSP in xmlNodeList)
                {
                    // 属性の取得
                    XmlNode xmlNodeKey = xmlNodeSP.Attributes.GetNamedItem(FxLiteral.XML_CMN_ATTR_KEY);
                    XmlNode xmlNodeVal = xmlNodeSP.Attributes.GetNamedItem(FxLiteral.XML_CMN_ATTR_VALUE);

                    if (xmlNodeKey == null)
                    {
                        // id属性なしの場合

                        throw new FrameworkException(
                                  FrameworkExceptionMessage.SHAREDPROPERTY_XML_FORMAT_ERROR[0],
                                  String.Format(FrameworkExceptionMessage.SHAREDPROPERTY_XML_FORMAT_ERROR[1],
                                                String.Format(FrameworkExceptionMessage.SHAREDPROPERTY_XML_FORMAT_ERROR_ATTR, FxLiteral.XML_CMN_ATTR_KEY, "-")));
                    }

                    if (xmlNodeVal == null)
                    {
                        // description属性なしの場合

                        throw new FrameworkException(
                                  FrameworkExceptionMessage.SHAREDPROPERTY_XML_FORMAT_ERROR[0],
                                  String.Format(FrameworkExceptionMessage.SHAREDPROPERTY_XML_FORMAT_ERROR[1],
                                                String.Format(FrameworkExceptionMessage.SHAREDPROPERTY_XML_FORMAT_ERROR_ATTR, FxLiteral.XML_CMN_ATTR_VALUE, xmlNodeKey.Value)));
                    }

                    this.DicSP.Add(xmlNodeKey.Value, xmlNodeVal.Value);
                }

                #endregion
            }
Ejemplo n.º 20
0
        /// <summary>
        /// Get message description from message ID
        /// </summary>
        /// <param name="messageID">
        /// messageID
        /// </param>
        /// <param name="cultureName">
        /// cultureName
        /// </param>
        /// <param name="useChildUICulture">
        /// 子カルチャを使用している場合:true<br/>
        /// use ChildUICulture : true
        /// </param>
        /// <param name="notExist">
        /// 子カルチャを使用している場合で、<br/>
        /// ファイルを発見できなかった場合はtrueを返す。<br/>
        /// if useChildUICulture == true<br/>
        /// then If the file is not found, return true.
        /// </param>
        /// <returns>
        /// メッセージ記述<br/>
        /// Get message description
        /// </returns>
        private static string GetMessageDescription(
            string messageID, string cultureName,
            bool useChildUICulture, out bool notExist)
        {
            #region local

            //bool xmlfilenotExist = false;
            notExist = false;

            string tempXMLFileName = string.Empty;
            string tempXMLFilePath = string.Empty;

            string defaultXMLFileName     = string.Empty;
            string defaultXMLFilePath     = string.Empty;
            string cultureWiseXMLFileName = string.Empty;
            string cultureWiseXMLFilePath = string.Empty;

            string cultureWiseXMLParentFileName = string.Empty;
            string cultureWiseXMLParentFilePath = string.Empty;

            bool defaultXMLFilePath_ResourceLoaderExists             = false;
            bool defaultXMLFilePath_EmbeddedResourceLoaderExists     = false;
            bool cultureWiseXMLFilePath_ResourceLoaderExists         = false;
            bool cultureWiseXMLFilePath_EmbeddedResourceLoaderExists = false;

            #endregion

            defaultXMLFilePath = GetConfigParameter.GetConfigValue(FxLiteral.XML_MSG_DEFINITION);

            GetMessage.GetCultureWiseXMLFileName(
                cultureName, defaultXMLFilePath, out defaultXMLFileName, out cultureWiseXMLFilePath, out cultureWiseXMLFileName);

            // This has been added for Threadsafe
            lock (thisLock)
            {
                #region ContainsKey

                // Check that XML file is already loaded.
                if (GetMessage.DicMSG.ContainsKey(cultureWiseXMLFileName))
                {
                    // culture wise XML file is already loaded.
                    if (GetMessage.DicMSG[cultureWiseXMLFileName].ContainsKey(messageID))
                    {
                        return(GetMessage.DicMSG[cultureWiseXMLFileName][messageID]);
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
                else
                {
                    // culture wise XML file isn't loaded.
                }

                if (GetMessage.DicMSG.ContainsKey(defaultXMLFileName))
                {
                    // default XML file is already loaded.

                    if (useChildUICulture)
                    {
                        // next, try load.
                    }
                    else
                    {
                        // default XML
                        if (DicMSG[defaultXMLFileName].ContainsKey(messageID))
                        {
                            return(GetMessage.DicMSG[defaultXMLFileName][messageID]);
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                }
                else
                {
                    // default XML file isn't loaded.
                }

                #endregion

                #region FillDictionary

                // cultureWiseXMLFilePath
                if (EmbeddedResourceLoader.Exists(cultureWiseXMLFilePath, false))
                {
                    // Exists cultureWiseXMLFile
                    cultureWiseXMLFilePath_EmbeddedResourceLoaderExists = true;
                }
                else
                {
                    // not exists
                    if (ResourceLoader.Exists(cultureWiseXMLFilePath, false))
                    {
                        // Exists cultureWiseXMLFile
                        cultureWiseXMLFilePath_ResourceLoaderExists = true;
                    }
                    else
                    {
                        // not exists

                        // defaultXMLFilePath
                        if (EmbeddedResourceLoader.Exists(defaultXMLFilePath, false))
                        {
                            // Exists defaultXMLFilePath
                            defaultXMLFilePath_EmbeddedResourceLoaderExists = true;
                        }
                        else
                        {
                            if (ResourceLoader.Exists(defaultXMLFilePath, false))
                            {
                                // Exists defaultXMLFilePath
                                defaultXMLFilePath_ResourceLoaderExists = true;
                            }
                        }
                    }
                }

                // select file path
                if (cultureWiseXMLFilePath_ResourceLoaderExists ||
                    cultureWiseXMLFilePath_EmbeddedResourceLoaderExists)
                {
                    // cultureWiseXMLFile
                    tempXMLFileName = cultureWiseXMLFileName;
                    tempXMLFilePath = cultureWiseXMLFilePath;
                }
                else
                {
                    // If the file is not found,
                    if (useChildUICulture)
                    {
                        // Look for use the culture info of the parent.
                        notExist = true;
                        return(string.Empty);
                    }
                    else
                    {
                        if (defaultXMLFilePath_ResourceLoaderExists ||
                            defaultXMLFilePath_EmbeddedResourceLoaderExists)
                        {
                            // defaultXMLFilePath
                            tempXMLFileName = defaultXMLFileName;
                            tempXMLFilePath = defaultXMLFilePath;
                        }
                        else
                        {
                            // use empty XML.
                        }
                    }
                }

                // select load method.
                XmlDocument xMLMSG = new XmlDocument();
                Dictionary <string, string> innerDictionary = new Dictionary <string, string>();

                if (defaultXMLFilePath_EmbeddedResourceLoaderExists ||
                    cultureWiseXMLFilePath_EmbeddedResourceLoaderExists)
                {
                    // Use EmbeddedResourceLoader
                    xMLMSG.LoadXml(EmbeddedResourceLoader.LoadXMLAsString(tempXMLFilePath));

                    //added by ritu
                    GetMessage.FillDictionary(xMLMSG, innerDictionary);

                    // and initialize DicMSG[tempXMLFileName]
                    DicMSG[tempXMLFileName] = innerDictionary;
                }
                else if (defaultXMLFilePath_ResourceLoaderExists ||
                         cultureWiseXMLFilePath_ResourceLoaderExists)
                {
                    // Load normally.
                    xMLMSG.Load(PubCmnFunction.BuiltStringIntoEnvironmentVariable(tempXMLFilePath));

                    //added by ritu
                    GetMessage.FillDictionary(xMLMSG, innerDictionary);
                    // and initialize DicMSG[tempXMLFileName]
                    DicMSG[tempXMLFileName] = innerDictionary;
                }
                else
                {
                    // If the file is not found, initialized as empty XML
                    xMLMSG.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><MSGD></MSGD>");

                    //added by ritu
                    GetMessage.FillDictionary(xMLMSG, innerDictionary);

                    // and initialize DicMSG[tempXMLFileName]
                    DicMSG[tempXMLFileName] = innerDictionary;
                    //xmlfilenotExist = true;
                }

                // and return GetMessageDescription.
                if (DicMSG[tempXMLFileName].ContainsKey(messageID))
                {
                    return(GetMessage.DicMSG[tempXMLFileName][messageID]);
                }
                else
                {
                    return(string.Empty);
                }

                #endregion
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// log4net.ILogインスタンスの取得
        /// </summary>
        /// <param name="loggerName">ロガー名</param>
        /// <returns>log4netのインターフェイス</returns>
        public static log4net.ILog GetLog4netIf(string loggerName)
        {
            lock (LogManager._lock)
            {
                // null対策
                if (LogManager._logIfHt == null)
                {
                    LogManager._logIfHt = new Dictionary <string, log4net.ILog>();
                }

                // すでにlog4net.ILogインスタンスが存在する。
                if (LogManager._logIfHt.ContainsKey(loggerName)) // Dic化でnullチェック変更
                {
                    // 生成済みのlog4net.ILogインスタンスを返す。
                    return((log4net.ILog)LogManager._logIfHt[loggerName]);
                }
                else
                {
                    // #12-start

                    // 定義ファイル
                    string log4netConfFile = GetConfigParameter.GetConfigValue(PubLiteral.LOG4NET_CONF_FILE);

                    // log4netの設定ファイルのパス
                    if (log4netConfFile == null || log4netConfFile == "")
                    {
                        // 定義ファイルのパスが無い場合

                        // 空のロガーを返す(エラーにはならない)
                        return(log4net.LogManager.GetLogger(""));
                    }
                    else
                    {
                        // 埋め込まれたリソース ローダで存在チェック
                        if (EmbeddedResourceLoader.Exists(log4netConfFile, false))
                        {
                            // ログ定義 [埋め込まれたリソース]
                            XmlDocument xmlDef = new XmlDocument();

                            // Exceptionが上がり得る。
                            xmlDef.LoadXml(EmbeddedResourceLoader.LoadXMLAsString(log4netConfFile));

                            if (xmlDef["log4net"] == null)
                            {
                                // XmlElement(log4net)が無い場合
                                throw new ArgumentException(String.Format(
                                                                PublicExceptionMessage.XML_ELEMENT_ERROR,
                                                                PublicExceptionMessage.XML_ELEMENT_ERROR_LOG4NET));
                            }

                            // log4net
                            XmlConfigurator.Configure(xmlDef["log4net"]);
                        }
                        else
                        {
                            // リソース ローダで存在チェック(存在しなければエラー)
                            ResourceLoader.Exists(log4netConfFile, true);

                            // ログ定義 [リソース ファイル] → ストリームを開く
                            FileStream s = new FileStream(
                                PubCmnFunction.BuiltStringIntoEnvironmentVariable(log4netConfFile),
                                FileMode.Open, FileAccess.Read, FileShare.Read);

                            // log4netのXML形式の設定ファイルを読み込む。
                            XmlConfigurator.Configure(s);
                            s.Close();
                        }

                        // log4net.ILogインスタンスを初期化する。
                        LogManager._logIfHt.Add(loggerName, log4net.LogManager.GetLogger(loggerName));

                        // 生成したlog4net.ILogインスタンスを返す。
                        return((log4net.ILog)LogManager._logIfHt[loggerName]);
                    }

                    // #12-end
                }
            }
        }