use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class DataStore method getIndexCount.
private static int getIndexCount(String realm, boolean referral) {
int count = 0;
if (adminToken != null) {
try {
ServiceConfigManager mgr = new ServiceConfigManager(SERVICE_NAME, adminToken);
ServiceConfig orgConf = mgr.getOrganizationConfig(realm, null);
if (orgConf != null) {
Map<String, Set<String>> map = orgConf.getAttributes();
Set<String> set = (referral) ? map.get(REFERRAL_INDEX_COUNT) : map.get(INDEX_COUNT);
if ((set != null) && !set.isEmpty()) {
String strCount = (String) set.iterator().next();
count = Integer.parseInt(strCount);
}
}
} catch (NumberFormatException ex) {
PolicyConstants.DEBUG.error("DataStore.getIndexCount", ex);
} catch (SMSException ex) {
PolicyConstants.DEBUG.error("DataStore.getIndexCount", ex);
} catch (SSOException ex) {
PolicyConstants.DEBUG.error("DataStore.getIndexCount", ex);
}
}
return count;
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class DataStore method getOrgConfig.
private ServiceConfig getOrgConfig(SSOToken adminToken, String realm) throws SMSException, SSOException {
ServiceConfigManager mgr = new ServiceConfigManager(SERVICE_NAME, adminToken);
ServiceConfig orgConf = mgr.getOrganizationConfig(realm, null);
if (orgConf == null) {
mgr.createOrganizationConfig(realm, null);
}
return orgConf;
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class EntitlementService method getApplicationConfiguration.
/**
* Get the service config for registered applications.
* @param token The admin token for access to the Service Config.
* @param realm The realm from which to retrieve the service config.
* @return The application Service Config.
*/
private ServiceConfig getApplicationConfiguration(SSOToken token, String realm) {
try {
if (token != null) {
if (realm.startsWith(SMSEntry.SUN_INTERNAL_REALM_PREFIX) || realm.startsWith(SMSEntry.SUN_INTERNAL_REALM_PREFIX2)) {
realm = "/";
}
// TODO. Since applications for the hidden realms have to be
// the same as root realm mainly for delegation without any
// referrals, the hack is to use root realm for hidden realm.
String hackRealm = LDAPUtils.isDN(realm) ? DNMapper.orgNameToRealmName(realm) : realm;
ServiceConfigManager mgr = new ServiceConfigManager(SERVICE_NAME, token);
ServiceConfig orgConfig = mgr.getOrganizationConfig(hackRealm, null);
if (orgConfig != null) {
return orgConfig.getSubConfig(EntitlementUtils.REGISTERED_APPLICATIONS);
}
} else {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration, admin token is missing");
}
} catch (ClassCastException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration", ex);
} catch (SMSException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration", ex);
} catch (SSOException ex) {
PolicyConstants.DEBUG.error("EntitlementService.getApplicationConfiguration", ex);
}
return null;
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class EntitlementService method addApplicationAction.
/**
* Adds a new action.
*
* @param appName application name.
* @param name Action name.
* @param defVal Default value.
* @throws EntitlementException if action cannot be added.
*/
public void addApplicationAction(String appName, String name, Boolean defVal) throws EntitlementException {
try {
SSOToken token = SubjectUtils.getSSOToken(getAdminSubject());
if (token == null) {
throw new EntitlementException(226);
}
ServiceConfig applConf = getApplicationSubConfig(token, realm, appName);
if (applConf != null) {
Map<String, Set<String>> data = applConf.getAttributes();
Map<String, Set<String>> result = addAction(data, name, defVal);
if (result != null) {
applConf.setAttributes(result);
}
}
} catch (SMSException ex) {
throw new EntitlementException(221, ex);
} catch (SSOException ex) {
throw new EntitlementException(221, ex);
}
}
use of com.sun.identity.sm.ServiceConfig 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;
}
Aggregations