/// <summary> /// Issues a request to the Signon host server to authenticate the specified user and password. /// /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void authenticate(String user, String password) throws IOException public virtual void authenticate(string user, string password) { if (Closed) { throw new IOException("Connection closed"); } object[] ret = getInfo(true, Info.System, out_, in_); sbyte[] clientSeed = (sbyte[])ret[1]; sbyte[] serverSeed = (sbyte[])ret[2]; sbyte[] userBytes = getUserBytes(user, Info.PasswordLevel); sbyte[] passwordBytes = getPasswordBytes(password, Info.PasswordLevel); password = null; sbyte[] encryptedPassword = getEncryptedPassword(userBytes, passwordBytes, clientSeed, serverSeed, Info.PasswordLevel); // Authenticate. sbyte[] userEBCDICBytes = (Info.PasswordLevel < 2) ? userBytes : getUserBytes(user, 0); sendSignonInfoRequest(out_, Info, userEBCDICBytes, encryptedPassword); out_.flush(); int length = in_.readInt(); if (length < 20) { throw DataStreamException.badLength("signonInfo", length); } in_.skipBytes(16); int rc = in_.readInt(); int numRead = 24; try { if (rc != 0) { string message = "Bad return code from signon info: 0x" + rc.ToString("x"); switch (rc) { case 0x20001: message = "User ID is not known."; break; case 0x3000B: message = "Password is incorrect."; break; } throw new IOException(message); } else { int serverCCSID = 0; bool foundServerCCSID = false; while (numRead < length && !foundServerCCSID) { int ll = in_.readInt(); int cp = in_.readShort(); int currentRead = 0; switch (cp) { case 0x1114: serverCCSID = in_.readInt(); currentRead = 4; foundServerCCSID = true; break; } in_.skipBytes(ll - 6 - currentRead); numRead += ll; } if (foundServerCCSID) { Info.ServerCCSID = serverCCSID; } } } finally { in_.skipBytes(length - numRead); in_.end(); } }
//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: 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); }