Search in sources :

Example 11 with AuthZ

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

the class AuditMgrConsole method printAuthZReport.

/**
 * @param list
 */
void printAuthZReport(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("**********************************");
            System.out.println("AUTHORIZATION AUDIT RECORD " + ctr++);
            System.out.println("***************************************");
            Date aDate = null;
            try {
                aDate = TUtil.decodeGeneralizedTime(authZ.getReqEnd());
            } catch (ParseException pe) {
                System.out.println("    Access Time    " + "ParseException=" + pe.getMessage());
            }
            if (aDate != null) {
                SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
                String formattedDate = formatter.format(aDate);
                System.out.println("    Access Time     " + formattedDate);
            }
            System.out.println("    userId          " + AuditUtil.getAuthZId(authZ.getReqAuthzID()));
            try {
                Permission pOp = getAuthZPerm(authZ);
                System.out.println("    Resource Name   " + pOp.getObjName());
                System.out.println("    Operation       " + pOp.getOpName());
                int rCtr = 0;
                if (pOp.getRoles() != null) {
                    // TODO: fix the NPE that happens here:
                    System.out.println("    Success?        " + authZ.getReqEntries().equals(GlobalIds.AUTHZ_COMPARE_FAILURE_FLAG));
                    for (String role : pOp.getRoles()) {
                        System.out.println("    Role[" + rCtr++ + "]         " + role);
                    }
                }
            } catch (LdapInvalidDnException e) {
                System.out.println("LdapInvalidDnException=" + e);
            }
            // System.out.println("    reqStart        [" + authZ.getReqStart() + "]");
            // System.out.println("    reqEnd          [" + authZ.getReqEnd() + "]");
            System.out.println();
            System.out.println();
        // System.out.println("**********************************");
        }
    } else {
        System.out.println("AuthZ list empty");
    }
}
Also used : AuthZ(org.apache.directory.fortress.core.model.AuthZ) Permission(org.apache.directory.fortress.core.model.Permission) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LdapInvalidDnException(org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)

Example 12 with AuthZ

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

the class AuditMgrConsole method getAuthReport.

/**
 */
void getAuthReport() {
    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.getUserAuthZs(uAudit);
        printAuthZReport(list);
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("getAuthReport 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 13 with AuthZ

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

the class AuditMgrConsole method findAuthZs.

/**
 */
void findAuthZs() {
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter object name to search Audit AuthZs with:");
        String val = ReaderUtil.readLn();
        UserAudit uAudit = new UserAudit();
        uAudit.setObjName(val);
        System.out.println("Enter operation name to search Audit AuthZs with:");
        val = ReaderUtil.readLn();
        uAudit.setOpName(val);
        System.out.println("Enter userId to search Audit AuthZs with:");
        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);
        List<AuthZ> list = am.searchAuthZs(uAudit);
        printAuthZs(list);
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("findAuthZs 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)

Example 14 with AuthZ

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

the class AuditMgrConsole method getAuthZs.

/**
 */
void getAuthZs() {
    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");
        }
        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);
        List<AuthZ> list = am.getUserAuthZs(uAudit);
        printAuthZs(list);
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("getUserAuthZs 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)

Example 15 with AuthZ

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

the class AuditMgrConsole method printfailedAuthNReport.

void printfailedAuthNReport(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("**********************************");
            System.out.println("FAILED AUTHENTICATIONS AUDIT RECORD " + ctr++);
            System.out.println("***************************************");
            Date aDate = null;
            try {
                aDate = TUtil.decodeGeneralizedTime(authZ.getReqEnd());
            } catch (ParseException pe) {
                System.out.println("    Access Time    " + "ParseException=" + pe.getMessage());
            }
            if (aDate != null) {
                SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
                String formattedDate = formatter.format(aDate);
                System.out.println("    Access Time     " + formattedDate);
            }
            System.out.println("    userId          " + AuditUtil.getAuthZId(authZ.getReqDN()));
            System.out.println("    Success?        " + authZ.getReqEntries().equals("1"));
            System.out.println("    reqDN           " + authZ.getReqDN());
            System.out.println();
            System.out.println();
        }
    } else {
        System.out.println("AuthZ list empty");
    }
}
Also used : AuthZ(org.apache.directory.fortress.core.model.AuthZ) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

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