Example #1
0
  /**
   * Update the AuthService global and organization settings. most of the code is moved in from
   * AuthenticatorManager.java.
   *
   * @param scm <code>ServiceSchemaManager</code> to be used for update
   * @throws SMSException if it fails to update auth service
   * @throws Exception
   */
  synchronized void updateAuthServiceGlobals(ServiceSchemaManager scm)
      throws SMSException, Exception {

    ServiceSchema schema = scm.getOrganizationSchema();
    Map attrs = schema.getAttributeDefaults();

    // get Global type attributes for iPlanetAMAuthService
    schema = scm.getGlobalSchema();

    attrs.putAll(schema.getAttributeDefaults());
    if (debug.messageEnabled()) {
      debug.message("attrs : " + attrs);
    }

    defaultAuthLocale = CollectionHelper.getMapAttr(attrs, ISAuthConstants.AUTH_LOCALE_ATTR);
    adminAuthModule = CollectionHelper.getMapAttr(attrs, ISAuthConstants.ADMIN_AUTH_MODULE);
    defaultAuthLevel =
        CollectionHelper.getMapAttr(attrs, ISAuthConstants.DEFAULT_AUTH_LEVEL, DEFAULT_AUTH_LEVEL);

    Set s = (Set) attrs.get(ISAuthConstants.AUTHENTICATORS);
    Iterator iter = s.iterator();
    while (iter.hasNext()) {
      String name = (String) iter.next();
      int dot = name.lastIndexOf('.');
      if (dot > -1) {
        String tmp = name.substring(dot + 1, name.length());
        authMethods.put(tmp, name);
      } else {
        authMethods.put(name, name);
      }
    }
    if (debug.messageEnabled()) {
      debug.message("AM.update authMethods = " + authMethods.toString());
    }

    defaultSuccessURLSet = (Set) attrs.get(ISAuthConstants.LOGIN_SUCCESS_URL);
    defaultFailureURLSet = (Set) attrs.get(ISAuthConstants.LOGIN_FAILURE_URL);

    if (debug.messageEnabled()) {
      debug.message("Default Success URL Set = " + defaultSuccessURLSet);
      debug.message("Default Failure URL Set = " + defaultFailureURLSet);
    }

    Integer sleepTime =
        new Integer(CollectionHelper.getMapAttr(attrs, ISAuthConstants.SLEEP_INTERVAL));
    defaultSleepTime = sleepTime.longValue();
  }
Example #2
0
  /**
   * Update the AuthConfiguration organization attributes.
   *
   * @param scm <code>ServiceSchemaManager</code> to be used for update
   * @throws SMSException if it fails to update auth service
   */
  synchronized void updateAuthConfigGlobals(ServiceSchemaManager scm) throws SMSException {

    ServiceSchema schema = scm.getOrganizationSchema();

    schema = schema.getSubSchema("Configurations");
    schema = schema.getSubSchema("NamedConfiguration");
    Map attrs = schema.getAttributeDefaults();

    if (attrs != null) {
      defaultServiceSuccessURLSet = (Set) attrs.get(ISAuthConstants.LOGIN_SUCCESS_URL);
      defaultServiceFailureURLSet = (Set) attrs.get(ISAuthConstants.LOGIN_FAILURE_URL);
    }
    if (debug.messageEnabled()) {
      debug.message("Default Service Success URL Set = " + defaultServiceSuccessURLSet);
      debug.message("Default Service Failure URL Set = " + defaultServiceFailureURLSet);
    }
  }
Example #3
0
  /**
   * Determine the listener list based on the diable list property and SMS DataStore notification
   * property in Realm mode
   */
  private static void getListenerList() {
    String list = SystemProperties.get(EVENT_LISTENER_DISABLE_LIST, "");
    if (debugger.messageEnabled()) {
      debugger.message(
          "EventService.getListenerList(): " + EVENT_LISTENER_DISABLE_LIST + ": " + list);
    }

    boolean enableDataStoreNotification =
        Boolean.parseBoolean(SystemProperties.get(Constants.SMS_ENABLE_DB_NOTIFICATION));
    if (debugger.messageEnabled()) {
      debugger.message(
          "EventService.getListenerList(): "
              + "com.sun.identity.sm.enableDataStoreNotification: "
              + enableDataStoreNotification);
    }

    boolean configTime =
        Boolean.parseBoolean(SystemProperties.get(Constants.SYS_PROPERTY_INSTALL_TIME));
    if (debugger.messageEnabled()) {
      debugger.message(
          "EventService.getListenerList(): "
              + Constants.SYS_PROPERTY_INSTALL_TIME
              + ": "
              + configTime);
    }

    // Copy the default listeners
    String[] tmpListeners = new String[ALL_LISTENERS.length];
    System.arraycopy(ALL_LISTENERS, 0, tmpListeners, 0, ALL_LISTENERS.length);

    // Process the configured disabled list first
    boolean disableACI = false, disableUM = false, disableSM = false;
    if (list.length() != 0) {
      StringTokenizer st = new StringTokenizer(list, ",");
      String listener = "";
      while (st.hasMoreTokens()) {
        listener = st.nextToken().trim();
        if (listener.equalsIgnoreCase("aci")) {
          disableACI = true;
        } else if (listener.equalsIgnoreCase("um")) {
          disableUM = true;
        } else if (listener.equalsIgnoreCase("sm")) {
          disableSM = true;
        } else {
          debugger.error(
              "EventService.getListenerList() - " + "Invalid listener name: " + listener);
        }
      }
    }

    if (!disableUM || !disableACI) {
      // Check if AMSDK is configured
      boolean disableAMSDK = true;
      if (!configTime) {
        try {
          ServiceSchemaManager scm =
              new ServiceSchemaManager(getSSOToken(), IdConstants.REPO_SERVICE, "1.0");
          ServiceSchema idRepoSubSchema = scm.getOrganizationSchema();
          Set idRepoPlugins = idRepoSubSchema.getSubSchemaNames();
          if (idRepoPlugins.contains("amSDK")) {
            disableAMSDK = false;
          }
        } catch (SMSException ex) {
          if (debugger.warningEnabled()) {
            debugger.warning(
                "EventService.getListenerList() - " + "Unable to obtain idrepo service", ex);
          }
        } catch (SSOException ex) {
          // Should not happen, ignore the exception
        }
      }
      if (disableAMSDK) {
        disableUM = true;
        disableACI = true;
        if (debugger.messageEnabled()) {
          debugger.message(
              "EventService.getListener"
                  + "List(): AMSDK is not configured or config time. "
                  + "Disabling UM and ACI event listeners");
        }
      }
    }

    // Verify if SMSnotification should be enabled
    if (configTime || ServiceManager.isRealmEnabled()) {
      disableSM = !enableDataStoreNotification;
      if (debugger.messageEnabled()) {
        debugger.message(
            "EventService.getListenerList(): In realm "
                + "mode or config time, SMS listener is set to datastore "
                + "notification flag: "
                + enableDataStoreNotification);
      }
    }

    // Disable the selected listeners
    if (disableACI) {
      tmpListeners[0] = null;
    }
    if (disableUM) {
      tmpListeners[1] = null;
    }
    if (disableSM) {
      tmpListeners[2] = null;
    }
    listeners = tmpListeners;

    // if all disabled, signal to not start the thread
    if (disableACI && disableUM && disableSM) {
      if (debugger.messageEnabled()) {
        debugger.message(
            "EventService.getListenerList() - "
                + "all listeners are disabled, EventService won't start");
      }
      _allDisabled = true;
    } else {
      _allDisabled = false;
    }
  }