code: protected Response register(Object principal, String password, Object extraData) throws Exception {
          Config config = configBean.getConfig();
  
          Object user = config.getAuthenticationDAO().getUserByPrincipal(session, config.getStoredProcedureProxyFactory(), principal);
          if (user == null) {
              String salt = generateRandomCode(config.getPasswordSaltLength());
              String hash = calculateHash(config, password, salt);
              config.getAuthenticationDAO().addNewUser(session, config.getStoredProcedureProxyFactory(), principal, hash, salt, extraData);
              return ok();
          } else {
              return handleUserAlreadyExists(principal);
          }
      }
docs: Base method for the register process. Should be called in JAX-RS method, which is API endpoint for register.
  <p/>
  Handles situations when user already exists, generates password salt, hash, writes new user
  into the storage using configured {@link AuthenticationDAO} implementation.
  
  @param principal Principal of user, which tries to register.
  @param password  Specified password.
  @param extraData Any object, which contains extra data for new registrant (e.g. name, phone number).
  This object will be consumed by {@link AuthenticationDAO} implementation.
  @return {@link Response} which should be passed to API user. Returns simple 200 OK response if
  registration succeeded, otherwise calls handleUserAlreadyExists() method.
  @throws Exception