Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LBAC-10 Added exception for Daemon thread user to access the methods covered with AOP Advices #13

Merged
merged 1 commit into from Jul 12, 2018

Conversation

@suthagar23
Copy link
Member

@suthagar23 suthagar23 commented Jul 11, 2018

Description

Added exception for Daemon thread to access the methods which are covered by AOP Advices in Location based access control. Then the daemon thread user will not have any restrictions to access the objects from different locations.

Ticket

Ticket : https://issues.openmrs.org/browse/LBAC-10

@@ -52,37 +52,37 @@ public Advice getAdvice() {

private class PatientSearchAdvise implements MethodInterceptor {
public Object invoke(MethodInvocation invocation) throws Throwable {
Integer sessionLocationId = Context.getUserContext().getLocationId();
String locationAttributeUuid = Context.getAdministrationService().getGlobalProperty(LocationBasedAccessConstants.LOCATION_ATTRIBUTE_GLOBAL_PROPERTY_NAME);
Object object = invocation.proceed();
Copy link
Member

@dkayiwa dkayiwa Jul 11, 2018

To avoid all these formatting changes, can't you just return object if daemon user? Then the rest of the code stays as is.

Copy link
Member Author

@suthagar23 suthagar23 Jul 12, 2018

The actual problem occurred at this point,
Integer sessionLocationId = Context.getUserContext().getLocationId();
daemon doesn't have any Location attribute. So that, I have cheked it before this line.

Copy link
Member

@dkayiwa dkayiwa Jul 12, 2018

Did you understand my comment?

Copy link
Member Author

@suthagar23 suthagar23 Jul 12, 2018

Yes got it @dkayiwa and Fixed

@@ -13,4 +13,5 @@
public class LocationBasedAccessConstants {

public static final String LOCATION_ATTRIBUTE_GLOBAL_PROPERTY_NAME = "locationbasedaccess.locationAttributeUuid";
public static final String DAEMON_USER_UUID = "A4F30A1B-5EB9-11DF-A648-37A07F9C90FB";
Copy link
Member

@dkayiwa dkayiwa Jul 12, 2018

Instead of duplicating this which is already in the Daemon class, can't we just use Daemon.isDaemonUser()?

Copy link
Member Author

@suthagar23 suthagar23 Jul 12, 2018

In the Daemon class, it was protected. So Can't use in outside.
In AppUI and EMRAPI also, we have defined this as a separate constant.

Copy link
Member

@dkayiwa dkayiwa Jul 12, 2018

Did you understand my alternative suggestion?

Copy link
Member Author

@suthagar23 suthagar23 Jul 12, 2018

Ya Ya, Got it now and changed the code.

Copy link
Member

@dkayiwa dkayiwa Jul 12, 2018

Have you tested again to confirm that all is well?

…covered with AOP Advices

LBAC-10 Added exception for Daemon thread user to access the methods covered with AOP Advices
@dkayiwa dkayiwa merged commit dc1f254 into master Jul 12, 2018
2 checks passed
@suthagar23 suthagar23 deleted the LBAC-10 branch Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants