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;
}
}
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;
}
}
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);
}
}
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;
}
}
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);
}
}
Aggregations