Exemplo n.º 1
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;
        }
Exemplo n.º 2
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);
        }