Search in sources :

Example 6 with AuthZ

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

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

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

the class AuditMgrConsole method printAuthZs.

/**
 * @param list
 */
void printAuthZs(List<AuthZ> list) {
    ReaderUtil.clearScreen();
    if (list != null && list.size() > 0) {
        int ctr = 0;
        for (AuthZ authZ : list) {
            /*
            public class AuthZ
            {
                private String createTimestamp;
                private String creatorsName;
                private String entryCSN;
                private String entryDN;
                private String entryUUID;
                private String hasSubordinates;
                private String modifiersName;
                private String modifyTimestamp;
                private String objectClass;
                private String reqAttr;
                private String reqAttrsOnly;
                private String reqAuthzID;
                private String reqControls;
                private String reqDN;
                private String reqDerefAliases;
                private String reqEnd;
                private String reqEntries;
                private String reqFilter;
                private String reqResult;
                private String reqScope;
                private String reqSession;
                private String reqSizeLimit;
                private String reqStart;
                private String reqTimeLimit;
                private String reqType;
                private String structuralObjectClass;
                private String subschemaSubentry;
                */
            System.out.println("AUDIT AUTHZ OBJECT [" + ctr++ + "]:");
            System.out.println("    reqAuthzID               [" + authZ.getReqAuthzID() + "]");
            System.out.println("    reqDN                    [" + authZ.getReqDN() + "]");
            System.out.println("    reqFilter                [" + authZ.getReqFilter() + "]");
            System.out.println("    reqEntries               [" + authZ.getReqEntries() + "]");
            System.out.println("    reqStart                 [" + authZ.getReqStart() + "]");
            System.out.println("    reqEnd                   [" + authZ.getReqEnd() + "]");
            System.out.println("    createTimestamp          [" + authZ.getCreateTimestamp() + "]");
            System.out.println("    creatorsName             [" + authZ.getCreatorsName() + "]");
            System.out.println("    entryCSN                 [" + authZ.getEntryCSN() + "]");
            System.out.println("    entryDN                  [" + authZ.getEntryDN() + "]");
            System.out.println("    entryUUID                [" + authZ.getEntryUUID() + "]");
            System.out.println("    hasSubordinates          [" + authZ.getHasSubordinates() + "]");
            System.out.println("    modifiersName            [" + authZ.getModifiersName() + "]");
            System.out.println("    modifyTimestamp          [" + authZ.getModifyTimestamp() + "]");
            System.out.println("    objectClass              [" + authZ.getObjectClass() + "]");
            System.out.println("    reqControls              [" + authZ.getReqControls() + "]");
            System.out.println("    reqResult                [" + authZ.getReqResult() + "]");
            System.out.println("    reqSession               [" + authZ.getReqSession() + "]");
            System.out.println("    reqType                  [" + authZ.getReqType() + "]");
            System.out.println("    structuralObjectClass    [" + authZ.getStructuralObjectClass() + "]");
            System.out.println("    reqAttr                  [" + authZ.getReqAttr() + "]");
            System.out.println("    reqAttrsOnly             [" + authZ.getReqAttrsOnly() + "]");
            System.out.println("    reqDerefAliases          [" + authZ.getReqDerefAliases() + "]");
            System.out.println("    reqScope                 [" + authZ.getReqScope() + "]");
            System.out.println("    reqSizeLimit             [" + authZ.getReqSizeLimit() + "]");
            System.out.println("    reqTimeLimit             [" + authZ.getReqTimeLimit() + "]");
        }
    } else {
        System.out.println("AuthZ list empty");
    }
}
Also used : AuthZ(org.apache.directory.fortress.core.model.AuthZ)

Example 9 with AuthZ

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

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

AuthZ (org.apache.directory.fortress.core.model.AuthZ)17 UserAudit (org.apache.directory.fortress.core.model.UserAudit)7 SecurityException (org.apache.directory.fortress.core.SecurityException)6 Date (java.util.Date)4 ArrayList (java.util.ArrayList)3 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)3 SearchCursor (org.apache.directory.api.ldap.model.cursor.SearchCursor)3 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)3 AuditMgr (org.apache.directory.fortress.core.AuditMgr)3 FinderException (org.apache.directory.fortress.core.FinderException)3 FortRequest (org.apache.directory.fortress.core.model.FortRequest)3 FortResponse (org.apache.directory.fortress.core.model.FortResponse)3 LdapConnection (org.apache.directory.ldap.client.api.LdapConnection)3 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 User (org.apache.directory.fortress.core.model.User)2 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)1 ObjectFactory (org.apache.directory.fortress.core.model.ObjectFactory)1 Permission (org.apache.directory.fortress.core.model.Permission)1