Need help on RegEx Java

Viewed 49

My scenario is, want to restrict users to SELECT some specific table and some specific columns, below is the Java code

--- The below Regex IF will restrict the access when a user tries to use the "PASSWORD" column in their query

if (sourceCode.matches("(?i:PASSWORD.*)")) {
            return "ACCESS DENIED";

--- Need help on this scenario, when the source code has the "users" table, we need to look if all the columns are selected from the table -- ie., consider if the table is given with an alias like (select a.* from users a), -- then we need to verify if a.* is used or specific column is selected (we can ignore if specific column is selected)

if (sourceCode.matches("(?i:users.*)")) {
    ???<LOGIC??>???
    }

Also please let me know if this scenario can be achieved with Java methods like find(), etc.,

thank you.

0 Answers
Related