List getAllAuthZs()

in src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java [410:478]


    List<AuthZ> getAllAuthZs( UserAudit audit ) throws FinderException
    {
        List<AuthZ> auditList = new ArrayList<>();
        LdapConnection ld = null;
        String auditRoot = Config.getInstance().getProperty( AUDIT_ROOT );
        String userRoot = getRootDn( audit.getContextId(), GlobalIds.USER_ROOT );

        try
        {
            String filter = GlobalIds.FILTER_PREFIX + ACCESS_AUTHZ_CLASS_NM + ")(";

            if ( audit.getUserId() != null && audit.getUserId().length() > 0 )
            {
                filter += REQUAUTHZID + "=" + SchemaConstants.UID_AT + "=" + audit.getUserId() + "," + userRoot + ")";
            }
            else
            {
                // have to limit the query to only authorization entries.
                // TODO: determine why the cn=Manager user is showing up in this search:
                filter += REQUAUTHZID + "=*)(!(" + REQUAUTHZID + "=cn=Manager," + Config.getInstance().getProperty( GlobalIds.SUFFIX )
                    + "))";

                // TODO: fix this so filter by only the Fortress AuthZ entries and not the others:
                if ( audit.isFailedOnly() )
                {
                    filter += "(" + REQRESULT + "=" + GlobalIds.AUTHZ_COMPARE_FAILURE_FLAG + ")";
                }
            }

            if ( audit.getBeginDate() != null )
            {
                String szTime = TUtil.encodeGeneralizedTime( audit.getBeginDate() );
                filter += "(" + REQEND + ">=" + szTime + ")";
            }
            filter += ")";
            //log.warn("filter=" + filter);
            ld = getLogConnection();
            try ( SearchCursor searchResults = search( ld, auditRoot,
                SearchScope.ONELEVEL, filter, AUDIT_AUTHZ_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
            {
                long sequence = 0;
                while ( searchResults.next() )
                {
                    auditList.add( getAuthzEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
                }
            }
            catch ( IOException i )
            {
                String error = "IOException in AuditDAO.getAllAuthZs id=" + i.getMessage();
                throw new FinderException( GlobalErrIds.AUDT_AUTHZ_SEARCH_FAILED, error, i );
            }
            catch ( CursorException e )
            {
                String error = "CursorException in AuditDAO.getAllAuthZs id=" + e.getMessage();
                throw new FinderException( GlobalErrIds.AUDT_AUTHZ_SEARCH_FAILED, error, e );
            }
        }
        catch ( LdapException e )
        {
            String error = "LdapException in AuditDAO.getAllAuthZs id=" + e;
            throw new FinderException( GlobalErrIds.AUDT_AUTHZ_SEARCH_FAILED, error, e );
        }
        finally
        {
            closeLogConnection( ld );
        }

        return auditList;
    }