public synchronized boolean requestAccount(RequestData data) throws JPlagException {
  if (data.getRealName() == null && data.getEmail() == null && data.getEmailSecond() == null && data.getHomepage() == null && data.getReason() == null && data.getNotes() == null) {
    if (data.getPassword() == null && data.getUsername() != null) {
      if (exists(data.getUsername()))       return false;
 else       return !requestAdmin.exists(data.getUsername());
    }
 else     if (data.getPassword() != null && data.getUsername() == null) {
      String username=requestAdmin.validateRequest(data.getPassword());
      RequestData rd=requestAdmin.getRequestData(username);
      NodeList userList=rootElement.getElementsByTagName("user");
      for (int i=0; i < userList.getLength(); i++) {
        Element elem=(Element)userList.item(i);
        if ((parseInt(elem,"state") & MASK_REQUESTNOTIFY) != 0) {
          sendMail(elem.getAttribute("email"),MailTemplateAdmin.SERVER_REQUESTNOTIFY,rd);
        }
      }
      return true;
    }
  }
  if (data.getUsername() == null || data.getPassword() == null || data.getRealName() == null || data.getEmail() == null || data.getReason() == null)   throw new JPlagException("requestAccount","Username, password, " + "real name, primary email or reason is missing!","Check your input!");
  if (!isValidUsername(data.getUsername()))   throw new JPlagException("requestAccount","Illegal new username!","The username may only consist of the " + "following characters: 'A'-'Z', 'a'-'z', " + "'0'-'9', '@' and '.'");
  if (exists(data.getUsername()) || requestAdmin.exists(data.getUsername()))   throw new JPlagException("requestAccount","Username already used!","Seems like somebody else was faster ;)");
  String vericode=requestAdmin.addRequest(data);
  sendMail(data.getEmail(),MailTemplateAdmin.SERVER_VERIFICATION,data,"code",vericode);
  return true;
}

public synchronized boolean requestAccount ( RequestData data ) throws JPlagException { if ( data . getRealName ( ) == null && data . getEmail ( ) == null && data . getEmailSecond ( ) == null && data . getHomepage ( ) == null && data . getReason ( ) == null && data . getNotes ( ) == null ) { if ( data . getPassword ( ) == null && data . getUsername ( ) != null ) { if ( exists ( data . getUsername ( ) ) ) return false ; else return ! requestAdmin . exists ( data . getUsername ( ) ) ; } else if ( data . getPassword ( ) != null && data . getUsername ( ) == null ) { String username = requestAdmin . validateRequest ( data . getPassword ( ) ) ; RequestData rd = requestAdmin . getRequestData ( username ) ; NodeList userList = rootElement . getElementsByTagName ( "user" ) ; for ( int i = 0 ; i < userList . getLength ( ) ; i ++ ) { Element elem = ( Element ) userList . item ( i ) ; if ( ( parseInt ( elem , "state" ) & MASK_REQUESTNOTIFY ) != 0 ) { sendMail ( elem . getAttribute ( "email" ) , MailTemplateAdmin . SERVER_REQUESTNOTIFY , rd ) ; } } return true ; } } if ( data . getUsername ( ) == null || data . getPassword ( ) == null || data . getRealName ( ) == null || data . getEmail ( ) == null || data . getReason ( ) == null ) throw new JPlagException ( "requestAccount" , "Username, password, " + "real name, primary email or reason is missing!" , "Check your input!" ) ; if ( ! isValidUsername ( data . getUsername ( ) ) ) throw new JPlagException ( "requestAccount" , "Illegal new username!" , "The username may only consist of the " + "following characters: 'A'-'Z', 'a'-'z', " + "'0'-'9', '@' and '.'" ) ; if ( exists ( data . getUsername ( ) ) || requestAdmin . exists ( data . getUsername ( ) ) ) throw new JPlagException ( "requestAccount" , "Username already used!" , "Seems like somebody else was faster ;)" ) ; String vericode = requestAdmin . addRequest ( data ) ; sendMail ( data . getEmail ( ) , MailTemplateAdmin . SERVER_VERIFICATION , data , "code" , vericode ) ; return true ; }
called by the server page . - if everything but username is null , it returns , whether the username is ok ( true ) or it is already used ( false ) . - if everything but password is null and password is the email validation code sent to the user , the request becomes available to the admintool and an email is sent to the administrator , if the code is wrong , false is returned . - if username , password , realname , email and reason is not null , it saves the data and sends a validation email to the user . - otherwise an exception is thrown .
