if (pap.isRemote()) {
throw new XACMLPolicyManagementServiceException("Forbidden operation for a remote PAP");
}
PapContainer papContainer = new PapContainer(pap);
List<PolicySetType> targetPolicySetList = getTargetPolicySetList(papContainer);
if (targetPolicySetList.isEmpty()) {
log.debug("targetPolicySet not found");
unbanResult.setStatusCode(1);
return unbanResult;
}
PolicyType targetPolicy = null;
for (PolicySetType targetPolicySet : targetPolicySetList) {
targetPolicy = getTargetPolicy(papContainer, targetPolicySet);
if (targetPolicy != null) {
break;
}
}
if (targetPolicy == null) {
log.debug("targetPolicy not found");
unbanResult.setStatusCode(1);
return unbanResult;
}
PolicyWizard policyWizard = new PolicyWizard(targetPolicy);
TypeStringUtils.releaseUnneededMemory(targetPolicy);
if (policyWizard.removeDenyRuleForAttribute(bannedAttributeWizard)) {
log.debug("ban rule found, updating policy");
if (policyWizard.getNumberOfRules() == 0) {
papContainer.removePolicyAndReferences(policyWizard.getPolicyId());
} else {
String oldVersion = policyWizard.getVersionString();
policyWizard.increaseVersion();
papContainer.updatePolicy(oldVersion, policyWizard.getXACML());
}
unbanResult.setStatusCode(0);
return unbanResult;
}