use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class RealmTest method setRealmAttributeValues.
@Parameters({ "realm" })
@Test(groups = { "cli-realm", "set-realm-attrs" }, dependsOnMethods = { "removeRealmAttribute" })
public void setRealmAttributeValues(String realm) throws CLIException, SMSException, SSOException {
String[] param = { realm };
entering("setRealmAttributeValues", param);
String[] args = { "set-realm-attrs", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, realm, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, "sunIdentityRepositoryService", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES, "sunOrganizationStatus=Active" };
CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
cmdManager.addToRequestQueue(req);
cmdManager.serviceRequestQueue();
OrganizationConfigManager ocm = new OrganizationConfigManager(getAdminSSOToken(), realm);
Map values = ocm.getAttributes("sunIdentityRepositoryService");
Set attrValues = (Set) values.get("sunOrganizationStatus");
assert attrValues.contains("Active");
exiting("setRealmAttributeValues");
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class RealmTest method removeRealmAttribute.
@Parameters({ "realm" })
@Test(groups = { "cli-realm", "delete-realm-attr" })
public void removeRealmAttribute(String realm) throws CLIException, SMSException, SSOException {
String[] param = { realm };
entering("removeRealmAttribute", param);
String[] args = { "delete-realm-attr", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, realm, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, "sunIdentityRepositoryService", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_NAME, "sunOrganizationStatus" };
CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
cmdManager.addToRequestQueue(req);
cmdManager.serviceRequestQueue();
OrganizationConfigManager ocm = new OrganizationConfigManager(getAdminSSOToken(), realm);
Map values = ocm.getAttributes("sunIdentityRepositoryService");
Set attrValues = (Set) values.get("sunOrganizationStatus");
assert (attrValues == null);
exiting("removeRealmAttribute");
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class UpgradeIdRepoSubConfigs method perform.
@Override
public void perform() throws UpgradeException {
for (Map.Entry<String, Set<String>> entry : repos.entrySet()) {
try {
String realm = entry.getKey();
OrganizationConfigManager ocm = new OrganizationConfigManager(getAdminToken(), realm);
for (String subConfig : entry.getValue()) {
UpgradeProgress.reportStart("upgrade.data.store.start", subConfig);
Map<String, Set<String>> newValues = new HashMap<String, Set<String>>(2);
ServiceConfig sc = ocm.getServiceConfig(IdConstants.REPO_SERVICE);
ServiceConfig repoConfig = sc.getSubConfig(subConfig);
Map<String, Set<String>> attributes = repoConfig.getAttributes();
String className = CollectionHelper.getMapAttr(attributes, IdConstants.ID_REPO);
if (OLD_IDREPO_CLASS.equals(className)) {
newValues.put(IdConstants.ID_REPO, asSet(NEW_IDREPO_CLASS));
}
String newFilter = getModifiedFilter(attributes);
if (newFilter != null) {
if (DEBUG.messageEnabled()) {
DEBUG.message("Upgrading psearch filter for datastore: " + subConfig + " to: " + newFilter);
}
newValues.put(PSEARCH_FILTER, asSet(newFilter));
}
Map<String, String> sslModes = oldConnectionModeRepos.get(realm);
String sslMode = (sslModes == null) ? null : sslModes.get(subConfig);
if (sslMode != null) {
if (DEBUG.messageEnabled()) {
DEBUG.message("Upgrading connection mode for datastore: " + subConfig + " to: " + sslMode);
}
newValues.put(NEW_CONNECTION_MODE, asSet(sslMode));
}
//There is no need to remove the obsolete attributes here, because once we set an attribute, the SMS
//framework will automagically remove those that do not adhere to the schema.
repoConfig.setAttributes(newValues);
UpgradeProgress.reportEnd("upgrade.success");
}
} catch (Exception ex) {
UpgradeProgress.reportEnd("upgrade.failed");
DEBUG.error("An error occurred while upgrading service config ", ex);
throw new UpgradeException("Unable to upgrade IdRepo configuration");
}
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class ConfigFedMonitoring method getRealmsList.
/*
* get the list of realms, starting from "startRealm", usu. "/".
* return List with realms, with leading "/".
*/
private List getRealmsList(String startRealm) {
String classMethod = "ConfigFedMonitoring.getRealmsList: ";
try {
// for startRealm
int rlmCnt = 1;
OrganizationConfigManager orgMgr = new OrganizationConfigManager(ssoToken, startRealm);
Set orgs = orgMgr.getSubOrganizationNames("*", true);
rlmCnt += orgs.size();
realmList = new ArrayList(rlmCnt);
realmList.add(startRealm);
for (Iterator it = orgs.iterator(); it.hasNext(); ) {
String ss = "/" + (String) it.next();
realmList.add(ss);
}
return (realmList);
} catch (SMSException e) {
debug.error(classMethod + "SMSException getting OrgConfigMgr: " + e.getMessage());
}
return (new ArrayList());
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class ConfigureSocialAuthN method createOrModifySocialService.
/**
* Create a social service given the attributes specified.
* @param realm The realm/organisation
* @param chainName
* @param providerName
* @param icon
* @throws WorkflowException if there are problems modifying or assigning the service.
*/
private void createOrModifySocialService(String realm, String chainName, String providerName, String icon) throws WorkflowException {
try {
SSOToken token = getAdminToken();
OrganizationConfigManager ocm = new OrganizationConfigManager(token, realm);
Map<String, Set<String>> attrs = new HashMap<String, Set<String>>(4);
String prefix = "[" + providerName + "]=";
attrs.put(SERVICE_DISPLAY_NAME, asSet(prefix + providerName));
attrs.put(SERVICE_CHAIN_NAME, asSet(prefix + chainName));
attrs.put(SERVICE_ICON, asSet(prefix + icon));
attrs.put(SERVICE_ENABLED, asSet(providerName));
if (ocm.getAssignedServices().contains(SERVICE_NAME)) {
ServiceConfig serviceConfig = ocm.getServiceConfig(SERVICE_NAME);
serviceConfig.setAttributes(mergeAttributes(serviceConfig.getAttributesWithoutDefaults(), attrs));
} else {
ocm.assignService(SERVICE_NAME, attrs);
}
} catch (SMSException smse) {
DEBUG.error("An error occurred while creating/modifying social authentication service", smse);
throw new WorkflowException("social-service-error", null);
} catch (SSOException ssoe) {
DEBUG.warning("A session error occurred while creating/modifying social authentication service", ssoe);
throw new WorkflowException("social-service-error", null);
}
}
Aggregations