Search in sources :

Example 46 with ServiceConfigManager

use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.

the class MailServerImplTest method setup.

@BeforeMethod
public void setup() {
    ServiceConfigManager serviceConfigManagerMock = PowerMockito.mock(ServiceConfigManager.class);
    ServiceConfig serviceConfigMock = PowerMockito.mock(ServiceConfig.class);
    Debug debugMock = PowerMockito.mock(Debug.class);
    sendMailMock = PowerMockito.mock(AMSendMail.class);
    Map<String, Set<String>> options = createOptionsMap();
    try {
        Mockito.doNothing().when(sendMailMock).postMail(eq(recipients), anyString(), anyString(), anyString());
        Mockito.doNothing().when(sendMailMock).postMail(eq(recipients), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyBoolean());
    } catch (MessagingException e) {
        assert (false);
    }
    mailServerMock = new MailServerImpl(serviceConfigManagerMock, serviceConfigMock, debugMock, sendMailMock, options);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) MessagingException(javax.mail.MessagingException) AMSendMail(com.iplanet.am.util.AMSendMail) Matchers.anyString(org.mockito.Matchers.anyString) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) Debug(com.sun.identity.shared.debug.Debug) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 47 with ServiceConfigManager

use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.

the class ConfigurationBase method getRootServerConfig.

protected static ServiceConfig getRootServerConfig(SSOToken ssoToken) throws SMSException, SSOException {
    ServiceConfigManager scm = new ServiceConfigManager(Constants.SVC_NAME_PLATFORM, ssoToken);
    ServiceConfig globalSvcConfig = scm.getGlobalConfig(null);
    return (globalSvcConfig != null) ? globalSvcConfig.getSubConfig(CONFIG_SERVERS) : null;
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 48 with ServiceConfigManager

use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.

the class DeleteSubConfiguration method deleteSubConfigToRoot.

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);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 49 with ServiceConfigManager

use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.

the class AMCommonNameGenerator method initialize.

private void initialize() {
    try {
        serviceSchemaManager = new ServiceSchemaManager(G11N_SERVICE_NAME, adminSSOToken);
        serviceConfigManager = new ServiceConfigManager(G11N_SERVICE_NAME, adminSSOToken);
        //listener for org
        serviceConfigManager.addListener(this);
        //listener for global
        serviceSchemaManager.addListener(this);
    } catch (SMSException smse) {
        debug.error("AMCommonNameGenerator.initManager", smse);
    } catch (SSOException ssoe) {
        debug.error("AMCommonNameGenerator.initManager", ssoe);
    }
}
Also used : SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 50 with ServiceConfigManager

use of com.sun.identity.sm.ServiceConfigManager in project OpenAM by OpenRock.

the class ModifySubConfiguration method modifySubConfigToRealm.

private void modifySubConfigToRealm(String realmName, String serviceName, String subConfigName, Map attrValues, String operation) throws CLIException {
    SSOToken adminSSOToken = getAdminSSOToken();
    IOutput outputWriter = getOutputWriter();
    String[] params = { realmName, subConfigName, serviceName };
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_SUB_CONFIGURATION_IN_REALM", params);
    try {
        ServiceConfigManager scm = new ServiceConfigManager(serviceName, adminSSOToken);
        ServiceConfig sc = scm.getOrganizationConfig(realmName, null);
        if (sc == null) {
            sc = scm.createOrganizationConfig(realmName, null);
        }
        modifySubConfig(sc, subConfigName, attrValues, operation);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_MODIFY_SUB_CONFIGURATION_IN_REALM", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("modify-sub-configuration-to-realm-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { realmName, subConfigName, serviceName, e.getMessage() };
        debugError("ModifySubConfiguration.modifySubConfigToRealm", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_SUB_CONFIGURATIONT_IN_REALM", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { realmName, subConfigName, serviceName, e.getMessage() };
        debugError("ModifySubConfiguration.modifySubConfigToRealm", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_SUB_CONFIGURATIONT_IN_REALM", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Aggregations

ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)163 ServiceConfig (com.sun.identity.sm.ServiceConfig)123 SMSException (com.sun.identity.sm.SMSException)116 SSOException (com.iplanet.sso.SSOException)107 SSOToken (com.iplanet.sso.SSOToken)53 Set (java.util.Set)50 Map (java.util.Map)31 HashMap (java.util.HashMap)29 HashSet (java.util.HashSet)28 CLIException (com.sun.identity.cli.CLIException)17 Iterator (java.util.Iterator)16 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)15 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)13 ServiceNotFoundException (com.sun.identity.sm.ServiceNotFoundException)12 ByteString (org.forgerock.opendj.ldap.ByteString)12 JsonValue (org.forgerock.json.JsonValue)10 IOException (java.io.IOException)9 InternalServerErrorException (org.forgerock.json.resource.InternalServerErrorException)9 IOutput (com.sun.identity.cli.IOutput)8 PolicyException (com.sun.identity.policy.PolicyException)7