using System;
using System.Runtime.InteropServices;
namespace System.Security.Principal
{
/// Represents a generic principal.
// Token: 0x020005AA RID: 1450
[ComVisible(true)]
[Serializable]
public class GenericPrincipal : IPrincipal
{
/// Initializes a new instance of the class from a user identity and an array of role names to which the user represented by that identity belongs.
/// A basic implementation of that represents any user.
/// An array of role names to which the user represented by the parameter belongs.
/// The parameter is null.
// Token: 0x0600351A RID: 13594 RVA: 0x000B6E24 File Offset: 0x000B5024
public GenericPrincipal(IIdentity identity, string[] roles)
{
if (identity == null)
{
throw new ArgumentNullException("identity");
}
this.m_identity = identity;
if (roles != null)
{
this.m_roles = new string[roles.Length];
for (int i = 0; i < roles.Length; i++)
{
this.m_roles[i] = roles[i];
}
}
}
/// Gets the of the user represented by the current .
/// The of the user represented by the .
// Token: 0x17000A69 RID: 2665
// (get) Token: 0x0600351B RID: 13595 RVA: 0x000B6E84 File Offset: 0x000B5084
public virtual IIdentity Identity
{
get
{
return this.m_identity;
}
}
/// Determines whether the current belongs to the specified role.
/// true if the current is a member of the specified role; otherwise, false.
/// The name of the role for which to check membership.
// Token: 0x0600351C RID: 13596 RVA: 0x000B6E8C File Offset: 0x000B508C
public virtual bool IsInRole(string role)
{
if (this.m_roles == null)
{
return false;
}
int length = role.Length;
foreach (string text in this.m_roles)
{
if (text != null && length == text.Length && string.Compare(role, 0, text, 0, length, true) == 0)
{
return true;
}
}
return false;
}
// Token: 0x04001590 RID: 5520
private IIdentity m_identity;
// Token: 0x04001591 RID: 5521
private string[] m_roles;
}
}