use of com.sun.identity.sm.ServiceConfig 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();
}
use of com.sun.identity.sm.ServiceConfig 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;
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class EntitlementService method storeApplicationType.
/**
* Stores the application type to data store.
*
* @param applicationType Application type object.
* @throws EntitlementException if application type cannot be stored.
*/
public void storeApplicationType(ApplicationType applicationType) throws EntitlementException {
try {
SSOToken token = SubjectUtils.getSSOToken(getAdminSubject());
if (token == null) {
Object[] arg = { applicationType.getName() };
throw new EntitlementException(246, arg);
}
ServiceConfig conf = getApplicationTypeCollectionConfig(token);
if (conf != null) {
ServiceConfig sc = conf.getSubConfig(applicationType.getName());
if (sc == null) {
conf.addSubConfig(applicationType.getName(), EntitlementUtils.APPLICATION_TYPE, 0, getApplicationTypeData(applicationType));
} else {
sc.setAttributes(getApplicationTypeData(applicationType));
}
}
} catch (SMSException ex) {
Object[] arg = { applicationType.getName() };
throw new EntitlementException(241, arg, ex);
} catch (SSOException ex) {
Object[] arg = { applicationType.getName() };
throw new EntitlementException(241, arg, ex);
}
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class EntitlementService method addSubjectAttributeNames.
/**
* Returns subject attribute names.
*
* @param applicationName Application name.
* @param names subject attribute names.
* @throws EntitlementException if subject attribute names cannot be
* returned.
*/
public void addSubjectAttributeNames(String applicationName, Set<String> names) throws EntitlementException {
if ((names == null) || names.isEmpty()) {
return;
}
try {
SSOToken token = getSSOToken();
if (token == null) {
throw new EntitlementException(225);
}
Application appl = ApplicationManager.getApplication(PolicyConstants.SUPER_ADMIN_SUBJECT, realm, applicationName);
if (appl != null) {
appl.addAttributeNames(names);
}
ServiceConfig applConf = getApplicationSubConfig(token, realm, applicationName);
String parentRealm = realm;
while (applConf == null) {
parentRealm = getParentRealm(parentRealm);
if (parentRealm == null) {
break;
}
applConf = getApplicationSubConfig(token, parentRealm, applicationName);
}
if (applConf != null) {
Set<String> orig = (Set<String>) applConf.getAttributes().get(ATTR_NAME_SUBJECT_ATTR_NAMES);
if ((orig == null) || orig.isEmpty()) {
orig = new HashSet<String>();
}
orig.addAll(names);
Map<String, Set<String>> map = new HashMap<String, Set<String>>();
map.put(ATTR_NAME_SUBJECT_ATTR_NAMES, orig);
applConf.setAttributes(map);
}
} catch (SMSException ex) {
throw new EntitlementException(220, ex);
} catch (SSOException ex) {
throw new EntitlementException(220, ex);
}
}
use of com.sun.identity.sm.ServiceConfig 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;
}
Aggregations