-
Notifications
You must be signed in to change notification settings - Fork 545
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
Add XACML DAO Interfaces #5686
Add XACML DAO Interfaces #5686
Conversation
PR builder started |
@@ -369,9 +370,6 @@ public void removePolicy(String policyId, boolean dePromote) throws EntitlementE | |||
} | |||
handleStatus(EntitlementConstants.StatusTypes.DELETE_POLICY, oldPolicy, true, null); | |||
|
|||
//remove versions | |||
EntitlementAdminEngine.getInstance().getVersionManager().deletePolicy(policyId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Policy versioning is removed from this layer and moved to DAO level impl (PolicyDAO.removePolicy()
) itself. Validate whether this is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be ok, since PolicyDAO.removePolicy()
only get called from here.
@@ -764,12 +763,6 @@ private void addOrUpdatePolicy(PolicyDTO policyDTO, boolean isAdd) throws Entitl | |||
} else { | |||
throw new EntitlementException("Unsupported Entitlement Policy. Policy can not be parsed"); | |||
} | |||
try { | |||
String version = versionManager.createVersion(policyDTO); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Policy versioning is removed from this layer and moved to DAO level impl (PolicyDAO.addOrUpdatePolicy()
) itself. Validate whether this is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PAPPolicyStoreManager.addOrUpdatePolicy()
getting called from three other places.
EntitlementUtil.addFilesystemPolicy()
behaves similarly like here.
ie: Creating new version removed from the method impl and new version creation now handled in PolicyDAO.addOrUpdatePolicy().
But two other places (mentioned below) does not creates a version as of now. But with the proposed change it will creates a new version.
EntitlementPolicyAdminService.orderPolicy()
EntitlementPolicyAdminService.enableDisablePolicy()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This causes a behavioral change where a new policy version is created when updating the policy order or enabling/disabling a published policy from PDP. New versions should not be created for such minor adjustments. To address, we can make versioning a conditional process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made versioning in addOrUpdatePolicy
conditional.
PR builder completed |
PAPPolicyStoreReader reader = new PAPPolicyStoreReader(policyStore); | ||
policyDTO = reader.readPolicyDTO(policyDTO.getPolicyId()); | ||
|
||
if (Boolean.parseBoolean(System.getProperty(ENHANCED_XACML_LOADING_SYSTEM_PROPERTY)) && promote) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing Boolean.parseBoolean(System.getProperty(ENHANCED_XACML_LOADING_SYSTEM_PROPERTY)
intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current impl works as if property ENHANCED_XACML_LOADING_SYSTEM_PROPERTY
was true. Earlier behavior where when this property is false, in addition to policy being published to PDP, a subscriber event being published is missed.
See EntitlementUtil.addPolicyToPDP()
. Must check if this is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the called method executes a version store update, which was not initially triggered in this flow. Perhaps versioning should be conditional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the usage, removing this doesn't seem to have much impact, since the flow works by publishing the policy to pdp.
|
||
if (properties.getProperty("PDP.Policy.Store.Module") != null) { | ||
String className = properties.getProperty("PDP.Policy.Store.Module"); | ||
Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className); | ||
policyStoreStore = (PolicyStoreManageModule) clazz.newInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PDP.Policy.Store.Module
type used to be PolicyStoreManageModule
but with this change its needs to be the type PolicyDAO
.
PolicyAttributeBuilder policyAttributeBuilder = new PolicyAttributeBuilder(); | ||
dto.setAttributeDTOs(policyAttributeBuilder. | ||
getPolicyMetaDataFromRegistryProperties(resource.getProperties())); | ||
dto.setPolicy(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to validate, whether this approach (pulling the policy from the database and setting the policy as null in the runtime) will actually serve the purpose of building "Light weight" policy DTO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer #5686 (comment)
|
||
dto.setPolicyEditor(resource.getProperty(PDPConstants.POLICY_EDITOR_TYPE)); | ||
|
||
dto.setPolicy(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to validate, whether this approach (pulling the policy from the database and setting the policy as null in the runtime) will actually serve the purpose of building "Light weight" policy DTO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously also we anyway load the full resource from registry and only set a subset of the attributes in the DTO. Since we are loading the full object, with regards to registry impl there might not be a considerable performance hit. But we could optimize this by only querying the required data in the db impl to be introduced later, but this will be a complexity overhead.
So, IMO it won't have much of a performance hit.
* | ||
* @return whether supported or not | ||
*/ | ||
public boolean isPolicyOrderingSupport(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to check whether removing this is intentional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might have been removed since all usages of isPolicyOrderingSupport()
evaluate to true. To minimize impact, better to reintroduce it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reintroduced to AbstractPolicyFinderModule
* | ||
* @return whether supported or not | ||
*/ | ||
public boolean isPolicyDeActivationSupport(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to check whether removing this is intentional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might have been removed since all usages of isPolicyDeActivationSupport()
evaluate to true. To minimize impact, better to reintroduce it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reintroduced
PR builder started |
PR builder completed |
|
PR builder started |
PR builder completed |
PR builder started |
PR builder completed
Adding a tenant fails |
We might also have to deprecate the method |
e1955f8
to
60d8f34
Compare
PR builder started |
9fd8b65
to
a8a2de6
Compare
...n.identity.entitlement/src/main/java/org/wso2/carbon/identity/entitlement/dao/PolicyDAO.java
Outdated
Show resolved
Hide resolved
...ntitlement/src/main/java/org/wso2/carbon/identity/entitlement/dao/RegistryConfigDAOImpl.java
Outdated
Show resolved
Hide resolved
try { | ||
return EntitlementUtil.getPolicyCombiningAlgorithm(algorithm); | ||
} catch (Exception e) { | ||
log.debug(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we are logging this, instead of throwing?
and can we use the warn log if applicable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation has been directly ported from:
Line 78 in 53fb513
log.debug(e); |
So we cannot throw the exception since that would require changing public methods at the higher level.
Here it is logging the exception that the algorithm specified in the entitlement.properties file is not supported, so we can change it to warn log instead.
...ntitlement/src/main/java/org/wso2/carbon/identity/entitlement/dao/RegistryConfigDAOImpl.java
Outdated
Show resolved
Hide resolved
@@ -39,7 +39,6 @@ | |||
import org.wso2.balana.finder.impl.CurrentEnvModule; | |||
import org.wso2.balana.finder.impl.SelectorModule; | |||
import org.wso2.carbon.context.CarbonContext; | |||
import org.wso2.carbon.context.PrivilegedCarbonContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this unused import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
|
||
private static Log log = LogFactory.getLog(PolicyStoreManager.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we removed the log here, I think its better to add some debug logs WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was removed since it is not used. This file doesn't handle any exceptions, and logs have been added at lower places where the exceptions are thrown.
...lement/src/main/java/org/wso2/carbon/identity/entitlement/dao/RegistrySubscriberDAOImpl.java
Outdated
Show resolved
Hide resolved
@@ -145,177 +132,6 @@ public void publishPolicy(String[] policyIds, String version, String action, boo | |||
executor.run(); | |||
} | |||
|
|||
|
|||
public void persistSubscriber(PublisherDataHolder holder, boolean update) throws EntitlementException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats the reason to remove these methods and move to RegistrySubscriberDAOImpl class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to separate these methods into a specific implementation of an interface that handles subscriber operations, to facilitate the database implementation.
...ntitlement/src/main/java/org/wso2/carbon/identity/entitlement/dao/RegistryConfigDAOImpl.java
Outdated
Show resolved
Hide resolved
...ntitlement/src/main/java/org/wso2/carbon/identity/entitlement/dao/RegistryConfigDAOImpl.java
Outdated
Show resolved
Hide resolved
...ntitlement/src/main/java/org/wso2/carbon/identity/entitlement/dao/RegistryPolicyDAOImpl.java
Outdated
Show resolved
Hide resolved
d69d796
to
52eafcc
Compare
PR builder started |
PR builder completed |
52eafcc
to
ae6f353
Compare
PR builder started |
PR builder completed |
PR builder started |
PR builder completed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/9641764635
Proposed changes in this pull request
Ideally, this change should not introduce any behavioral changes. When considering the future RDBMS implementation, some strictly necessary changes are introduced.
Behavioral changes
PDP.Policy.Store.Module
used to be of typePolicyStoreManageModule
but now it should be of typePolicyDAO
.Implementation changes
/repository/identity/entitlement/policy/data/
, while also persisting the full resource at/repository/identity/entitlement/policy/pdp/
. Now we only persist to the pdp path.PAPPolicyStore.java
andRegistryPolicyStoreManageModule
along with interfacePolicyStoreManageModule
.DefaultPolicyDataStore.java
and its interfacePolicyDataStore.java
PolicyPublisher.java
Description
Related Issues
Checklist (for reviewing)
General
Functionality
Code
Tests
Security
Documentation