@Test public void id() { Person p = initPerson(); p.setId("myid"); ARP arp = new ARP(); arp.getAttributes().put("urn:oid:1.3.6.1.4.1.1076.20.40.40.1", Collections.<Object>singletonList("*")); Person enforced = e.enforceARP(p, arp); assertThat(enforced.getId(), equalTo("myid")); assertThat(enforced.getDisplayName(), nullValue()); }
public Person enforceARP(Person person, ARP arp) { Assert.notNull(person); if (arp == null || arp.isNoArp()) { return person; } Person newP = new Person(); if (arp.isNoAttrArp()) { return newP; } final Set<String> arpAttributeNames = arp.getAttributes().keySet(); if (CollectionUtils.containsAny(nameAttributes, arpAttributeNames)) { newP.setDisplayName(person.getDisplayName()); newP.setName(person.getName()); newP.setNickname(person.getNickname()); } if (CollectionUtils.containsAny(organizationAttributes, arpAttributeNames)) { newP.setOrganizations(person.getOrganizations()); } if (arpAttributeNames.contains(Attribute.EMAIL.name)) { newP.setEmails(person.getEmails()); } if (CollectionUtils.containsAny(idAttributes, arpAttributeNames)) { newP.setTags(person.getTags()); newP.setAccounts(person.getAccounts()); newP.setId(person.getId()); newP.setVoot_membership_role(person.getVoot_membership_role()); } return newP; }
PersonARPEnforcer { public Person enforceARP(Person person, ARP arp) { Assert.notNull(person); if (arp == null || arp.isNoArp()) { return person; } Person newP = new Person(); if (arp.isNoAttrArp()) { return newP; } final Set<String> arpAttributeNames = arp.getAttributes().keySet(); if (CollectionUtils.containsAny(nameAttributes, arpAttributeNames)) { newP.setDisplayName(person.getDisplayName()); newP.setName(person.getName()); newP.setNickname(person.getNickname()); } if (CollectionUtils.containsAny(organizationAttributes, arpAttributeNames)) { newP.setOrganizations(person.getOrganizations()); } if (arpAttributeNames.contains(Attribute.EMAIL.name)) { newP.setEmails(person.getEmails()); } if (CollectionUtils.containsAny(idAttributes, arpAttributeNames)) { newP.setTags(person.getTags()); newP.setAccounts(person.getAccounts()); newP.setId(person.getId()); newP.setVoot_membership_role(person.getVoot_membership_role()); } return newP; } }
PersonARPEnforcer { public Person enforceARP(Person person, ARP arp) { Assert.notNull(person); if (arp == null || arp.isNoArp()) { return person; } Person newP = new Person(); if (arp.isNoAttrArp()) { return newP; } final Set<String> arpAttributeNames = arp.getAttributes().keySet(); if (CollectionUtils.containsAny(nameAttributes, arpAttributeNames)) { newP.setDisplayName(person.getDisplayName()); newP.setName(person.getName()); newP.setNickname(person.getNickname()); } if (CollectionUtils.containsAny(organizationAttributes, arpAttributeNames)) { newP.setOrganizations(person.getOrganizations()); } if (arpAttributeNames.contains(Attribute.EMAIL.name)) { newP.setEmails(person.getEmails()); } if (CollectionUtils.containsAny(idAttributes, arpAttributeNames)) { newP.setTags(person.getTags()); newP.setAccounts(person.getAccounts()); newP.setId(person.getId()); newP.setVoot_membership_role(person.getVoot_membership_role()); } return newP; }  }
PersonARPEnforcer { public Person enforceARP(Person person, ARP arp) { Assert.notNull(person); if (arp == null || arp.isNoArp()) { return person; } Person newP = new Person(); if (arp.isNoAttrArp()) { return newP; } final Set<String> arpAttributeNames = arp.getAttributes().keySet(); if (CollectionUtils.containsAny(nameAttributes, arpAttributeNames)) { newP.setDisplayName(person.getDisplayName()); newP.setName(person.getName()); newP.setNickname(person.getNickname()); } if (CollectionUtils.containsAny(organizationAttributes, arpAttributeNames)) { newP.setOrganizations(person.getOrganizations()); } if (arpAttributeNames.contains(Attribute.EMAIL.name)) { newP.setEmails(person.getEmails()); } if (CollectionUtils.containsAny(idAttributes, arpAttributeNames)) { newP.setTags(person.getTags()); newP.setAccounts(person.getAccounts()); newP.setId(person.getId()); newP.setVoot_membership_role(person.getVoot_membership_role()); } return newP; }  Person enforceARP(Person person, ARP arp); }
PersonARPEnforcer { public Person enforceARP(Person person, ARP arp) { Assert.notNull(person); if (arp == null || arp.isNoArp()) { return person; } Person newP = new Person(); if (arp.isNoAttrArp()) { return newP; } final Set<String> arpAttributeNames = arp.getAttributes().keySet(); if (CollectionUtils.containsAny(nameAttributes, arpAttributeNames)) { newP.setDisplayName(person.getDisplayName()); newP.setName(person.getName()); newP.setNickname(person.getNickname()); } if (CollectionUtils.containsAny(organizationAttributes, arpAttributeNames)) { newP.setOrganizations(person.getOrganizations()); } if (arpAttributeNames.contains(Attribute.EMAIL.name)) { newP.setEmails(person.getEmails()); } if (CollectionUtils.containsAny(idAttributes, arpAttributeNames)) { newP.setTags(person.getTags()); newP.setAccounts(person.getAccounts()); newP.setId(person.getId()); newP.setVoot_membership_role(person.getVoot_membership_role()); } return newP; }  Person enforceARP(Person person, ARP arp);  }