[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security/Principal Gen
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security/Principal GenericIdentity.cs,NONE,1.1 GenericPrincipal.cs,NONE,1.1 WindowsAccountType.cs,NONE,1.1 WindowsBuiltInRole.cs,NONE,1.1 WindowsIdentity.cs,NONE,1.1 WindowsImpersonationContext.cs,NONE,1.1 WindowsPrincipal.cs,NONE,1.1 |
Date: |
Mon, 21 Apr 2003 21:30:47 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Security/Principal
In directory subversions:/tmp/cvs-serv27257/runtime/System/Security/Principal
Added Files:
GenericIdentity.cs GenericPrincipal.cs WindowsAccountType.cs
WindowsBuiltInRole.cs WindowsIdentity.cs
WindowsImpersonationContext.cs WindowsPrincipal.cs
Log Message:
Missing classes in "System.Security.Principal".
--- NEW FILE ---
/*
* GenericIdentity.cs - Implementation of the
* "System.Security.Principal.GenericIdentity" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Security.Principal
{
#if !ECMA_COMPAT
[Serializable]
public class GenericIdentity : IIdentity
{
// Internal state.
private String name;
private String type;
// Constructor.
public GenericIdentity(String name) : this(name, String.Empty) {}
public GenericIdentity(String name, String type)
{
if(name == null)
{
throw new ArgumentNullException("name");
}
if(type == null)
{
throw new ArgumentNullException("type");
}
this.name = name;
this.type = type;
}
// Get the type of authentication used.
public virtual String AuthenticationType
{
get
{
return type;
}
}
// Determine if we have been authenticated.
public virtual bool IsAuthenticated
{
get
{
return (name != String.Empty);
}
}
// Get the name associated with this identity.
public virtual String Name
{
get
{
return name;
}
}
}; // class GenericIdentity
#endif // !ECMA_COMPAT
}; // namespace System.Security.Principal
--- NEW FILE ---
/*
* GenericPrincipal.cs - Implementation of the
* "System.Security.Principal.GenericPrincipal" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Security.Principal
{
#if !ECMA_COMPAT
[Serializable]
public class GenericPrincipal : IPrincipal
{
// Internal state.
private IIdentity identity;
private String[] roles;
// Constructor.
public GenericPrincipal(IIdentity identity, String[] roles)
{
if(identity == null)
{
throw new
ArgumentNullException("identity");
}
this.identity = identity;
if(roles != null)
{
this.roles = (String[])(roles.Clone());
}
else
{
this.roles = null;
}
}
// Get the identity of the principal.
public virtual IIdentity Identity
{
get
{
return identity;
}
}
// Determine whether the principal belongs to a specific role.
public virtual bool IsInRole(String role)
{
if(role != null && roles != null)
{
return (Array.IndexOf(roles, role) !=
-1);
}
else
{
return false;
}
}
}; // class GenericPrincipal
#endif // !ECMA_COMPAT
}; // namespace System.Security.Principal
--- NEW FILE ---
/*
* WindowsAccountType.cs - Implementation of the
* "System.Security.Principal.WindowsAccountType" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Security.Principal
{
#if !ECMA_COMPAT
public enum WindowsAccountType
{
Normal = 0,
Guest = 1,
System = 2,
Anonymous = 3
}; // enum WindowsAccountType
#endif // !ECMA_COMPAT
}; // namespace System.Security.Principal
--- NEW FILE ---
/*
* WindowsBuiltInRole.cs - Implementation of the
* "System.Security.Principal.WindowsBuiltInRole" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Security.Principal
{
#if !ECMA_COMPAT
public enum WindowsBuiltInRole
{
Administrator = 0x0220,
User = 0x0221,
Guest = 0x0222,
PowerUser = 0x0223,
AccountOperator = 0x0224,
SystemOperator = 0x0225,
PrintOperator = 0x0226,
BackupOperator = 0x0227,
Replicator = 0x0228
}; // enum WindowsBuiltInRole
#endif // !ECMA_COMPAT
}; // namespace System.Security.Principal
--- NEW FILE ---
/*
* WindowsIdentity.cs - Implementation of the
* "System.Security.Principal.WindowsIdentity" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Security.Principal
{
#if !ECMA_COMPAT
using System.Runtime.Serialization;
// We don't use Windows identities in this implementation, but we
// still need to provide this class for API-compatibility.
[Serializable]
public class WindowsIdentity : IIdentity, IDeserializationCallback
{
// Internal state.
private IntPtr userToken;
private String name;
private String type;
private WindowsAccountType acctType;
private bool isAuthenticated;
// Constructor.
public WindowsIdentity(IntPtr userToken)
{
this.userToken = userToken;
this.name = String.Empty;
this.type = "NTLM";
this.acctType = WindowsAccountType.Normal;
this.isAuthenticated = false;
}
public WindowsIdentity(IntPtr userToken, String type)
{
this.userToken = userToken;
this.name = String.Empty;
this.type = type;
this.acctType = WindowsAccountType.Normal;
this.isAuthenticated = false;
}
public WindowsIdentity(IntPtr userToken, String type,
WindowsAccountType acctType)
{
this.userToken = userToken;
this.name = String.Empty;
this.type = type;
this.acctType = acctType;
this.isAuthenticated = false;
}
public WindowsIdentity(IntPtr userToken, String type,
WindowsAccountType acctType,
bool isAuthenticated)
{
this.userToken = userToken;
this.name = String.Empty;
this.type = type;
this.acctType = acctType;
this.isAuthenticated = isAuthenticated;
}
// Get the type of authentication used.
public virtual String AuthenticationType
{
get
{
return type;
}
}
// Determine if this account is anonymous.
public virtual bool IsAnonymous
{
get
{
return (acctType ==
WindowsAccountType.Anonymous);
}
}
// Determine if we have been authenticated.
public virtual bool IsAuthenticated
{
get
{
return isAuthenticated;
}
}
// Determine if this account is guest.
public virtual bool IsGuest
{
get
{
return (acctType ==
WindowsAccountType.Guest);
}
}
// Determine if this account is system.
public virtual bool IsSystem
{
get
{
return (acctType ==
WindowsAccountType.System);
}
}
// Get the name associated with this identity.
public virtual String Name
{
get
{
return name;
}
}
// Get the Windows user account token.
public virtual IntPtr Token
{
get
{
return userToken;
}
}
// Implement the IDeserializationCallback interface.
void IDeserializationCallback.OnDeserialization(Object sender)
{
// Nothing to do here in this implementation.
}
// Get the anonymous Windows identity object.
public static WindowsIdentity GetAnonymous()
{
return new WindowsIdentity
(IntPtr.Zero, String.Empty,
WindowsAccountType.Anonymous);
}
// Get the current Windows user identity.
public static WindowsIdentity GetCurrent()
{
WindowsIdentity identity = new WindowsIdentity
(IntPtr.Zero, String.Empty,
WindowsAccountType.Normal);
identity.name = Environment.UserName;
return identity;
}
// Create an impersonation context.
public virtual WindowsImpersonationContext Impersonate()
{
return new WindowsImpersonationContext();
}
public static WindowsImpersonationContext Impersonate(IntPtr userToken)
{
return (new
WindowsIdentity(userToken)).Impersonate();
}
}; // class WindowsIdentity
#endif // !ECMA_COMPAT
}; // namespace System.Security.Principal
--- NEW FILE ---
/*
* WindowsImpersonationContext.cs - Implementation of the
* "System.Security.Principal.WindowsImpersonationContext" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Security.Principal
{
#if !ECMA_COMPAT
// Impersonation is highly security-sensitive, so we deliberately
// don't implement it. i.e. the class below is deliberately a stub.
public class WindowsImpersonationContext
{
// Constructor.
internal WindowsImpersonationContext() {}
// Destructor.
~WindowsImpersonationContext() {}
// Revert to the original identity.
public void Undo() {}
}; // class WindowsImpersonationContext
#endif // !ECMA_COMPAT
}; // namespace System.Security.Principal
--- NEW FILE ---
/*
* WindowsPrincipal.cs - Implementation of the
* "System.Security.Principal.WindowsPrincipal" class.
*
* Copyright (C) 2003 Southern Storm Software, Pty Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
namespace System.Security.Principal
{
#if !ECMA_COMPAT
[Serializable]
public class WindowsPrincipal : IPrincipal
{
// Internal state.
private IIdentity identity;
// Constructor.
public WindowsPrincipal(IIdentity ntIdentity)
{
if(ntIdentity == null)
{
throw new
ArgumentNullException("ntIdentity");
}
identity = ntIdentity;
}
// Get the identity of the principal.
public virtual IIdentity Identity
{
get
{
return identity;
}
}
// Determine whether the principal belongs to a specific role.
// Always returns false because we don't support Windows principals.
public virtual bool IsInRole(String role)
{
return false;
}
public virtual bool IsInRole(int rid)
{
return false;
}
public virtual bool IsInRole(WindowsBuiltInRole role)
{
return false;
}
}; // class WindowsPrincipal
#endif // !ECMA_COMPAT
}; // namespace System.Security.Principal
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Security/Principal GenericIdentity.cs,NONE,1.1 GenericPrincipal.cs,NONE,1.1 WindowsAccountType.cs,NONE,1.1 WindowsBuiltInRole.cs,NONE,1.1 WindowsIdentity.cs,NONE,1.1 WindowsImpersonationContext.cs,NONE,1.1 WindowsPrincipal.cs,NONE,1.1,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.869,1.870
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetlib/resources/en_US/runtime Arg.txt,1.38,1.39 Exception.txt,1.19,1.20 Format.txt,1.11,1.12
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetlib ChangeLog,1.869,1.870
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetlib/resources/en_US/runtime Arg.txt,1.38,1.39 Exception.txt,1.19,1.20 Format.txt,1.11,1.12
- Index(es):