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;
 }
Esempio n. 2
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();
                }
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: static long sendExchangeRandomSeedsRequest(HostOutputStream out, int serverID) throws IOException
        internal static long sendExchangeRandomSeedsRequest(HostOutputStream @out, int serverID)
        {
            @out.writeInt(28);            // Length.
            @out.writeByte(1);            // Client attributes, 1 means capable of SHA-1.
            @out.writeByte(0);            // Server attributes.
            @out.writeShort(serverID);    // Server ID.
            @out.writeInt(0);             // CS instance.
            @out.writeInt(0);             // Correlation ID.
            @out.writeShort(8);           // Template length.
            @out.writeShort(0x7001);      // ReqRep ID.
            long clientSeed = DateTimeHelper.CurrentUnixTimeMillis();

            @out.writeLong(clientSeed);
            return(clientSeed);
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void sendDeleteFileRequest(HostOutputStream out, byte[] filenameUnicode) throws IOException
        private void sendDeleteFileRequest(HostOutputStream @out, sbyte[] filenameUnicode)
        {
            @out.writeInt(34 + filenameUnicode.Length); // Length.
            @out.writeShort(0);                         // Header ID.
            @out.writeShort(0xE002);                    // Server ID.
            @out.writeInt(0);                           // CS instance.
            @out.writeInt(newCorrelationID());          // Correlation ID.
            @out.writeShort(8);                         // Template length.
            @out.writeShort(0x000C);                    // ReqRep ID.
            @out.writeShort(0);                         // Chain indicator.
            @out.writeShort(1200);                      // CCSID.
            @out.writeInt(1);                           // Working dir handle.
            @out.writeInt(filenameUnicode.Length + 6);  // Filename LL.
            @out.writeShort(2);                         // Filename CP.
            @out.write(filenameUnicode);
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static void sendExchangeAttributesRequest(HostOutputStream out, String NLV) throws IOException
        private static void sendExchangeAttributesRequest(HostOutputStream @out, string NLV)
        {
            @out.writeInt(34);       // Length.
            @out.writeShort(0);      // Header ID.
            @out.writeShort(0xE008); // Server ID.
            @out.writeInt(0);        // CS instance.
            @out.writeInt(0);        // Correlation ID.
            @out.writeShort(14);     // Template length.
            @out.writeShort(0x1001); // ReqRep ID.
            @out.writeInt(1200);     // CCSID.
            // out.write("2924".getBytes("Cp037")); // NLV.
            sbyte[] NLVbytes = Conv.stringToEBCDICByteArray37(NLV);
            @out.write(NLVbytes);
            @out.writeInt(1);     // Client version.
            @out.writeShort(0);   // Client datastream level.
        }
Esempio n. 6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static void sendExchangeAttributesRequest(HostOutputStream out) throws IOException
        private static void sendExchangeAttributesRequest(HostOutputStream @out)
        {
            @out.writeInt(42);                          // Length.
            @out.writeShort(0);                         // Header ID.
            @out.writeShort(0xE002);                    // Server ID.
            @out.writeInt(0);                           // CS instance.
            @out.writeInt(0);                           // Correlation ID.
            @out.writeShort(10);                        // Template length.
            @out.writeShort(0x0016);                    // ReqRep ID.
            @out.writeShort(0);                         // Chain indicator.
            @out.writeShort(8);                         // Datastream level. V5R3 or higher.
            @out.writeShort(6);                         // Don't use posix return codes (8), use GMT (4), use PC pattern match (2).
            @out.writeInt(unchecked ((int)0xFFFFFFFF)); // Max data block.
            @out.writeInt(12);                          // CCSID LL.
            @out.writeShort(10);                        // CCSID CP.
            @out.writeShort(1200);                      // Preferred CCSID UTF-16.
            @out.writeShort(13488);                     // Preferred CCSID UnicodeBig.
            @out.writeShort(61952);                     // Preferred CCSID old IFS UnicodeBig.
        }
Esempio n. 7
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: static void sendStartServerRequest(HostOutputStream out, byte[] userBytes, byte[] encryptedPassword, int serverID) throws IOException
        internal static void sendStartServerRequest(HostOutputStream @out, sbyte[] userBytes, sbyte[] encryptedPassword, int serverID)
        {
            @out.writeInt(44 + encryptedPassword.Length);
            @out.writeByte(2);                                     // Client attributes, 2 means return job info.
            @out.writeByte(0);                                     // Server attribute.
            @out.writeShort(serverID);                             // Server ID.
            @out.writeInt(0);                                      // CS instance.
            @out.writeInt(0);                                      // Correlation ID.
            @out.writeShort(2);                                    // Template length.
            @out.writeShort(0x7002);                               // ReqRep ID.
            @out.writeByte(encryptedPassword.Length == 8 ? 1 : 3); // Password
            // encryption
            // type.
            @out.writeByte(1);                           // Send reply.
            @out.writeInt(6 + encryptedPassword.Length); // Password LL.
            @out.writeShort(0x1105);                     // Password CP. 0x1115 is other.
            @out.write(encryptedPassword);
            @out.writeInt(16);                           // User ID LL.
            @out.writeShort(0x1104);                     // User ID CP.
            @out.write(userBytes);
        }
Esempio n. 9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static long sendSignonExchangeAttributeRequest(HostOutputStream out) throws IOException
        private static long sendSignonExchangeAttributeRequest(HostOutputStream @out)
        {
            @out.writeInt(52);       // Length;
            @out.writeShort(0);      // Header ID (almost always zero for all datastreams).
            @out.writeShort(0xE009); // Server ID.
            @out.writeInt(0);        // CS instance.
            @out.writeInt(0);        // Correlation ID.
            @out.writeShort(0);      // Template length.
            @out.writeShort(0x7003); // ReqRep ID.
            @out.writeInt(10);       // Client version LL.
            @out.writeShort(0x1101); // Client version CP.
            @out.writeInt(1);        // Client version.
            @out.writeInt(8);        // Client datastream level LL.
            @out.writeShort(0x1102); // Client datastream level CP.
            @out.writeShort(2);      // Client datastream level.
            @out.writeInt(14);       // Client seed LL.
            @out.writeShort(0x1103); // Client seed CP.
            long clientSeed = DateTimeHelper.CurrentUnixTimeMillis();

            @out.writeLong(clientSeed);     // Client seed.
            return(clientSeed);
        }
Esempio n. 10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static void sendRunCommandRequest(HostOutputStream out, String cmd, int datastreamLevel) throws IOException
        private static void sendRunCommandRequest(HostOutputStream @out, string cmd, int datastreamLevel)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final boolean newerServer = datastreamLevel >= 10;
            bool newerServer = datastreamLevel >= 10;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final byte[] commandBytes = newerServer ? Conv.stringToUnicodeByteArray(cmd) : Conv.stringToEBCDICByteArray37(cmd);
            sbyte[] commandBytes = newerServer ? Conv.stringToUnicodeByteArray(cmd) : Conv.stringToEBCDICByteArray37(cmd);
            @out.writeInt(newerServer ? 31 + commandBytes.Length : 27 + commandBytes.Length); // Length.
            @out.writeShort(0);                                                               // Header ID.
            @out.writeShort(0xE008);                                                          // Server ID.
            @out.writeInt(0);                                                                 // CS instance.
            @out.writeInt(0);                                                                 // Correlation ID.
            @out.writeShort(1);                                                               // Template length.
            @out.writeShort(0x1002);                                                          // ReqRep ID.

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int messageOption = newerServer ? 4 : (datastreamLevel < 7 ? 0 : 2);
            int messageOption = newerServer ? 4 : (datastreamLevel < 7 ? 0 : 2);     // Always return all messages when possible.

            @out.writeByte(messageOption);

            if (newerServer)
            {
                @out.writeInt(10 + commandBytes.Length); // Command LL.
                @out.writeShort(0x1104);                 // Command CP.
                @out.writeInt(1200);                     // Command CCSID.
                @out.write(commandBytes);
            }
            else
            {
                @out.writeInt(6 + commandBytes.Length); // Command LL.
                @out.writeShort(0x1101);                // Command CP.
                @out.write(commandBytes);
            }
        }
Esempio n. 11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static void sendSignonInfoRequest(HostOutputStream out, SystemInfo info, byte[] userBytes, byte[] encryptedPassword) throws IOException
        private static void sendSignonInfoRequest(HostOutputStream @out, SystemInfo info, sbyte[] userBytes, sbyte[] encryptedPassword)
        {
            int total = 37 + encryptedPassword.Length + 16;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final boolean newerServer = info.getServerLevel() >= 5;
            bool newerServer = info.ServerLevel >= 5;

            if (newerServer)
            {
                total += 7;
            }

            @out.writeInt(total);                                  // Length.
            @out.writeShort(0);                                    // Header ID (almost always zero for all datastreams).
            @out.writeShort(0xE009);                               // Server ID.
            @out.writeInt(0);                                      // CS instance.
            @out.writeInt(0);                                      // Correlation ID.
            @out.writeShort(0x0001);                               // Template length.
            @out.writeShort(0x7004);                               // ReqRep ID.
            @out.writeByte(encryptedPassword.Length == 8 ? 1 : 3); // Password encryption type.
            @out.writeInt(10);                                     // Client CCSID LL.
            @out.writeShort(0x1113);                               // Client CCSID CP.
            @out.writeInt(1200);                                   // Client CCSID (big endian UTF-16).
            @out.writeInt(6 + encryptedPassword.Length);           // Password LL.
            @out.writeShort(0x1105);                               // Password CP. 0x1115 is other.
            @out.write(encryptedPassword);                         // Password.
            @out.writeInt(16);                                     // User ID LL.
            @out.writeShort(0x1104);                               // User ID CP.
            @out.write(userBytes);                                 // User ID.
            if (newerServer)
            {
                @out.writeInt(7);        // Return error messages LL.
                @out.writeShort(0x1128); // Return error messages CP.
                @out.writeByte(1);       // Return error messages.
            }
        }
Esempio n. 12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private static void sendCallProgramRequest(HostOutputStream out, String pgmLibrary, String pgmName, Parameter[] parms, int datastreamLevel) throws IOException
        private static void sendCallProgramRequest(HostOutputStream @out, string pgmLibrary, string pgmName, Parameter[] parms, int datastreamLevel)
        {
            int length = 43;

            for (int i = 0; i < parms.Length; ++i)
            {
                length += 12 + parms[i].InputLength;
            }

            @out.writeInt(length);   // Length;
            @out.writeShort(0);      // Header ID.
            @out.writeShort(0xE008); // Server ID.
            @out.writeInt(0);        // CS instance.
            @out.writeInt(0);        // Correlation ID.
            @out.writeShort(23);     // Template length.
            @out.writeShort(0x1003); // ReqRep ID.

            //    byte[] programBytes = Util.blankPadEBCDIC10(pgmName);
            //    out.write(programBytes, 0, 10);
            writePadEBCDIC10(pgmName, @out);
            //    byte[] libraryBytes = Util.blankPadEBCDIC10(pgmLibrary);
            //    out.write(libraryBytes, 0, 10);
            writePadEBCDIC10(pgmLibrary, @out);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final boolean newerServer = datastreamLevel >= 10;
            bool newerServer = datastreamLevel >= 10;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int messageOption = newerServer ? 4 : (datastreamLevel < 7 ? 0 : 2);
            int messageOption = newerServer ? 4 : (datastreamLevel < 7 ? 0 : 2);     // Always return all messages when possible.

            @out.writeByte(messageOption);

            @out.writeShort(parms.Length);     // Number of parameters.
            for (int i = 0; i < parms.Length; ++i)
            {
                @out.writeInt(12 + parms[i].InputLength); // Parameter LL.
                @out.writeShort(0x1103);                  // Parameter CP.
                @out.writeInt(parms[i].MaxLength);        // Either the input length or output length, whichever is larger.
                switch (parms[i].Type)
                {
                case Parameter.TYPE_NULL:
                    if (datastreamLevel < 6)
                    {
                        // Nulls not allowed.
                        @out.writeShort(1);         // Treat as input.
                    }
                    else
                    {
                        @out.writeShort(255);
                    }
                    break;

                case Parameter.TYPE_INPUT:
                    @out.writeShort(11);
                    @out.write(parms[i].InputData, 0, parms[i].InputLength);
                    break;

                case Parameter.TYPE_OUTPUT:
                    @out.writeShort(12);
                    break;

                case Parameter.TYPE_INPUT_OUTPUT:
                    @out.writeShort(13);
                    @out.write(parms[i].InputData, 0, parms[i].InputLength);
                    break;
                }
            }
        }
//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);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected static void writeStringToUnicodeBytes(String s, HostOutputStream out) throws IOException
        protected internal static void writeStringToUnicodeBytes(string s, HostOutputStream @out)
        {
            Conv.writeStringToUnicodeBytes(s, @out);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected static void writePadEBCDIC(String s, int len, HostOutputStream out) throws IOException
        protected internal static void writePadEBCDIC(string s, int len, HostOutputStream @out)
        {
            Conv.writePadEBCDIC(s, len, @out);
        }
Esempio n. 16
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;
 }
Esempio n. 17
0
 private SignonConnection(SystemInfo info, Socket socket, HostInputStream @in, HostOutputStream @out, string user) : base(info, user, info.SignonJobName, socket, @in, @out)
 {
 }
Esempio n. 18
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);
        }
Esempio n. 19
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();
                }
            }
        }
Esempio n. 20
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;
 }