public void publishPolicy(String id, String name, boolean isRoot, InputStream policy, OnapPDPGroup group)
throws PAPException {
// copy the (one) file into the target directory on the PAP servlet
- copyFile(id, group, policy);
+ copyFile(id, group, policy, null);
// adjust the local copy of the group to include the new policy
PDPPolicy pdpPolicy = new StdPDPPolicy(id, isRoot, name);
* @param policy Input stream of policy
* @throws PAPException exception
*/
- public void copyFile(String policyId, OnapPDPGroup group, InputStream policy) throws PAPException {
+ public void copyFile(String policyId, OnapPDPGroup group, InputStream policy, String usrId) throws PAPException {
// send the policy file to the PAP Servlet
try {
- sendToPap("POST", policy, null, null, GROUP_ID + group.getId(), "policyId=" + policyId);
+ sendToPap("POST", policy, null, null, GROUP_ID + group.getId(), "policyId=" + policyId, "userId=" + usrId );
} catch (Exception e) {
String message = UNABLE_MSG + policyId + EXCEPTION_MSG + e;
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + message, e);
}
@Override
- public void copyPolicy(PDPPolicy policy, OnapPDPGroup group) throws PAPException {
+ public void copyPolicy(PDPPolicy policy, OnapPDPGroup group, String userId) throws PAPException {
if (policy == null || group == null) {
throw new PAPException("Null input policy=" + policy + " group=" + group);
}
try (InputStream is = new FileInputStream(new File(policy.getLocation()))) {
- copyFile(policy.getId(), group, is);
+ copyFile(policy.getId(), group, is, userId);
} catch (Exception e) {
String message = UNABLE_MSG + policy.getId() + EXCEPTION_MSG + e;
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + message, e);
}
// copy policy to PAP
try {
- controller.getPapEngine().copyPolicy(selectedPolicy, (StdPDPGroup) pdpDestinationGroupId);
+ controller.getPapEngine().copyPolicy(selectedPolicy, (StdPDPGroup) pdpDestinationGroupId, userId);
} catch (PAPException e) {
logger.error("Exception Occured" + e);
return null;
updatedGroupObject.setPipConfigs(group.getPipConfigs());
updatedGroupObject.setStatus(group.getStatus());
updatedGroupObject.setOperation("delete");
- this.container.updateGroup(updatedGroupObject);
+ this.container.updateGroup(updatedGroupObject, userId);
}
response.setContentType(PolicyUtils.APPLICATION_JSON);
private String policyType = "testType";
private String policyContent = "testContent";
private int jmxport = 0;
+ private String userId = "testId";
OnapPDPGroup group = Mockito.mock(OnapPDPGroup.class);
OnapPDPGroup newGroup = Mockito.mock(OnapPDPGroup.class);
OnapPDP pdp = Mockito.mock(OnapPDP.class);
engine.publishPolicy(id, name, false, policy, newGroup)
);
- engine.copyFile(id, newGroup, policy);
+ engine.copyFile(id, newGroup, policy, userId);
PDPPolicy pdpPolicy = Mockito.mock(PDPPolicy.class);
assertThatExceptionOfType(PAPException.class).isThrownBy(() ->
- engine.copyPolicy(pdpPolicy, newGroup)
+ engine.copyPolicy(pdpPolicy, newGroup, userId)
);
assertThatExceptionOfType(PAPException.class).isThrownBy(() ->
);
assertThatExceptionOfType(PAPException.class).isThrownBy(() ->
- engine.copyPolicy(null, null)
+ engine.copyPolicy(null, null, null)
);
//