Esempio n. 1
0
 /// <summary>
 /// Encodes -- that is: serializes -- a XDR opaque into a XDR stream in
 /// compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- a XDR opaque into a XDR stream in
 /// compliance to RFC 1832.
 /// </remarks>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 public virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     xdr.xdrEncodeDynamicOpaque(value);
 }
		/// <summary>
		/// Encodes -- that is: serializes -- an ONC/RPC authentication object
		/// (its verifier) on the server side.
		/// </summary>
		/// <remarks>
		/// Encodes -- that is: serializes -- an ONC/RPC authentication object
		/// (its verifier) on the server side.
		/// </remarks>
		/// <exception cref="org.acplt.oncrpc.OncRpcException">if an ONC/RPC error occurs.</exception>
		/// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
		public sealed override void xdrEncodeVerf(org.acplt.oncrpc.XdrEncodingStream xdr)
		{
			if (shorthandVerf != null)
			{
				//
				// Encode AUTH_SHORT shorthand verifier (credential).
				//
				xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_SHORT);
				xdr.xdrEncodeDynamicOpaque(shorthandVerf);
			}
			else
			{
				//
				// Encode an AUTH_NONE verifier with zero length, if no shorthand
				// verifier (credential) has been supplied by now.
				//
				xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
				xdr.xdrEncodeInt(0);
			}
		}
Esempio n. 3
0
 /// <summary>
 /// Encodes ONC/RPC authentication information in form of a credential
 /// and a verifier when sending an ONC/RPC call message.
 /// </summary>
 /// <remarks>
 /// Encodes ONC/RPC authentication information in form of a credential
 /// and a verifier when sending an ONC/RPC call message. The
 /// <code>AUTH_UNIX</code> authentication method only uses the credential
 /// but no verifier. If the ONC/RPC server sent a <code>AUTH_SHORT</code>
 /// "shorthand" credential together with the previous reply message, it
 /// is used instead of the original credential.
 /// </remarks>
 /// <param name="xdr">
 /// XDR stream where to encode the credential and the verifier
 /// to.
 /// </param>
 /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
 /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 internal override void xdrEncodeCredVerf(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     if (shorthandCred == null)
     {
         //
         // Encode the credential, which contains some unsecure information
         // about user and group ID, etc. Note that the credential itself
         // is encoded as a variable-sized bunch of octets.
         //
         if ((gids.Length > org.acplt.oncrpc.OncRpcAuthConstants.ONCRPC_MAX_GROUPS) || (machinename
             .Length > org.acplt.oncrpc.OncRpcAuthConstants.ONCRPC_MAX_MACHINE_NAME))
         {
             throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
                 .ONCRPC_AUTH_FAILED));
         }
         xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_UNIX);
         int len = 4 + ((machinename.Length + 7) & ~3) + 4 + 4 + gids.Length * 4 + 4;
         // length of stamp
         // len string incl. len
         // length of uid
         // length of gid
         // length of vector of gids incl. len
         if (len > org.acplt.oncrpc.OncRpcAuthConstants.ONCRPC_MAX_AUTH_BYTES)
         {
             throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
                 .ONCRPC_AUTH_FAILED));
         }
         xdr.xdrEncodeInt(len);
         xdr.xdrEncodeInt(stamp);
         xdr.xdrEncodeString(machinename);
         xdr.xdrEncodeInt(uid);
         xdr.xdrEncodeInt(gid);
         xdr.xdrEncodeIntVector(gids);
     }
     else
     {
         //
         // Use shorthand credential instead of original credential.
         //
         xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_SHORT);
         xdr.xdrEncodeDynamicOpaque(shorthandCred);
     }
     //
     // We also need to encode the verifier, which is always of
     // type AUTH_NONE.
     //
     xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
     xdr.xdrEncodeInt(0);
 }