in Education by
We are using MyBatis 3.0.3 & Spring 3.0.5 in our project. We are trying to implement data level security through a table which stores where clauses (userid < 200, active == true, ...). So, the problem comes when we want to add a clause to a select query dinamically in execution time. We are thinking about the possibility of using Spring AOP but we are not sure if it is possible or not, if it is a good solution and appart from that we don't know how to implement it. Please share your thoughts. Thanks in advance, Silvia. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I think this is possible. Implement the service layer so you can fetch the user (userID) via the security context (Spring security) or you can also give the user as a parameter in your service layer methodes. An example of a possible Aspect implementation: @Aspect public class MyAspect { @Pointcut("within(my.package.MyClass)") public void pointcutClass() { } @Pointcut("execution(* create*(..))") public void pointcutMethod() { } @Pointcut("pointcutClass() && pointcutMethod()") public void myPointcut() { } @Before("myPointcut()") public void checkAuthorization(final JoinPoint joinPoint) { // Fetch User via spring security: Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); if (principal == null) throw new Exception("No principal found"); if (!(principal instanceof User)) { throw new Exception("principal is not a User"); } User user = (User) principal; // Or fetch User via the joinPoint: Object[] args = joinPoint.getArgs(); User user = (User) args[0] if (user.getUserId == null || user.getUserId > 200) throw new Exception("User is not authorised."); }

Related questions

0 votes
    Which command clauses is used to delete tuples from a database table? Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    I have a search method that takes a list of ID's and I wish to restrict the query based on the ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    What are some common clauses used with SELECT query in SQL?...
asked Dec 9, 2020 in Technology by JackTerrance
0 votes
    I have a blade template that creates a form. The form uses a foreach loop to iterate through a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
0 votes
    I have a blade template that creates a form. The form uses a foreach loop to iterate through a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 22, 2022 in Education by JackTerrance
0 votes
    What does stack overflow' refer to? a. accessing item from an undefined stack b. index out of bounds exception ... from an empty stack Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    What does stack overflow' refer to? a. accessing item from an undefined stack b. index out of bounds exception ... from an empty stack Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    can i actually see the locally created Sql light databases .? for example: where does chrome stores them ? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    can i actually see the locally created Sql light databases .? for example: where does chrome stores them ? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    In a database where the encryption is applied the data is cannot be handled by the unauthorised user ... Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    The primary medium for the long-term online storage of data is the __________ where the entire database is ... topic in portion Storage and File Structures of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    _____ is a process of verifying transactions, bundling them into blocks, and adding those blocks to the blockchain. A. Mining B. Digging C. Filtering D. Coding...
asked Nov 23, 2022 in Education by JackTerrance
0 votes
    I found found several question's answers similar to this, I tried some of them, but no luck. May ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I found found several question's answers similar to this, I tried some of them, but no luck. May ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I am trying to add controls to a simple jquery carousel however I am not sure of how to do that. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 26, 2022 in Education by JackTerrance
...