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 }