/** * Utility method to extract a modification item from an array of modifications. * * @param mods the array of ModificationItems to extract the Attribute from. * @param type the attributeType spec of the Attribute to extract * @return the modification item on the attributeType specified */ public static Modification getModificationItem( List<Modification> mods, AttributeType type ) { for ( Modification modification : mods ) { Attribute attribute = modification.getAttribute(); if ( attribute.getAttributeType() == type ) { return modification; } } return null; }
/** * Check if the entry contains any collective AttributeType (those starting with 'c-') */ private boolean containsAnyCollectiveAttributes( Entry entry ) throws LdapException { for ( Attribute attribute : entry.getAttributes() ) { AttributeType attributeType = attribute.getAttributeType(); if ( attributeType.isCollective() ) { return true; } } return false; }
AttributeType attributeType = entryAttribute.getAttributeType();
/** * Anonymize an attribute using pure random values (either chars of bytes, depending on the Attribute type) */ @Override public Attribute anonymize( Map<Value, Value> valueMap, Set<Value> valueSet, Attribute attribute ) { Attribute result = new DefaultAttribute( attribute.getAttributeType() ); for ( Value value : attribute ) { byte[] bytesValue = value.getBytes(); byte[] newValue = computeNewValue( bytesValue ); try { result.add( newValue ); Value anonValue = new Value( attribute.getAttributeType(), newValue ); valueMap.put( ( Value ) value, anonValue ); valueSet.add( anonValue ); } catch ( LdapInvalidAttributeValueException e ) { throw new RuntimeException( I18n.err( I18n.ERR_13436_ERROR_ANONYMIZING_VALUE, value ) ); } } return result; }
AttributeType attributeType = attribute.getAttributeType();
/** * Anonymize an attribute using pure random values (either chars of bytes, depending on the Attribute type) */ @Override public Attribute anonymize( Map<Value, Value> valueMap, Set<Value> valueSet, Attribute attribute ) { Attribute result = new DefaultAttribute( attribute.getAttributeType() ); for ( Value value : attribute ) { byte[] bytesValue = value.getBytes(); byte[] newValue = computeNewValue( bytesValue ); try { result.add( newValue ); Value anonValue = new Value( attribute.getAttributeType(), newValue ); valueMap.put( ( Value ) value, anonValue ); valueSet.add( anonValue ); } catch ( LdapInvalidAttributeValueException e ) { throw new RuntimeException( I18n.err( I18n.ERR_13436_ERROR_ANONYMIZING_VALUE, value ) ); } } return result; }
/** * Anonymize an attribute using pure random values (either chars of bytes, depending on the Attribute type) */ @Override public Attribute anonymize( Map<Value, Value> valueMap, Set<Value> valueSet, Attribute attribute ) { Attribute result = new DefaultAttribute( attribute.getAttributeType() ); for ( Value value : attribute ) { byte[] bytesValue = value.getBytes(); byte[] newValue = computeNewValue( bytesValue ); try { result.add( newValue ); Value anonValue = new Value( attribute.getAttributeType(), newValue ); valueMap.put( ( Value ) value, anonValue ); valueSet.add( anonValue ); } catch ( LdapInvalidAttributeValueException e ) { throw new RuntimeException( I18n.err( I18n.ERR_13436_ERROR_ANONYMIZING_VALUE, value ) ); } } return result; }
AttributeType attributeType = attribute.getAttributeType();
public Attribute anonymize( Map<Value, Value> valueMap, Set<Value> valueSet, Attribute attribute ) AttributeType attributeType = attribute.getAttributeType(); Attribute result = new DefaultAttribute( attributeType ); Value anonValue = new Value( attribute.getAttributeType(), newValue ); valueMap.put( ( Value ) value, anonValue ); valueSet.add( anonValue );
/** * {@inheritDoc} */ @Override public void add( AddOperationContext addContext ) throws LdapException { if ( algorithm == null ) { next( addContext ); return; } for ( Attribute attribute : addContext.getEntry().getAttributes() ) { if ( attributeTypes.contains( attribute.getAttributeType() ) ) { includeHashed( attribute ); } } next( addContext ); }
/** * {@inheritDoc} */ @Override public void modify( ModifyOperationContext modifyContext ) throws LdapException { if ( algorithm == null ) { next( modifyContext ); return; } List<Modification> mods = modifyContext.getModItems(); for ( Modification mod : mods ) { Attribute attribute = mod.getAttribute(); if ( attributeTypes.contains( attribute.getAttributeType() ) ) { includeHashed( attribute ); } } next( modifyContext ); } }
if ( !objectClass.getAttributeType().equals( objectClassAttributeType ) )
/** * Creates a new instance of DefaultModification. * * @param schemaManager The schema manager * @param modification The modification */ public DefaultModification( SchemaManager schemaManager, Modification modification ) { operation = modification.getOperation(); Attribute modAttribute = modification.getAttribute(); try { AttributeType at = modAttribute.getAttributeType(); if ( at == null ) { at = schemaManager.lookupAttributeTypeRegistry( modAttribute.getId() ); } attribute = new DefaultAttribute( at, modAttribute ); } catch ( LdapException ne ) { // The attributeType is incorrect. Log, but do nothing otherwise. LOG.error( I18n.err( I18n.ERR_13230_INCORRECT_ATTRIBUTE, modAttribute.getId() ) ); } }
/** * Creates a new instance of DefaultModification. * * @param schemaManager The schema manager * @param modification The modification */ public DefaultModification( SchemaManager schemaManager, Modification modification ) { operation = modification.getOperation(); Attribute modAttribute = modification.getAttribute(); try { AttributeType at = modAttribute.getAttributeType(); if ( at == null ) { at = schemaManager.lookupAttributeTypeRegistry( modAttribute.getId() ); } attribute = new DefaultAttribute( at, modAttribute ); } catch ( LdapException ne ) { // The attributeType is incorrect. Log, but do nothing otherwise. LOG.error( I18n.err( I18n.ERR_13230_INCORRECT_ATTRIBUTE, modAttribute.getId() ) ); } }
/** * Creates a new instance of DefaultModification. * * @param schemaManager The schema manager * @param modification The modification */ public DefaultModification( SchemaManager schemaManager, Modification modification ) { operation = modification.getOperation(); Attribute modAttribute = modification.getAttribute(); try { AttributeType at = modAttribute.getAttributeType(); if ( at == null ) { at = schemaManager.lookupAttributeTypeRegistry( modAttribute.getId() ); } attribute = new DefaultAttribute( at, modAttribute ); } catch ( LdapException ne ) { // The attributeType is incorrect. Log, but do nothing otherwise. LOG.error( I18n.err( I18n.ERR_13230_INCORRECT_ATTRIBUTE, modAttribute.getId() ) ); } }
/** * Convert a ServerEntry into a BasicAttributes. The Dn is lost * during this conversion, as the Attributes object does not store * this element. * * @param entry The entry to convert * @return An instance of a AttributesImpl() object */ public static Attributes toBasicAttributes( Entry entry ) { if ( entry == null ) { return null; } Attributes attributes = new BasicAttributes( true ); for ( Attribute attribute : entry.getAttributes() ) { AttributeType attributeType = attribute.getAttributeType(); Attribute attr = entry.get( attributeType ); // Deal with a special case : an entry without any ObjectClass if ( attributeType.getOid().equals( SchemaConstants.OBJECT_CLASS_AT_OID ) && attr.size() == 0 ) { // We don't have any objectClass, just dismiss this element continue; } attributes.put( toBasicAttribute( attr ) ); } return attributes; }
AttributeType attrType = attr.getAttributeType();
/** * Proceed with the Modification operation when the PasswordPolicy is not activated. */ private void processStandardModify( ModifyOperationContext modifyContext ) throws LdapException { next( modifyContext ); List<Modification> modifications = modifyContext.getModItems(); for ( Modification modification : modifications ) { if ( directoryService.getAtProvider().getUserPassword() .equals( modification.getAttribute().getAttributeType() ) ) { invalidateAuthenticatorCaches( modifyContext.getDn() ); break; } } return; }
/** * Convert a ServerAttribute into a BasicAttribute. The Dn is lost * during this conversion, as the Attributes object does not store * this element. * * @param entryAttribute The Server entry to convert * @return An instance of a AttributesImpl() object */ public static javax.naming.directory.Attribute toBasicAttribute( Attribute entryAttribute ) { AttributeType attributeType = entryAttribute.getAttributeType(); javax.naming.directory.Attribute attribute = new BasicAttribute( attributeType.getName() ); for ( Value value : entryAttribute ) { if ( attributeType.isHR() ) { attribute.add( value.getValue() ); } else { attribute.add( value.getBytes() ); } } return attribute; }
/** * {@inheritDoc} */ @Override public void add( AddOperationContext addContext ) throws LdapException { next( addContext ); if ( !changeLog.isEnabled() ) { return; } Entry addEntry = addContext.getEntry(); // we don't want to record addition of a tag as a change if ( addEntry.get( REV_AT_OID ) != null ) { return; } LdifEntry forward = new LdifEntry(); forward.setChangeType( ChangeType.Add ); forward.setDn( addContext.getDn() ); for ( Attribute attribute : addEntry.getAttributes() ) { AttributeType attributeType = attribute.getAttributeType(); forward.addAttribute( addEntry.get( attributeType ).clone() ); } LdifEntry reverse = LdifRevertor.reverseAdd( addContext.getDn() ); addContext.setChangeLogEvent( changeLog.log( getPrincipal( addContext ), forward, reverse ) ); }