code: public TenantDefinition defineTenant(TenantDefinition tenantDef) {
          checkServiceState();
          String tenantName = tenantDef.getName();
          if (getTenantDef(tenantName) != null) {
              throw new DuplicateException("Tenant already exists: " + tenantName);
          }
          defineNewTenant(tenantDef);
          TenantDefinition updatedTenantDef = getTenantDef(tenantName);
          if (updatedTenantDef == null) {
              throw new RuntimeException("Tenant definition could not be retrieved after creation: " + tenantName);
          }
          removeUserHashes(updatedTenantDef);
          return updatedTenantDef;
      }
docs: Create a new tenant with the given definition and return the updated definition.
  Throw a {@link DuplicateException} if the tenant has already been defined.
  
  @param tenantDef {@link TenantDefinition} of new tenant.
  @return          Updated definition.