@Test public void testFromXacmlStringNull() { String testTitle = "FromXacmlNull"; LOG.info(testTitle); RequestPolicy privacyPolicy1 = null; RequestPolicy privacyPolicy2 = null; try { privacyPolicy1 = PrivacyPolicyUtils.fromXacmlString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); privacyPolicy2 = PrivacyPolicyUtils.fromXacmlString(""); } catch (Exception e) { LOG.info("[Test Exception] "+testTitle+": "+e.getMessage(), e); fail("[Error testFromXmlNull] "+testTitle+": "+e.getMessage()); } assertNull("Privacy policy (only header) should be null", privacyPolicy1); assertNull("Privacy policy should be null", privacyPolicy2); }
public static RequestPolicy fromXacmlString(String xmlPrivacyPolicy) { if (null == xmlPrivacyPolicy || xmlPrivacyPolicy.equals("")) { return null; } String[] encoding = {"UTF-8", "ISO-8859-1"}; if (!xmlPrivacyPolicy.startsWith("<?xml")) { xmlPrivacyPolicy = "<?xml version=\"1.0\" encoding=\""+encoding[0]+"\"?>\n"+xmlPrivacyPolicy; } if (xmlPrivacyPolicy.endsWith("?>")) { return null; } Document docPrivacyPolicy = null; try { DocumentBuilder xmlDocumentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); for(int i=0; i<encoding.length; i++) { try { if (0 == i) { docPrivacyPolicy = xmlDocumentBuilder.parse(new ByteArrayInputStream(xmlPrivacyPolicy.getBytes())); if (null != docPrivacyPolicy) { break; } } docPrivacyPolicy = xmlDocumentBuilder.parse(new ByteArrayInputStream(xmlPrivacyPolicy.getBytes(encoding[i]))); if (null != docPrivacyPolicy) { break; } } catch (UnsupportedEncodingException e) { } } } catch (ParserConfigurationException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } catch (SAXException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } catch (IOException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } RequestPolicy result = fromXmlDocument(docPrivacyPolicy); return result; }
PrivacyPolicyUtils { public static RequestPolicy fromXacmlString(String xmlPrivacyPolicy) { if (null == xmlPrivacyPolicy || xmlPrivacyPolicy.equals("")) { return null; } String[] encoding = {"UTF-8", "ISO-8859-1"}; if (!xmlPrivacyPolicy.startsWith("<?xml")) { xmlPrivacyPolicy = "<?xml version=\"1.0\" encoding=\""+encoding[0]+"\"?>\n"+xmlPrivacyPolicy; } if (xmlPrivacyPolicy.endsWith("?>")) { return null; } Document docPrivacyPolicy = null; try { DocumentBuilder xmlDocumentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); for(int i=0; i<encoding.length; i++) { try { if (0 == i) { docPrivacyPolicy = xmlDocumentBuilder.parse(new ByteArrayInputStream(xmlPrivacyPolicy.getBytes())); if (null != docPrivacyPolicy) { break; } } docPrivacyPolicy = xmlDocumentBuilder.parse(new ByteArrayInputStream(xmlPrivacyPolicy.getBytes(encoding[i]))); if (null != docPrivacyPolicy) { break; } } catch (UnsupportedEncodingException e) { } } } catch (ParserConfigurationException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } catch (SAXException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } catch (IOException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } RequestPolicy result = fromXmlDocument(docPrivacyPolicy); return result; } }
PrivacyPolicyUtils { public static RequestPolicy fromXacmlString(String xmlPrivacyPolicy) { if (null == xmlPrivacyPolicy || xmlPrivacyPolicy.equals("")) { return null; } String[] encoding = {"UTF-8", "ISO-8859-1"}; if (!xmlPrivacyPolicy.startsWith("<?xml")) { xmlPrivacyPolicy = "<?xml version=\"1.0\" encoding=\""+encoding[0]+"\"?>\n"+xmlPrivacyPolicy; } if (xmlPrivacyPolicy.endsWith("?>")) { return null; } Document docPrivacyPolicy = null; try { DocumentBuilder xmlDocumentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); for(int i=0; i<encoding.length; i++) { try { if (0 == i) { docPrivacyPolicy = xmlDocumentBuilder.parse(new ByteArrayInputStream(xmlPrivacyPolicy.getBytes())); if (null != docPrivacyPolicy) { break; } } docPrivacyPolicy = xmlDocumentBuilder.parse(new ByteArrayInputStream(xmlPrivacyPolicy.getBytes(encoding[i]))); if (null != docPrivacyPolicy) { break; } } catch (UnsupportedEncodingException e) { } } } catch (ParserConfigurationException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } catch (SAXException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } catch (IOException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } RequestPolicy result = fromXmlDocument(docPrivacyPolicy); return result; }  }
PrivacyPolicyUtils { public static RequestPolicy fromXacmlString(String xmlPrivacyPolicy) { if (null == xmlPrivacyPolicy || xmlPrivacyPolicy.equals("")) { return null; } String[] encoding = {"UTF-8", "ISO-8859-1"}; if (!xmlPrivacyPolicy.startsWith("<?xml")) { xmlPrivacyPolicy = "<?xml version=\"1.0\" encoding=\""+encoding[0]+"\"?>\n"+xmlPrivacyPolicy; } if (xmlPrivacyPolicy.endsWith("?>")) { return null; } Document docPrivacyPolicy = null; try { DocumentBuilder xmlDocumentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); for(int i=0; i<encoding.length; i++) { try { if (0 == i) { docPrivacyPolicy = xmlDocumentBuilder.parse(new ByteArrayInputStream(xmlPrivacyPolicy.getBytes())); if (null != docPrivacyPolicy) { break; } } docPrivacyPolicy = xmlDocumentBuilder.parse(new ByteArrayInputStream(xmlPrivacyPolicy.getBytes(encoding[i]))); if (null != docPrivacyPolicy) { break; } } catch (UnsupportedEncodingException e) { } } } catch (ParserConfigurationException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } catch (SAXException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } catch (IOException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } RequestPolicy result = fromXmlDocument(docPrivacyPolicy); return result; }  static RequestPolicy inferPrivacyPolicy(PrivacyPolicyTypeConstants privacyPolicyType, Map configuration); static RequestPolicy inferCisPrivacyPolicy(
			PrivacyPolicyBehaviourConstants globalBehaviour,
			MembershipCrit membershipCriteria,
			Map<String, String> configuration); static RequestPolicy inferCisPrivacyPolicy(
			PrivacyPolicyBehaviourConstants globalBehaviour,
			MembershipCrit membershipCriteria); static RequestPolicy infer3pServicePrivacyPolicy(
			Map<String, String> configuration); static List<String> getDataTypes(RequestPolicy privacyPolicy); static List<String> getDataTypes(DataIdentifierScheme schemeFilter, RequestPolicy privacyPolicy); static String toXacmlString(RequestPolicy privacyPolicy); @Deprecated static String toXmlString(RequestPolicy privacyPolicy); static RequestPolicy fromXacmlString(String xmlPrivacyPolicy); }
PrivacyPolicyUtils { public static RequestPolicy fromXacmlString(String xmlPrivacyPolicy) { if (null == xmlPrivacyPolicy || xmlPrivacyPolicy.equals("")) { return null; } String[] encoding = {"UTF-8", "ISO-8859-1"}; if (!xmlPrivacyPolicy.startsWith("<?xml")) { xmlPrivacyPolicy = "<?xml version=\"1.0\" encoding=\""+encoding[0]+"\"?>\n"+xmlPrivacyPolicy; } if (xmlPrivacyPolicy.endsWith("?>")) { return null; } Document docPrivacyPolicy = null; try { DocumentBuilder xmlDocumentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); for(int i=0; i<encoding.length; i++) { try { if (0 == i) { docPrivacyPolicy = xmlDocumentBuilder.parse(new ByteArrayInputStream(xmlPrivacyPolicy.getBytes())); if (null != docPrivacyPolicy) { break; } } docPrivacyPolicy = xmlDocumentBuilder.parse(new ByteArrayInputStream(xmlPrivacyPolicy.getBytes(encoding[i]))); if (null != docPrivacyPolicy) { break; } } catch (UnsupportedEncodingException e) { } } } catch (ParserConfigurationException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } catch (SAXException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } catch (IOException e) { LOG.error("Error during transformation of the string to an XML document: "+e.getMessage(), e); } RequestPolicy result = fromXmlDocument(docPrivacyPolicy); return result; }  static RequestPolicy inferPrivacyPolicy(PrivacyPolicyTypeConstants privacyPolicyType, Map configuration); static RequestPolicy inferCisPrivacyPolicy(
			PrivacyPolicyBehaviourConstants globalBehaviour,
			MembershipCrit membershipCriteria,
			Map<String, String> configuration); static RequestPolicy inferCisPrivacyPolicy(
			PrivacyPolicyBehaviourConstants globalBehaviour,
			MembershipCrit membershipCriteria); static RequestPolicy infer3pServicePrivacyPolicy(
			Map<String, String> configuration); static List<String> getDataTypes(RequestPolicy privacyPolicy); static List<String> getDataTypes(DataIdentifierScheme schemeFilter, RequestPolicy privacyPolicy); static String toXacmlString(RequestPolicy privacyPolicy); @Deprecated static String toXmlString(RequestPolicy privacyPolicy); static RequestPolicy fromXacmlString(String xmlPrivacyPolicy);  }