Skip to content

Commit

Permalink
fix: Fix UserPasswordHashMigration execution with an idm schema other…
Browse files Browse the repository at this point in the history
… than public

(cherry picked from commit 06c9646)
  • Loading branch information
azayati authored and Jihed525 committed Feb 6, 2025
1 parent f9e858d commit 59eaa9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ public class UserPasswordHashMigration extends UpgradeProductPlugin {
private static final String PASSWORD_SALT_USER_ATTRIBUTE = "passwordSalt128";

private static final String DEFAULT_ENCODER = "org.exoplatform.web.security.hash.Argon2IdPasswordEncoder";

private static final String IDM_DATASOURCE_SCHEMA_NAME = "idm.datasource.schema.name";

private String idmDatasourceSchemaName = "";

public UserPasswordHashMigration(EntityManagerService entityManagerService,
PicketLinkIDMService picketLinkIDMService,
InitParams initParams) {
super(initParams);
this.entityManagerService = entityManagerService;
this.picketLinkIDMService = picketLinkIDMService;
if (initParams.containsKey(IDM_DATASOURCE_SCHEMA_NAME)) {
idmDatasourceSchemaName = initParams.getValueParam(IDM_DATASOURCE_SCHEMA_NAME).getValue();
}
}

@Override
Expand All @@ -73,6 +80,7 @@ public void processUpgrade(String s, String s1) {
+ " GROUP BY jbid_io_attr.IDENTITY_OBJECT_ID) jia ON jbid_io_creden.IDENTITY_OBJECT_ID = jia.IDENTITY_OBJECT_ID;";

RequestLifeCycle.begin(container);
sqlString = sqlString.replace("jbid", idmDatasourceSchemaName + ".jbid");
Query nativeQuery = entityManager.createNativeQuery(sqlString);
List<Object[]> result = nativeQuery.getResultList();
UpgradeReport upgradeReport = new UpgradeReport(result.size());
Expand All @@ -88,7 +96,7 @@ public void processUpgrade(String s, String s1) {
throw new IllegalStateException("UserPasswordHashMigration upgrade failed due to previous errors");
}
} catch (Exception e) {
throw new IllegalStateException("UserPasswordHashMigration upgrade failed due to previous errors");
throw new IllegalStateException("UserPasswordHashMigration upgrade failed due to previous errors", e);
} finally {
RequestLifeCycle.end();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<description>The plugin will be executed in an asynchronous mode</description>
<value>true</value>
</value-param>
<value-param>
<name>idm.datasource.schema.name</name>
<description>The plugin will use the idm datasource schema name for queries</description>
<value>${idm.datasource.schema.name:public}</value>
</value-param>
</init-params>
</component-plugin>
<component-plugin>
Expand Down

0 comments on commit 59eaa9e

Please sign in to comment.