Search in sources :

Example 1 with UserAudit

use of org.apache.directory.fortress.core.model.UserAudit 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 UserAudit

use of org.apache.directory.fortress.core.model.UserAudit 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 UserAudit

use of org.apache.directory.fortress.core.model.UserAudit 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 UserAudit

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

the class AuditMgrConsole method getAuthNInvalidReport.

void getAuthNInvalidReport() {
    ReaderUtil.clearScreen();
    try {
        UserAudit uAudit = new UserAudit();
        System.out.println("Enter userId to search Audit AuthZs with:");
        String val = ReaderUtil.readLn();
        if (StringUtils.isNotEmpty(val)) {
            uAudit.setUserId(val);
            System.out.println("size=" + val.length() + " val=" + val);
        } else {
            System.out.println("val is empty or null");
        }
        // uAudit.setUserId(val);
        // System.out.println("Check for failed only? (Enter 'Y' for yes or 'N' for no");
        // val = ReaderUtil.readLn();
        // if (val.equalsIgnoreCase("Y"))
        uAudit.setFailedOnly(true);
        System.out.println("Check within the last n hours?  Enter number of hours or null for unlimited");
        val = ReaderUtil.readLn();
        if (val != null && val.length() > 0) {
            int hours = Integer.parseInt(val);
            Date date = new Date();
            long millis = date.getTime();
            millis = millis - (1000 * 60 * 60 * hours);
            Date date2 = new Date(millis);
            uAudit.setBeginDate(date2);
        }
        List<AuthZ> list = am.searchInvalidUsers(uAudit);
        printfailedAuthNReport(list);
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("getAuthNInvalidReport caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}
Also used : UserAudit(org.apache.directory.fortress.core.model.UserAudit) AuthZ(org.apache.directory.fortress.core.model.AuthZ) Date(java.util.Date)

Example 5 with UserAudit

use of org.apache.directory.fortress.core.model.UserAudit 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)

Aggregations

UserAudit (org.apache.directory.fortress.core.model.UserAudit)14 AuthZ (org.apache.directory.fortress.core.model.AuthZ)7 AuditMgr (org.apache.directory.fortress.core.AuditMgr)6 SecurityException (org.apache.directory.fortress.core.SecurityException)6 Date (java.util.Date)5 User (org.apache.directory.fortress.core.model.User)5 Mod (org.apache.directory.fortress.core.model.Mod)4 Bind (org.apache.directory.fortress.core.model.Bind)3