コード例 #1
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();
 }
コード例 #2
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 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));
     }
 }
コード例 #3
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 sealed override 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));
     }
 }
コード例 #4
0
 /// <summary>Close the server transport and free any resources associated with it.</summary>
 /// <remarks>
 /// Close the server transport and free any resources associated with it.
 /// <p>Note that the server transport is <b>not deregistered</b>. You'll
 /// have to do it manually if you need to do so. The reason for this
 /// behaviour is, that the portmapper removes all entries regardless of
 /// the protocol (TCP/IP or UDP/IP) for a given ONC/RPC program number
 /// and version.
 /// <p>Calling this method on a <code>OncRpcTcpServerTransport</code>
 /// results in the listening TCP network socket immediately being closed.
 /// The handler thread will therefore either terminate directly or when
 /// it tries to sent back replies.
 /// </remarks>
 public override void Close()
 {
     if (socket != null)
     {
         //
         // Since there is a non-zero chance of getting race conditions,
         // we now first set the socket instance member to null, before
         // we close the corresponding socket. This avoids null-pointer
         // exceptions in the method which waits for new requests: it is
         // possible that this method is awakened because the socket has
         // been closed before we could set the socket instance member to
         // null. Many thanks to Michael Smith for tracking down this one.
         //
         Socket deadSocket = socket;
         socket = null;
         try
         {
             deadSocket.Close();
         }
         catch (System.IO.IOException)
         {
         }
     }
     if (sendingXdr != null)
     {
         org.acplt.oncrpc.XdrEncodingStream deadXdrStream = sendingXdr;
         sendingXdr = null;
         try
         {
             deadXdrStream.Close();
         }
         catch (System.IO.IOException)
         {
         }
         catch (org.acplt.oncrpc.OncRpcException)
         {
         }
     }
     if (receivingXdr != null)
     {
         org.acplt.oncrpc.XdrDecodingStream deadXdrStream = receivingXdr;
         receivingXdr = null;
         try
         {
             deadXdrStream.Close();
         }
         catch (System.IO.IOException)
         {
         }
         catch (org.acplt.oncrpc.OncRpcException)
         {
         }
     }
     if (parent != null)
     {
         parent.removeTransport(this);
         parent = null;
     }
 }
コード例 #5
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 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));
            }
        }
コード例 #6
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)
 {
     //
     // 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>
        /// 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));
            }
            }
        }
コード例 #8
0
 /// <summary>
 /// Decodes -- that is: deserializes -- the result from a PMAP_DUMP remote
 /// procedure call from a XDR stream.
 /// </summary>
 /// <remarks>
 /// Decodes -- that is: deserializes -- the result from a PMAP_DUMP remote
 /// procedure call 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)
 {
     //
     // Calling removeAllElements() instead of clear() preserves
     // pre-JDK2 compatibility.
     //
     servers.Clear();
     //
     // Pull the server ident object off the xdr stream. Each object is
     // preceeded by a boolean value indicating whether there is still an
     // object in the pipe.
     //
     while (xdr.xdrDecodeBoolean())
     {
         servers.Add(new org.acplt.oncrpc.OncRpcServerIdent(xdr));
     }
 }
コード例 #9
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);
        }
コード例 #10
0
 /// <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);
 }
コード例 #11
0
ファイル: OncRpcServerAuth.cs プロジェクト: SonnyX/NFS-Client
 /// <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 abstract void xdrDecodeCredVerf(org.acplt.oncrpc.XdrDecodingStream xdr);
コード例 #12
0
 /// <summary>
 /// Decodes -- that is: deserializes -- a XDR char from a XDR stream in
 /// compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Decodes -- that is: deserializes -- a XDR char 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)
 {
     value = (char)xdr.xdrDecodeByte();
 }
コード例 #13
0
ファイル: XdrVoid.cs プロジェクト: SonnyX/NFS-Client
 /// <summary>
 /// Decodes -- that is: deserializes -- a void from a XDR stream in
 /// compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Decodes -- that is: deserializes -- a void 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)
 {
 }
コード例 #14
0
 /// <summary>
 /// Constructs an <code>OncRpcServerAuthShort</code> object and pulls its
 /// state off an XDR stream.
 /// </summary>
 /// <remarks>
 /// Constructs an <code>OncRpcServerAuthShort</code> object and pulls its
 /// state off an XDR stream.
 /// </remarks>
 /// <param name="xdr">XDR stream to retrieve the object state from.</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 OncRpcServerAuthShort(org.acplt.oncrpc.XdrDecodingStream xdr)
 {
     xdrDecodeCredVerf(xdr);
 }
コード例 #15
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();
 }
コード例 #16
0
 /// <summary>
 /// Decodes -- that is: deserializes -- the variant part of an object from
 /// a XDR stream in compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Decodes -- that is: deserializes -- the variant part of an object from
 /// a XDR stream in compliance to RFC 1832. Note that the variant part is
 /// deserialized before the common part.
 /// </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 abstract void xdrDecodeVariant(org.acplt.oncrpc.XdrDecodingStream xdr);
コード例 #17
0
 /// <summary>
 /// Decodes -- that is: deserializes -- the common part of an object from
 /// a XDR stream in compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Decodes -- that is: deserializes -- the common part of an object from
 /// a XDR stream in compliance to RFC 1832. Note that the common part is
 /// deserialized after the variant part.
 /// </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 abstract void xdrDecodeCommon(org.acplt.oncrpc.XdrDecodingStream xdr);
コード例 #18
0
 /// <summary>
 /// Constructs an <code>OncRpcServerIdent</code> object and restores
 /// its state from the given XDR stream.
 /// </summary>
 /// <remarks>
 /// Constructs an <code>OncRpcServerIdent</code> object and restores
 /// its state from the given XDR stream.
 /// </remarks>
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 public OncRpcServerIdent(org.acplt.oncrpc.XdrDecodingStream xdr)
 {
     xdrDecode(xdr);
 }
コード例 #19
0
 /// <summary>
 /// Decodes -- that is: deserializes -- a XDR opaque from a XDR stream in
 /// compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Decodes -- that is: deserializes -- a XDR opaque 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)
 {
     xdr.xdrDecodeOpaque(value);
 }
コード例 #20
0
ファイル: OncRpcServerAuth.cs プロジェクト: SonnyX/NFS-Client
        /// <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);
        }
コード例 #21
0
        /// <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;
            }
            }
        }
コード例 #22
0
ファイル: XdrBytes.cs プロジェクト: wespday/RemoteTea.Net
 /// <summary>
 /// Decodes -- that is: deserializes -- a XDR bytes value from a XDR stream in
 /// compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Decodes -- that is: deserializes -- a XDR bytes value 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)
 {
     value = xdr.xdrDecodeByteVector();
 }
コード例 #23
0
ファイル: XdrDouble.cs プロジェクト: wespday/RemoteTea.Net
 /// <summary>
 /// Decodes -- that is: deserializes -- a XDR double from a XDR stream in
 /// compliance to RFC 1832.
 /// </summary>
 /// <remarks>
 /// Decodes -- that is: deserializes -- a XDR double 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)
 {
     value = xdr.xdrDecodeDouble();
 }
コード例 #24
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 abstract void xdrDecodeVerf(org.acplt.oncrpc.XdrDecodingStream xdr);