/// <summary> /// Deserializes AccessControlList Kind from byte stream. /// </summary> /// <param name="rm">Not used.</param> /// <param name="reader">Binary reader containing message byte stream.</param> /// <param name="usage_size">Not used. ACL has fix length.</param> /// <returns></returns> public IUsage FromReader(ReloadMessage rm, BinaryReader reader, long usage_size) { codePoint = Usage_Code_Point.ACCESS_LIST; UInt16 len = 0; // for opaque string lengths try { /* read resource_name*/ len = (UInt16)(System.Net.IPAddress.HostToNetworkOrder((short)reader.ReadInt16())); resource_name = Encoding.UTF8.GetString(reader.ReadBytes(len), 0, len); /* read length of PDU */ length = (UInt16)(System.Net.IPAddress.HostToNetworkOrder((short)reader.ReadInt16())); /* read to_user value */ len = (UInt16)(System.Net.IPAddress.HostToNetworkOrder((short)reader.ReadInt16())); string to_uri = Encoding.UTF8.GetString(reader.ReadBytes(len), 0, len); /* read kindId to be shared */ UInt32 kindId = (UInt32)System.Net.IPAddress.NetworkToHostOrder((int)reader.ReadInt32()); /* read allow_delegation flag */ Boolean allow_delegation = (reader.ReadByte() == 0 ? false : true); /* Create ACL data */ data = new AccessListData(kindId, to_uri, allow_delegation); usage_size = usage_size - (length + 1); } catch (Exception ex) { myManager.m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_ERROR, String.Format("AccessList FromReader(): {0}", ex.Message)); } SetHashCode(); return this; }
/// <summary> /// This contructor instanciates an Access List Kind. /// </summary> /// <param name="resource_name">The Name of the Resource to be shared.</param> /// <param name="kindId">The Kind Id of the Resource to be shared.</param> /// <param name="to_user"></param> /// <param name="to_user"></param> /// <param name="allow_delegation"></param> private AccessList(string resource_name, string to_user, UInt32 kindId, Boolean allow_delegation, UsageManager manager) { if (resource_name == null || kindId == 0 || to_user == null) throw new ArgumentNullException("An Access List does not allow null parameter."); codePoint = Usage_Code_Point.ACCESS_LIST; this.resource_name = resource_name; length = (UInt16)(resource_name.Length + 2); length += (UInt16)2; // KindId length += (UInt16)(to_user.Length + 2); length += (UInt16)1; // Boolean allow_delegation length += 2; // the length itself data = new AccessListData(kindId, to_user, allow_delegation); myManager = manager; SetHashCode(); }