/** * Create a XACML string representing the Privacy Policy from a Java RequestPolicy * * @param privacyPolicy Privacy policy as a Java object * @return A string containing the XACML version the privacy policy */ public static String toXmlString( org.societies.api.schema.privacytrust.privacy.model.privacypolicy.RequestPolicy requestPolicy) { StringBuilder sb = new StringBuilder(); if (null != requestPolicy) { sb.append("<RequestPolicy>"); sb.append(RequestorUtils.toXmlString(requestPolicy.getRequestor())); sb.append(RequestItemUtils.toXmlString(requestPolicy.getRequestItems())); sb.append("</RequestPolicy>"); } return sb.toString(); }
public static RequestPolicy toRequestPolicy( org.societies.api.schema.privacytrust.privacy.model.privacypolicy.RequestPolicy requestPolicyBean, IIdentityManager identityManager) throws InvalidFormatException { if (null == requestPolicyBean) { return null; } return new RequestPolicy( RequestorUtils.toRequestor(requestPolicyBean.getRequestor(), identityManager), RequestItemUtils.toRequestItems(requestPolicyBean.getRequestItems())); }
public static org.societies.api.schema.privacytrust.privacy.model.privacypolicy.RequestPolicy toRequestPolicyBean(RequestPolicy requestPolicy) { if (null == requestPolicy) { return null; } org.societies.api.schema.privacytrust.privacy.model.privacypolicy.RequestPolicy requestPolicyBean = new org.societies.api.schema.privacytrust.privacy.model.privacypolicy.RequestPolicy(); requestPolicyBean.setRequestor(RequestorUtils.toRequestorBean(requestPolicy.getRequestor())); requestPolicyBean.setRequestItems( RequestItemUtils.toRequestItemBeans(requestPolicy.getRequests())); return requestPolicyBean; }
public static boolean equal( org.societies.api.schema.privacytrust.privacy.model.privacypolicy.RequestPolicy o1, Object o2) { // -- Verify reference equality if (o1 == o2) { return true; } if (o2 == null) { return false; } if (o1 == null) { return false; } if (o1.getClass() != o2.getClass()) { return false; } // -- Verify obj type org.societies.api.schema.privacytrust.privacy.model.privacypolicy.RequestPolicy ro2 = (org.societies.api.schema.privacytrust.privacy.model.privacypolicy.RequestPolicy) o2; return ( /*PrivacyPolicyTypeConstantsUtils.equal(o1.getPrivacyPolicyType(), ro2.getPrivacyPolicyType()) && */ RequestItemUtils.equal(o1.getRequestItems(), ro2.getRequestItems()) && RequestorUtils.equal(o1.getRequestor(), ro2.getRequestor())); }
/** * Help a developer or a user to create a CIS privacy policy by inferring a default one using * information about the CIS. The privacy policy in result will be slightly completed but still * need to be filled. E.g. if a CIS membership criteria engine requires access to geolocation * data, the inference engine will add geolocation data line to the privacy policy. * * @param globalBehaviour Global behavior of the privacy policy: private (default), members only, * public or custom * @param membershipCriteria Membership criteria of the CIS (optional) * @param configuration Other optional configuration * @return A slightly completed privacy policy */ public static RequestPolicy inferCisPrivacyPolicy( PrivacyPolicyBehaviourConstants globalBehaviour, MembershipCrit membershipCriteria, Map<String, String> configuration) throws PrivacyException { // --- Prepare common data // -- Actions: read List<Action> actions = ActionUtils.createList(ActionConstants.READ, ActionConstants.CREATE); // -- Conditions List<Condition> conditions = new ArrayList<Condition>(); // - Common conditions.add(ConditionUtils.create(ConditionConstants.STORE_IN_SECURE_STORAGE, "1")); // - Visibility // Public if (PrivacyPolicyBehaviourConstants.PUBLIC.name().equals(globalBehaviour.name())) { conditions.add(ConditionUtils.createPublic()); } // Members only else if (PrivacyPolicyBehaviourConstants.MEMBERS_ONLY.name().equals(globalBehaviour.name())) { conditions.add(ConditionUtils.createMembersOnly()); } // Private else { conditions.add(ConditionUtils.createPrivate()); } // --- Prepare request item list List<RequestItem> requestItems = new ArrayList<RequestItem>(); boolean optional = false; // - CIS Member list { Resource resource = ResourceUtils.create(DataIdentifierScheme.CIS, CisAttributeTypes.MEMBER_LIST); RequestItem requestItem = RequestItemUtils.create(resource, actions, conditions, optional); requestItems.add(requestItem); } // - Location symbolic { Resource resource = ResourceUtils.create(DataIdentifierScheme.CONTEXT, CtxAttributeTypes.LOCATION_SYMBOLIC); RequestItem requestItem = RequestItemUtils.create(resource, actions, conditions, optional); requestItems.add(requestItem); } optional = true; // - Location coordinates { Resource resource = ResourceUtils.create( DataIdentifierScheme.CONTEXT, CtxAttributeTypes.LOCATION_COORDINATES); RequestItem requestItem = RequestItemUtils.create(resource, actions, conditions, optional); requestItems.add(requestItem); } // - Interests { Resource resource = ResourceUtils.create(DataIdentifierScheme.CONTEXT, CtxAttributeTypes.INTERESTS); RequestItem requestItem = RequestItemUtils.create(resource, actions, conditions, optional); requestItems.add(requestItem); } // - Email { Resource resource = ResourceUtils.create(DataIdentifierScheme.CONTEXT, CtxAttributeTypes.EMAIL); RequestItem requestItem = RequestItemUtils.create(resource, actions, conditions, optional); requestItems.add(requestItem); } // - Occupation { Resource resource = ResourceUtils.create(DataIdentifierScheme.CONTEXT, CtxAttributeTypes.OCCUPATION); RequestItem requestItem = RequestItemUtils.create(resource, actions, conditions, optional); requestItems.add(requestItem); } // - Occupation { Resource resource = ResourceUtils.create(DataIdentifierScheme.CONTEXT, CtxAttributeTypes.WORK_POSITION); RequestItem requestItem = RequestItemUtils.create(resource, actions, conditions, optional); requestItems.add(requestItem); } // --- Prepare parameters Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("globalBehaviour", globalBehaviour); parameters.put("membershipCriteria", membershipCriteria); parameters.put("requestItems", requestItems); if (null != configuration) { parameters.putAll(configuration); } return inferPrivacyPolicy(PrivacyPolicyTypeConstants.CIS, parameters); }