private static void removeEmptyValue(String emptyValue, Attribute attr) { if (emptyValue != null && attr != null) { attr.remove(emptyValue); } }
public void removeMemberFromMemberAttributes(String dnMember){ if(this.getListeMembersAttributes()!=null){ this.getListeMembersAttributes().remove(dnMember); } }
public void removeMember(LDAPEntry childEntry) { Attribute memberAttribute = getLDAPAttributes().get(MEMBER); if (memberAttribute != null) { memberAttribute.remove(childEntry.getDN()); } try { if (!memberAttribute.getAll().hasMoreElements()) { memberAttribute.add(SPACE_STRING); } } catch (NamingException e) { e.printStackTrace(); } }
/** * Unregisters an ContextPartition with this BackendManager. Called for each * registered Backend right befor it is to be stopped. This prevents * protocol server requests from reaching the Backend and effectively puts * the ContextPartition's naming context offline. * * Operations against the naming context should result in an LDAP BUSY * result code in the returnValue if the naming context is not online. * * @param partition ContextPartition component to unregister with this * BackendNexus. */ private void unregister( Partition partition ) throws NamingException { Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR ); namingContexts.remove( partition.getSuffix().toString() ); partitions.remove( partition.getSuffix().toString() ); }
public synchronized void removeContextPartition( LdapDN suffix ) throws NamingException { String key = suffix.toString(); Partition partition = ( Partition ) partitions.get( key ); if ( partition == null ) { throw new NameNotFoundException( "No partition with suffix: " + key ); } Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR ); namingContexts.remove( partition.getUpSuffix().toString() ); partitions.remove( key ); partition.sync(); partition.destroy(); }
/** * {@inheritDoc} */ @Override public void removeAttributeValue(String name, Object value) { if (!updateMode && value != null) { Attribute attr = originalAttrs.get(name); if (attr != null) { attr.remove(value); if (attr.size() == 0) { originalAttrs.remove(name); } } } else if (updateMode) { Attribute attr = updatedAttrs.get(name); if (attr == null) { if (originalAttrs.get(name) != null) { attr = (Attribute) originalAttrs.get(name).clone(); attr.remove(value); updatedAttrs.put(attr); } } else { attr.remove(value); } } }
/** * {@inheritDoc} */ @Override public void removeAttributeValue(String name, Object value) { if (!updateMode && value != null) { Attribute attr = originalAttrs.get(name); if (attr != null) { attr.remove(value); if (attr.size() == 0) { originalAttrs.remove(name); } } } else if (updateMode) { Attribute attr = updatedAttrs.get(name); if (attr == null) { if (originalAttrs.get(name) != null) { attr = (Attribute) originalAttrs.get(name).clone(); attr.remove(value); updatedAttrs.put(attr); } } else { attr.remove(value); } } }
/** * {@inheritDoc} */ @Override public void removeAttributeValue(String name, Object value) { if (!updateMode && value != null) { Attribute attr = originalAttrs.get(name); if (attr != null) { attr.remove(value); if (attr.size() == 0) { originalAttrs.remove(name); } } } else if (updateMode) { Attribute attr = updatedAttrs.get(name); if (attr == null) { if (originalAttrs.get(name) != null) { attr = (Attribute) originalAttrs.get(name).clone(); attr.remove(value); updatedAttrs.put(attr); } } else { attr.remove(value); } } }
/** * {@inheritDoc} */ @Override public void removeAttributeValue(String name, Object value) { if (!updateMode && value != null) { Attribute attr = originalAttrs.get(name); if (attr != null) { attr.remove(value); if (attr.size() == 0) { originalAttrs.remove(name); } } } else if (updateMode) { Attribute attr = updatedAttrs.get(name); if (attr == null) { if (originalAttrs.get(name) != null) { attr = (Attribute) originalAttrs.get(name).clone(); attr.remove(value); updatedAttrs.put(attr); } } else { attr.remove(value); } } }
private static void removeEmptyValue(String emptyValue, Attribute attr) { try { // we must compare parsed LdapName objects rather then strings here if (emptyValue != null && attr != null) { LdapName emptyDn = new LdapName(emptyValue); for (int i = 0; i < attr.size(); i++) { String value = (String) attr.get(i); LdapName dn = new LdapName(value); if (emptyDn.equals(dn)) { attr.remove(i); i--; } } } } catch (NamingException e) { throw new NucleusException(e.getMessage(), e); } }
/** * Checks to see if removing a set of attributes from an entry completely removes * that attribute's values. If change has zero size then all attributes are * presumed to be removed. * * @param change * @param entry * @return * @throws NamingException */ private boolean isCompleteRemoval( Attribute change, Attributes entry ) throws NamingException { // if change size is 0 then all values are deleted then we're in trouble if ( change.size() == 0 ) { return true; } // can't do math to figure our if all values are removed since some // values in the modify request may not be in the entry. we need to // remove the values from a cloned version of the attribute and see // if nothing is left. Attribute changedEntryAttr = ( Attribute ) entry.get( change.getID() ).clone(); for ( int jj = 0; jj < change.size(); jj++ ) { changedEntryAttr.remove( change.get( jj ) ); } return changedEntryAttr.size() == 0; }
public void addMember(LDAPEntry childEntry) { Attribute memberAttribute = getLDAPAttributes().get(MEMBER); if (memberAttribute != null) { if (memberAttribute.contains(SPACE_STRING)) { memberAttribute.remove(SPACE_STRING); } } else { memberAttribute = new BasicAttribute(MEMBER); } memberAttribute.add(childEntry.getDN()); getLDAPAttributes().put(memberAttribute); }
@Override protected void removeFromRelationships(final IdentityContext context, final IdentityType identityType) { String bindingDN = getBindingDN(identityType, true); for (LDAPMappingConfiguration relationshipConfig : getConfig().getRelationshipConfigs()) { for (String attributeName : relationshipConfig.getMappedProperties().values()) { StringBuilder filter = new StringBuilder(); filter.append("(&(").append(attributeName).append(EQUAL).append("").append(bindingDN).append("))"); try { List<SearchResult> search = this.operationManager.search(getMappingConfig(relationshipConfig.getRelatedAttributedType()).getBaseDN(), filter.toString(), getMappingConfig(relationshipConfig.getRelatedAttributedType())); for (SearchResult result : search) { Attributes attributes = result.getAttributes(); Attribute relationshipAttribute = attributes.get(attributeName); if (relationshipAttribute != null && relationshipAttribute.contains(bindingDN)) { relationshipAttribute.remove(bindingDN); if (relationshipAttribute.size() == 0) { relationshipAttribute.add(EMPTY_ATTRIBUTE_VALUE); } this.operationManager.modifyAttribute(result.getNameInNamespace(), relationshipAttribute); } } } catch (NamingException e) { throw new IdentityManagementException("Could not remove " + identityType + " from relationship " + relationshipConfig.getMappedClass(), e); } } } }
@Override protected void removeFromRelationships(final IdentityContext context, final IdentityType identityType) { String bindingDN = getBindingDN(identityType, true); for (LDAPMappingConfiguration relationshipConfig : getConfig().getRelationshipConfigs()) { for (String attributeName : relationshipConfig.getMappedProperties().values()) { StringBuilder filter = new StringBuilder(); filter.append("(&(").append(attributeName).append(EQUAL).append("").append(bindingDN).append("))"); try { List<SearchResult> search = this.operationManager.search(getMappingConfig(relationshipConfig.getRelatedAttributedType()).getBaseDN(), filter.toString(), getMappingConfig(relationshipConfig.getRelatedAttributedType())); for (SearchResult result : search) { Attributes attributes = result.getAttributes(); Attribute relationshipAttribute = attributes.get(attributeName); if (relationshipAttribute != null && relationshipAttribute.contains(bindingDN)) { relationshipAttribute.remove(bindingDN); if (relationshipAttribute.size() == 0) { relationshipAttribute.add(EMPTY_ATTRIBUTE_VALUE); } this.operationManager.modifyAttribute(result.getNameInNamespace(), relationshipAttribute); } } } catch (NamingException e) { throw new IdentityManagementException("Could not remove " + identityType + " from relationship " + relationshipConfig.getMappedClass(), e); } } } }
ocFinalState.remove( ocChanges.get( ii ) );
while(allValues.hasMoreElements()) { Object attributeValue = allValues.nextElement(); if (!originalClone.remove(attributeValue)) { addedValuesAttribute.add(attributeValue);
while(allValues.hasMoreElements()) { Object attributeValue = allValues.nextElement(); if (!originalClone.remove(attributeValue)) { addedValuesAttribute.add(attributeValue);
private void removeMemberShipEntry(LDAPEntry ldapEntry, LDAPEntry member) { String dn = ldapEntry.getDN(); LDAPEntry storedGroupRole = getLdapManager().lookup(dn); if (storedGroupRole != null) { Attribute memberAttribute = storedGroupRole.getLDAPAttributes().get(MEMBER); if (memberAttribute.contains(member.getDN())) { memberAttribute.remove(member.getDN()); memberAttribute.add(SPACE_STRING); getLdapManager().modifyAttribute(dn, memberAttribute); getLdapManager().rebind(dn, storedGroupRole); } } }
for ( int jj = 0; jj < mods[ii].getAttribute().size(); jj++ ) ocFinalState.remove( mods[ii].getAttribute().get( jj ) );
@Override public void unassignUser(String userId, GroupName group) throws UserNotFoundException, GroupNotFoundException { if (userId==null) { throw new UserNotFoundException(userId); } if (group==null || group.getName()==null) { throw new GroupNotFoundException(group); } try { Name userDN = builUserDn(userId); DirContextOperations ctxOps = ldapTemplate.lookupContext(userDN); Attributes allAttrs = ctxOps.getAttributes(); Attribute groupAttr = allAttrs.get(JoomlaLDAPConstants.GROUP_ATTR_NAME); // disallowing unassigning user from predefined required group name if (groupAttr.contains(group.getName()) && !PREDEFINED_REQUIRED_GROUP_NAME.equals(group.getName())) { groupAttr.remove(group.getName()); ldapTemplate.modifyAttributes(userDN, new ModificationItem[] { new ModificationItem(DirContext.REPLACE_ATTRIBUTE, groupAttr)}); } } catch (NameNotFoundException e) { throw new UserNotFoundException(userId); } }