Search in sources :

Example 1 with SMSAuditor

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();
    }
}
Also used : SMSAuditor(org.forgerock.openam.auditors.SMSAuditor) DeleteOperation(org.opends.server.core.DeleteOperation) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) ResultCode(org.forgerock.opendj.ldap.ResultCode)

Example 2 with SMSAuditor

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");
    }
}
Also used : SMSAuditor(org.forgerock.openam.auditors.SMSAuditor) SMSException(com.sun.identity.sm.SMSException) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) AddOperation(org.opends.server.core.AddOperation) ResultCode(org.forgerock.opendj.ldap.ResultCode)

Example 3 with SMSAuditor

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");
    }
}
Also used : SMSAuditor(org.forgerock.openam.auditors.SMSAuditor) SMSException(com.sun.identity.sm.SMSException) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ModifyOperation(org.opends.server.core.ModifyOperation) ResultCode(org.forgerock.opendj.ldap.ResultCode)

Aggregations

SMSException (com.sun.identity.sm.SMSException)3 SMSAuditor (org.forgerock.openam.auditors.SMSAuditor)3 ResultCode (org.forgerock.opendj.ldap.ResultCode)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 AddOperation (org.opends.server.core.AddOperation)1 DeleteOperation (org.opends.server.core.DeleteOperation)1 ModifyOperation (org.opends.server.core.ModifyOperation)1