Protection Proxyとは? わかりやすく解説

Protection Proxy (C#)

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2020/10/02 16:40 UTC 版)

Proxy パターン」の記事における「Protection Proxy (C#)」の解説

以下のC#の例では、RealClient はアカウント番号格納する正しパスワード知っているユーザーだけが、このアカウント番号アクセスできる。RealClient はパスワード知っている ProtectionProxy で守られている。ユーザーアカウント番号得たい場合、まずプロキシユーザーに対して認証求めユーザー正しパスワード入力したときだけプロキシが RealClient を呼び出してアカウント番号ユーザー通知する。 この例では、正しパスワードは thePassword である。 using System;namespace ConsoleApplicationTest.FundamentalPatterns.ProtectionProxyPattern{ public interface IClient { string GetAccountNo(); } public class RealClient : IClient { private string accountNo = "12345"; public RealClient() { Console.WriteLine("RealClient: Initialized"); } public string GetAccountNo() { Console.WriteLine("RealClient's AccountNo: " + accountNo); return accountNo; } } public class ProtectionProxy : IClient { private string password; //秘密のパスワード RealClient client; public ProtectionProxy(string pwd) { Console.WriteLine("ProtectionProxy: Initialized"); password = pwd; client = new RealClient(); } // ユーザー認証しアカウント番号返す public String GetAccountNo() { Console.Write("Password: "); string tmpPwd = Console.ReadLine(); if (tmpPwd == password) { return client.GetAccountNo(); } else { Console.WriteLine("ProtectionProxy: Illegal password!"); return ""; } } } class ProtectionProxyExample { [STAThread] public static void Main(string[] args) { IClient client = new ProtectionProxy("thePassword"); Console.WriteLine(); Console.WriteLine("main received: " + client.GetAccountNo()); Console.WriteLine("\nPress any key to continue . . ."); Console.Read(); } }}

※この「Protection Proxy (C#)」の解説は、「Proxy パターン」の解説の一部です。
「Protection Proxy (C#)」を含む「Proxy パターン」の記事については、「Proxy パターン」の概要を参照ください。

ウィキペディア小見出し辞書の「Protection Proxy」の項目はプログラムで機械的に意味や本文を生成しているため、不適切な項目が含まれていることもあります。ご了承くださいませ。 お問い合わせ



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Protection Proxy」の関連用語

Protection Proxyのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Protection Proxyのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
ウィキペディアウィキペディア
Text is available under GNU Free Documentation License (GFDL).
Weblio辞書に掲載されている「ウィキペディア小見出し辞書」の記事は、WikipediaのProxy パターン (改訂履歴)の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。

©2025 GRAS Group, Inc.RSS