Search in sources :

Example 91 with ServiceConfigManager

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

the class SchemaTest method deleteSubConfiguration.

@Test(groups = { "schema", "delete-sub-cfg" }, dependsOnMethods = { "setSubConfiguration" })
public void deleteSubConfiguration() throws CLIException, SMSException, SSOException {
    entering("deleteSubConfiguration", null);
    String[] args = { "delete-sub-cfg", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, TEST_SERVICE, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUB_CONFIGURATION_NAME, "/testConfig" };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        ServiceConfigManager scm = new ServiceConfigManager(TEST_SERVICE, getAdminSSOToken());
        ServiceConfig sc = scm.getGlobalConfig(null);
        sc = sc.getSubConfig("testConfig");
        assert (sc == null);
        exiting("deleteSubConfiguration");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "deleteSubConfiguration", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "deleteSubConfiguration", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "deleteSubConfiguration", e.getMessage());
        throw e;
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 92 with ServiceConfigManager

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

the class SchemaTest method createSubConfiguration.

@Test(groups = { "schema", "create-sub-cfg" })
public void createSubConfiguration() throws CLIException, SMSException, SSOException {
    entering("createSubConfiguration", null);
    String[] args = { "create-sub-cfg", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, TEST_SERVICE, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUB_CONFIGURATION_ID, "subschemaX", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SUB_CONFIGURATION_NAME, "testConfig", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES, "attr1=1", "attr2=2" };
    CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
    cmdManager.addToRequestQueue(req);
    try {
        cmdManager.serviceRequestQueue();
        ServiceConfigManager scm = new ServiceConfigManager(TEST_SERVICE, getAdminSSOToken());
        ServiceConfig sc = scm.getGlobalConfig(null);
        sc = sc.getSubConfig("testConfig");
        assert (sc != null);
        exiting("createSubConfiguration");
    } catch (CLIException e) {
        this.log(Level.SEVERE, "createSubConfiguration", e.getMessage());
        throw e;
    } catch (SMSException e) {
        this.log(Level.SEVERE, "createSubConfiguration", e.getMessage());
        throw e;
    } catch (SSOException e) {
        this.log(Level.SEVERE, "createSubConfiguration", e.getMessage());
        throw e;
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) CLIRequest(com.sun.identity.cli.CLIRequest) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 93 with ServiceConfigManager

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

the class DSConnectValidation method processDSServers.

private void processDSServers(SSOToken ssoToken) {
    String amService = IDREPO_SERVICE;
    try {
        ServiceConfigManager scm = new ServiceConfigManager(amService, ssoToken);
        ServiceConfig serviceConfig = scm.getOrganizationConfig("/", null);
        Set subCfgNames = serviceConfig.getSubConfigNames();
        if ((subCfgNames != null) && !subCfgNames.isEmpty()) {
            for (Iterator i = subCfgNames.iterator(); i.hasNext(); ) {
                String dStore = (String) i.next();
                toolOutWriter.printMessage("cnt-ds-datastore", new String[] { dStore });
                ServiceConfig subConfig = serviceConfig.getSubConfig(dStore);
                if ((subConfig != null)) {
                    Map dsAttrs = subConfig.getAttributes();
                    processEntries(dsAttrs);
                }
            }
        }
    } catch (Exception e) {
        Debug.getInstance(DEBUG_NAME).error("DSConnectValidation.processDSServers: " + "Exception during processing DS entries ", e);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) Iterator(java.util.Iterator) Map(java.util.Map) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 94 with ServiceConfigManager

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

the class UmaUserUiRolePredicate method apply.

@Override
public boolean apply(Context context) {
    try {
        String id = context.asContext(SSOTokenContext.class).getCallerSSOToken().getProperty(Constants.UNIVERSAL_IDENTIFIER);
        if (sessionService.get().isSuperUser(id)) {
            return false;
        }
        String realm = context.asContext(RealmContext.class).getResolvedRealm();
        SSOToken token = AccessController.doPrivileged(AdminTokenAction.getInstance());
        ServiceConfigManager serviceConfigManager = new ServiceConfigManager(token, UmaConstants.SERVICE_NAME, UmaConstants.SERVICE_VERSION);
        return serviceConfigManager.getOrganizationConfig(realm, null).exists();
    } catch (Exception e) {
        logger.message("Could not access realm config", e);
        return false;
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) RealmContext(org.forgerock.openam.rest.RealmContext) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 95 with ServiceConfigManager

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

the class UpgradeUtils method replaceSubConfigAttributeDefaultValues.

/**
     * Replaces attributes default values in service sub-configuration.
     *
     * @param serviceName name of the service
     * @param sunServiceID a set of subconfig service identifiers.
     * @param realm the realm name.
     * @param subConfigName the name of the service sub-configuration.
     * @param attributeName name of the attribute
     * @param oldValues set of values to be replaced.
     * @param newValues set of values to be added.
     */
public static void replaceSubConfigAttributeDefaultValues(String serviceName, Set sunServiceID, String realm, String subConfigName, String attributeName, Set oldValues, Set newValues) {
    String classMethod = "UpgradeUtils:replaceSubConfigAttributeDefaultValues : ";
    try {
        ServiceConfigManager scm = getServiceConfigManager(serviceName);
        ServiceConfig sc = scm.getOrganizationConfig(realm, null);
        ServiceConfig subConfig = sc.getSubConfig(subConfigName);
        String serviceID = getSunServiceID(subConfig);
        if (debug.messageEnabled()) {
            debug.message("sunServiceID :" + sunServiceID);
            debug.message("serviceID :" + serviceID);
            debug.message("subConfigName :" + subConfigName);
        }
        if (sunServiceID.contains(serviceID)) {
            subConfig.replaceAttributeValues(attributeName, oldValues, newValues);
        }
    } catch (SSOException ssoe) {
        debug.error(classMethod + "Invalid SSO Token: ", ssoe);
    } catch (SMSException sme) {
        debug.error(classMethod + "Error replacing default values for attribute : " + attributeName, sme);
    }
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ByteString(org.forgerock.opendj.ldap.ByteString) 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