using System;
using System.Collections;
using System.Collections.Generic;
using System.Security.Principal;
using System.Text;

namespace BusinessCommon
{
    public class MyPrincipal : IPrincipal
    {
        private MyIdentity mIdentity;
        private IList<string> mRoles = new List<string>();

        public MyPrincipal(MyIdentity identity)
        {
            mIdentity = identity;
        }

        public MyIdentity Identity
        {
            get { return mIdentity; }
        }

        IIdentity IPrincipal.Identity
        {
            get { return mIdentity; }
        }

        public bool IsInRole(string role)
        {
            return Array.BinarySearch<string>(mIdentity.Ticket.Roles, role) >= 0;
        }
    }
}
