use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class IdServicesImpl method createRealmIdentity.
private AMIdentity createRealmIdentity(SSOToken token, IdType type, String name, Map attrMap, String orgName) throws IdRepoException, SSOException {
try {
OrganizationConfigManager orgMgr = new OrganizationConfigManager(token, orgName);
Map<String, Set<String>> newAttrMap = new HashMap<>(attrMap);
if (!newAttrMap.containsKey(IdConstants.ORGANIZATION_STATUS_ATTR)) {
newAttrMap.put(IdConstants.ORGANIZATION_STATUS_ATTR, CollectionUtils.asSet("Active"));
}
Map serviceAttrsMap = new HashMap();
serviceAttrsMap.put(IdConstants.REPO_SERVICE, newAttrMap);
orgMgr.createSubOrganization(name, serviceAttrsMap);
return getSubRealmIdentity(token, name, orgName);
} catch (SMSException sme) {
DEBUG.error("AMIdentityRepository.createIdentity() - " + "Error occurred while creating " + type.getName() + ":" + name, sme);
throw new IdRepoException(sme.getMessage());
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class RealmRemovedTest method setup.
@BeforeClass
public void setup() throws Exception {
if (!migrated) {
return;
}
OrganizationConfigManager ocm = new OrganizationConfigManager(adminToken, "/");
String subRealm = SUB_REALM1.substring(1);
ocm.createSubOrganization(subRealm, Collections.EMPTY_MAP);
subRealm = SUB_REALM2.substring(1);
ocm.createSubOrganization(subRealm, Collections.EMPTY_MAP);
createApplicationPrivilege();
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class TestEvaluator method cleanup.
@AfterClass
public void cleanup() throws Exception {
if (!migrated) {
return;
}
PrivilegeManager pm = PrivilegeManager.getInstance(SUB_REALM, adminSubject);
pm.remove(PRIVILEGE1_NAME);
Set<AMIdentity> identities = new HashSet<AMIdentity>();
identities.add(user1);
identities.add(user2);
IdRepoUtils.deleteIdentities("/", identities);
ApplicationManager.deleteApplication(adminSubject, "/", APPL_NAME);
OrganizationConfigManager orgMgr = new OrganizationConfigManager(adminToken, "/");
orgMgr.deleteSubOrganization(SUB_REALM, true);
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class UpgradeUtils method createOrgAuthConfig.
/**
* Creates auth configurations for auth modules configuration in
* core auth service.
*/
private static void createOrgAuthConfig(String realmName) throws Exception {
String classMethod = "UpgradeUtils:createOrgAuthConfig: ";
OrganizationConfigManager org = new OrganizationConfigManager(ssoToken, realmName);
ServiceConfig orgConfig = org.getServiceConfig(AUTH_SERVICE_NAME);
if (orgConfig != null) {
Map aa = orgConfig.getAttributes();
if (debug.messageEnabled()) {
debug.message(classMethod + "Org is :" + realmName);
debug.message(classMethod + "Attribute Map is :" + aa);
}
String orgName = realmName;
if (LDAPUtils.isDN(realmName)) {
orgName = LDAPUtils.rdnValueFromDn(realmName);
}
String authConfigName = orgName + "-authconfig";
String adminAuthConfigName = orgName + "-admin-authconfig";
Set authConfigAttrValue = (Set) aa.get(ATTR_ORG_AUTH_MODULE);
if (debug.messageEnabled()) {
debug.message(classMethod + "authConfigAttrValue : " + authConfigAttrValue);
}
Set newVal = new HashSet();
if (authConfigAttrValue.size() != 1 && !authConfigAttrValue.contains(authConfigName)) {
newVal.add(authConfigName);
orgConfig.replaceAttributeValues(ATTR_ORG_AUTH_MODULE, authConfigAttrValue, newVal);
}
Set adminConfigAttrValue = (Set) aa.get(ATTR_ADMIN_AUTH_MODULE);
if (debug.messageEnabled()) {
debug.message("adminauthConfigAttrValue : " + adminConfigAttrValue);
}
if (adminConfigAttrValue.size() != 1 && !adminConfigAttrValue.contains(adminAuthConfigName)) {
newVal.clear();
newVal.add(adminAuthConfigName);
orgConfig.replaceAttributeValues(ATTR_ADMIN_AUTH_MODULE, adminConfigAttrValue, newVal);
}
aa = orgConfig.getAttributes();
ServiceConfig s = org.getServiceConfig(AUTH_CONFIG_SERVICE);
ServiceConfig authConfig = s.getSubConfig(NAMED_CONFIG);
if (authConfig == null) {
s.addSubConfig(NAMED_CONFIG, null, 0, null);
authConfig = s.getSubConfig(NAMED_CONFIG);
}
Map aMap = new HashMap();
aMap.put(ATTR_AUTH_CONFIG, authConfigAttrValue);
authConfig.addSubConfig(authConfigName, SUB_NAMED_CONFIG, 0, aMap);
aMap.clear();
aMap.put(ATTR_AUTH_CONFIG, adminConfigAttrValue);
authConfig.addSubConfig(adminAuthConfigName, SUB_NAMED_CONFIG, 0, aMap);
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class AbstractUpgradeStep method getRealmNames.
/**
* Returns the names of the realms available in the OpenAM configuration. The returned set is ordered, so the realm
* hierarchy maintained (i.e. subrealm precedes sub-subrealm).
*
* @return The set of realmnames available in OpenAM.
* @throws UpgradeException In case retrieving the realmnames was not successful.
*/
protected final Set<String> getRealmNames() throws UpgradeException {
try {
OrganizationConfigManager ocm = new OrganizationConfigManager(getAdminToken(), "/");
Set<String> realms = CollectionUtils.asOrderedSet("/");
realms.addAll(ocm.getSubOrganizationNames("*", true));
if (DEBUG.messageEnabled()) {
DEBUG.message("Discovered realms in the configuration: " + realms);
}
return realms;
} catch (SMSException smse) {
DEBUG.error("An error occurred while trying to retrieve the list of realms", smse);
throw new UpgradeException("Unable to retrieve realms from SMS");
}
}
Aggregations