Represents a named collection of values within a resource object, although the simplest case is a name-value pair (e.g., email, employeeID). Values can be empty, null, or set with various types. Empty and null are supported because it makes a difference on some resources (in particular database resources). The developer of a Connector will use an builder to construct an instance of ConnectorAttribute.
        /// <summary>
        /// Concatenates two attributes' values 
        /// </summary>
        /// <param name="ca1">Must be non null</param>
        /// <param name="ca2">May be null</param>
        /// <returns>new attribute with name of ca1 and value of ca1 + ca2</returns>
        public ConnectorAttribute AttConcat(ConnectorAttribute ca1, ConnectorAttribute ca2)
        {
            ConnectorAttributeBuilder builder = new ConnectorAttributeBuilder();
            Assert.IsNotNull(ca1);
            if (ca2 == null)
            {
                // if the second is null, just build up a dummy one
                ca2 = ConnectorAttributeBuilder.Build(ca1.Name);
            }

            Assert.AreEqual(ca1.Name, ca2.Name);
            builder.Name = ca1.Name;
            builder.AddValue(ca1.Value);
            builder.AddValue(ca2.Value);

            return builder.Build();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets the integer value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the integer value from.</param>
 /// <returns>null if the value is null otherwise the integer value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">iff the object in the attribute is not an integer.</exception>
 /// <exception cref="ArgumentException">iff the attribute is a multi valued instead of single valued.</exception>
 public static double? GetDoubleValue(ConnectorAttribute attr)
 {
     Object obj = GetSingleValue(attr);
     return obj != null ? (double?)obj : null;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the date value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the date value from.</param>
 /// <returns>null if the value is null otherwise the date value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">iff the object in the attribute is not an long.</exception>
 /// <exception cref="ArgumentException">iff the attribute is a multi valued instead of single valued.</exception>
 public static DateTime? GetDateTimeValue(ConnectorAttribute attr)
 {
     long? val = GetLongValue(attr);
     if (val != null)
     {
         return DateTimeUtil.GetDateTimeFromUtcMillis(val.Value);
     }
     return null;
 }
Exemplo n.º 4
0
 public static bool? GetBooleanValue(ConnectorAttribute attr)
 {
     object obj = GetSingleValue(attr);
     return obj != null ? (bool?)obj : null;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Renames the connector attribute to new name; transforms value by keeping Common Name only
        /// </summary>
        /// <param name="cattribute">ConnectorAttribute to be renamed</param>
        /// <param name="newName">New attribute name</param>
        /// <returns>Renamed and transformed ConnectorAttribute</returns>
        /// <exception cref="ArgumentNullException">If some of the params is null</exception>
        internal static ConnectorAttribute ExtractCommonName(ConnectorAttribute cattribute, string newName)
        {
            Assertions.NullCheck(cattribute, "cattribute");
            Assertions.NullCheck(newName, "newName");

            var attBuilder = new ConnectorAttributeBuilder();
            if (cattribute.Value != null)
            {
                ICollection<object> convertedValues = new List<object>();
                foreach (object oldValue in cattribute.Value)
                {
                    if (oldValue != null)       // should be always the case
                    {
                        convertedValues.Add(ExtractCommonName(oldValue.ToString()));
                    }
                }
                attBuilder.AddValue(convertedValues);
            }
            attBuilder.Name = newName;
            return attBuilder.Build();
        }
Exemplo n.º 6
0
 public static bool IsOperationalAttribute(ConnectorAttribute attr)
 {
     string name = (attr != null) ? attr.Name : null;
     return OPERATIONAL_ATTRIBUTE_NAMES.Contains(name);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Gets the string value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the string value from.</param>
 /// <returns>null if the value is null otherwise the string value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">iff the object in the attribute is not an string.</exception>
 /// <exception cref="ArgumentException">iff the attribute is a multi valued instead of single valued.</exception>
 public static string GetStringValue(ConnectorAttribute attr)
 {
     return (string)GetSingleValue(attr);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Gets the long value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the long value from.</param>
 /// <returns>null if the value is null otherwise the long value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">iff the object in the attribute is not an long.</exception>
 /// <exception cref="ArgumentException">iff the attribute is a multi valued instead of single valued.</exception>
 public static long? GetLongValue(ConnectorAttribute attr)
 {
     Object obj = GetSingleValue(attr);
     return obj != null ? (long?)obj : null;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Gets the dictionary value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the dictionary value from.</param>
 /// <returns>null if the value is null otherwise the dictionary value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">if the object in the attribute is not a dictionary.</exception>
 /// <exception cref="ArgumentException">if the attribute is a multi valued instead of single valued.</exception>
 /// <remarks>Since 1.4</remarks>
 public static IDictionary<object, object> GetDictionaryValue(ConnectorAttribute attr)
 {
     object obj = GetSingleValue(attr);
     return obj != null ? (IDictionary<object, object>)obj : null;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Gets the big integer value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the big integer value from.</param>
 /// <returns>null if the value is null otherwise the big integer value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">if the object in the attribute is not a big integer.</exception>
 /// <exception cref="ArgumentException">if the attribute is a multi valued instead of single valued.</exception>
 /// <remarks>Since 1.4</remarks>
 public static BigInteger GetBigIntegerValue(ConnectorAttribute attr)
 {
     object obj = GetSingleValue(attr);
     return obj != null ? (BigInteger)obj : null;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Gets the big decimal value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the big decimal value from.</param>
 /// <returns>null if the value is null otherwise the big decimal value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">if the object in the attribute is not a big decimal.</exception>
 /// <exception cref="ArgumentException">if the attribute is a multi valued instead of single valued.</exception>
 /// <remarks>Since 1.4</remarks>
 public static BigDecimal GetBigDecimalValue(ConnectorAttribute attr)
 {
     object obj = GetSingleValue(attr);
     return obj != null ? (BigDecimal)obj : null;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Gets the byte value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the byte value from.</param>
 /// <returns>null if the value is null otherwise the byte value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">if the object in the attribute is not a byte.</exception>
 /// <exception cref="ArgumentException">if the attribute is a multi valued instead of single valued.</exception>
 /// <remarks>Since 1.4</remarks>
 public static byte[] GetByteArrayValue(ConnectorAttribute attr)
 {
     object obj = GetSingleValue(attr);
     return obj != null ? (byte[])obj : null;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Gets the float value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the float value from.</param>
 /// <returns>null if the value is null otherwise the float value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">if the object in the attribute is not a float.</exception>
 /// <exception cref="ArgumentException">if the attribute is a multi valued instead of single valued.</exception>
 /// <remarks>Since 1.4</remarks>
 public static float? GetFloatValue(ConnectorAttribute attr)
 {
     Object obj = GetSingleValue(attr);
     return obj != null ? (float?)obj : null;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Gets the guarded byte array value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the guarded byte array value from.</param>
 /// <returns>null if the value is null otherwise the guarded byte array value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">if the object in the attribute is not a guarded byte array.</exception>
 /// <exception cref="ArgumentException">if the attribute is a multi valued instead of single valued.</exception>
 /// <remarks>Since 1.4</remarks>
 public static GuardedByteArray GetGuardedByteArrayValue(ConnectorAttribute attr)
 {
     object obj = GetSingleValue(attr);
     return obj != null ? (GuardedByteArray)obj : null;
 }
Exemplo n.º 15
0
 public static GuardedString GetGuardedStringValue(ConnectorAttribute attr)
 {
     object obj = GetSingleValue(attr);
     return obj != null ? (GuardedString)obj : null;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Gets the integer value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the integer value from.</param>
 /// <returns>null if the value is null otherwise the integer value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">iff the object in the attribute is not an integer.</exception>
 /// <exception cref="ArgumentException">iff the attribute is a multi valued instead of single valued.</exception>
 public static int? GetIntegerValue(ConnectorAttribute attr)
 {
     object obj = GetSingleValue(attr);
     return obj != null ? (int?)obj : null;
 }
Exemplo n.º 17
0
 /// <summary>
 /// Gets the character value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the character value from.</param>
 /// <returns>null if the value is null otherwise the character value for the
 /// attribute.</returns>
 /// <exception cref="InvalidCastException ">if the object in the attribute is not an string.</exception>
 /// <exception cref="ArgumentException">if the attribute is a multi valued instead of single valued.</exception>
 /// <remarks>Since 1.4</remarks>
 public static char? GetCharacterValue(ConnectorAttribute attr)
 {
     object obj = GetSingleValue(attr);
     return obj != null ? (char?)obj : null;
 }
Exemplo n.º 18
0
 /// <summary>
 /// Get the single value from the ConnectorAttribute.
 /// </summary>
 /// <remarks>
 /// Return
 /// null if the attribute's list of values is null or empty.
 /// </remarks>
 public static object GetSingleValue(ConnectorAttribute attr)
 {
     Object ret = null;
     IList<Object> val = attr.Value;
     if (val != null && val.Count > 0)
     {
         // make sure this only called for single value..
         if (val.Count > 1)
         {
             const string MSG = "The method is only for single value attributes.";
             throw new ArgumentException(MSG);
         }
         ret = val[0];
     }
     return ret;
 }
        /// <summary>
        /// Renames the connector attribute to new name
        /// </summary>
        /// <param name="cattribute">ConnectorAttribute to be renamed</param>
        /// <param name="newName">New attribute name</param>
        /// <returns>Renamed ConnectorAttribute</returns>
        /// <exception cref="ArgumentNullException">If some of the params is null</exception>
        internal static ConnectorAttribute RenameAttribute(ConnectorAttribute cattribute, string newName)
        {
            Assertions.NullCheck(cattribute, "cattribute");
            Assertions.NullCheck(newName, "newName");

            var attBuilder = new ConnectorAttributeBuilder();
            attBuilder.AddValue(cattribute.Value);
            attBuilder.Name = newName;
            return attBuilder.Build();
        }
Exemplo n.º 20
0
 /// <summary>
 /// Determines if this attribute is a special attribute.
 /// </summary>
 /// <param name="attr">
 /// <see cref="ConnectorAttribute" /> to test for against.</param>
 /// <returns>true iff the attribute value is a <see cref="Uid" />,
 /// <see cref="ObjectClass" />, <see cref="Password" />, or
 /// <see cref="OperationalAttributes" />.</returns>
 /// <exception cref="NullReferenceException">iff the attribute parameter is null.</exception>
 public static bool IsSpecial(ConnectorAttribute attr)
 {
     // note this is dangerous because we need to be consistent
     // in the naming of special attributes.
     String name = attr.Name;
     return IsSpecialName(name);
 }
Exemplo n.º 21
0
        internal void AddConnectorAttributeToADProperties(ObjectClass oclass,
            DirectoryEntry directoryEntry, ConnectorAttribute attribute,
            UpdateType type)
        {
            // Boolean translated = false;
            if (directoryEntry == null)
            {
                throw new ConnectorException(_configuration.ConnectorMessages.Format(
                    "ex_CouldNotAddNullAttributeToDe",
                    "Could not add connector attribute to <null> directory entry"));
            }

            _customHandlers.UpdateDeFromCa(oclass, type,
                directoryEntry, attribute);
        }
 public ConnectorAttribute NormalizeAttribute(ObjectClass oclass, ConnectorAttribute attribute)
 {
     if (attribute.Is("foo"))
     {
         String val = ConnectorAttributeUtil.GetStringValue(attribute);
         return ConnectorAttributeBuilder.Build("foo", val.Trim());
     }
     else
     {
         return attribute;
     }
 }
Exemplo n.º 23
0
 /// <summary>
 /// Gets the string value from the single value attribute.
 /// </summary>
 /// <param name="attr">ConnectorAttribute to retrieve the string value from.</param>
 /// <returns>null if the value is null otherwise the string value for the
 /// attribute.</returns>
 /// <exception cref="ArgumentException">iff the attribute is a multi valued instead of single valued.</exception>
 public static string GetAsStringValue(ConnectorAttribute attr)
 {
     object obj = GetSingleValue(attr);
     return obj != null ? obj.ToString() : null;
 }