码迷,mamicode.com
首页 > 其他好文 > 详细

使用TRoleAuth类对DataSnap服务端的接口授权

时间:2015-04-08 21:15:46      阅读:291      评论:0      收藏:0      [点我收藏+]

标签:

使用Troleauth类,一种类似注视的代码进行授权,也是最简单和方便的方式,实现如下:

unit ServerMethodsUnit1;

interface

uses System.SysUtils, System.Classes, System.Json,
    Datasnap.DSServer, Datasnap.DSAuth, DataSnap.DSProviderDataModuleAdapter;

type
  TServerMethods1 = class(TDSServerModule)
  private
    { Private declarations }
  public
    { Public declarations }
    [TRoleAuth(AdminGroup,GuestGroup)]
    function EchoString(Value: string): string;

    [TRoleAuth(GuestGroup,AdminGroup)]
    function ReverseString(Value: string): string;
  end;

implementation


{$R *.dfm}


uses System.StrUtils;

function TServerMethods1.EchoString(Value: string): string;
begin
  Result := Value;
end;

function TServerMethods1.ReverseString(Value: string): string;
begin
  Result := System.StrUtils.ReverseString(Value);
end;

end.

 

编译环境:Delphi XE7

加入DataSnap高级交流群439992010,即可下载本DEMO

使用TRoleAuth类对DataSnap服务端的接口授权

标签:

原文地址:http://www.cnblogs.com/Kim53622744/p/4403596.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!