/// <summary>
		/// Decodes -- that is: deserializes -- an ONC/RPC authentication object
		/// (credential & verifier) on the server side.
		/// </summary>
		/// <remarks>
		/// Decodes -- that is: deserializes -- an ONC/RPC authentication object
		/// (credential & 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 xdrDecodeCredVerf(org.acplt.oncrpc.XdrDecodingStream 
			xdr)
		{
			//
			// As the authentication type has already been pulled off the XDR
			// stream, we only need to make sure that really no opaque data follows.
			//
			if (xdr.xdrDecodeInt() != 0)
			{
				throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
					.ONCRPC_AUTH_BADCRED));
			}
			//
			// We also need to decode the verifier. This must be 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.
			//
			if ((xdr.xdrDecodeInt() != org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE) || (
				xdr.xdrDecodeInt() != 0))
			{
				throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
					.ONCRPC_AUTH_BADVERF));
			}
		}
 /// <summary>
 /// Decodes -- that is: deserializes -- a ONC/RPC message header object
 /// from a XDR stream according to RFC 1831.
 /// </summary>
 /// <remarks>
 /// Decodes -- that is: deserializes -- a ONC/RPC message header object
 /// from a XDR stream according to RFC 1831.
 /// </remarks>
 /// <param name="xdr">A decoding XDR stream from which to receive all the mess.</param>
 /// <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 xdrDecode(org.acplt.oncrpc.XdrDecodingStream xdr)
 {
     messageId = xdr.xdrDecodeInt();
     //
     // Make sure that we are really decoding an ONC/RPC message call
     // header. Otherwise, throw the appropriate OncRpcException exception.
     //
     messageType = xdr.xdrDecodeInt();
     if (messageType != org.acplt.oncrpc.OncRpcMessageType.ONCRPC_CALL)
     {
         throw (new org.acplt.oncrpc.OncRpcException(org.acplt.oncrpc.OncRpcException.RPC_WRONGMESSAGE
             ));
     }
     //
     // Make sure that the other side is talking the right slang --
     // we will only understand version 2 slang of ONC/RPC.
     //
     oncRpcVersion = xdr.xdrDecodeInt();
     if (oncRpcVersion != ONCRPC_VERSION)
     {
         throw (new org.acplt.oncrpc.OncRpcException(org.acplt.oncrpc.OncRpcException.RPC_VERSMISMATCH
             ));
     }
     //
     // Now decode the remaining fields of the call header.
     //
     program = xdr.xdrDecodeInt();
     version = xdr.xdrDecodeInt();
     procedure = xdr.xdrDecodeInt();
     //
     // Last comes the authentication data. Note that the "factory" hidden
     // within xdrNew() will graciously recycle any old authentication
     // protocol handling object if it is of the same authentication type
     // as the new one just coming in from the XDR wire.
     //
     auth = org.acplt.oncrpc.server.OncRpcServerAuth.xdrNew(xdr, auth);
 }
示例#3
0
		/// <summary>
		/// Decodes -- that is: deserializes -- an object from a XDR stream in
		/// compliance to RFC 1832.
		/// </summary>
		/// <remarks>
		/// Decodes -- that is: deserializes -- an object from 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 xdrDecode(org.acplt.oncrpc.XdrDecodingStream xdr)
		{
			//
			// Make sure that when deserializing this object's state that
			// the stream provides state information indeed intended for this
			// particular class.
			//
			int xdrTypeCode = xdr.xdrDecodeInt();
			if (xdrTypeCode != getXdrTypeCode())
			{
				throw (new System.Exception(this.GetType().Name +  "non-matching XDR type code received."));
			}
			//
			// 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.
			//
			xdrDecodeVariant(xdr);
			xdrDecodeCommon(xdr);
		}
示例#4
0
 /// <summary>
 /// Decodes -- that is: deserializes -- an <code>OncRpcGetPortParams</code>
 /// object from a XDR stream.
 /// </summary>
 /// <remarks>
 /// Decodes -- that is: deserializes -- an <code>OncRpcGetPortParams</code>
 /// object from 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 xdrDecode(org.acplt.oncrpc.XdrDecodingStream xdr)
 {
     port = xdr.xdrDecodeInt();
 }
		/// <summary>
		/// Decodes -- that is: deserializes -- a ONC/RPC message header object
		/// from a XDR stream.
		/// </summary>
		/// <remarks>
		/// Decodes -- that is: deserializes -- a ONC/RPC message header object
		/// from 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 xdrDecode(org.acplt.oncrpc.XdrDecodingStream xdr)
		{
			messageId = xdr.xdrDecodeInt();
			//
			// Make sure that we are really decoding an ONC/RPC message call
			// header. Otherwise, throw the appropriate OncRpcException exception.
			//
			messageType = xdr.xdrDecodeInt();
			if (messageType != org.acplt.oncrpc.OncRpcMessageType.ONCRPC_REPLY)
			{
				throw (new org.acplt.oncrpc.OncRpcException(org.acplt.oncrpc.OncRpcException.RPC_WRONGMESSAGE
					));
			}
			replyStatus = xdr.xdrDecodeInt();
			switch (replyStatus)
			{
				case org.acplt.oncrpc.OncRpcReplyStatus.ONCRPC_MSG_ACCEPTED:
				{
					//
					// Decode the information returned for accepted message calls.
					// If we have an associated client-side authentication protocol
					// object, we use that. Otherwise we fall back to the default
					// handling of only the AUTH_NONE authentication.
					//
					if (auth != null)
					{
						auth.xdrDecodeVerf(xdr);
					}
					else
					{
						//
						// If we don't have a protocol handler and the server sent its
						// reply using another authentication scheme than AUTH_NONE, we
						// will throw an exception. Also we check that no-one is
						// actually sending opaque information within AUTH_NONE.
						//
						if (xdr.xdrDecodeInt() != org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE)
						{
							throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
								.ONCRPC_AUTH_FAILED));
						}
						if (xdr.xdrDecodeInt() != 0)
						{
							throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
								.ONCRPC_AUTH_FAILED));
						}
					}
					//
					// Even if the call was accepted by the server, it can still
					// indicate an error. Depending on the status of the accepted
					// call we will receive an indication about the range of
					// versions a particular program (server) supports.
					//
					acceptStatus = xdr.xdrDecodeInt();
					switch (acceptStatus)
					{
						case org.acplt.oncrpc.OncRpcAcceptStatus.ONCRPC_PROG_MISMATCH:
						{
							lowVersion = xdr.xdrDecodeInt();
							highVersion = xdr.xdrDecodeInt();
							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.
					//
					rejectStatus = xdr.xdrDecodeInt();
					switch (rejectStatus)
					{
						case org.acplt.oncrpc.OncRpcRejectStatus.ONCRPC_RPC_MISMATCH:
						{
							lowVersion = xdr.xdrDecodeInt();
							highVersion = xdr.xdrDecodeInt();
							break;
						}

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

						default:
						{
							break;
						}
					}
					break;
				}
			}
		}
		/// <summary>
		/// Decodes ONC/RPC authentication information in form of a verifier
		/// when receiving an ONC/RPC reply message.
		/// </summary>
		/// <remarks>
		/// Decodes ONC/RPC authentication information in form of a verifier
		/// when receiving an ONC/RPC reply message.
		/// </remarks>
		/// <param name="xdr">
		/// XDR stream from which to receive the verifier sent together
		/// with an ONC/RPC reply message.
		/// </param>
		/// <exception cref="OncRpcAuthenticationException">
		/// if the received verifier is
		/// not kosher.
		/// </exception>
		/// <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 xdrDecodeVerf(org.acplt.oncrpc.XdrDecodingStream xdr)
		{
			//
			// Make sure that we received a AUTH_NONE verifier and that it
			// does not contain any opaque data. Anything different from this
			// is not kosher and an authentication exception will be thrown.
			//
			if ((xdr.xdrDecodeInt() != org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE) || (
				xdr.xdrDecodeInt() != 0))
			{
				throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
					.ONCRPC_AUTH_FAILED));
			}
		}
示例#7
0
        /// <summary>Restores (deserializes) an authentication object from an XDR stream.</summary>
        /// <remarks>Restores (deserializes) an authentication object from an XDR stream.</remarks>
        /// <param name="xdr">
        /// XDR stream from which the authentication object is
        /// restored.
        /// </param>
        /// <param name="recycle">
        /// old authtentication object which is intended to be
        /// reused in case it is of the same authentication type as the new
        /// one just arriving from the XDR stream.
        /// </param>
        /// <returns>
        /// Authentication information encapsulated in an object, whose class
        /// is derived from <code>OncRpcServerAuth</code>.
        /// </returns>
        /// <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 static org.acplt.oncrpc.server.OncRpcServerAuth xdrNew(org.acplt.oncrpc.XdrDecodingStream
			 xdr, org.acplt.oncrpc.server.OncRpcServerAuth recycle)
        {
            org.acplt.oncrpc.server.OncRpcServerAuth auth;
            //
            // In case we got an old authentication object and we are just about
            // to receive an authentication with the same type, we reuse the old
            // object.
            //
            int authType = xdr.xdrDecodeInt();
            if ((recycle != null) && (recycle.getAuthenticationType() == authType))
            {
                //
                // Simply recycle authentication object and pull its new state
                // of the XDR stream.
                //
                auth = recycle;
                auth.xdrDecodeCredVerf(xdr);
            }
            else
            {
                switch (authType)
                {
                    case org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE:
                    {
                        //
                        // Create a new authentication object and pull its state off
                        // the XDR stream.
                        //
                        auth = org.acplt.oncrpc.server.OncRpcServerAuthNone.AUTH_NONE;
                        auth.xdrDecodeCredVerf(xdr);
                        break;
                    }

                    case org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_SHORT:
                    {
                        auth = new org.acplt.oncrpc.server.OncRpcServerAuthShort(xdr);
                        break;
                    }

                    case org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_UNIX:
                    {
                        auth = new org.acplt.oncrpc.server.OncRpcServerAuthUnix(xdr);
                        break;
                    }

                    default:
                    {
                        //
                        // In case of an unknown or unsupported type, throw an exception.
                        // Note: using AUTH_REJECTEDCRED is in sync with the way Sun's
                        // ONC/RPC implementation does it. But don't ask me why they do
                        // it this way...!
                        //
                        throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
                            .ONCRPC_AUTH_REJECTEDCRED));
                    }
                }
            }
            return auth;
        }
示例#8
0
 /// <summary>
 /// Decodes -- that is: deserializes -- an OncRpcServerIdent object
 /// from a XDR stream.
 /// </summary>
 /// <remarks>
 /// Decodes -- that is: deserializes -- an OncRpcServerIdent object
 /// from 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 xdrDecode(org.acplt.oncrpc.XdrDecodingStream xdr)
 {
     program = xdr.xdrDecodeInt();
     version = xdr.xdrDecodeInt();
     protocol = xdr.xdrDecodeInt();
     port = xdr.xdrDecodeInt();
 }
		/// <summary>
		/// Decodes -- that is: deserializes -- an ONC/RPC authentication object
		/// (credential & verifier) on the server side.
		/// </summary>
		/// <remarks>
		/// Decodes -- that is: deserializes -- an ONC/RPC authentication object
		/// (credential & 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 xdrDecodeCredVerf(org.acplt.oncrpc.XdrDecodingStream 
			xdr)
		{
			//
			// Reset some part of the object's state...
			//
			shorthandVerf = null;
			//
			// Now pull off the object state of the XDR stream...
			//
			int realLen = xdr.xdrDecodeInt();
			stamp = xdr.xdrDecodeInt();
			machinename = xdr.xdrDecodeString();
			uid = xdr.xdrDecodeInt();
			gid = xdr.xdrDecodeInt();
			gids = xdr.xdrDecodeIntVector();
			//
			// Make sure that the indicated length of the opaque data is kosher.
			// If not, throw an exception, as there is something strange going on!
			//
			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 (realLen != len)
			{
				if (realLen < len)
				{
					throw (new org.acplt.oncrpc.OncRpcException(org.acplt.oncrpc.OncRpcException.RPC_BUFFERUNDERFLOW
						));
				}
				else
				{
					throw (new org.acplt.oncrpc.OncRpcException(org.acplt.oncrpc.OncRpcException.RPC_AUTHERROR
						));
				}
			}
			//
			// We also need to decode the verifier. This must be 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.
			//
			if ((xdr.xdrDecodeInt() != org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE) || (
				xdr.xdrDecodeInt() != 0))
			{
				throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
					.ONCRPC_AUTH_BADVERF));
			}
		}
示例#10
0
        /// <summary>
        /// Decodes -- that is: deserializes -- an ONC/RPC authentication object
        /// (credential & verifier) on the server side.
        /// </summary>
        /// <remarks>
        /// Decodes -- that is: deserializes -- an ONC/RPC authentication object
        /// (credential & 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 xdrDecodeCredVerf(org.acplt.oncrpc.XdrDecodingStream 
			xdr)
        {
            //
            // Reset the authentication object's state properly...
            //
            shorthandCred = null;
            shorthandVerf = null;
            //
            // Pull off the shorthand credential information (opaque date) of
            // the XDR stream...
            //
            shorthandCred = xdr.xdrDecodeDynamicOpaque();
            if (shorthandCred.Length > org.acplt.oncrpc.OncRpcAuthConstants.ONCRPC_MAX_AUTH_BYTES)
            {
                throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
                    .ONCRPC_AUTH_BADCRED));
            }
            //
            // We also need to decode the verifier. This must be 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.
            //
            if ((xdr.xdrDecodeInt() != org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE) || (
                xdr.xdrDecodeInt() != 0))
            {
                throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
                    .ONCRPC_AUTH_BADVERF));
            }
        }
示例#11
0
        /// <summary>
        /// Decodes ONC/RPC authentication information in form of a verifier
        /// when receiving an ONC/RPC reply message.
        /// </summary>
        /// <remarks>
        /// Decodes ONC/RPC authentication information in form of a verifier
        /// when receiving an ONC/RPC reply message.
        /// </remarks>
        /// <param name="xdr">
        /// XDR stream from which to receive the verifier sent together
        /// with an ONC/RPC reply message.
        /// </param>
        /// <exception cref="OncRpcAuthenticationException">
        /// if the received verifier is
        /// not kosher.
        /// </exception>
        /// <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 xdrDecodeVerf(org.acplt.oncrpc.XdrDecodingStream xdr)
        {
            switch (xdr.xdrDecodeInt())
            {
                case org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_NONE:
                {
                    //
                    // The verifier sent in response to AUTH_UNIX or AUTH_SHORT credentials
                    // can only be AUTH_NONE or AUTH_SHORT. In the latter case we drop
                    // any old shorthand credential and use the new one.
                    //
                    //
                    // Make sure that the verifier does not contain any opaque data.
                    // Anything different from this is not kosher and an authentication
                    // exception will be thrown.
                    //
                    if (xdr.xdrDecodeInt() != 0)
                    {
                        throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
                            .ONCRPC_AUTH_FAILED));
                    }
                    break;
                }

                case org.acplt.oncrpc.OncRpcAuthType.ONCRPC_AUTH_SHORT:
                {
                    //
                    // Fetch the credential from the XDR stream and make sure that
                    // it does conform to the length restriction as set forth in
                    // the ONC/RPC protocol.
                    //
                    shorthandCred = xdr.xdrDecodeDynamicOpaque();
                    if (shorthandCred.Length > org.acplt.oncrpc.OncRpcAuthConstants.ONCRPC_MAX_AUTH_BYTES)
                    {
                        throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
                            .ONCRPC_AUTH_FAILED));
                    }
                    break;
                }

                default:
                {
                    //
                    // Do not accept any other kind of verifier sent.
                    //
                    throw (new org.acplt.oncrpc.OncRpcAuthenticationException(org.acplt.oncrpc.OncRpcAuthStatus
                        .ONCRPC_AUTH_INVALIDRESP));
                }
            }
        }