Ejemplo n.º 1
0
  protected IUserService createUserService(File realmFile) {
    IUserService service = null;
    if (realmFile.getName().toLowerCase().endsWith(".conf")) {
      // config-based realm file
      service = new ConfigUserService(realmFile);
    }

    assert service != null;

    if (!realmFile.exists()) {
      // Create the Administrator account for a new realm file
      try {
        realmFile.createNewFile();
      } catch (IOException x) {
        logger.error(MessageFormat.format("COULD NOT CREATE REALM FILE {0}!", realmFile), x);
      }
      UserModel admin = new UserModel("admin");
      admin.password = "******";
      admin.canAdmin = true;
      admin.excludeFromFederation = true;
      service.updateUserModel(admin);
    }

    return service;
  }
Ejemplo n.º 2
0
 /**
  * Adds/updates a user object keyed by username. This method allows for renaming a user.
  *
  * @param username the old username
  * @param model the user object to use for username
  * @return true if update is successful
  */
 @Override
 public boolean updateUserModel(String username, UserModel model) {
   final boolean isCreate = null == userService.getUserModel(username);
   if (userService.updateUserModel(username, model)) {
     if (isCreate) {
       callCreateUserListeners(model);
     }
     return true;
   }
   return false;
 }