use of org.forgerock.openam.auditors.SMSAuditor in project OpenAM by OpenRock.
the class SMSEmbeddedLdapObject method delete.
/**
* Delete the entry in the directory. This will delete sub-entries also!
*/
public void delete(SSOToken token, String dn) throws SMSException, SSOException {
SMSAuditor auditor = newAuditor(token, dn, readCurrentState(dn));
// Check if there are sub-entries, delete if present
Iterator se = subEntries(token, dn, "*", 0, false, false).iterator();
while (se.hasNext()) {
String entry = (String) se.next();
if (debug.messageEnabled()) {
debug.message("SMSEmbeddedLdapObject: deleting sub-entry: " + entry);
}
delete(token, getNamingAttribute() + "=" + entry + "," + dn);
}
// Check if there are suborganizations, delete if present
// The recursive 'false' here has the scope SCOPE_ONE
// while searching for the suborgs.
// Loop through the suborg at the first level and if there
// is no next suborg, delete that.
Set subOrgNames = searchSubOrgNames(token, dn, "*", 0, false, false, false);
for (Iterator so = subOrgNames.iterator(); so.hasNext(); ) {
String subOrg = (String) so.next();
if (debug.messageEnabled()) {
debug.message("SMSEmbeddedLdapObject: deleting " + "suborganization: " + subOrg);
}
delete(token, subOrg);
}
DeleteOperation dop = icConn.processDelete(dn);
ResultCode resultCode = dop.getResultCode();
if (resultCode != ResultCode.SUCCESS) {
if (debug.warningEnabled()) {
debug.warning("SMSEmbeddedLdapObject.delete: " + "Unable to delete entry:" + dn);
}
throw (new SMSException("", "sms-entry-cannot-delete"));
}
objectChanged(dn, DELETE);
if (auditor != null) {
auditor.auditDelete();
}
}
use of org.forgerock.openam.auditors.SMSAuditor in project OpenAM by OpenRock.
the class SMSEmbeddedLdapObject method internalCreate.
/**
* Create an entry in the directory using the principal name
*/
private void internalCreate(SSOToken token, String dn, Map attrs) throws SMSException, SSOException {
SMSAuditor auditor = newAuditor(token, dn, null);
List attrList = copyMapToAttrList(attrs);
AddOperation ao = icConn.processAdd(dn, attrList);
ResultCode resultCode = ao.getResultCode();
if (resultCode == ResultCode.SUCCESS) {
if (debug.messageEnabled()) {
debug.message("SMSEmbeddedLdapObject.create: Successfully created" + " entry: " + dn);
}
if (auditor != null) {
auditor.auditCreate(attrs);
}
} else if (resultCode == ResultCode.ENTRY_ALREADY_EXISTS) {
// During install time and other times,
// this error gets throws due to unknown issue. Issue:
// Hence mask it.
debug.warning("SMSEmbeddedLdapObject.create: Entry " + "Already Exists Error for DN" + dn);
} else {
debug.error("SMSEmbeddedLdapObject.create: Error creating entry: " + dn + ", error code = " + resultCode);
throw new SMSException("", "sms-entry-cannot-create");
}
}
use of org.forgerock.openam.auditors.SMSAuditor in project OpenAM by OpenRock.
the class SMSEmbeddedLdapObject method modify.
/**
* Save the entry using the token provided. The principal provided will be
* used to get the proxy connection.
*/
public void modify(SSOToken token, String dn, ModificationItem[] mods) throws SMSException, SSOException {
SMSAuditor auditor = newAuditor(token, dn, readCurrentState(dn));
List modList = copyModItemsToLDAPModList(mods);
ModifyOperation mo = icConn.processModify(dn, modList);
ResultCode resultCode = mo.getResultCode();
if (resultCode == ResultCode.SUCCESS) {
if (debug.messageEnabled()) {
debug.message("SMSEmbeddedLdapObject.modify: Successfully " + "modified entry: " + dn);
}
if (auditor != null) {
auditor.auditModify(mods);
}
} else {
debug.error("SMSEmbeddedLdapObject.modify: Error modifying entry " + dn + " by Principal: " + token.getPrincipal().getName() + ", error code = " + resultCode);
throw new SMSException("", "sms-entry-cannot-modify");
}
}
Aggregations