class LdapAuthorizationPolicy implements AuthorizationPolicy {

    private static final Logger Log = LoggerFactory.getLogger(LdapAuthorizationPolicy.class) ;

    private LdapManager manager;
    private String usernameField;
    private String authorizeField;

    public LdapAuthorizationPolicy() {
        // Convert XML based provider setup to Database based
        JiveGlobals.migrateProperty("ldap.authorizeField");

        manager = LdapManager.getInstance();
        usernameField = manager.getUsernameField();
        authorizeField = JiveGlobals.getProperty("ldap.authorizeField", "k5login");
    }

    /**
     * Returns true if the provided XMPP authentication identity (identity whose password will be used) is explicitly
     * allowed to the provided XMPP authorization identity (identity to act as).
     *
     * @param authzid XMPP authorization identity (identity to act as).
     * @param authcid XMPP authentication identity, or 'principal' (identity whose password will be used)
     * @return true if the authzid is explicitly allowed to be used by the user authenticated with the authcid.
     */
    @Override
    public boolean authorize(String authzid, String authcid) {
        return getAuthorized(authzid).contains(authcid);
    }

    /**
     * Returns a collection of XMPP authentication identities (or 'principals') that are authorized to use the XMPP
     * authorization identity (identity to act as) as provided in the argument of this method.
     *
     * @param authzid XMPP authorization identity (identity to act as).
     * @return A collection of XMPP authentication identities (or 'principals') that are authorized to use the authzid
     */
    private Collection<String> getAuthorized(String authzid) {<FILL_FUNCTION_BODY>}

    /**
     * Returns the short name of the Policy
     *
     * @return The short name of the Policy
     */
    @Override
    public String name() {
        return "LDAP Authorization Policy";
    }

    /**
     * Returns a description of the Policy
     *
     * @return The description of the Policy.
     */
    @Override
    public String description() {
        return "Provider for authorization using LDAP. Checks if the authentication identity, or 'principal' (identity" +
            " whose password will be used) is in the user's LDAP object using the authorizeField property.";
    }
}

        // Un-escape Node
        authzid = JID.unescapeNode(authzid);

        Collection<String> authorized = new ArrayList<>();
        DirContext ctx = null;
        try {
            Rdn[] userRDN = manager.findUserRDN(authzid);
            // Load record.
            String[] attributes = new String[]{
                    usernameField,
                    authorizeField
            };
            ctx = manager.getContext();
            Attributes attrs = ctx.getAttributes(LdapManager.escapeForJNDI(userRDN), attributes);
            Attribute authorizeField_a = attrs.get(authorizeField);
            if (authorizeField_a != null) {
                for (Enumeration e = authorizeField_a.getAll(); e.hasMoreElements();) {
                    authorized.add((String)e.nextElement());
                }
            }

            return authorized;
        }
        catch (Exception ex) {
            Log.debug("An exception occurred while trying to retrieve authorized principals for user {}.", authzid, ex);
        }
        finally {
            try {
                if (ctx != null) {
                    ctx.close();
                }
            }
            catch (Exception ex) {
                Log.debug("An exception occurred while trying to close a LDAP context after trying to retrieve authorized principals for user {}.", authzid, ex);
            }
        }
        return authorized;
    
<no_super_class>