예제 #1
0
 ///  <summary>
 ///     Initializes a new instance of the <strong>X509AlternativeName</strong> class by using alternative name
 ///     type and alternative name value.
 ///  </summary>
 ///  <param name="type">
 ///     Specifies the type of the alternative name contained in the <strong>value</strong> parameter.
 ///  </param>
 ///  <param name="value">
 ///     Specifies the alternative name value. For acceptable value types see <strong>Remarks</strong> section.
 ///  </param>
 /// <exception cref="InvalidOperationException">
 ///     The constructor cannot be used for <strong>OtherName</strong> type.
 /// </exception>
 /// <exception cref="ArgumentException">
 ///     The value does not fall within the expected type. For acceptable value types see <strong>Remarks</strong> section.
 /// </exception>
 /// <remarks>
 ///     The following table defines alternative name type and value type mappings:
 /// <list type="table">
 ///     <listheader>
 ///         <term>Alternative Name Type</term>
 ///         <description>Value Type</description>
 ///     </listheader>
 ///     <item>
 ///         <term>OtherName</term>
 ///         <description>Not supported in this constructor.</description>
 ///     </item>
 ///     <item>
 ///     <term>Rfc822Name</term>
 ///         <description>The value must be a string.</description>
 ///     </item>
 ///     <item>
 ///         <term>DnsName</term>
 ///         <description>The value must be a string.</description>
 ///     </item>
 ///     <item>
 ///         <term>DirectoryName</term>
 ///         <description>
 ///             Can be a string that represents a X.500 distinguished name, or a <see cref="X500DistinguishedName"/>
 ///             object.
 ///         </description>
 ///     </item>
 ///     <item>
 ///         <term>URL</term>
 ///         <description>Can be a string that represents an absulute or relative URL or a <see cref="Uri"/> object.</description>
 ///     </item>
 ///     <item>
 ///         <term>IpAddress</term>
 ///         <description>
 ///             <para>
 ///             Must be a string that represents either, IPv4 or IPv6 address. For IPv6 address shortcuts
 ///             are allowed (for example, ::1).
 ///             </para>
 ///             <para>
 ///             For X.509 Name Constraints certificate extension purposes, you must provide either, IPv4
 ///             or IPv6 address with network mask. In this case, network mask must be specified as the
 ///             number of bits held by mask after a slash character. For example, IPv4 network "192.168.5.0"
 ///             with network mask "255.255.255.0" must be passed as "192.168.5.0/24". The same syntax is used
 ///             for IPv6 networks. To specify individual IP address, network mask bust be set to 32 for IPv4
 ///             addresses and 128 for IPv6 addresses.
 ///             </para>
 ///         </description>
 ///     </item>
 ///     <item>
 ///         <term>RegisteredId</term>
 ///         <description>
 ///             Can be a string that represents a registered in the <strong>IANA</strong> (<i>Internet Assigned
 ///             Numbers Authority</i>) or <strong>ISO</strong> (<i>International Standards Organization</i>) object
 ///             identifier, or an instance of <see cref="Oid"/> object or <see cref="Oid2"/> object that contains
 ///             registered object identifier.
 ///         </description>
 ///     </item>
 ///     <item>
 ///         <term>Guid</term>
 ///         <description>
 ///             Can be a string that represents a globally unique identifier and should identify a server
 ///             to the Active Directory replication system as a domain controller or an instance of the
 ///             <see cref="Guid"/> object.
 ///         </description>
 ///     </item>
 ///     <item>
 ///         <term>UserPrincipalName</term>
 ///         <description>
 ///             Must be a string that is a user logon name in email address format.
 ///         </description>
 ///		</item>
 /// </list>
 /// <pare>
 /// For compatibility with Name Constraints extension, null value can be passed for any name type except
 /// IPAddress name type. For IPAddress name type, global IP subnet must be used instead of empty value.
 /// For example, "0.0.0.0/0".
 /// </pare>
 /// </remarks>
 public X509AlternativeName(X509AlternativeNamesEnum type, Object value)
 {
     //if (value == null) { throw new ArgumentNullException(nameof(value)); }
     if (type == X509AlternativeNamesEnum.OtherName)
     {
         throw new InvalidOperationException("Invalid constructor.");
     }
     m_initialize(type, value);
 }
예제 #2
0
 ///   <summary>
 ///  		Initializes a new instance of the <strong>X509AlternativeName</strong> class by using alternative name
 ///  		type, alternative name value and alternative name object identifier. This constructor supports only
 ///  		<strong>OtherName</strong> type which can be either: <strong>OtherName</strong>, <strong>Guid</strong>
 ///  		or <strong>UserPrincipalName</strong>. Use additional constructor for the rest alternative name types.
 ///   </summary>
 ///   <param name="type">
 ///  		Specifies the type of the alternative name contained in the <strong>value</strong> parameter. Type can be either:
 ///  		<strong>OtherName</strong>, <strong>Guid</strong> or <strong>UserPrincipalName</strong>.
 ///   </param>
 ///   <param name="value">
 /// 		Specifies the alternative name value. This parameter accepts either, string or byte array that
 /// 		represents other name value.
 ///   </param>
 /// <param name="oid">
 ///		Specifies the object identifier of the other name.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// 		<strong>rawData</strong> value is null reference.
 ///  </exception>
 ///  <exception cref="InvalidOperationException">
 ///  		The constructor cannot be used for <strong>OtherName</strong> type.
 ///   </exception>
 ///   <exception cref="ArgumentException">
 ///  		The value does not fall within the expected type.
 ///   </exception>
 /// <remarks>
 /// For compatibility with Name Constraints extension, null value can be passed for any name type
 /// supported by this constructor.
 /// </remarks>
 public X509AlternativeName(X509AlternativeNamesEnum type, Object value, Oid oid) {
     if (
         type != X509AlternativeNamesEnum.OtherName &&
         type != X509AlternativeNamesEnum.Guid &&
         type != X509AlternativeNamesEnum.UserPrincipalName
         ) { throw new InvalidOperationException("Invalid constructor."); }
     if (String.IsNullOrEmpty(oid?.Value)) { throw new ArgumentNullException(nameof(oid)); }
     encodeOtherName(value, oid);
 }
예제 #3
0
 // constructor initializers
 void m_initialize(X509AlternativeNamesEnum type, Object value)
 {
     Type = type;
     encodeFromValue(value);
 }