use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class RealmResourceOfferingModelImpl method setRealmDiscoEntry.
/**
* Set resource offering entry.
*
* @param realm Realm Name.
* @param smData Resource offering entry.
* @throws AMConsoleException if entry cannot be set.
*/
public void setRealmDiscoEntry(String realm, SMDiscoveryServiceData smData) throws AMConsoleException {
String[] params = { realm, AMAdminConstants.DISCOVERY_SERVICE };
logEvent("ATTEMPT_MODIFY_SERVICE_UNDER_REALM", params);
Map map = new HashMap(2);
map.put(AMAdminConstants.DISCOVERY_SERVICE_NAME_DYNAMIC_DISCO_ENTRIES, smData.getDiscoveryEntries());
try {
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realm);
AMIdentity realmIdentity = repo.getRealmIdentity();
Set servicesFromIdRepo = realmIdentity.getAssignedServices();
if (servicesFromIdRepo.contains(AMAdminConstants.DISCOVERY_SERVICE)) {
realmIdentity.modifyService(AMAdminConstants.DISCOVERY_SERVICE, map);
} else {
OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realm);
orgCfgMgr.modifyService(AMAdminConstants.DISCOVERY_SERVICE, map);
}
logEvent("SUCCEED_MODIFY_SERVICE_UNDER_REALM", params);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
logEvent("SSO_EXCEPTION_MODIFY_SERVICE_UNDER_REALM", paramsEx);
throw new AMConsoleException(strError);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
logEvent("IDREPO_EXCEPTION_MODIFY_SERVICE_UNDER_REALM", paramsEx);
throw new AMConsoleException(strError);
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
logEvent("SMS_EXCEPTION_MODIFY_SERVICE_UNDER_REALM", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class ServicesModelImpl method unassignServices.
/**
* Unassigns services from realm.
*
* @param realmName Name of Realm.
* @param names Names of services that are to be unassigned.
* @throws AMConsoleException if services cannot be unassigned.
*/
public void unassignServices(String realmName, Set names) throws AMConsoleException {
if ((names != null) && !names.isEmpty()) {
if ((realmName == null) || (realmName.trim().length() == 0)) {
realmName = "/";
}
String[] params = new String[2];
params[0] = realmName;
String curServiceName = "";
try {
OrganizationConfigManager scm = new OrganizationConfigManager(getUserSSOToken(), realmName);
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
AMIdentity realmIdentity = repo.getRealmIdentity();
Set realmServices = realmIdentity.getAssignedServices();
for (Iterator iter = names.iterator(); iter.hasNext(); ) {
String name = (String) iter.next();
curServiceName = name;
params[1] = name;
logEvent("ATTEMPT_UNASSIGN_SERVICE_FROM_REALM", params);
if (realmServices.contains(name)) {
realmIdentity.unassignService(name);
} else {
scm.unassignService(name);
}
logEvent("SUCCEED_UNASSIGN_SERVICE_FROM_REALM", params);
}
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { realmName, curServiceName, strError };
logEvent("SMS_EXCEPTION_UNASSIGN_SERVICE_FROM_REALM", paramsEx);
throw new AMConsoleException(strError);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { realmName, curServiceName, strError };
logEvent("SSO_EXCEPTION_UNASSIGN_SERVICE_FROM_REALM", paramsEx);
throw new AMConsoleException(strError);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] paramsEx = { realmName, curServiceName, strError };
logEvent("IDREPO_EXCEPTION_UNASSIGN_SERVICE_FROM_REALM", paramsEx);
throw new AMConsoleException(strError);
}
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class ServicesModelImpl method getAssignedServiceNames.
/**
* Returns a map of assigned service name to its localized name under a
* realm.
*
* @param realmName Name of Realm.
* @return a map of assigned service name to its localized name under a
* realm.
* @throws AMConsoleException if service names cannot be obtained.
*/
public Map getAssignedServiceNames(String realmName) throws AMConsoleException {
String[] param = { realmName };
logEvent("ATTEMPT_GET_ASSIGNED_SERVICE_OF_REALM", param);
try {
OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realmName);
Set names = orgCfgMgr.getAssignedServices();
if ((names == null) || names.isEmpty()) {
names = new HashSet();
}
getIdentityServices(realmName, names);
/*
* Need to use adminSSOToken because policy admin does not
* have the correct privileges.
*/
AMAuthenticationManager mgr = new AMAuthenticationManager(adminSSOToken, realmName);
AMAdminUtils.removeAllCaseIgnore(names, mgr.getAuthenticationServiceNames());
removeNonDisplayableServices(names, SUPPORTED_SCHEMA_TYPE);
// remove auth configuration service too
names.remove(AMAdminConstants.AUTH_CONFIG_SERVICE);
names.remove(AMAdminConstants.CORE_AUTH_SERVICE);
/*
Creation and edit of instances of the Rest/Soap STS services handled by the STS tab.
*/
names.remove(AMAdminConstants.REST_STS_SERVICE);
names.remove(AMAdminConstants.SOAP_STS_SERVICE);
logEvent("SUCCEED_GET_ASSIGNED_SERVICE_OF_REALM", param);
return mapNameToDisplayName(names);
} catch (AMConfigurationException e) {
String strError = getErrorString(e);
String[] paramsEx = { realmName, strError };
logEvent("CONFIGURATION_EXCEPTION_GET_ASSIGNED_SERVICE_OF_REALM", paramsEx);
throw new AMConsoleException(strError);
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { realmName, strError };
logEvent("SMS_EXCEPTION_GET_ASSIGNED_SERVICE_OF_REALM", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class ServicesModelImpl method getAssignableServiceNames.
/**
* Returns a map of service name to its display name that can be assigned
* to a realm.
*
* @param realmName Name of Realm.
* @return a map of service name to its display name that can be assigned
* to a realm.
* @throws AMConsoleException if service names cannot be obtained.
*/
public Map getAssignableServiceNames(String realmName) throws AMConsoleException {
String[] param = { realmName };
logEvent("ATTEMPT_GET_ASSIGNABLE_SERVICE_OF_REALM", param);
try {
OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realmName);
Set names = orgCfgMgr.getAssignableServices();
addIdentityUnassignedServices(realmName, names);
names.removeAll(orgCfgMgr.getAssignedServices());
AMAuthenticationManager mgr = new AMAuthenticationManager(getUserSSOToken(), realmName);
AMAdminUtils.removeAllCaseIgnore(names, mgr.getAuthenticationServiceNames());
removeNonDisplayableServices(names, SUPPORTED_SCHEMA_TYPE);
names.remove(AMAdminConstants.CORE_AUTH_SERVICE);
/*
Creation and edit of instances of the Rest/Soap STS services handled by the STS tab.
*/
names.remove(AMAdminConstants.REST_STS_SERVICE);
names.remove(AMAdminConstants.SOAP_STS_SERVICE);
logEvent("SUCCEED_GET_ASSIGNABLE_SERVICE_OF_REALM", param);
return mapNameToDisplayName(names);
} catch (AMConfigurationException e) {
String strError = getErrorString(e);
String[] paramsEx = { realmName, strError };
logEvent("CONFIGURATION_EXCEPTION_GET_ASSIGNABLE_SERVICE_OF_REALM", paramsEx);
if (debug.warningEnabled()) {
debug.warning("ServicesModel.getAssignableServiceNames " + strError);
}
throw new AMConsoleException("no.properties");
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { realmName, strError };
logEvent("SMS_EXCEPTION_GET_ASSIGNABLE_SERVICE_OF_REALM", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class RMRealmModelImpl method createSubRealm.
/**
* Creates sub realm.
*
* @param parentRealm Parent realm name.
* @param name Name of new sub realm.
* @param attrValues Map of attribute name to a set of attribute values.
* @throws AMConsoleException if sub realm cannot be created.
*/
public void createSubRealm(String parentRealm, String name, Map attrValues) throws AMConsoleException {
if ((parentRealm == null) || (parentRealm.length() == 0)) {
parentRealm = "/";
}
String[] params = { parentRealm, name };
logEvent("ATTEMPT_CREATE_REALM", params);
try {
OrganizationConfigManager orgMgr = new OrganizationConfigManager(getUserSSOToken(), parentRealm);
Map map = mapAttributeValuesToServiceName(attrValues);
orgMgr.createSubOrganization(name, map);
logEvent("SUCCEED_CREATE_REALM", params);
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { parentRealm, name, strError };
logEvent("SMS_EXCEPTION_CREATE_REALM", paramsEx);
throw new AMConsoleException(strError);
}
}
Aggregations