zoukankan      html  css  js  c++  java
  • remoting 安全认证,密码,用户名

    服务器端: 
    namespace   RemoteServer 

          public   class   Scoop   :   MarshalByRefObject 
          { 
                public   Scoop() 
                { 
                } 

                public   string   GetTheScoop(string   name) 
                { 
                      return   "Here 's   the   scoop,   " 
                        +   Thread.CurrentPrincipal.Identity.Name   +   "! "; 
                } 
          } 

    配制文件: 
    <configuration> 
        <system.runtime.remoting> 
            <application> 
                <service> 
                    <wellknown   mode= "SingleCall "   
                        type= "RemoteServer.Scoop,RemoteServer "   
                        objectUri= "Scoop.soap "   /> 
                </service> 
            </application> 
        </system.runtime.remoting> 
        <system.web> 
            <authentication   mode= "None "   /> 
            <authorization> 
                <deny   users= "? "   /> 
            </authorization>   
        </system.web> </configuration> 

    客户端: 
    static   void   Main(string[]   args) 

          ChannelServices.RegisterChannel(new   HttpClientChannel()); 
          RemotingConfiguration.RegisterWellKnownClientType( 
              typeof(RemoteServer.Scoop), 
              "http://localhost/ScoopRemoting/Scoop.soap "); 

          Scoop   srv   =   new   Scoop(); 

          IDictionary   props   =   ChannelServices.GetChannelSinkProperties(srv); 
          props[ "username "]   =   "test "; 
          props[ "password "]   =   "test "; 

          string   s   =   srv.GetTheScoop( "Greg "); 
          Console.WriteLine(s); 


    如果这样做的话,别人写个客户端不是可以随便模仿一下登录?   
    如果限制角色: 
    <authorization> 
            <allow   role= "aaaa "   /> 
            <deny   users= "* "   /> 
    </authorization> 

    别人如果知道你的角色是什么,   也可以写个客户端模仿吧?

  • 相关阅读:
    asp.net core 2.0的认证和授权
    数据库性能优化详解
    StringUtils.defaultIfBlank
    SQL优化(二) 快速计算Distinct Count
    SQL语句中Left join,right join,inner join用法
    sql中的limit关键字
    多线程之间的资源共享
    面试长谈的String,StringBuffer,StringBuilder三兄弟有啥区别
    关于java中的值传递与引用传递遇到的问题
    Struts1和Struts2的区别和对比:
  • 原文地址:https://www.cnblogs.com/heimark/p/2029111.html
Copyright © 2011-2022 走看看