Search in sources :

Example 16 with ServiceConfigManager

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

the class UserIdRepo method getOrgConfig.

static ServiceConfig getOrgConfig(SSOToken adminToken) throws SMSException, SSOException {
    ServiceConfigManager svcCfgMgr = new ServiceConfigManager(IdConstants.REPO_SERVICE, adminToken);
    ServiceConfig cfg = svcCfgMgr.getOrganizationConfig("", null);
    Map values = new HashMap();
    if (cfg == null) {
        OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(adminToken, "/");
        ServiceSchemaManager schemaMgr = new ServiceSchemaManager(IdConstants.REPO_SERVICE, adminToken);
        ServiceSchema orgSchema = schemaMgr.getOrganizationSchema();
        Set attrs = orgSchema.getAttributeSchemas();
        for (Iterator iter = attrs.iterator(); iter.hasNext(); ) {
            AttributeSchema as = (AttributeSchema) iter.next();
            values.put(as.getName(), as.getDefaultValues());
        }
        cfg = orgCfgMgr.addServiceConfig(IdConstants.REPO_SERVICE, values);
    }
    return cfg;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) ServiceConfig(com.sun.identity.sm.ServiceConfig) HashMap(java.util.HashMap) OrganizationConfigManager(com.sun.identity.sm.OrganizationConfigManager) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) Map(java.util.Map) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 17 with ServiceConfigManager

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

the class ServiceConfigServlet method printInfo.

private void printInfo(AuthContext lc, String servicename, String method, PrintWriter out) throws Exception {
    // Obtain the SSO Token
    SSOToken token = lc.getSSOToken();
    out.println("<br><h3>SSOToken:</h3> " + token.getTokenID());
    out.println("<p>");
    // Obtain Service Manager
    if (method.equalsIgnoreCase("globalSchema")) {
        ServiceSchemaManager ssm = new ServiceSchemaManager(servicename, token);
        out.println(ssm.getGlobalSchema().toString());
    } else if (method.equalsIgnoreCase("globalConfig")) {
        ServiceConfigManager scm = new ServiceConfigManager(servicename, token);
        out.println(scm.getGlobalConfig(null).toString());
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 18 with ServiceConfigManager

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

the class SchemaTest method getSubConfigurationValues.

private Map getSubConfigurationValues(String name) throws SMSException, SSOException {
    ServiceConfigManager scm = new ServiceConfigManager(TEST_SERVICE, getAdminSSOToken());
    ServiceConfig sc = scm.getGlobalConfig(null);
    sc = sc.getSubConfig("testConfig");
    return sc.getAttributes();
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager)

Example 19 with ServiceConfigManager

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

the class DelegationManager method getConfiguredPrivilegeNames.

/**
     * Returns all the names of the delegation privileges that are configured
     * with the realm.
     *
     * @return <code>Set</code> of <code>DelegationPrivilege</code> names
     * configured with the realm.
     *
     * @throws DelegationException  for any abnormal condition
     */
public Set getConfiguredPrivilegeNames() throws DelegationException {
    Set privNames = null;
    Set globalPrivNames = null;
    Set orgPrivNames = null;
    ServiceConfig privsConfig;
    ServiceConfig sc;
    String subConfigName = null;
    int revisionNum = DelegationUtils.getRevisionNumber();
    if (revisionNum == DelegationUtils.AM70_DELEGATION_REVISION) {
        subConfigName = DelegationManager.PERMISSIONS;
    } else {
        subConfigName = DelegationManager.PRIVILEGES;
    }
    try {
        ServiceConfigManager scm = new ServiceConfigManager(DELEGATION_SERVICE, getAdminToken());
        // get the globally defined privilege names
        sc = scm.getGlobalConfig(null);
        if (sc != null) {
            privsConfig = sc.getSubConfig(subConfigName);
            if (privsConfig != null) {
                globalPrivNames = privsConfig.getSubConfigNames();
            }
        }
        try {
            // get the organizationally defined privilege names
            sc = scm.getOrganizationConfig(orgName, null);
            if (sc != null) {
                privsConfig = sc.getSubConfig(subConfigName);
                if (privsConfig != null) {
                    orgPrivNames = privsConfig.getSubConfigNames();
                }
            }
        } catch (SMSException ex) {
        //ignore if organization configuration is not present
        }
        // merge the privilege names
        if ((globalPrivNames != null) && (!globalPrivNames.isEmpty())) {
            privNames = globalPrivNames;
            if ((orgPrivNames != null) && (!orgPrivNames.isEmpty())) {
                privNames.addAll(orgPrivNames);
            }
        } else {
            privNames = orgPrivNames;
        }
    } catch (Exception e) {
        throw new DelegationException(e);
    }
    return privNames;
}
Also used : Set(java.util.Set) CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSException(com.sun.identity.sm.SMSException) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) SMSException(com.sun.identity.sm.SMSException) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException)

Example 20 with ServiceConfigManager

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

the class EntitlementService method getApplicationSubConfig.

private ServiceConfig getApplicationSubConfig(SSOToken token, String realm, String appName) throws SMSException, SSOException {
    ServiceConfig applConf = null;
    ServiceConfigManager mgr = new ServiceConfigManager(SERVICE_NAME, token);
    ServiceConfig orgConfig = mgr.getOrganizationConfig(realm, null);
    if (orgConfig != null) {
        ServiceConfig conf = orgConfig.getSubConfig(EntitlementUtils.REGISTERED_APPLICATIONS);
        if (conf != null) {
            applConf = conf.getSubConfig(appName);
        }
    }
    return applConf;
}
Also used : ServiceConfig(com.sun.identity.sm.ServiceConfig) 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