private void deleteSubConfigToRoot(String serviceName, String subConfigName) throws CLIException { SSOToken adminSSOToken = getAdminSSOToken(); IOutput outputWriter = getOutputWriter(); String[] params = {subConfigName, serviceName}; writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_DELETE_SUB_CONFIGURATION", params); try { ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken); ServiceConfig sc = scm.getGlobalConfig(null); deleteSubConfig(sc, subConfigName); writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_DELETE_SUB_CONFIGURATION", params); outputWriter.printlnMessage( MessageFormat.format( getResourceString("delete-sub-configuration-succeed"), (Object[]) params)); } catch (SSOException e) { String[] args = {subConfigName, serviceName, e.getMessage()}; debugError("DeleteSubConfiguration.deleteSubConfigToRoot", e); writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_SUB_CONFIGURATION", args); throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED); } catch (SMSException e) { String[] args = {subConfigName, serviceName, e.getMessage()}; debugError("DeleteSubConfiguration.deleteSubConfigToRoot", e); writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_DELETE_SUB_CONFIGURATION", args); throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED); } }
private synchronized void registerListeners() { if (!hasRegisteredListeners) { SSOToken adminToken = AccessController.doPrivileged(AdminTokenAction.getInstance()); for (String serviceName : migratedServiceNames) { try { ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminToken); scm.addListener(this); } catch (SSOException | SMSException ex) { Debug.getInstance(SetupConstants.DEBUG_NAME) .error("ConfigurationObserver.registeringListeners", ex); } } hasRegisteredListeners = true; } }
private ServiceConfig getServiceConfig(String realm) { try { return configManager.getOrganizationConfig(realm, null); } catch (SMSException | SSOException e) { throw new ConfigRetrievalException("Unable to retrieve organisation config", e); } }
/** * Returns available subject attribute names. * * @return a set of available subject attribute names or null if not found */ public Set<String> getAvailableSubjectAttributeNames() throws EntitlementException { try { ServiceConfig sc = idRepoServiceConfigManager.getOrganizationConfig(realm, null); if (sc == null) { return null; } Set subConfigNames = sc.getSubConfigNames(); if ((subConfigNames == null) || (subConfigNames.isEmpty())) { return null; } CaseInsensitiveHashSet result = null; for (Iterator iter = subConfigNames.iterator(); iter.hasNext(); ) { String idRepoName = (String) iter.next(); ServiceConfig reposc = sc.getSubConfig(idRepoName); Map attrMap = reposc.getAttributesForRead(); Set userAttrs = (Set) attrMap.get(LDAPv3Config_USER_ATTR); if ((userAttrs != null) && (!userAttrs.isEmpty())) { if (result == null) { result = new CaseInsensitiveHashSet(); } result.addAll(userAttrs); } } return result; } catch (SMSException e) { throw new EntitlementException(602, e); } catch (SSOException e) { throw new EntitlementException(602, e); } }
private static void registerListener() { SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance()); EntitlementConfiguration ec = EntitlementConfiguration.getInstance(SubjectUtils.createSubject(adminToken), "/"); if (ec.migratedToEntitlementService()) { try { ServiceConfigManager scm = new ServiceConfigManager(IdConstants.REPO_SERVICE, adminToken); scm.addListener(new SubRealmObserver()); } catch (SMSException e) { PrivilegeManager.debug.error("SubRealmObserver.registerListener", e); } catch (SSOException e) { PrivilegeManager.debug.error("SubRealmObserver.registerListener", e); } } }
private void addServiceListener() { try { final SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance()); final ServiceConfigManager serviceConfigManager = new ServiceConfigManager( token, OAuth2ProviderService.NAME, OAuth2ProviderService.VERSION); if (serviceConfigManager.addListener(new OAuth2ProviderSettingsChangeListener()) == null) { logger.error( "Could not add listener to ServiceConfigManager instance. OAuth2 provider service " + "changes will not be dynamically updated for realm " + realm); } } catch (Exception e) { String message = "OAuth2Utils::Unable to construct ServiceConfigManager: " + e; logger.error(message, e); throw OAuthProblemException.OAuthError.SERVER_ERROR.handle(null, message); } }
private ServiceConfig getSocialAuthenticationServiceConfig(final String realm) throws SSOException, SMSException { ServiceConfig realmSocialAuthServiceConfig = realmSocialAuthServiceConfigMap.get(realm); if (realmSocialAuthServiceConfig == null || !realmSocialAuthServiceConfig.isValid()) { synchronized (realmSocialAuthServiceConfigMap) { realmSocialAuthServiceConfig = realmSocialAuthServiceConfigMap.get(realm); if (realmSocialAuthServiceConfig == null || !realmSocialAuthServiceConfig.isValid()) { SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance()); ServiceConfigManager mgr = new ServiceConfigManager(SocialAuthenticationImplementation.SERVICE_NAME, token); realmSocialAuthServiceConfig = mgr.getOrganizationConfig(realm, null); realmSocialAuthServiceConfigMap.put(realm, realmSocialAuthServiceConfig); } } } return realmSocialAuthServiceConfig; }
private void addSubConfigToRoot( String serviceName, String subConfigName, String subConfigId, Map attrValues, int priority) throws CLIException { SSOToken adminSSOToken = getAdminSSOToken(); IOutput outputWriter = getOutputWriter(); String[] params = {subConfigName, serviceName}; writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_SUB_CONFIGURATION", params); try { ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken); ServiceConfig sc = scm.getGlobalConfig(null); if (sc == null) { String[] args = {subConfigName, serviceName, "no global configiration"}; writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_CONFIGURATION", args); String[] ar = {serviceName}; String message = MessageFormat.format( getResourceString("add-sub-configuration-no-global-config"), (Object[]) ar); throw new CLIException(message, ExitCodes.REQUEST_CANNOT_BE_PROCESSED); } addSubConfig(sc, subConfigName, subConfigId, attrValues, priority); writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SUB_CONFIGURATION", params); outputWriter.printlnMessage( MessageFormat.format( getResourceString("add-sub-configuration-succeed"), (Object[]) params)); } catch (SSOException e) { String[] args = {subConfigName, serviceName, e.getMessage()}; debugError("AddSubConfiguration.addSubConfigToRoot", e); writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_CONFIGURATION", args); throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED); } catch (SMSException e) { e.printStackTrace(); String[] args = {subConfigName, serviceName, e.getMessage()}; debugError("AddSubConfiguration.addSubConfigToRoot", e); writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_CONFIGURATION", args); throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED); } }
private void addSubConfigToRealm( String realmName, String serviceName, String subConfigName, String subConfigId, Map attrValues, int priority) throws CLIException { SSOToken adminSSOToken = getAdminSSOToken(); IOutput outputWriter = getOutputWriter(); String[] params = {realmName, subConfigName, serviceName}; writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_ADD_SUB_CONFIGURATION_TO_REALM", params); try { ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken); ServiceConfig sc = scm.getOrganizationConfig(realmName, null); if (sc == null) { sc = scm.createOrganizationConfig(realmName, null); } addSubConfig(sc, subConfigName, subConfigId, attrValues, priority); writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_ADD_SUB_CONFIGURATION_TO_REALM", params); outputWriter.printlnMessage( MessageFormat.format( getResourceString("add-sub-configuration-to-realm-succeed"), (Object[]) params)); } catch (SSOException e) { String[] args = {realmName, subConfigName, serviceName, e.getMessage()}; debugError("AddSubConfiguration.addSubConfigToRealm", e); writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_CONFIGURATIONT_TO_REALM", args); throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED); } catch (SMSException e) { String[] args = {realmName, subConfigName, serviceName, e.getMessage()}; debugError("AddSubConfiguration.addSubConfigToRealm", e); writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_ADD_SUB_CONFIGURATIONT_TO_REALM", args); throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED); } }
@Inject public ConsoleConfigHandlerImpl( DNWrapper dnUtils, PrivilegedAction<SSOToken> ssoTokenPrivilegedAction) { this.dnUtils = dnUtils; changeListeners = new CopyOnWriteArrayList<>(); try { configManager = new ServiceConfigManager(ssoTokenPrivilegedAction.run(), SERVICE_NAME, SERVICE_VERSION); configManager.addListener(new ConfigChangeHandler()); } catch (SMSException | SSOException e) { throw new ConfigRetrievalException("Unable to retrieve the config manager", e); } }
/** * Default Constructor * * @param realm in which emails service shall be created */ public MailServerImpl(String realm) { debug = Debug.getInstance("amMailServer"); sendMail = new AMSendMail(); try { mgr = new ServiceConfigManager( (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance()), SERVICE_NAME, SERVICE_VERSION); scm = mgr.getOrganizationConfig(realm, null); options = scm.getAttributes(); } catch (Exception e) { debug.error("Cannot get ServiceConfigManager", e); } }