private Authenticator createAuthenticator() { UserList userList = new UserList(); User user = new User("111-1111", "password"); userList.add(user); Login login = new Login(console, userList); return new Authenticator(null, login); }
// Methods for the treatment of the different message types private void loginMessageTreatment() throws IncorrectMessageException { String content = message.getText().trim(); if (content != null && !content.contains("&")) { if (this.userList.getUserByNick(content) != null) { // The nick already exist (send 301) String response = new Integer(Message.ERROR_MESSAGE_EXISTING_NICK).toString(); sendDatagram( new User( null, messageToProcces.getAddress().getHostAddress(), this.messageToProcces.getPort()), response); // Comprobamos el nick pero, ¿Y si ya hay un usuario en esa IP??? } else { // Everything correct, send ACK User newUser = new User( content, this.messageToProcces.getAddress().getHostAddress(), this.messageToProcces.getPort()); userList.add(newUser); String response = new Integer(Message.SERVER_MESSAGE_CONNECTED).toString() + this.userList.toString(); sendDatagram(newUser, response); } } else { throw new IncorrectMessageException( "The Login message is not correct: '" + content.toString() + "'"); } }
public User setupUser(User user) { final User user2 = getUserByFullUserLogin(user.getFullUserLogin()); if (user2 == null) { mUserList.add(user); mContactList.add(user); service.sendRosterAdded(user); return user; } else { user2.setUserState(user.getUserState()); service.sendRosterUpdated(user2); return user2; } }
void transportCheck() { final UserList transportList = new UserList(); for (final User user : mUserList) { if (user.getTransportState() == User.TSTATE_IS_TRANSPORT) { transportList.add(user); } } for (final User user : mUserList) { if (!transportList.contains(user)) { for (final User transport : transportList) { user.transportCheck(transport); } } } }