use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class DirectoryServicesImpl method getAttributesFromDS.
/**
* Gets the specific attributes corresponding to the entryDN. This method
* obtains the DC Tree node attributes and also performs compliance related
* verification checks in compliance mode. Note: In compliance mode you can
* skip the compliance checks by setting ignoreCompliance to "false".
*
* @param token
* a valid SSOToken
* @param entryDN
* the DN of the entry whose attributes need to retrieved
* @param attrNames
* a Set of names of the attributes that need to be retrieved.
* The attrNames should not be null.
* @param ignoreCompliance
* a boolean value specificying if compliance related entries
* need to ignored or not. Ignored if true.
* @return a Map containing attribute names as keys and Set of values
* corresponding to each key.
* @throws AMException
* if an error is encountered in fetching the attributes
*/
public Map getAttributesFromDS(SSOToken token, String entryDN, Set attrNames, boolean ignoreCompliance, boolean byteValues, int profileType) throws AMException, SSOException {
if (attrNames == null) {
return getAttributes(token, entryDN, ignoreCompliance, byteValues, profileType);
}
try {
// Convert the attrNames to String[]
String[] names = (String[]) attrNames.toArray(new String[attrNames.size()]);
PersistentObject po = UMSObject.getObjectHandle(token, new Guid(entryDN));
// Perform compliance related checks
AttrSet attrSet;
if (!ignoreCompliance && ComplianceServicesImpl.isComplianceUserDeletionEnabled()) {
// check for deleted user by getting complaince attributes
attrSet = complianceImpl.verifyAndGetAttributes(po, names);
} else {
attrSet = po.getAttributes(names);
}
AMHashMap attributes = (AMHashMap) CommonUtils.attrSetToMap(attrSet, byteValues);
// Obtain DC tree attributes if applicable
Map dcAttributes = getDCTreeAttributes(token, entryDN, attrNames, byteValues, profileType);
attributes.copy(dcAttributes);
return attributes;
} catch (UMSException e) {
if (debug.warningEnabled()) {
debug.warning("DirectoryServicesImpl.getAttributes(): " + "Unable to get attributes: ", e);
}
// Extract the ldap error code from Exception
throw new AMException(token, "330", e);
}
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class CallBackHelper method preProcess.
public Map preProcess(SSOToken token, String entryDN, String orgDN, Map oldAttrMap, Map newAttrMap, int operation, int objectType, boolean softDelete) throws AMException {
Set implSet = getPrePostImpls(orgDN);
if (implSet != null && !implSet.isEmpty()) {
// Post processing impls present
// Iterate through the Pre-Processing Impls and execute
Iterator itr = implSet.iterator();
while (itr.hasNext()) {
String className = (String) itr.next();
AMCallBack impl = getCallBackObject(className);
if (impl == null) {
continue;
}
try {
Map map;
switch(operation) {
case CREATE:
map = impl.preProcessCreate(token, entryDN, newAttrMap, objectType);
newAttrMap = ((map == null) ? newAttrMap : map);
break;
case MODIFY:
map = impl.preProcessModify(token, entryDN, oldAttrMap, newAttrMap, objectType);
newAttrMap = ((map == null) ? newAttrMap : map);
break;
case DELETE:
impl.preProcessDelete(token, entryDN, oldAttrMap, softDelete, objectType);
break;
}
} catch (AMException ae) {
// Exception thrown by the external impl
debug.error("CallBackHelper.preProcess(): Preprocessing" + "impl " + className + " exception thrown by impl:", ae);
throw ae;
}
}
return newAttrMap;
}
// not null as newAttrSet will be the latest one needed for updation
return ((newAttrMap != null) ? newAttrMap : oldAttrMap);
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class CallBackHelper method preProcess.
// TODO: Remove this. Use the Maps interface only
public AttrSet preProcess(SSOToken token, String entryDN, String orgDN, AttrSet oldAttrSet, AttrSet newAttrSet, int operation, int objectType, boolean softDelete) throws AMException {
Set implSet = getPrePostImpls(orgDN);
if (implSet != null && !implSet.isEmpty()) {
// Post processing impls present
// Iterate through the Pre-Processing Impls and execute
Iterator itr = implSet.iterator();
Map newAttrMap = CommonUtils.attrSetToMap(newAttrSet);
Map oldAttrMap = CommonUtils.attrSetToMap(oldAttrSet);
while (itr.hasNext()) {
String className = (String) itr.next();
AMCallBack impl = getCallBackObject(className);
if (impl == null) {
continue;
}
try {
Map map;
switch(operation) {
case CREATE:
map = impl.preProcessCreate(token, entryDN, newAttrMap, objectType);
newAttrMap = ((map == null) ? newAttrMap : map);
break;
case MODIFY:
map = impl.preProcessModify(token, entryDN, oldAttrMap, newAttrMap, objectType);
newAttrMap = ((map == null) ? newAttrMap : map);
break;
case DELETE:
impl.preProcessDelete(token, entryDN, oldAttrMap, softDelete, objectType);
break;
}
} catch (AMException ae) {
// Exception thrown by the external impl
debug.error("CallBackHelper.preProcess(): Preprocessing" + "impl " + className + " exception thrown by impl:", ae);
throw ae;
}
}
return CommonUtils.mapToAttrSet(newAttrMap);
}
// not null as newAttrSet will be the latest one needed for updation
return ((newAttrSet != null) ? newAttrSet : oldAttrSet);
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class CallBackHelper method postProcess.
public void postProcess(SSOToken token, String entryDN, String orgDN, Map oldAttrMap, Map newAttrMap, int operation, int objectType, boolean softDelete) throws AMException {
// Use the external impls instantiated at the time of pre-processing
Set implSet = getPrePostImpls(orgDN);
if ((implSet != null) && (!implSet.isEmpty())) {
// Iterate through the Pre-Processing Impls and execute
Iterator itr = implSet.iterator();
while (itr.hasNext()) {
String className = (String) itr.next();
AMCallBack impl = getCallBackObject(className);
if (impl == null) {
continue;
}
try {
switch(operation) {
case CREATE:
impl.postProcessCreate(token, entryDN, newAttrMap, objectType);
break;
case MODIFY:
impl.postProcessModify(token, entryDN, oldAttrMap, newAttrMap, objectType);
break;
case DELETE:
impl.postProcessDelete(token, entryDN, oldAttrMap, softDelete, objectType);
break;
}
} catch (AMException ae) {
// Exception thrown by the external impl
debug.error("CallBackHelper.postProcess(): Preprocessing" + "impl " + impl.getClass().getName() + " exception thrown: ", ae);
}
}
}
}
use of com.iplanet.am.sdk.AMException in project OpenAM by OpenRock.
the class OrgConfigViaAMSDK method setAttributes.
/**
* Sets attributes to AMSDK Organization. The organziation attribute names
* are defined in the IdRepo service.
*/
void setAttributes(Map attributes) throws SMSException {
Map amsdkAttrs = null;
// These attributes must be defined in ../idm/xml/idRepoService.xml
if (attributes != null && !attributes.isEmpty()) {
Map smsIdRepoAttrs = new CaseInsensitiveHashMap(attributes);
// Iterate through the attribute mappings
Map attrs = getAttributeMapping();
Map existingAttributes = getAttributes();
if (attrs != null && !attrs.isEmpty()) {
for (Iterator items = attrs.keySet().iterator(); items.hasNext(); ) {
String key = (String) items.next();
Set value = (Set) smsIdRepoAttrs.get(key);
if (value != null) {
if (amsdkAttrs == null) {
amsdkAttrs = new HashMap();
}
boolean notEmptyFlg = false;
if (!value.isEmpty()) {
for (Iterator iter = value.iterator(); iter.hasNext(); ) {
String val = (String) iter.next();
// Avoid empty string storage.
if (val.length() > 0) {
notEmptyFlg = true;
}
}
if (notEmptyFlg) {
amsdkAttrs.put(attrs.get(key), value);
}
} else {
Set existingValues = (Set) existingAttributes.get(key);
if (existingValues != null && !existingValues.isEmpty()) {
amsdkAttrs.put(attrs.get(key), value);
}
}
}
}
}
}
// Update the organization entry
if (amsdkAttrs != null) {
try {
parentOrg.setAttributes(amsdkAttrs);
parentOrg.store();
} catch (AMException ame) {
if (debug.messageEnabled()) {
debug.message("OrgConfigViaAMSDK::createSub" + "Organization: failed with AMException", ame);
}
throw (new SMSException(AMSDKBundle.BUNDLE_NAME, ame.getMessage(), ame, ame.getMessage()));
} catch (SSOException ssoe) {
throw (new SMSException(bundle.getString("sms-INVALID_SSO_TOKEN"), ssoe, "sms-INVALID_SSO_TOKEN"));
}
}
}
Aggregations