From 10985f00f8b56447616b3e3ed6b56a9601c04abc Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Mon, 23 May 2022 17:16:00 +0200 Subject: [PATCH] Downgrading OrientDB to 3.0.42 --- pom.xml | 2 +- .../dbinitialization/DatabaseEnvironment.java | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e5ea611..6d2eb78 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ implementation we use a lighter dependency --> orientdb-client - 3.2.6 + 3.0.42 org.graalvm.tools diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java index 6b741ba..40e7031 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java @@ -320,6 +320,8 @@ public class DatabaseEnvironment { OUser newAdminUser = oSecurity.createUser(CHANGED_ADMIN_USERNAME, CHANGED_ADMIN_PASSWORD, adminRole); newAdminUser.save(); + DatabaseEnvironment.changeDefaultAdminPassword(oSecurity); + setRecordLevelSecurity(oMetadata); oDatabaseSession.commit(); @@ -339,5 +341,28 @@ public class DatabaseEnvironment { public static Key getDatabaseKey() { return KEY; } + + @Deprecated + // This code must be removed for OrientDB versions higher than 3.2.X + public static void changeDefaultAdminPassword(OSecurity oSecurity) { + for(PermissionMode permissionMode : DEFAULT_PASSWORDS.keySet()) { + try { + logger.trace("Going to update password for user {}", permissionMode.toString()); + OUser oUser = oSecurity.getUser(permissionMode.toString()); + oUser.setPassword(DEFAULT_PASSWORDS.get(permissionMode)); + oUser.save(); + logger.trace("Updated password for user {}", permissionMode.toString()); + }catch (Exception e) { + logger.trace("Unable to update password for user {}. {}", permissionMode.toString(), e.getMessage()); + } + } + + try { + logger.trace("Removing 'admin' user"); + oSecurity.dropUser("admin"); + }catch (Exception e) { + logger.info("Unable to delete admin user. {}", e.getMessage()); + } + } }