/// <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.
		/// </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)
		{
			//
			// The credential only consists of the indication of AUTH_NONE with
			// no opaque authentication data following.
			//
			xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
			xdr.xdrEncodeInt(0);
			//
			// But we also need to encode the verifier. This is always of type
			// AUTH_NONE too. For some obscure historical reasons, we have to
			// deal with credentials and verifiers, although they belong together,
			// according to Sun's specification.
			//
			xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
			xdr.xdrEncodeInt(0);
		}
		/// <summary>
		/// Encodes -- that is: serializes -- a ONC/RPC message header object
		/// into a XDR stream according to RFC 1831.
		/// </summary>
		/// <remarks>
		/// Encodes -- that is: serializes -- a ONC/RPC message header object
		/// into a XDR stream according to RFC 1831.
		/// </remarks>
		/// <param name="xdr">An encoding XDR stream where to put the mess in.</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>
		public virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
		{
			xdr.xdrEncodeInt(messageId);
			xdr.xdrEncodeInt(messageType);
			xdr.xdrEncodeInt(oncRpcVersion);
			xdr.xdrEncodeInt(program);
			xdr.xdrEncodeInt(version);
			xdr.xdrEncodeInt(procedure);
			//
			// Now encode the authentication data. If we have an authentication
			// protocol handling object at hand, then we let do the dirty work
			// for us. Otherwise, we fall back to AUTH_NONE handling.
			//
			if (auth != null)
			{
				auth.xdrEncodeCredVerf(xdr);
			}
			else
			{
				xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
				xdr.xdrEncodeInt(0);
				xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
				xdr.xdrEncodeInt(0);
			}
		}
Beispiel #3
0
		/// <summary>
		/// Encodes -- that is: serializes -- an object into a XDR stream in
		/// compliance to RFC 1832.
		/// </summary>
		/// <remarks>
		/// Encodes -- that is: serializes -- an object 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)
		{
			//
			// For historial reasons (read: "for dumb and pure idiotic reasons")
			// and compatibility with the ACPLT/KS C++ Communication Library we
			// encode/decode the variant part *first* before encoding/decoding
			// the common part.
			//
			xdr.xdrEncodeInt(getXdrTypeCode());
			xdrEncodeVariant(xdr);
			xdrEncodeCommon(xdr);
		}
 /// <summary>
 /// Encodes -- that is: serializes -- an <code>OncRpcGetPortParams</code>
 /// object into a XDR stream.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- an <code>OncRpcGetPortParams</code>
 /// object into a XDR stream.
 /// </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.xdrEncodeInt(port);
 }
		/// <summary>
		/// Encodes -- that is: serializes -- a ONC/RPC reply header object
		/// into a XDR stream.
		/// </summary>
		/// <remarks>
		/// Encodes -- that is: serializes -- a ONC/RPC reply header object
		/// into a XDR stream.
		/// </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 virtual void xdrEncode(org.acplt.oncrpc.XdrEncodingStream xdr)
		{
			xdr.xdrEncodeInt(messageId);
			xdr.xdrEncodeInt(messageType);
			xdr.xdrEncodeInt(replyStatus);
			switch (replyStatus)
			{
				case org.acplt.oncrpc.OncRpcReplyStatus.ONCRPC_MSG_ACCEPTED:
				{
					//
					// Encode the information returned for accepted message calls.
					//
					// First encode the authentification data. If someone has
					// nulled (nuked?) the authentication protocol handling object
					// from the call information object, then we can still fall back
					// to sending AUTH_NONE replies...
					//
					if (auth != null)
					{
						auth.xdrEncodeVerf(xdr);
					}
					else
					{
						xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
						xdr.xdrEncodeInt(0);
					}
					//
					// Even if the call was accepted by the server, it can still
					// indicate an error. Depending on the status of the accepted
					// call we have to send back an indication about the range of
					// versions we support of a particular program (server).
					//
					xdr.xdrEncodeInt(acceptStatus);
					switch (acceptStatus)
					{
						case org.acplt.oncrpc.OncRpcAcceptStatus.ONCRPC_PROG_MISMATCH:
						{
							xdr.xdrEncodeInt(lowVersion);
							xdr.xdrEncodeInt(highVersion);
							break;
						}

						default:
						{
							//
							// Otherwise "open ended set of problem", like the author
							// of Sun's ONC/RPC source once wrote...
							//
							break;
						}
					}
					break;
				}

				case org.acplt.oncrpc.OncRpcReplyStatus.ONCRPC_MSG_DENIED:
				{
					//
					// Encode the information returned for denied message calls.
					//
					xdr.xdrEncodeInt(rejectStatus);
					switch (rejectStatus)
					{
						case org.acplt.oncrpc.OncRpcRejectStatus.ONCRPC_RPC_MISMATCH:
						{
							xdr.xdrEncodeInt(lowVersion);
							xdr.xdrEncodeInt(highVersion);
							break;
						}

						case org.acplt.oncrpc.OncRpcRejectStatus.ONCRPC_AUTH_ERROR:
						{
							xdr.xdrEncodeInt(authStatus);
							break;
						}

						default:
						{
							break;
						}
					}
					break;
				}
			}
		}
 /// <summary>
 /// Encodes -- that is: serializes -- an OncRpcServerIdent object
 /// into a XDR stream.
 /// </summary>
 /// <remarks>
 /// Encodes -- that is: serializes -- an OncRpcServerIdent object
 /// into a XDR stream.
 /// </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.xdrEncodeInt(program);
     xdr.xdrEncodeInt(version);
     xdr.xdrEncodeInt(protocol);
     xdr.xdrEncodeInt(port);
 }
		/// <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);
			}
		}
 /// <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 override sealed void xdrEncodeVerf(org.acplt.oncrpc.XdrEncodingStream xdr)
 {
     //
     // Encode an AUTH_NONE verifier with zero length.
     //
     xdr.xdrEncodeInt(org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE);
     xdr.xdrEncodeInt(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);
 }