use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class DirectoryServicesImpl method removeEntry.
/**
* Remove an entry from the directory.
*
* @param token
* SSOToken
* @param entryDN
* dn of the profile to be removed
* @param objectType
* profile type
* @param recursive
* if true, remove all sub entries & the object
* @param softDelete
* Used to let pre/post callback plugins know that this delete is
* either a soft delete (marked for deletion) or a purge/hard
* delete itself, otherwise, remove the object only
*/
public void removeEntry(SSOToken token, String entryDN, int objectType, boolean recursive, boolean softDelete) throws AMException, SSOException {
if (debug.messageEnabled()) {
debug.message("DirectoryServicesImpl.removeEntry(): Removing: " + entryDN + " & recursive: " + recursive);
}
if (recursive) {
// will list all entries in the sub-tree and delete them
// one by one.
removeSubtree(token, entryDN, softDelete);
} else {
removeSingleEntry(token, entryDN, objectType, softDelete);
}
// realm must also be deleted.
if (objectType == AMObject.ORGANIZATION && ServiceManager.isCoexistenceMode() && ServiceManager.isRealmEnabled()) {
try {
// Check if realm exisits, this throws SMSException
// if realm does not exist
OrganizationConfigManager ocm = new OrganizationConfigManager(token, entryDN);
// Since the above did not throw an exception, the
// realm must be deleted
ocm.deleteSubOrganization(null, recursive);
} catch (SMSException smse) {
if (debug.messageEnabled()) {
debug.message("DirectoryServicesImpl::removeEntry " + "unable to delete corresponding realm: " + entryDN);
}
}
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class AMAuthenticationManager method createAuthenticationInstance.
/**
* Creates an <code>AMAuthenticationInstance</code> instance with the
* specified parameters.
*
* @param name Name of the authentication module instance.
* @param type Type of the authentication module instance.
* @param attributes A Map of parameters for this module instance.
* @return <code>AMAuthenticationInstance</code> object is newly created.
* @throws AMConfigurationException if error occurred during the
* authentication creation.
*/
public AMAuthenticationInstance createAuthenticationInstance(String name, String type, Map attributes) throws AMConfigurationException {
if (name.indexOf(' ') != -1) {
throw new AMConfigurationException(BUNDLE_NAME, "invalidAuthenticationInstanceName", null);
}
Set moduleTypes = getAuthenticationTypes();
if (!moduleTypes.contains(type)) {
throw new AMConfigurationException(BUNDLE_NAME, "wrongType", new Object[] { type });
}
AMAuthenticationInstance instance = getAuthenticationInstance(name);
if (instance != null) {
if (instance.getServiceConfig() != null) {
throw new AMConfigurationException(BUNDLE_NAME, "authInstanceExist", new Object[] { name });
} else {
throw new AMConfigurationException(BUNDLE_NAME, "authInstanceIsGlobal", new Object[] { name });
}
}
String serviceName = getServiceName(type);
ServiceSchema schema = null;
try {
ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, token);
schema = ssm.getSchema(SchemaType.GLOBAL);
} catch (SSOException e) {
if (DEBUG.warningEnabled()) {
DEBUG.warning("Token doesn't have access to service: " + token + " -> " + serviceName);
}
} catch (SMSException e) {
// normal exception for service without global configuration.
// no need to log anything.
}
try {
OrganizationConfigManager ocm = new OrganizationConfigManager(token, realm);
// Check if service is assigned
if (!ocm.getAssignedServices().contains(serviceName)) {
ocm.assignService(serviceName, null);
}
ServiceConfig orgConfig = ocm.getServiceConfig(serviceName);
if (orgConfig == null) {
orgConfig = ocm.addServiceConfig(serviceName, null);
}
ServiceConfig subConfig = orgConfig;
if (!name.equals(type)) {
orgConfig.addSubConfig(name, ISAuthConstants.SERVER_SUBSCHEMA, 0, attributes);
subConfig = orgConfig.getSubConfig(name);
} else {
// if the module instance name equals to its type, set the
// the attributes in its organization config, not sub config.
subConfig.setAttributes(attributes);
}
//AMAuthLevelManager listeners are in place, so let's reinitialize to be on the safe side.
if (!SystemProperties.isServerMode()) {
buildModuleInstanceForService(realm, serviceName);
}
return new AMAuthenticationInstance(name, type, subConfig, schema);
} catch (Exception e) {
throw new AMConfigurationException(e);
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class RMRealmModelImpl method getDataMap.
/**
* Returns Map of attribute name to empty set of values.
*
* @throws AMConsoleException if map cannot be obtained.
*/
public Map getDataMap() {
Map map = new HashMap();
try {
OrganizationConfigManager orgMgr = new OrganizationConfigManager(getUserSSOToken(), "/");
Set serviceSchemas = orgMgr.getServiceSchemas();
for (Iterator iter = serviceSchemas.iterator(); iter.hasNext(); ) {
ServiceSchema ss = (ServiceSchema) iter.next();
String serviceName = ss.getServiceName();
Set attrSchemas = ss.getAttributeSchemas();
for (Iterator i = attrSchemas.iterator(); i.hasNext(); ) {
AttributeSchema as = (AttributeSchema) i.next();
map.put(serviceName + "_" + as.getName(), Collections.EMPTY_SET);
}
}
} catch (SMSException e) {
debug.error("RMRealmModelImpl.getDataMap", e);
}
return map;
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class RMRealmModelImpl method deleteSubRealms.
/**
* Deletes sub realms
*
* @param parentRealm Parent realm name.
* @param names List of realm names to be deleted.
* @throws AMConsoleException if sub realms cannot be deleted.
*/
public void deleteSubRealms(String parentRealm, Collection names) throws AMConsoleException {
String[] params = new String[2];
params[0] = parentRealm;
String currentName = "";
try {
OrganizationConfigManager orgMgr = new OrganizationConfigManager(getUserSSOToken(), parentRealm);
List orderedByLength = AMAdminUtils.orderByStringLength(names);
for (Iterator iter = orderedByLength.iterator(); iter.hasNext(); ) {
String name = (String) iter.next();
currentName = name;
params[1] = name;
logEvent("ATTEMPT_DELETE_REALM", params);
orgMgr.deleteSubOrganization(name, true);
logEvent("SUCCEED_DELETE_REALM", params);
}
} catch (SMSException e) {
String strError = getErrorString(e);
String[] paramsEx = { parentRealm, currentName, strError };
logEvent("SMS_EXCEPTION_DELETE_REALM", paramsEx);
throw new AMConsoleException(strError);
}
}
use of com.sun.identity.sm.OrganizationConfigManager in project OpenAM by OpenRock.
the class RMRealmModelImpl method getDefaultValues.
/**
* Returns Map of default attribute values used when creating
* new realms. This only returns default values for single choice
* type attributes. Returning other default values runs the risk
* of violating the attribute uniqueness plugin while creating a
* new realm.
*
* @throws AMConsoleException if map cannot be obtained.
*/
public Map getDefaultValues() {
Map map = new HashMap();
try {
OrganizationConfigManager orgMgr = new OrganizationConfigManager(getUserSSOToken(), "/");
Set serviceSchemas = orgMgr.getServiceSchemas();
for (Iterator iter = serviceSchemas.iterator(); iter.hasNext(); ) {
ServiceSchema ss = (ServiceSchema) iter.next();
String serviceName = ss.getServiceName();
Set attrSchemas = ss.getAttributeSchemas();
for (Iterator i = attrSchemas.iterator(); i.hasNext(); ) {
AttributeSchema as = (AttributeSchema) i.next();
if (as.getType() == AttributeSchema.Type.SINGLE_CHOICE) {
map.put(serviceName + "_" + as.getName(), as.getDefaultValues());
}
}
}
} catch (SMSException e) {
debug.error("RMRealmModelImpl.getDefaultValues", e);
}
return map;
}
Aggregations