private static final Logger LOGGER = FlexLogger.getLogger(MicroServiceConfigPolicy.class);
private static Map<String, String> mapAttribute = new HashMap<>();
- private static Map<String, String> matchMap = new HashMap<>();
+ private static Map<String, String> mapMatch = new HashMap<>();
+
+ private static synchronized Map<String, String> getMatchMap () {
+ return mapMatch;
+ }
+
+ private static synchronized void setMatchMap(Map<String, String> mm) {
+ mapMatch = mm;
+ }
public MicroServiceConfigPolicy() {
super();
String jsonVersion = StringUtils.replaceEach(rootNode.get("version").toString(), new String[]{"\""}, new String[]{""});
matching = getValueFromDictionary(policyAdapter.getServiceType() + "-v" + jsonVersion);
}
-
+
+ Map<String, String> matchMap = null;
if (matching != null && !matching.isEmpty()){
matchMap = Splitter.on(",").withKeyValueSeparator("=").split(matching);
+ setMatchMap(matchMap);
if(policyAdapter.getJsonBody() != null){
pullMatchValue(rootNode);
}
assignment7.setExpression(new ObjectFactory().createAttributeValue(configNameAttributeValue7));
advice.getAttributeAssignmentExpression().add(assignment7);
-
+
+ Map<String, String> matchMap = getMatchMap();
if (matchMap==null || matchMap.isEmpty()){
AttributeAssignmentExpressionType assignment6 = new AttributeAssignmentExpressionType();
assignment6.setAttributeId("matching:" + CONFIGID);
try{
em.getTransaction().commit();
} catch(Exception e){
+ logger.warn("List of remote PolicyDBDaos will be empty", e);
try{
em.getTransaction().rollback();
} catch(Exception e2){
try{
newPolicyDBDaoEntity.setPassword(encryptPassword(url[2]));
} catch(Exception e){
+ logger.debug(e);
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Could not encrypt PAP password");
}
try{
em.getTransaction().commit();
} catch(Exception e){
+ logger.debug(e);
try{
em.getTransaction().rollback();
} catch(Exception e2){
+ logger.debug(e2);
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, "PolicyDBDao", "Could not add new PolicyDBDao to the database");
}
}
try{
encryptedPassword = encryptPassword(url[2]);
} catch(Exception e){
+ logger.debug(e);
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Could not encrypt PAP password");
}
if(url[1] != null && !stringEquals(url[1], foundPolicyDBDaoEntity.getUsername())){
try{
em.getTransaction().commit();
} catch(Exception e){
+ logger.debug(e);
try{
em.getTransaction().rollback();
} catch(Exception e2){
+ logger.debug(e2);
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, "PolicyDBDao", "Could not update PolicyDBDao in the database");
}
}
try{
password = decryptPassword(dbdEntity.getPassword());
} catch(Exception e){
+ logger.debug(e);
//if we can't decrypt, might as well try it anyway
password = dbdEntity.getPassword();
}
readTimeout = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_NOTIFY_TIMEOUT));
} catch(Exception e){
- logger.error("xacml.rest.pap.notify.timeoutms property not set, using a default.");
+ logger.error("xacml.rest.pap.notify.timeoutms property not set, using a default.", e);
readTimeout = 10000;
}
connection.setReadTimeout(readTimeout);
handleIncomingPolicyChange(url, entityId,extraData);
break;
} catch(Exception e){
+ logger.debug(e);
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught exception on handleIncomingPolicyChange("+url+", "+entityId+", "+extraData+")");
}
try{
Thread.sleep(pauseBetweenRetries);
}catch(InterruptedException ie){
+ Thread.currentThread().interrupt();
break;
}
}
handleIncomingPdpChange(url, entityId, transaction);
break;
} catch(Exception e){
+ logger.debug(e);
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught exception on handleIncomingPdpChange("+url+", "+entityId+", "+transaction+")");
}
try{
Thread.sleep(pauseBetweenRetries);
}catch(InterruptedException ie){
+ Thread.currentThread().interrupt();
break;
}
}
handleIncomingGroupChange(url, entityId, extraData, transaction, xacmlPapServlet);
break;
}catch(Exception e){
+ logger.debug(e);
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught exception on handleIncomingGroupChange("+url+", "+entityId+", "+extraData+", "+transaction+", "+xacmlPapServlet+")");
}
try{
Thread.sleep(pauseBetweenRetries);
}catch(InterruptedException ie){
+ Thread.currentThread().interrupt();
break;
}
}
try{
startTransactionSynced(this.em,transactionWaitTime);
} catch(Exception e){
+ logger.debug(e);
throw new PersistenceException("Could not lock transaction within "+transactionWaitTime+" milliseconds");
}
}
+ "\n TimeStamp = " + date.getTime()
+ "\n\n");
}
+ Thread.currentThread().interrupt();
return;
}
if(logger.isDebugEnabled()){
try{
em.close();
}catch(Exception e){
- logger.warn("Could not close already closed transaction");
+ logger.warn("Could not close already closed transaction", e);
}
}
try{
configPath = Paths.get(configPath).toString();
} catch(InvalidPathException e){
- logger.error("Invalid config path: "+configPath);
+ logger.error("Invalid config path: "+configPath, e);
throw new IllegalArgumentException("Invalid config path: "+configPath);
}
return configPath;
try{
policyQueryList = policyQuery.getResultList();
} catch(Exception e){
+ logger.debug(e);
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "Caught Exception trying to check if policy exists policyQuery.getResultList()");
throw new PersistenceException("Query failed trying to check if policy "+policyNameScopeAndVersion[0]+" exists");
}
}
}
}catch(Exception e){
+ logger.debug(e);
PolicyLogger.error("Could not delete old versions for policy "+policy.getPolicyName()+", ID: "+policy.getPolicyId());
}
group.addPolicyToGroup(policy);