Code Access Security
åãã¦Code Access Security(以éCAS)ã®èª¬æãè¦ãã¨ããå ¨ããã³ã¨æ¥ã¾ããã§ãããCASãç¥ããªãã¦ãããã°ã©ã ãåãã®ã§ãç¹å¥æèããªãã®ãçç±ã®ï¼ã¤ã§ã¯ãªãã§ããããã*1
ããã«ããã¡ã¤ã«ãéãã¦éããã ãã®åç´ãªã³ã¼ããããã¾ãã
using System; using System.IO; using System.Security; using System.Security.Permissions; static class Program { static void Main (string[] args) { Console.WriteLine ("Hello, World"); FileStream fs = File.OpenRead (@"c:\home\projects\security.txt"); fs.Close (); } }
å®è¡ããã¨ã
Hello, World
ã¨è¡¨ç¤ºãã¦çµäºãã¾ããã¤ã¾ããªãã³ã¼ãã§ããããããããæªæã®ããããã°ã©ã ã ã¨ãããã©ãã§ããããï¼ ã²ãã£ã¨ãããããã¼ã«ã«ãã£ã¹ã¯ããéè¦ãªæ
å ±ãèªã¿åãããå¯è½æ§ãããã¾ãã
é常使ããã¦ãã権éã¯ã管çè
ããã¯ã¼ã¦ã¼ã¶ãªã©äººã«å¯¾ãã¦æ¨©éãä¸ãããã³ã¤ãã¯ã³ã³ãã¥ã¼ã¿ã«è©³ãããããã¹ã£ã¦æªãããªããã°ã©ã ãå®è¡ããªãã ãããã¨ããèãã«åºã¥ãã¦ãã¾ããããããå®è¡ãããã¨ããããã°ã©ã ããã£ããã¨ãã¡ã¤ã«ã¢ã¯ã»ã¹ããããæ¥ç¶ããã¦ããªããã©ãããªãã¦åãããªãã£ãããã¾ãããªã®ã§ãããã®ããã°ã©ã ã¯ç¹å®ã®ãã£ã¬ã¯ããªã ãããã¢ã¯ã»ã¹ã許ããªãããããããã¸ã®æ¥ç¶ã¯ãããªããã¨ãã£ãæå®ãåºæ¥ãã¨ä¾¿å©ã§ããCASã¯ãããå®ç¾ããã¢ãã§ã大ãã£ã±ã«è¨ãã¨äººã§ã¯ãªãã³ã¼ãã«æ¨©éãä¸ããã®ã§ãã
çåï¼ãã£ãã®ãµã³ãã«ããã°ã©ã ã¯ãã¡ã¤ã«ã¢ã¯ã»ã¹ãã¦ãããããªãããæ®æ®µã¯CASã¯ç¡å¹ã«ãªã£ã¦ããã®ï¼
åçï¼ããããæå¹ã§ãã権éè¨å®ã¯ã¢ããªã±ã¼ã·ã§ã³æ¯ã«æå®ããã®ã¯å¤§å¤ãªã®ã§ãã°ã«ã¼ã(ã³ã¼ãã°ã«ã¼ãã¨å¼ã°ãã)æ¯ã«è¨å®ãã¾ããããã©ã«ãã®ã°ã«ã¼ãããï¼ã¤ã°ããåæãã¦ã¿ã¾ãã
- My_Computer_Zone : FullTrust(ä½ã§ãåºæ¥ã)
- LocalIntranet_Zone : LocalIntranet(ãã¡ã¤ã«ãã¬ã¸ã¹ããªã¸ã®ã¢ã¯ã»ã¹ãªã©ã¯åºæ¥ãªã)
- Internet_Zone : Internet_Zone(ç°å¢å¤æ°ã¸ã®ã¢ã¯ã»ã¹ããªãã¬ã¯ã·ã§ã³ãªã©ã¯åºæ¥ãªã)
My_Computer_Zoneã¯ãã¼ã«ã«ã§å®è¡ããå ´åãLocalInternet_Zoneã¯UNCåã§ã®ã¢ã¯ã»ã¹ãInternet_Zoneã¯ã¤ã³ã¿ã¼ãããå®è¡ããå ´åãã¨ãå®è¡ããå ´æã«ãã£ã¦åã°ã«ã¼ããé©å¿ããã¾ããä¾ãã°ãå ã»ã©ã®ããã°ã©ã ãå ±æãã©ã«ãã¨ãã¦å ¬éãã¦UNCåã§å®è¡ãããä¾å¤ãçºçãã¾ãããã®ããã«CASã¯æå¹ã«ãªã£ã¦ããã®ã§ãããæ®æ®µã¯FullTrust権éã§åãã¦ããã®ã§æ°ã¥ããªããã§ããã
ããã©ã«ã以å¤ã®ã³ã¼ãã°ã«ã¼ãã®ä½ææ¹æ³ããCASãæèããã³ã¼ãã£ã³ã°ã«ã¤ãã¦ã¯ãã¾ã次åã»ã»ã»ã®äºå®ã(^^;
*1:ã¶ã£ã¡ããåãããããè³æãå°ãªãæçºã