Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<Byte> two = new ArrayList<Byte>();
- List<Byte> user = new ArrayList<Byte>();
- List<Byte> pass = new ArrayList<Byte>();
- two.add(Byte.MIN_VALUE);
- two.add(Byte.MIN_VALUE);
- while (!(two.get(0)==13&&two.get(1)==10)) {
- byte cc = inFromClient.readByte();
- two.add(cc);
- user.add(cc);
- if(two.size()>2){two.remove(0);}
- //writeDown += new String(new byte[]{cc}, "US-ASCII");
- }
- //this.userName = writeDown.substring(0, writeDown.length() - 2);
- System.out.println("Received: " + c.getRemoteSocketAddress().toString() + ":" + writeDown);
- outToClient.writeBytes("201 PASSWORD\r\n");
- //writeDown = "";
- two.clear();
- two.add(Byte.MIN_VALUE);
- two.add(Byte.MIN_VALUE);
- while (!(two.get(0)==13&&two.get(1)==10)) {
- byte cc = inFromClient.readByte();
- two.add(cc);
- pass.add(cc);
- if(two.size()>2){two.remove(0);}
- //writeDown += new String(new byte[]{cc}, "US-ASCII");
- }
- //this.password = writeDown.substring(0, writeDown.length() - 2);
- System.out.println("Received: " + c.getRemoteSocketAddress().toString() + ":" + writeDown);
- byte[] robot = {user.get(0),user.get(1),user.get(2),user.get(3),user.get(4)};
- String robotStr =new String(robot);
- if (!"Robot".equals(robotStr)) {
- outToClient.writeBytes("500 LOGIN FAILED\r\n");
- c.close();
- return;
- }
- Integer passwordAsItMustBe = 0;
- byte[] unb = this.userName.getBytes("US-ASCII");
- for (byte b : user) {
- passwordAsItMustBe += b;
- }
- if (!pass.equals(passwordAsItMustBe.toString())) {
- outToClient.writeBytes("500 LOGIN FAILED\r\n");
- c.close();
- return;
- }
- outToClient.writeBytes("202 OK\r\n");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement