Implement missing constructor
[mono.git] / mcs / class / corlib / System.Security.AccessControl / QualifiedAce.cs
index 39401593cec002a677be40f034791f3efcc5fad9..343914d500bacf0f3584591ffa5f73b04a1b0e1e 100644 (file)
@@ -1,10 +1,12 @@
 //
 // System.Security.AccessControl.QualifiedAce implementation
 //
-// Author:
+// Authors:
 //     Dick Porter  <dick@ximian.com>
+//     Atsushi Enomoto  <atsushi@ximian.com>
+//     Kenneth Bell
 //
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2006-2007 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
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 namespace System.Security.AccessControl {
        public abstract class QualifiedAce : KnownAce
        {
-               public AceQualifier AceQualifier
+               private byte [] opaque;
+               
+               internal QualifiedAce (AceType type, AceFlags flags,
+                                      byte[] opaque)
+                       : base (type, flags)
+               {
+                       SetOpaque (opaque);
+               }
+               
+               internal QualifiedAce (byte[] binaryForm, int offset)
+                       : base(binaryForm, offset)
                {
+               }
+
+               public AceQualifier AceQualifier {
                        get {
-                               throw new NotImplementedException ();
+                               switch(AceType)
+                               {
+                               case AceType.AccessAllowed:
+                               case AceType.AccessAllowedCallback:
+                               case AceType.AccessAllowedCallbackObject:
+                               case AceType.AccessAllowedCompound:
+                               case AceType.AccessAllowedObject:
+                                       return AceQualifier.AccessAllowed;
+                               
+                               case AceType.AccessDenied:
+                               case AceType.AccessDeniedCallback:
+                               case AceType.AccessDeniedCallbackObject:
+                               case AceType.AccessDeniedObject:
+                                       return AceQualifier.AccessDenied;
+                                       
+                               case AceType.SystemAlarm:
+                               case AceType.SystemAlarmCallback:
+                               case AceType.SystemAlarmCallbackObject:
+                               case AceType.SystemAlarmObject:
+                                       return AceQualifier.SystemAlarm;
+                                       
+                               case AceType.SystemAudit:
+                               case AceType.SystemAuditCallback:
+                               case AceType.SystemAuditCallbackObject:
+                               case AceType.SystemAuditObject:
+                                       return AceQualifier.SystemAudit;
+                                       
+                               default:
+                                       throw new ArgumentException("Unrecognised ACE type: " + AceType);
+                               }
                        }
                }
                
-               public bool IsCallback
-               {
+               public bool IsCallback {
                        get {
-                               throw new NotImplementedException ();
+                               return AceType == AceType.AccessAllowedCallback
+                                       || AceType == AceType.AccessAllowedCallbackObject
+                                       || AceType == AceType.AccessDeniedCallback
+                                       || AceType == AceType.AccessDeniedCallbackObject
+                                       || AceType == AceType.SystemAlarmCallback
+                                       || AceType == AceType.SystemAlarmCallbackObject
+                                       || AceType == AceType.SystemAuditCallback
+                                       || AceType == AceType.SystemAuditCallbackObject;
                        }
                }
                
-               public int OpaqueLength
-               {
+               public int OpaqueLength {
                        get {
-                               throw new NotImplementedException ();
+                               if (opaque == null)
+                                       return  0;
+                               return opaque.Length;
                        }
                }
                
                public byte[] GetOpaque ()
                {
-                       throw new NotImplementedException ();
+                       if (opaque == null)
+                               return null;
+                       return (byte []) opaque.Clone();
                }
                
                public void SetOpaque (byte[] opaque)
                {
-                       throw new NotImplementedException ();
+                       if (opaque == null)
+                               this.opaque = null;
+                       else
+                               this.opaque = (byte []) opaque.Clone();
                }
        }
 }
 
-#endif