/** * Services a Commandline Request. * * @param rc Request Context. * @throw CLIException if the request cannot serviced. */ public void handleRequest(RequestContext rc) throws CLIException { super.handleRequest(rc); ldapLogin(); String serviceName = getStringOptionValue(IArgument.SERVICE_NAME); String i18nKey = getStringOptionValue(ARGUMENT_I18N_KEY); ServiceSchemaManager ssm = getServiceSchemaManager(); IOutput outputWriter = getOutputWriter(); try { String[] params = {serviceName, i18nKey}; writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SET_SERVICE_SCHEMA_I18N_KEY", params); ssm.setI18NKey(i18nKey); writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SET_SERVICE_SCHEMA_I18N_KEY", params); outputWriter.printlnMessage( MessageFormat.format( getResourceString("service-schema-set-i18n-key-succeed"), (Object[]) params)); } catch (SSOException e) { String[] args = {serviceName, i18nKey, e.getMessage()}; debugError("SetServiceSchemaI18nKey.handleRequest", e); writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SERVICE_SCHEMA_I18N_KEY", args); throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED); } catch (SMSException e) { String[] args = {serviceName, i18nKey, e.getMessage()}; debugError("SetServiceSchemaI18nKey.handleRequest", e); writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SET_SERVICE_SCHEMA_I18N_KEY", args); throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED); } }
/** * Initialized auth service global attributes * * @throws SMSException if it fails to get auth service for name * @throws SSOException if admin <code>SSOToken</code> is not valid * @throws Exception */ private void initAuthServiceGlobalSettings() throws SMSException, SSOException, Exception { ServiceSchemaManager scm = new ServiceSchemaManager(ISAuthConstants.AUTH_SERVICE_NAME, ssoAuthSession); revisionNumber = scm.getRevisionNumber(); if (debug.messageEnabled()) { debug.message("revision number = " + revisionNumber); } updateAuthServiceGlobals(scm); new AuthConfigMonitor(scm); }
private void detectMode(String service, String attribute) { try { ServiceSchema schema = schemaManager.getGlobalSchema(); Map defaults = schema.getAttributeDefaults(); enabled = Boolean.parseBoolean(CollectionHelper.getMapAttr(defaults, attribute, "")); if (listenerId == null) { listenerId = schemaManager.addListener(this); } } catch (SMSException e) { DEBUG.error("Could not get " + service, e); throw new IllegalStateException("Could not get " + service, e); } }
/** * 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(); }
/** * Update the PlatformService global attributes. * * @param scm <code>ServiceSchemaManager</code> to be used for update * @throws SMSException if it fails to initialize platform service */ synchronized void updatePlatformServiceGlobals(ServiceSchemaManager scm) throws SMSException { platformSchema = scm.getGlobalSchema(); Map attrs = platformSchema.getAttributeDefaults(); platformLocale = CollectionHelper.getMapAttr(attrs, ISAuthConstants.PLATFORM_LOCALE_ATTR); if (debug.messageEnabled()) { debug.message("PlatformLocale = " + platformLocale); } }
/** * 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); } }
/** * Update the SessionService dynamic attributes. * * @param scm <code>ServiceSchemaManager</code> to be used for update * @throws SMSException if it fails to update session service */ synchronized void updateSessionServiceDynamics(ServiceSchemaManager scm) throws SMSException { sessionSchema = scm.getDynamicSchema(); if (debug.messageEnabled()) { Map attrs = sessionSchema.getAttributeDefaults(); String defaultMaxSessionTime = CollectionHelper.getMapAttr(attrs, ISAuthConstants.MAX_SESSION_TIME, "120"); String defaultMaxIdleTime = CollectionHelper.getMapAttr(attrs, ISAuthConstants.SESS_MAX_IDLE_TIME, "30"); String defaultMaxCachingTime = CollectionHelper.getMapAttr(attrs, ISAuthConstants.SESS_MAX_CACHING_TIME, "3"); debug.message( "AuthD.defaultMaxSessionTime=" + defaultMaxSessionTime + "\nAuthD.defaultMaxIdleTime=" + defaultMaxIdleTime + "\nAuthD.defaultMaxCachingTime=" + defaultMaxCachingTime); } }
/** * 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; } }