use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class UpgradeUtils method addSubConfiguration.
/**
* Adds SubConfiguration to a service.
*
* @param serviceName the service name
* @param svcConfigName the service config
* @param subConfigName the subconfig name
* @param subConfigID the subconfig id
* @param attrValues a map of attribute value pairs to be added to the
* subconfig.
* @param priority the priority value
* @throws UpgradeException if there is an error.
*/
public static void addSubConfiguration(String serviceName, String svcConfigName, String subConfigName, String subConfigID, Map attrValues, int priority) throws UpgradeException {
String classMethod = "UpgradeUtils:addSubConfiguration";
try {
ServiceConfigManager scm = new ServiceConfigManager(serviceName, ssoToken);
ServiceConfig sc = scm.getGlobalConfig(null);
if (sc != null) {
sc.addSubConfig(subConfigName, subConfigID, priority, attrValues);
} else {
debug.error(classMethod + "Error adding sub cofiguration " + subConfigName);
throw new UpgradeException("Error adding subconfig");
}
} catch (SSOException ssoe) {
throw new UpgradeException("invalid sso token");
} catch (SMSException sm) {
debug.error(classMethod + "Error loading subconfig", sm);
throw new UpgradeException("error adding subconfig");
}
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class DelegationConfigUpgradeStep method initConfig.
/**
* Cache gets cleared after #initialize is called but before #perform, so need to re-get the config options each
* time.
*/
private void initConfig() throws SMSException, SSOException {
final ServiceConfig delegationConfig = configManager.getGlobalConfig(null);
permissionsConfig = delegationConfig.getSubConfig(PERMISSIONS);
privilegesConfig = delegationConfig.getSubConfig(PRIVILEGES);
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class UpgradeUtils method addSubConfigAttributeDefaultValues.
/**
* Adds defaults values to service sub-configuration
*
* @param serviceName the service name
* @param sunServiceID set of sunservice identifiers for sub-configuration
* @param realm the realm name
* @param subConfigName the sub-configuration name
* @param attributeName the attribute name
* @param defaultValues set of default values to be updated.
*/
public static void addSubConfigAttributeDefaultValues(String serviceName, Set sunServiceID, String realm, String subConfigName, String attributeName, Set defaultValues) {
String classMethod = "UpgradeUtils:addSubConfigAttributeDefaultValues : ";
try {
Set oldVal = new HashSet();
ServiceConfigManager scm = getServiceConfigManager(serviceName);
ServiceConfig sc = scm.getOrganizationConfig(realm, null);
ServiceConfig subConfig = sc.getSubConfig(subConfigName);
String serviceID = getSunServiceID(subConfig);
if (sunServiceID.contains(serviceID)) {
Set valSet = getExistingValues(subConfig, attributeName, defaultValues);
defaultValues.removeAll(valSet);
subConfig.replaceAttributeValues(attributeName, oldVal, defaultValues);
}
} catch (SSOException ssoe) {
debug.error(classMethod + "Invalid SSOToken", ssoe);
} catch (SMSException sme) {
debug.error(classMethod + "Error adding values ", sme);
}
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class IdRepoAttributeValidatorManager method getIdRepoAttributeValidator.
/**
* Returns an instance of <code>IdRepoAttributeValidator</code> for
* specified realm.
* @param realm the realm
* @return an instance of <code>IdRepoAttributeValidator</code>
* @throws IdRepoException if there are repository related error conditions.
*/
public IdRepoAttributeValidator getIdRepoAttributeValidator(String realm) throws IdRepoException {
IdRepoAttributeValidator validator = validatorCache.get(realm);
if (validator != null) {
return validator;
}
Map<String, Set<String>> configParams = new HashMap();
synchronized (validatorCache) {
try {
ServiceConfig orgConfig = idRepoServiceConfigManager.getOrganizationConfig(realm, null);
Map<String, Set<String>> attrMap = orgConfig.getAttributesForRead();
Set<String> attrValues = attrMap.get(ATTR_IDREPO_ATTRIBUTE_VALIDATOR);
String className = null;
for (String attrValue : attrValues) {
int index = attrValue.indexOf("=");
if (index != -1) {
String name = attrValue.substring(0, index).trim();
String value = attrValue.substring(index + 1).trim();
if (name.equals("class")) {
className = value;
} else {
Set<String> values = configParams.get(name);
if (values == null) {
values = new HashSet();
configParams.put(name, values);
}
values.add(value);
}
}
}
Class validatorClass = Class.forName(className);
validator = (IdRepoAttributeValidator) validatorClass.newInstance();
} catch (Exception ex) {
if (debug.warningEnabled()) {
debug.warning("IdRepoAttributeValidatorManager." + "initializeListeners:", ex);
}
}
if (validator == null) {
validator = new IdRepoAttributeValidatorImpl();
}
validator.initialize(configParams);
}
return validator;
}
use of com.sun.identity.sm.ServiceConfig in project OpenAM by OpenRock.
the class OpenAMSettingsImpl method getSetting.
/**
* {@inheritDoc}
*/
public Set<String> getSetting(String realm, String attributeName) throws SSOException, SMSException {
final ServiceConfig serviceConfig = getServiceConfig(realm);
final Map<String, Set<String>> attributes = serviceConfig.getAttributes();
return attributes.get(attributeName);
}
Aggregations