use of com.sun.identity.idm.AMIdentityRepository 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.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class ServicesModelImpl method getIdentityServices.
private void getIdentityServices(String realmName, Set names) {
/*
* It is ok that administrator such as policy administrator
* does not have access to AMIdentityRepository. We just ignore it.
*/
try {
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realmName);
AMIdentity realmIdentity = repo.getRealmIdentity();
names.addAll(realmIdentity.getAssignedServices());
} catch (SSOException e) {
debug.warning("ServicesModelImpl.getIdentityServices", e);
} catch (IdRepoException e) {
debug.warning("ServicesModelImpl.getIdentityServices", e);
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class ServicesProfileModelImpl method assignService.
/**
* Assigns service to a realm.
*
* @param map Map of attribute name to Set of attribute values.
* @throws AMConsoleException if values cannot be set.
*/
public void assignService(Map map) throws AMConsoleException {
String[] params = { currentRealm, serviceName };
logEvent("ATTEMPT_ASSIGN_SERVICE_TO_REALM", params);
try {
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), currentRealm);
AMIdentity realmIdentity = repo.getRealmIdentity();
Set servicesFromIdRepo = realmIdentity.getAssignableServices();
if (servicesFromIdRepo.contains(serviceName)) {
realmIdentity.assignService(serviceName, map);
} else {
OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), currentRealm);
orgCfgMgr.assignService(serviceName, map);
}
logEvent("SUCCEED_ASSIGN_SERVICE_TO_REALM", params);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, serviceName, strError };
logEvent("SSO_EXCEPTION_ASSIGN_SERVICE_TO_REALM", paramsEx);
throw new AMConsoleException(strError);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, serviceName, strError };
logEvent("IDREPO_EXCEPTION_ASSIGN_SERVICE_TO_REALM", paramsEx);
throw new AMConsoleException(strError);
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, serviceName, strError };
logEvent("SMS_EXCEPTION_ASSIGN_SERVICE_TO_REALM", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class ServicesProfileModelImpl method setAttributes.
/**
* Set attributes of an service.
*
* @param attrValues Map of attribute name to its values.
* @throws AMConsoleException if values cannot be set.
*/
public void setAttributes(Map attrValues) throws AMConsoleException {
String[] params = { currentRealm, serviceName };
logEvent("ATTEMPT_MODIFY_SERVICE_UNDER_REALM", params);
try {
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), currentRealm);
AMIdentity realmIdentity = repo.getRealmIdentity();
Set servicesFromIdRepo = realmIdentity.getAssignedServices();
if (servicesFromIdRepo.contains(serviceName)) {
realmIdentity.modifyService(serviceName, attrValues);
} else {
OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), currentRealm);
orgCfgMgr.modifyService(serviceName, attrValues);
}
logEvent("SUCCEED_MODIFY_SERVICE_UNDER_REALM", params);
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, serviceName, strError };
logEvent("SSO_EXCEPTION_MODIFY_SERVICE_UNDER_REALM", paramsEx);
throw new AMConsoleException(strError);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, serviceName, strError };
logEvent("IDREPO_EXCEPTION_MODIFY_SERVICE_UNDER_REALM", paramsEx);
throw new AMConsoleException(strError);
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { currentRealm, serviceName, strError };
logEvent("SMS_EXCEPTION_MODIFY_SERVICE_UNDER_REALM", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.idm.AMIdentityRepository in project OpenAM by OpenRock.
the class RealmResourceOfferingModelImpl method getRealmDiscoEntry.
/**
* Returns resource offering entry stored for a realm name.
*
* @param realm Realm Name.
* @return resource offering entry stored for a given user.
* @throws AMConsoleException if entry cannot be determined.
*/
public SMDiscoveryServiceData getRealmDiscoEntry(String realm) throws AMConsoleException {
SMDiscoveryServiceData resourceOffering = null;
String[] params = { realm, AMAdminConstants.DISCOVERY_SERVICE, AMAdminConstants.DISCOVERY_SERVICE_NAME_DYNAMIC_DISCO_ENTRIES };
logEvent("ATTEMPT_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", params);
try {
AMIdentityRepository repo = new AMIdentityRepository(getUserSSOToken(), realm);
AMIdentity realmIdentity = repo.getRealmIdentity();
Set servicesFromIdRepo = realmIdentity.getAssignedServices();
Map map = null;
if (servicesFromIdRepo.contains(AMAdminConstants.DISCOVERY_SERVICE)) {
map = realmIdentity.getServiceAttributes(AMAdminConstants.DISCOVERY_SERVICE);
} else {
OrganizationConfigManager orgCfgMgr = new OrganizationConfigManager(getUserSSOToken(), realm);
map = orgCfgMgr.getServiceAttributes(AMAdminConstants.DISCOVERY_SERVICE);
}
logEvent("SUCCEED_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", params);
resourceOffering = SMDiscoveryServiceData.getEntries((Set) map.get(AMAdminConstants.DISCOVERY_SERVICE_NAME_DYNAMIC_DISCO_ENTRIES));
} catch (SSOException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
logEvent("SSO_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
debug.error("RealmResourceOfferingModelImpl.getAttributeValues", e);
} catch (IdRepoException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
logEvent("IDREPO_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
debug.error("RealmResourceOfferingModelImpl.getAttributeValues", e);
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { realm, AMAdminConstants.DISCOVERY_SERVICE, strError };
logEvent("SMS_EXCEPTION_GET_ATTR_VALUE_OF_SERVICE_UNDER_REALM", paramsEx);
debug.error("RealmResourceOfferingModelImpl.getAttributeValues", e);
}
return resourceOffering;
}
Aggregations