in src/main/java/org/apache/directory/fortress/core/impl/PolicyDAO.java [281:415]
void update( PwPolicy entity ) throws UpdateException
{
LdapConnection ld = null;
String dn = getDn( entity );
try
{
List<Modification> mods = new ArrayList<Modification>();
if ( entity.getMinAge() != null )
{
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_MIN_AGE, entity.getMinAge().toString() ) );
}
if ( entity.getMaxAge() != null )
{
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_MAX_AGE, entity.getMaxAge().toString() ) );
}
if ( entity.getInHistory() != null )
{
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_IN_HISTORY, entity.getInHistory().toString() ) );
}
if ( entity.getCheckQuality() != null )
{
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_CHECK_QUALITY, entity.getCheckQuality().toString() ) );
}
if ( entity.getMinLength() != null )
{
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_MIN_LENGTH, entity.getMinLength().toString() ) );
}
if ( entity.getExpireWarning() != null )
{
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_EXPIRE_WARNING, entity.getExpireWarning().toString() ) );
}
if ( entity.getGraceLoginLimit() != null )
{
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_GRACE_LOGIN_LIMIT, entity.getGraceLoginLimit().toString() ) );
}
if ( entity.getLockout() != null )
{
/**
* OpenLDAP requires the boolean values to be upper case:
*/
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_LOCKOUT, entity.getLockout().toString().toUpperCase() ) );
}
if ( entity.getLockoutDuration() != null )
{
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_LOCKOUT_DURATION, entity.getLockoutDuration().toString() ) );
}
if ( entity.getMaxFailure() != null )
{
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_MAX_FAILURE, entity.getMaxFailure().toString() ) );
}
if ( entity.getFailureCountInterval() != null )
{
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_FAILURE_COUNT_INTERVAL, entity.getFailureCountInterval().toString() ) );
}
if ( entity.getMustChange() != null )
{
/**
* OpenLDAP requires the boolean values to be upper case:
*/
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_MUST_CHANGE, entity.getMustChange().toString().toUpperCase() ) );
}
if ( entity.getAllowUserChange() != null )
{
/**
* OpenLDAP requires the boolean values to be upper case:
*/
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_ALLOW_USER_CHANGE, entity.getAllowUserChange().toString().toUpperCase() ) );
}
if ( entity.getSafeModify() != null )
{
/**
* OpenLDAP requires the boolean values to be upper case:
*/
mods.add( new DefaultModification(
ModificationOperation.REPLACE_ATTRIBUTE,
PW_SAFE_MODIFY, entity.getSafeModify().toString().toUpperCase() ) );
}
if ( mods != null && mods.size() > 0 )
{
ld = getAdminConnection();
modify( ld, dn, mods, entity );
}
}
catch ( LdapException e )
{
String error = "update name [" + entity.getName() + "] caught LdapException=" + e;
throw new UpdateException( GlobalErrIds.PSWD_UPDATE_FAILED, error, e );
}
finally
{
closeAdminConnection( ld );
}
}