Flex and. NET Interop (ix)

Source: Internet
Author: User
Tags bool

Flex vs. NET Interop (ix): Fluorinefx.net Authentication (authentication) and authorization (Authorization)

Fluorinefx.net Authentication (authentication) is similar to authorization (Authorization) and ASP.net, verifying that the identity of the user is both authenticated and authorized to determine whether a user has some kind of executive authority, Applications can grant and reject execution based on user information. Fluorinefx.net Authentication and authorization uses the. Net Framework for role-based Security support.

For example, we need to customize an authentication and authorization scheme that specifies those methods on the remote service that will be authenticated or authorized and authorized by the user role group, and we You need to customize a logincommand and implement the Ilogincommand interface or inherit from the FluorineFx.Security.GenericLoginCommand (this class implements the Ilogincommand interface) base class. The interface is defined as follows:

1 namespace FluorineFx.Security
2 {
3 public interface ILoginCommand
4 {
5 IPrincipal DoAuthentication(string username, Hashtable credentials);
6 bool DoAuthorization (IPrincipal principal, IList roles);
7 bool Logout(IPrincipal principal);
8 void Start();
9 void Stop();
10 }
11 }

The gateway implements validation by invoking the method Doauthentication () in the interface, which we can customize (the implementation of the Override method).

1 /// <summary>
2 /// 自定义 LoginCommand
3 /// </summary>
4 public class LoginCommand : GenericLoginCommand
5 {
6     public override IPrincipal DoAuthentication(string username, Hashtable credentials)
7     {
8         string password = credentials["password"] as string;
9          if (username == "admin" && password == "123456")
10         {
11              //用户标识
12             GenericIdentity identity = new GenericIdentity (username);
13             //角色数组
14             GenericPrincipal principal = new GenericPrincipal(identity, new string[] { "admin", "privilegeduser" });
15             return principal;
16         }
17         else
18         {
19              return null;
20         }
21     }
22 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.