This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mcs / class / corlib / System.Security.Principal / GenericPrincipal.cs
index 5fa85b9e72bc1155884f0f83ee39bae703fc3ea7..491ee487b13f055dc73051cbc177a21e712cff3a 100644 (file)
@@ -7,6 +7,29 @@
 // (C) Ximian, Inc.  http://www.ximian.com
 //
 
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
 namespace System.Security.Principal {
 
        [Serializable]
@@ -16,18 +39,27 @@ namespace System.Security.Principal {
                
                public GenericPrincipal (IIdentity identity, string [] roles)
                {
+                       if (identity == null)
+                               throw new ArgumentNullException ("identity");
+
                        this.identity = identity;
-                       this.roles = roles;
+                       if (roles != null) {
+                               // make our own (unchangeable) copy of the roles
+                               this.roles = new string [roles.Length];
+                               for (int i=0; i < roles.Length; i++)
+                                       this.roles [i] = roles [i];
+                       }
                }
 
                public virtual IIdentity Identity {
-                       get {
-                               return identity;
-                       }
+                       get { return identity; }
                }
 
                public virtual bool IsInRole (string role)
                {
+                       if (roles == null)
+                               return false;
+
                        foreach (string r in roles)
                                if (role == r)
                                        return true;