Description



Description

The Authorization class contains authentication information returned by an IAuthenticationModule module. Authorization instances are used to pass server challenge responses and client preauthentication information.

[Note: Applications do not create or access instances of this type directly; instances of this type are created by authentication modules and used by the AuthenticationManager.]

Example

using System;

using System.Net;

using System.Text;



public class AuthorizationSample

{

    public static void Main()

    {

        String credentials = "username:password";

        ASCIIEncoding e = new ASCIIEncoding();

        Byte[] bytes = e.GetBytes(credentials);

        String token = "BASIC " + Convert.ToBase64String(bytes);

        Authorization au = new Authorization(token, false, "Group1");

        String realm1 = "c:\\samples\\mytestsamples\\";

        String realm2 = "c:\\data\\mytestdata\\";

        String[] realms = {realm1, realm2};

        au.ProtectionRealm = realms;



        Console.WriteLine("Authorization Complete = {0}",

            au.Complete);

        Console.WriteLine("Authorization ConnectionGroupId = '{0}'",

            au.ConnectionGroupId);

        Console.WriteLine("Authorization.Message = '{0}'",

            au.Message);

        Console.WriteLine();

        Console.WriteLine("Authorization.ProtectionRealm:");

        foreach (String s in au.ProtectionRealm)

        {

            Console.WriteLine(s);

        }

    }

}


The output is


Authorization Complete = False

Authorization ConnectionGroupId = 'Group1'

Authorization.Message = 'BASIC dXNlcm5hbWU6cGFzc3dvcmQ='



Authorization.ProtectionRealm:

c:\samples\mytestsamples\

c:\data\mytestdata\