private void receiveServerIdent() throws IOException { final Buffer.PlainBuffer buf = new Buffer.PlainBuffer(); while ((serverID = readIdentification(buf)).isEmpty()) { int b = connInfo.in.read(); if (b == -1) { log.error("Received end of connection, but no identification received. "); throw new TransportException("Server closed connection during identification exchange"); } buf.putByte((byte) b); } }
@Test public void testDataTypes() throws Buffer.BufferException { // bool assertEquals(handyBuf.putBoolean(true).readBoolean(), true); // byte assertEquals(handyBuf.putByte((byte) 10).readByte(), (byte) 10); // byte array assertArrayEquals(handyBuf.putBytes("some string".getBytes()).readBytes(), "some string".getBytes()); // mpint BigInteger bi = new BigInteger("1111111111111111111111111111111"); assertEquals(handyBuf.putMPInt(bi).readMPInt(), bi); // string assertEquals(handyBuf.putString("some string").readString(), "some string"); // uint32 assertEquals(handyBuf.putUInt32(0xffffffffL).readUInt32(), 0xffffffffL); }
.putMPInt(kex.getK()) .putRawBytes(H) .putByte((byte) 0) // <placeholder> .putRawBytes(sessionID); final int pos = hashInput.available() - sessionID.length - 1; // Position of <placeholder>
.putMPInt(kex.getK()) .putRawBytes(H) .putByte((byte) 0) // <placeholder> .putRawBytes(sessionID); final int pos = hashInput.available() - sessionID.length - 1; // Position of <placeholder>
public String parseIdentificationString() throws IOException { for (;;) { Buffer.PlainBuffer lineBuffer = new Buffer.PlainBuffer(); int lineStartPos = buffer.rpos(); for (;;) { if (buffer.available() == 0) { buffer.rpos(lineStartPos); return ""; } byte b = buffer.readByte(); lineBuffer.putByte(b); if (b == '\n') { if (checkForIdentification(lineBuffer)) { return readIdentification(lineBuffer); } else { logHeaderLine(lineBuffer); } break; } } } }
@Override public void init(String remoteHost, int remotePort, InputStream in, OutputStream out) throws TransportException { connInfo = new ConnInfo(remoteHost, remotePort, in, out); try { log.info("Client identity string: {}", clientID); connInfo.out.write((clientID + "\r\n").getBytes(IOUtils.UTF8)); connInfo.out.flush(); // Read server's ID final Buffer.PlainBuffer buf = new Buffer.PlainBuffer(); while ((serverID = readIdentification(buf)).isEmpty()) { buf.putByte((byte) connInfo.in.read()); } log.info("Server identity string: {}", serverID); } catch (IOException e) { throw new TransportException(e); } reader.start(); }
private byte[] generateMIC() throws UserAuthException { byte[] msg = new PlainBuffer().putString(params.getTransport().getSessionID()) .putByte(Message.USERAUTH_REQUEST.toByte()) .putString(params.getUsername()) .putString(params.getNextServiceName()) .putString(getName()) .getCompactData(); try { return secContext.getMIC(msg, 0, msg.length, null); } catch (GSSException e) { throw new UserAuthException("Exception getting message integrity code", e); } }
private void receiveServerIdent() throws IOException { final Buffer.PlainBuffer buf = new Buffer.PlainBuffer(); while ((serverID = readIdentification(buf)).isEmpty()) { int b = connInfo.in.read(); if (b == -1) { log.error("Received end of connection, but no identification received. "); throw new TransportException("Server closed connection during identification exchange"); } buf.putByte((byte) b); } }
.putMPInt(kex.getK()) .putRawBytes(H) .putByte((byte) 0) // <placeholder> .putRawBytes(sessionID); final int pos = hashInput.available() - sessionID.length - 1; // Position of <placeholder>
public String parseIdentificationString() throws IOException { for (;;) { Buffer.PlainBuffer lineBuffer = new Buffer.PlainBuffer(); int lineStartPos = buffer.rpos(); for (;;) { if (buffer.available() == 0) { buffer.rpos(lineStartPos); return ""; } byte b = buffer.readByte(); lineBuffer.putByte(b); if (b == '\n') { if (checkForIdentification(lineBuffer)) { return readIdentification(lineBuffer); } else { logHeaderLine(lineBuffer); } break; } } } }
private byte[] generateMIC() throws UserAuthException { byte[] msg = new PlainBuffer().putString(params.getTransport().getSessionID()) .putByte(Message.USERAUTH_REQUEST.toByte()) .putString(params.getUsername()) .putString(params.getNextServiceName()) .putString(getName()) .getCompactData(); try { return secContext.getMIC(msg, 0, msg.length, null); } catch (GSSException e) { throw new UserAuthException("Exception getting message integrity code", e); } }