Search in sources :

Example 1 with AuditMgr

use of org.apache.directory.fortress.core.AuditMgr in project directory-fortress-core by apache.

the class AuditMgrImplTest method searchBinds.

/**
 * @param msg
 * @param uArray
 */
private static void searchBinds(String msg, String[][] uArray) {
    LogUtil.logIt(msg);
    try {
        AuditMgr auditMgr = getManagedAuditMgr();
        for (String[] usr : uArray) {
            User user = UserTestData.getUser(usr);
            // now search for successful authentications:
            UserAudit uAudit = new UserAudit();
            uAudit.setUserId(user.getUserId());
            uAudit.setFailedOnly(false);
            List<Bind> binds = auditMgr.searchBinds(uAudit);
            assertNotNull(binds);
            assertTrue(CLS_NM + "searchBinds failed search for successful authentication user [" + user.getUserId() + "]", binds.size() > 0);
            // now search for failed authentications:
            uAudit.setFailedOnly(true);
            binds = auditMgr.searchBinds(uAudit);
            assertNotNull(binds);
            assertTrue(CLS_NM + "searchBinds failed search for failed authentication user [" + user.getUserId() + "]", binds.size() > 0);
        }
        LOG.debug("searchBinds successful");
    } catch (SecurityException ex) {
        LOG.error("searchBinds: failed with SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : Bind(org.apache.directory.fortress.core.model.Bind) User(org.apache.directory.fortress.core.model.User) UserAudit(org.apache.directory.fortress.core.model.UserAudit) AuditMgr(org.apache.directory.fortress.core.AuditMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 2 with AuditMgr

use of org.apache.directory.fortress.core.AuditMgr in project directory-fortress-core by apache.

the class AuditMgrImplTest method getAuthZs.

/**
 * @param msg
 * @param uArray
 */
private static void getAuthZs(String msg, String[][] uArray) {
    LogUtil.logIt(msg);
    try {
        AuditMgr auditMgr = getManagedAuditMgr();
        for (String[] usr : uArray) {
            User user = UserTestData.getUser(usr);
            // now search for successful authentications:
            UserAudit uAudit = new UserAudit();
            uAudit.setUserId(user.getUserId());
            uAudit.setFailedOnly(false);
            List<AuthZ> authZs = auditMgr.getUserAuthZs(uAudit);
            assertNotNull(authZs);
            assertTrue(CLS_NM + "getUserAuthZs failed search for successful authorization user [" + user.getUserId() + "]", authZs.size() > 0);
            // now search for failed authentications:
            uAudit.setFailedOnly(true);
            authZs = auditMgr.getUserAuthZs(uAudit);
            assertNotNull(authZs);
            assertTrue(CLS_NM + "getUserAuthZs failed search for failed authorization user [" + user.getUserId() + "]", authZs.size() > 0);
        }
        LOG.debug("getUserAuthZs successful");
    } catch (SecurityException ex) {
        LOG.error("getUserAuthZs: failed with SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : User(org.apache.directory.fortress.core.model.User) UserAudit(org.apache.directory.fortress.core.model.UserAudit) AuthZ(org.apache.directory.fortress.core.model.AuthZ) AuditMgr(org.apache.directory.fortress.core.AuditMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 3 with AuditMgr

use of org.apache.directory.fortress.core.AuditMgr in project directory-fortress-core by apache.

the class AuditMgrImplTest method searchAuthZs.

/**
 * @param msg
 * @param uArray
 */
private static void searchAuthZs(String msg, String[][] uArray, String[][] oArray, String[][] opArray, boolean failedOnly) {
    LogUtil.logIt(msg);
    try {
        AuditMgr auditMgr = getManagedAuditMgr();
        for (String[] usr : uArray) {
            User user = UserTestData.getUser(usr);
            // now search for successful authentications:
            UserAudit uAudit = new UserAudit();
            uAudit.setUserId(user.getUserId());
            uAudit.setFailedOnly(false);
            for (String[] obj : oArray) {
                uAudit.setObjName(PermTestData.getName(obj));
                for (String[] op : opArray) {
                    uAudit.setOpName(PermTestData.getName(op));
                    uAudit.setObjId(PermTestData.getObjId(op));
                    uAudit.setFailedOnly(failedOnly);
                    List<AuthZ> authZs = auditMgr.searchAuthZs(uAudit);
                    assertNotNull(authZs);
                    assertTrue(CLS_NM + "searchAuthZs failedOnly=" + failedOnly + ", search authorizations user [" + user.getUserId() + "], objName [" + uAudit.getObjName() + "], opName [" + uAudit.getOpName() + "], objId [" + uAudit.getObjId() + "]", authZs.size() > 0);
                }
            }
        }
        LOG.debug("searchAuthZs successful");
    } catch (SecurityException ex) {
        LOG.error("searchAuthZs: failed with SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : User(org.apache.directory.fortress.core.model.User) UserAudit(org.apache.directory.fortress.core.model.UserAudit) AuthZ(org.apache.directory.fortress.core.model.AuthZ) AuditMgr(org.apache.directory.fortress.core.AuditMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 4 with AuditMgr

use of org.apache.directory.fortress.core.AuditMgr in project directory-fortress-core by apache.

the class AuditMgrImplTest method searchAuthNInvalid.

/**
 * @param msg
 */
private static void searchAuthNInvalid(String msg) {
    LogUtil.logIt(msg);
    try {
        AuditMgr auditMgr = getManagedAuditMgr();
        UserAudit uAudit = new UserAudit();
        List<AuthZ> resultSet = auditMgr.searchInvalidUsers(uAudit);
        assertNotNull(resultSet);
        assertTrue(CLS_NM + "searchInvalidUsers failed search for invalid authentications", resultSet.size() > 0);
        LOG.debug("searchInvalidUsers successful");
    } catch (SecurityException ex) {
        LOG.error("searchInvalidUsers: failed with SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : UserAudit(org.apache.directory.fortress.core.model.UserAudit) AuthZ(org.apache.directory.fortress.core.model.AuthZ) AuditMgr(org.apache.directory.fortress.core.AuditMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Example 5 with AuditMgr

use of org.apache.directory.fortress.core.AuditMgr in project directory-fortress-core by apache.

the class AuditMgrImplTest method searchMods.

/**
 * @param msg
 * @param uArray
 */
private static void searchMods(String msg, String[][] uArray) {
    LogUtil.logIt(msg);
    try {
        AuditMgr auditMgr = getManagedAuditMgr();
        for (String[] usr : uArray) {
            User user = UserTestData.getUser(usr);
            // now search for successful session creation events:
            UserAudit uAudit = new UserAudit();
            uAudit.setUserId(user.getUserId());
            uAudit.setFailedOnly(false);
            List<Mod> mods = auditMgr.searchUserSessions(uAudit);
            assertNotNull(mods);
            assertTrue(CLS_NM + "searchUserSessions failed search for successful authentication user [" + user.getUserId() + "]", mods.size() > 0);
        }
        LOG.debug("searchUserSessions successful");
    } catch (SecurityException ex) {
        LOG.error("searchUserSessions: failed with SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
        fail(ex.getMessage());
    }
}
Also used : User(org.apache.directory.fortress.core.model.User) Mod(org.apache.directory.fortress.core.model.Mod) UserAudit(org.apache.directory.fortress.core.model.UserAudit) AuditMgr(org.apache.directory.fortress.core.AuditMgr) SecurityException(org.apache.directory.fortress.core.SecurityException)

Aggregations

AuditMgr (org.apache.directory.fortress.core.AuditMgr)6 SecurityException (org.apache.directory.fortress.core.SecurityException)6 UserAudit (org.apache.directory.fortress.core.model.UserAudit)6 User (org.apache.directory.fortress.core.model.User)5 AuthZ (org.apache.directory.fortress.core.model.AuthZ)3 Mod (org.apache.directory.fortress.core.model.Mod)2 Bind (org.apache.directory.fortress.core.model.Bind)1