Skip to content

Commit

Permalink
removed deprecated ldapShaPasswordEncoder + related unused test methods
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Dec 21, 2022
1 parent 2ed8b76 commit 55d64de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.model.api.simulation.SimulationResultContext;
import com.evolveum.midpoint.model.api.simulation.SimulationResultManager;
import com.evolveum.midpoint.model.common.archetypes.ArchetypeManager;

import com.evolveum.midpoint.task.api.AggregatedObjectProcessingListener;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.mutable.MutableInt;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -79,7 +73,10 @@
import com.evolveum.midpoint.model.api.expr.MidpointFunctions;
import com.evolveum.midpoint.model.api.hooks.HookRegistry;
import com.evolveum.midpoint.model.api.interaction.DashboardService;
import com.evolveum.midpoint.model.api.simulation.SimulationResultContext;
import com.evolveum.midpoint.model.api.simulation.SimulationResultManager;
import com.evolveum.midpoint.model.api.util.ReferenceResolver;
import com.evolveum.midpoint.model.common.archetypes.ArchetypeManager;
import com.evolveum.midpoint.model.common.stringpolicy.FocusValuePolicyOriginResolver;
import com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor;
import com.evolveum.midpoint.model.test.asserter.*;
Expand Down Expand Up @@ -133,6 +130,7 @@
import com.evolveum.midpoint.security.enforcer.api.AuthorizationParameters;
import com.evolveum.midpoint.security.enforcer.api.ItemSecurityConstraints;
import com.evolveum.midpoint.security.enforcer.api.SecurityEnforcer;
import com.evolveum.midpoint.task.api.AggregatedObjectProcessingListener;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.*;
import com.evolveum.midpoint.test.asserter.*;
Expand Down Expand Up @@ -170,10 +168,6 @@ public abstract class AbstractModelIntegrationTest extends AbstractIntegrationTe
protected static final ItemPath ACTIVATION_VALID_TO_PATH = SchemaConstants.PATH_ACTIVATION_VALID_TO;
protected static final ItemPath PASSWORD_VALUE_PATH = SchemaConstants.PATH_CREDENTIALS_PASSWORD_VALUE;

protected static final ItemPath PATH_ADMINISTRATIVE_AVAILABILITY_STATUS_PATH = ItemPath.create(
ResourceType.F_ADMINISTRATIVE_OPERATIONAL_STATE,
AdministrativeOperationalStateType.F_ADMINISTRATIVE_AVAILABILITY_STATUS);

private static final String DEFAULT_CHANNEL = SchemaConstants.CHANNEL_USER_URI;

protected static final String NS_PIRACY = "http://midpoint.evolveum.com/xml/ns/samples/piracy";
Expand Down Expand Up @@ -4514,35 +4508,6 @@ protected void assertPassword(PrismObject<UserType> user, String expectedPasswor
assertEquals("Wrong password in " + user, expectedPassword, decryptedUserPassword);
}

protected void assertUserLdapPassword(PrismObject<UserType> user, String expectedPassword) throws EncryptionException {
CredentialsType credentialsType = user.asObjectable().getCredentials();
assertNotNull("No credentials in " + user, credentialsType);
PasswordType passwordType = credentialsType.getPassword();
assertNotNull("No password in " + user, passwordType);
ProtectedStringType protectedStringType = passwordType.getValue();
assertLdapPassword(protectedStringType, expectedPassword, user);
}

protected void assertShadowLdapPassword(PrismObject<ShadowType> shadow, String expectedPassword) throws EncryptionException {
CredentialsType credentialsType = shadow.asObjectable().getCredentials();
assertNotNull("No credentials in " + shadow, credentialsType);
PasswordType passwordType = credentialsType.getPassword();
assertNotNull("No password in " + shadow, passwordType);
ProtectedStringType protectedStringType = passwordType.getValue();
assertLdapPassword(protectedStringType, expectedPassword, shadow);
}

protected <O extends ObjectType> void assertLdapPassword(ProtectedStringType protectedStringType, String expectedPassword, PrismObject<O> source) throws EncryptionException {
assertNotNull("No password value in " + source, protectedStringType);
String decryptedUserPassword = protector.decryptString(protectedStringType);
assertNotNull("Null password in " + source, decryptedUserPassword);
if (decryptedUserPassword.startsWith("{") || decryptedUserPassword.contains("}")) {
assertTrue("Wrong password hash in " + source + ": " + decryptedUserPassword + ", expected " + expectedPassword, ldapShaPasswordEncoder.matches(decryptedUserPassword, expectedPassword));
} else {
assertEquals("Wrong password in " + source, expectedPassword, decryptedUserPassword);
}
}

protected void assertGroupMember(DummyGroup group, String accountId) {
IntegrationTestTools.assertGroupMember(group, accountId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ public abstract class AbstractIntegrationTest extends AbstractSpringTest

// Values used to check if something is unchanged or changed properly

protected LdapShaPasswordEncoder ldapShaPasswordEncoder = new LdapShaPasswordEncoder();

private final Map<InternalCounters, Long> lastCountMap = new HashMap<>();

private CachingStatistics lastResourceCacheStats;
Expand Down

0 comments on commit 55d64de

Please sign in to comment.