class LdapEntryPoisoningDetector extends OpcodeStackDetector {

    private String LDAP_ENTRY_POISONING = "LDAP_ENTRY_POISONING";

    private static final InvokeMatcherBuilder PATTERN_SEARCH_CONTROLS_INIT = invokeInstruction() //
            .atClass("javax/naming/directory/SearchControls") //
            .atMethod("<init>").withArgs("(IJI[Ljava/lang/String;ZZ)V");
    private static final InvokeMatcherBuilder PATTERN_SEARCH_CONTROLS_SETTER = invokeInstruction() //
            .atClass("javax/naming/directory/SearchControls") //
            .atMethod("setReturningObjFlag").withArgs("(Z)V");

    private BugReporter bugReporter;

    public LdapEntryPoisoningDetector(BugReporter bugReporter) {
        this.bugReporter = bugReporter;
    }

    @Override
    public void sawOpcode(int seen) {<FILL_FUNCTION_BODY>}
}


        boolean shouldReportBug = false;

        if(seen == INVOKESPECIAL) {
            if(PATTERN_SEARCH_CONTROLS_INIT.matches(this)) {
                OpcodeStack.Item item = stack.getStackItem(1);
                Object param = item.getConstant();
                shouldReportBug = param instanceof Integer && Integer.valueOf(1).equals(param);
            }
        }
        else if(seen == INVOKEVIRTUAL) {
            if(PATTERN_SEARCH_CONTROLS_SETTER.matches(this)) {
                OpcodeStack.Item item = stack.getStackItem(0);
                Object param = item.getConstant();
                shouldReportBug = param instanceof Integer && Integer.valueOf(1).equals(param);
            }
        }

        if(shouldReportBug) {

            bugReporter.reportBug(new BugInstance(this, LDAP_ENTRY_POISONING, Priorities.NORMAL_PRIORITY) //
                    .addClass(this).addMethod(this).addSourceLine(this));
        }

    
<no_super_class>