protected internal HostServerConnection(SystemInfo info, string user, string jobName, Socket socket, HostInputStream @in, HostOutputStream @out)
 {
     info_    = info;
     user_    = user;
     jobName_ = jobName;
     socket_  = socket;
     in_      = @in;
     out_     = @out;
 }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static long convertDate(HostInputStream in) throws IOException
        private static long convertDate(HostInputStream @in)
        {
            // The IFS format is 32-bit seconds, 32-bit milliseconds.
            int  seconds      = @in.readInt();
            int  microseconds = @in.readInt();
            long milliseconds = (seconds * 1000L) + (microseconds / 1000);

            return(milliseconds);
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static FileConnection getConnection(final boolean isSSL, SystemInfo info, String user, String password, int filePort) throws IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        public static FileConnection getConnection(bool isSSL, SystemInfo info, string user, string password, int filePort)
        {
            if (filePort < 0 || filePort > 65535)
            {
                throw new IOException("Bad file port: " + filePort);
            }
            FileConnection conn = null;

            Socket fileServer = isSSL? SSLSocketFactory.Default.createSocket(info.System, filePort) : new Socket(info.System, filePort);
            Stream @in        = fileServer.InputStream;
            Stream @out       = fileServer.OutputStream;

            try
            {
                HostOutputStream dout    = new HostOutputStream(new BufferedOutputStream(@out));
                HostInputStream  din     = new HostInputStream(new BufferedInputStream(@in));
                string           jobName = connect(info, dout, din, 0xE002, user, password);

                sendExchangeAttributesRequest(dout);
                dout.flush();

                int length = din.readInt();
                if (length < 22)
                {
                    throw DataStreamException.badLength("fileExchangeAttributes", length);
                }
                din.skipBytes(16);
                int rc = din.readShort();
                if (rc != 0)
                {
                    throw DataStreamException.badReturnCode("fileExchangeAttributes", rc);
                }
                int datastreamLevel = din.readShort();
                din.skipBytes(2);
                int maxDataBlockSize = din.readInt();
                //int ccsidLL = din.readInt();
                //int ccsidCP = din.readShort();
                din.skipBytes(6);
                int ccsid     = din.readShort();
                int remaining = length - 38;
                din.skipBytes(remaining);

                conn = new FileConnection(info, fileServer, din, dout, ccsid, datastreamLevel, maxDataBlockSize, user, jobName);
                return(conn);
            }
            finally
            {
                if (conn == null)
                {
                    @in.Close();
                    @out.Close();
                    fileServer.close();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Connects to the Signon host server on the specified port and authenticates the specified user.
        ///
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static SignonConnection getConnection(final boolean isSSL, String system, String user, String password, int signonPort) throws IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        public static SignonConnection getConnection(bool isSSL, string system, string user, string password, int signonPort)
        {
            if (signonPort > 0 && signonPort < 65536)
            {
                Socket           signonServer = isSSL? SSLSocketFactory.Default.createSocket(system, signonPort) : new Socket(system, signonPort);
                Stream           @in          = signonServer.InputStream;
                Stream           @out         = signonServer.OutputStream;
                HostOutputStream dout         = new HostOutputStream(new BufferedOutputStream(@out));
                HostInputStream  din          = new HostInputStream(new BufferedInputStream(@in));

                SystemInfo       info = (SystemInfo)getInfo(false, system, dout, din)[0];
                SignonConnection conn = new SignonConnection(info, signonServer, din, dout, user);
                conn.authenticate(user, password);
                return(conn);
            }
            else
            {
                throw new IOException("Bad port number: " + signonPort);
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected static String connect(SystemInfo info, HostOutputStream dout, HostInputStream din, int serverID, String user, String password) throws IOException
        protected internal static string connect(SystemInfo info, HostOutputStream dout, HostInputStream din, int serverID, string user, string password)
        {
            // Exchange random seeds.
            long seed = sendExchangeRandomSeedsRequest(dout, serverID);

            sbyte[] clientSeed = Conv.longToByteArray(seed);
            dout.flush();

            int length = din.readInt();

            if (length < 20)
            {
                throw DataStreamException.badLength("exchangeRandomSeeds-" + serverID, length);
            }
            din.skipBytes(16);
            int rc = din.readInt();

            if (rc != 0)
            {
                throw DataStreamException.badReturnCode("exchangeRandomSeeds-" + serverID, rc);
            }
            sbyte[] serverSeed = new sbyte[8];
            din.readFully(serverSeed);

            sbyte[] userBytes     = getUserBytes(user, info.PasswordLevel);
            sbyte[] passwordBytes = getPasswordBytes(password, info.PasswordLevel);
            password = null;
            sbyte[] encryptedPassword = getEncryptedPassword(userBytes, passwordBytes, clientSeed, serverSeed, info.PasswordLevel);

            din.end();

            sbyte[] userEBCDICBytes = (info.PasswordLevel < 2) ? userBytes : getUserBytes(user, 0);
            sendStartServerRequest(dout, userEBCDICBytes, encryptedPassword, serverID);
            dout.flush();

            length = din.readInt();
            if (length < 20)
            {
                throw DataStreamException.badLength("startServer-" + serverID, length);
            }
            din.skipBytes(16);
            rc = din.readInt();
            if (rc != 0)
            {
                string msg = getReturnCodeMessage(rc);
                throw string.ReferenceEquals(msg, null) ? DataStreamException.badReturnCode("startServer-" + serverID, rc) : DataStreamException.errorMessage("startServer-" + serverID, new Message(rc.ToString(), msg));
            }
            string jobName   = null;
            int    remaining = length - 24;

            while (remaining > 10)
            {
                int ll = din.readInt();
                int cp = din.readShort();
                remaining -= 6;
                if (cp == 0x111F)                 // Job name.
                {
                    din.skipBytes(4);             // CCSID is always 0.
                    remaining -= 4;
                    int     jobLength = ll - 10;
                    sbyte[] jobBytes  = new sbyte[jobLength];
                    din.readFully(jobBytes);
                    jobName    = Conv.ebcdicByteArrayToString(jobBytes, 0, jobLength);
                    remaining -= jobLength;
                }
                else
                {
                    din.skipBytes(ll - 6);
                    remaining -= (ll - 6);
                }
            }
            din.skipBytes(remaining);
            din.end();
            return(jobName);
        }
Exemplo n.º 6
0
 private FileConnection(SystemInfo info, Socket socket, HostInputStream @in, HostOutputStream @out, int ccsid, int datastreamLevel, int maxDataBlockSize, string user, string jobName) : base(info, user, jobName, socket, @in, @out)
 {
     ccsid_            = ccsid;
     datastreamLevel_  = datastreamLevel;
     maxDataBlockSize_ = maxDataBlockSize;
 }
Exemplo n.º 7
0
 private SignonConnection(SystemInfo info, Socket socket, HostInputStream @in, HostOutputStream @out, string user) : base(info, user, info.SignonJobName, socket, @in, @out)
 {
 }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static Object[] getInfo(boolean doSeeds, String system, HostOutputStream out, HostInputStream in) throws IOException
        private static object[] getInfo(bool doSeeds, string system, HostOutputStream @out, HostInputStream @in)
        {
            object[] ret = new object[3];
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long clientSeedLong = sendSignonExchangeAttributeRequest(out);
            long clientSeedLong = sendSignonExchangeAttributeRequest(@out);

            if (doSeeds)
            {
                sbyte[] clientSeed = Conv.longToByteArray(clientSeedLong);
                ret[1] = clientSeed;
            }
            @out.flush();

            int length = @in.readInt();

            if (length < 20)
            {
                throw DataStreamException.badLength("signonExchangeAttributes", length);
            }
            @in.skipBytes(16);
            int rc = @in.readInt();

            if (rc != 0)
            {
                @in.skipBytes(length - 24);
                throw DataStreamException.badReturnCode("signonExchangeAttributes", rc);
            }
            int    curLength          = 24;
            int    serverVersion      = -1;
            bool   foundServerVersion = false;
            int    serverLevel        = -1;
            bool   foundServerLevel   = false;
            bool   foundServerSeed    = false;
            int    passwordLevel      = -1;
            bool   foundPasswordLevel = false;
            string jobName            = null;

            //        while (curLength < length && !foundServerSeed && !foundPasswordLevel && !foundJobName)
            while (curLength < length && (!foundServerVersion || !foundServerLevel || !foundPasswordLevel || (!doSeeds || (doSeeds && !foundServerSeed))))
            {
                int oldLength = curLength;
                int ll        = @in.readInt();
                int cp        = @in.readShort();
                curLength += 6;
                switch (cp)
                {
                case 0x1101:
                    serverVersion      = @in.readInt();
                    curLength         += 4;
                    foundServerVersion = true;
                    break;

                case 0x1102:
                    serverLevel      = @in.readShort();
                    curLength       += 2;
                    foundServerLevel = true;
                    break;

                case 0x1103:
                    if (doSeeds)
                    {
                        sbyte[] serverSeed = new sbyte[ll - 6];
                        @in.readFully(serverSeed);
                        ret[2]          = serverSeed;
                        curLength      += ll - 6;
                        foundServerSeed = true;
                    }
                    else
                    {
                        @in.skipBytes(ll - 6);
                        curLength += ll - 6;
                    }
                    break;

                case 0x1119:
                    passwordLevel      = @in.read();
                    curLength         += 1;
                    foundPasswordLevel = true;
                    break;

                case 0x111F:
                    @in.skipBytes(4);       // CCSID is always 0.
                    curLength += 4;
                    sbyte[] jobBytes = new sbyte[ll - 10];
                    @in.readFully(jobBytes);
                    jobName    = Conv.ebcdicByteArrayToString(jobBytes, 0, jobBytes.Length);
                    curLength += ll - 10;
                    break;

                default:
                    @in.skipBytes(ll - 6);
                    curLength += ll - 6;
                    break;
                }
                int diff = ll - (curLength - oldLength);
                if (diff > 0)
                {
                    @in.skipBytes(diff);
                }
            }
            @in.skipBytes(length - curLength);
            @in.end();

            ret[0] = new SystemInfo(system, serverVersion, serverLevel, passwordLevel, jobName);
            return(ret);
        }
Exemplo n.º 9
0
 private CommandConnection(SystemInfo info, Socket socket, HostInputStream @in, HostOutputStream @out, int ccsid, int datastreamLevel, string user, string jobName, string NLV) : base(info, user, jobName, socket, @in, @out)
 {
     ccsid_           = ccsid;
     datastreamLevel_ = datastreamLevel;
     NLV_             = NLV;
 }
Exemplo n.º 10
0
        /// <summary>
        /// Connects to the Remote Command host server on the specified port using the specified system information and user.
        ///
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static CommandConnection getConnection(final boolean isSSL, SystemInfo info, String user, String password, int commandPort, boolean compress) throws IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        public static CommandConnection getConnection(bool isSSL, SystemInfo info, string user, string password, int commandPort, bool compress)
        {
            if (commandPort < 0 || commandPort > 65535)
            {
                throw new IOException("Bad command port: " + commandPort);
            }
            CommandConnection conn = null;

            Socket commandServer = isSSL? SSLSocketFactory.Default.createSocket(info.System, commandPort) : new Socket(info.System, commandPort);
            Stream @in           = commandServer.InputStream;
            Stream @out          = commandServer.OutputStream;

            try
            {
                if (compress)
                {
                    throw new IOException("Experimental compression streams not enabled.");
                    //        in = new CompressionInputStream(in);
                    //        out = new CompressionOutputStream(new BufferedOutputStream(out));
                }

                // Exchange random seeds.
                HostOutputStream dout    = new HostOutputStream(compress ? @out : new BufferedOutputStream(@out));
                HostInputStream  din     = new HostInputStream(new BufferedInputStream(@in));
                string           jobName = connect(info, dout, din, 0xE008, user, password);

                string NLV = Conv.DefaultNLV;
                sendExchangeAttributesRequest(dout, NLV);
                dout.flush();

                int length = din.readInt();
                if (length < 20)
                {
                    throw DataStreamException.badLength("commandExchangeAttributes", length);
                }
                din.skipBytes(16);
                int rc = din.readShort();
                // We ignore the same return codes that JTOPEN ignores
                if (rc != 0x0100 && rc != 0x0104 && rc != 0x0105 && rc != 0x0106 && rc != 0x0107 && rc != 0x0108 && rc != 0)
                {
                    throw DataStreamException.badReturnCode("commandExchangeAttributes", rc);
                }
                int     ccsid    = din.readInt();
                sbyte[] nlvBytes = new sbyte[4];
                nlvBytes[0] = (sbyte)din.readByte();
                nlvBytes[1] = (sbyte)din.readByte();
                nlvBytes[2] = (sbyte)din.readByte();
                nlvBytes[3] = (sbyte)din.readByte();
                NLV         = Conv.ebcdicByteArrayToString(nlvBytes, 0, 4);
                // Server version
                din.skipBytes(4);

                int datastreamLevel = din.readShort();
                din.skipBytes(length - 36);
                din.end();

                conn = new CommandConnection(info, commandServer, din, dout, ccsid, datastreamLevel, user, jobName, NLV);
                return(conn);
            }
            finally
            {
                if (conn == null)
                {
                    @in.Close();
                    @out.Close();
                    commandServer.close();
                }
            }
        }