Skip to content
Permalink
Browse files
FC-291 - Support Relax Control - check response for errors on raw ops
  • Loading branch information
shawnmckinney committed Apr 6, 2021
1 parent 5f4a7ed commit 18cdc9b836a02fddb0e63377666fe1473f941ab6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
@@ -239,7 +239,7 @@ public String newValue(String value)
User create( User entity ) throws CreateException
{
LdapConnection ld = null;
boolean setRelaxedControl = false;
boolean setRelaxControl = false;
try
{
entity.setInternalId();
@@ -305,7 +305,7 @@ else if( !Config.getInstance().getBoolean( GlobalIds.USER_CREATION_PASSWORD_FIEL
if ( ( Config.getInstance().isOpenldap() || Config.getInstance().isApacheds() ) && StringUtils.isNotEmpty( entity.getPwPolicy() ) )
{
myEntry.add( OPENLDAP_POLICY_SUBENTRY, PolicyDAO.getPolicyDn( entity ) );
setRelaxedControl = true;
setRelaxControl = true;
}

if ( StringUtils.isNotEmpty( entity.getOu() ) )
@@ -352,7 +352,7 @@ else if( !Config.getInstance().getBoolean( GlobalIds.USER_CREATION_PASSWORD_FIEL
}

ld = getAdminConnection();
add( ld, myEntry, entity, setRelaxedControl );
add( ld, myEntry, entity, setRelaxControl );
entity.setDn( dn );
}
catch ( LdapEntryAlreadyExistsException e )
@@ -383,7 +383,7 @@ User update( User entity ) throws UpdateException
{
LdapConnection ld = null;
String userDn = getDn( entity.getUserId(), entity.getContextId() );
boolean setRelaxedControl = false;
boolean setRelaxControl = false;
try
{
List<Modification> mods = new ArrayList<Modification>();
@@ -435,7 +435,7 @@ User update( User entity ) throws UpdateException
{
mods.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, OPENLDAP_POLICY_SUBENTRY,
PolicyDAO.getPolicyDn( entity ) ) );
setRelaxedControl = true;
setRelaxControl = true;
}

if ( entity.isSystem() != null )
@@ -501,7 +501,7 @@ User update( User entity ) throws UpdateException
if ( mods.size() > 0 )
{
ld = getAdminConnection();
modify( ld, userDn, mods, entity, setRelaxedControl );
modify( ld, userDn, mods, entity, setRelaxControl );
entity.setDn( userDn );
}

@@ -229,10 +229,10 @@ protected void add( LdapConnection connection, Entry entry, FortEntity entity )
* @param connection handle to ldap connection.
* @param entry contains data to add..
* @param entity contains audit context.
* @param setRelaxedControl when true adds managed dsa control to request
* @param setRelaxControl when true attaches relax control to request
* @throws LdapException in the event system error occurs.
*/
protected void add( LdapConnection connection, Entry entry, FortEntity entity, boolean setRelaxedControl ) throws LdapException
protected void add( LdapConnection connection, Entry entry, FortEntity entity, boolean setRelaxControl ) throws LdapException
{
COUNTERS.incrementAdd();

@@ -255,12 +255,12 @@ protected void add( LdapConnection connection, Entry entry, FortEntity entity, b
}
AddRequest addRequest = new AddRequestImpl();
addRequest.setEntry( entry );
if ( setRelaxedControl )
if ( setRelaxControl )
{
addRequest.addControl( new RelaxControlImpl() );
}
// TODO: verify response has no errors:
AddResponse response = connection.add( addRequest );
ResultCodeEnum.processResponse(response);
}


@@ -318,11 +318,11 @@ protected void modify( LdapConnection connection, String dn, List<Modification>
* @param dn contains distinguished node of entry.
* @param mods contains data to modify.
* @param entity contains audit context.
* @param setRelaxedControl when true adds managed dsa control to request
* @param setRelaxControl when true attaches relax control to request
* @throws LdapException in the event system error occurs.
*/
protected void modify( LdapConnection connection, String dn, List<Modification> mods,
FortEntity entity, boolean setRelaxedControl ) throws LdapException
FortEntity entity, boolean setRelaxControl ) throws LdapException
{
COUNTERS.incrementMod();
audit( mods, entity );
@@ -332,13 +332,13 @@ protected void modify( LdapConnection connection, String dn, List<Modification>
{
modRequest.addModification( mod );
}
if ( setRelaxedControl )
if ( setRelaxControl )
{
modRequest.addControl( new RelaxControlImpl() );
}
modRequest.setName( new Dn( dn ) );
// TODO: verify response has no errors:
ModifyResponse response = connection.modify( modRequest );
ResultCodeEnum.processResponse(response);
}


0 comments on commit 18cdc9b

Please sign in to comment.