public HybridUserProvider() {

    // Migrate user provider properties
    JiveGlobals.migrateProperty("hybridUserProvider.primaryProvider.className");
    JiveGlobals.migrateProperty("hybridUserProvider.secondaryProvider.className");
    JiveGlobals.migrateProperty("hybridUserProvider.tertiaryProvider.className");

    userproviders = new ArrayList<UserProvider>();

    // Load primary, secondary, and tertiary user providers.
    String primaryClass = JiveGlobals.getProperty("hybridUserProvider.primaryProvider.className");
    if (primaryClass == null) {
      Log.error(
          "A primary UserProvider must be specified via openfire.xml or the system properties");
      return;
    }
    try {
      Class c = ClassUtils.forName(primaryClass);
      UserProvider primaryProvider = (UserProvider) c.newInstance();
      userproviders.add(primaryProvider);
      Log.debug("Primary user provider: " + primaryClass);
    } catch (Exception e) {
      Log.error(
          "Unable to load primary user provider: "
              + primaryClass
              + ". Users in this provider will be disabled.",
          e);
      return;
    }
    String secondaryClass =
        JiveGlobals.getProperty("hybridUserProvider.secondaryProvider.className");
    if (secondaryClass != null) {
      try {
        Class c = ClassUtils.forName(secondaryClass);
        UserProvider secondaryProvider = (UserProvider) c.newInstance();
        userproviders.add(secondaryProvider);
        Log.debug("Secondary user provider: " + secondaryClass);
      } catch (Exception e) {
        Log.error("Unable to load secondary user provider: " + secondaryClass, e);
      }
    }
    String tertiaryClass = JiveGlobals.getProperty("hybridUserProvider.tertiaryProvider.className");
    if (tertiaryClass != null) {
      try {
        Class c = ClassUtils.forName(tertiaryClass);
        UserProvider tertiaryProvider = (UserProvider) c.newInstance();
        userproviders.add(tertiaryProvider);
        Log.debug("Tertiary user provider: " + tertiaryClass);
      } catch (Exception e) {
        Log.error("Unable to load tertiary user provider: " + tertiaryClass, e);
      }
    }
  }
Пример #2
0
 private static Class loadClass(String className) throws ClassNotFoundException {
   try {
     return ClassUtils.forName(className);
   } catch (ClassNotFoundException e) {
     return WorkgroupUtils.class.getClassLoader().loadClass(className);
   }
 }
Пример #3
0
  /** Loads the provider names from the jive properties config file. */
  private static void loadProviders() {
    if (factory == null) {
      // Use className as a convenient object to get a lock on.
      synchronized (classNames) {
        if (factory == null) {
          try {
            Class[] providers = new Class[classNames.length];
            for (int i = 0; i < classNames.length; i++) {
              // Convert XML based provider setup to Database based
              JiveGlobals.migrateProperty(propNames[i]);

              String className = classNames[i];
              // See if the classname has been set as a Jive property.
              String classNameProp = JiveGlobals.getProperty(propNames[i]);
              if (classNameProp != null) {
                className = classNameProp;
              }
              try {
                providers[i] = ClassUtils.forName(className);
              } catch (Exception e) {
                Log.error("Exception loading class: " + className, e);
              }
            }
            setProviders(providers);
          } catch (Exception e) {
            Log.error("Exception loading class: " + classNames, e);
          }
        }
      }
    }
  }
Пример #4
0
 private GroupManager() {
   // Initialize caches.
   CacheManager.initializeCache("group", 128 * 1024);
   CacheManager.initializeCache("group member", 32 * 1024);
   groupCache = CacheManager.getCache("group");
   // Load a group provider.
   String className =
       JiveGlobals.getXMLProperty(
           "provider.group.className", "org.jivesoftware.wildfire.group.DefaultGroupProvider");
   try {
     Class c = ClassUtils.forName(className);
     provider = (GroupProvider) c.newInstance();
   } catch (Exception e) {
     Log.error("Error loading group provider: " + className, e);
     provider = new DefaultGroupProvider();
   }
 }
Пример #5
0
  /**
   * Initializes the server's security audit provider, based on configuration and defaults to
   * DefaultSecurityAuditProvider if the specified provider is not valid or not specified.
   */
  private void initProvider() {
    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("provider.securityAudit.className");

    String className =
        JiveGlobals.getProperty(
            "provider.securityAudit.className",
            "org.jivesoftware.openfire.security.DefaultSecurityAuditProvider");
    // Check if we need to reset the provider class
    if (provider == null || !className.equals(provider.getClass().getName())) {
      try {
        Class c = ClassUtils.forName(className);
        provider = (SecurityAuditProvider) c.newInstance();
      } catch (Exception e) {
        Log.error("Error loading security audit provider: " + className, e);
        provider = new DefaultSecurityAuditProvider();
      }
    }
  }