diff --git a/pom.xml b/pom.xml index 17e97ae..b4cc297 100644 --- a/pom.xml +++ b/pom.xml @@ -56,10 +56,10 @@ To work with Thinkerpop® it is required to use this artifactId orientdb-graphdb Giving that we just use OrientDB classes and not Thinkerpop® - implementation we use a lighter dependecy + implementation we use a lighter dependency --> orientdb-client - 3.0.38 + 3.2.5 org.gcube.common 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 3f9603a..77076f8 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java @@ -84,17 +84,11 @@ public class DatabaseEnvironment { private static final String ROOT_PASSWORD; private static final String ROOT_PASSWORD_VARNAME = "ROOT_PASSWORD"; - private static final String DEFAULT_ADMIN_USERNAME; - private static final String DEFAULT_ADMIN_USERNAME_VARNAME = "DEFAULT_ADMIN_USERNAME"; - public static final String DEFAULT_ADMIN_ROLE = "admin"; private static final String CHANGED_ADMIN_USERNAME; private static final String CHANGED_ADMIN_USERNAME_VARNAME = "CHANGED_ADMIN_USERNAME"; - private static final String DEFAULT_ADMIN_PASSWORD; - private static final String DEFAULT_ADMIN_PASSWORD_VARNAME = "DEFAULT_ADMIN_PASSWORD"; - private static final String CHANGED_ADMIN_PASSWORD; private static final String CHANGED_ADMIN_PASSWORD_VARNAME = "CHANGED_ADMIN_PASSWORD"; @@ -164,9 +158,6 @@ public class DatabaseEnvironment { DEFAULT_CREATED_WRITER_USER_PASSWORD = properties.getProperty(DEFAULT_CREATED_WRITER_USER_PASSWORD_VARNAME); DEFAULT_CREATED_READER_USER_PASSWORD = properties.getProperty(DEFAULT_CREATED_READER_USER_PASSWORD_VARNAME); - DEFAULT_ADMIN_USERNAME = properties.getProperty(DEFAULT_ADMIN_USERNAME_VARNAME); - DEFAULT_ADMIN_PASSWORD = properties.getProperty(DEFAULT_ADMIN_PASSWORD_VARNAME); - DEFAULT_PASSWORDS = new HashMap(); DEFAULT_PASSWORDS.put(PermissionMode.WRITER, DEFAULT_CREATED_WRITER_USER_PASSWORD); @@ -302,10 +293,7 @@ public class DatabaseEnvironment { logger.info("The database {} does not exist. Going to create it.", DB_URI); orientDB.create(DB, ODatabaseType.PLOCAL); - logger.trace("Connecting to newly created database {} as {} with default password", DB_URI, - DEFAULT_ADMIN_USERNAME); - - ODatabasePool pool = new ODatabasePool(orientDB, DB, DEFAULT_ADMIN_USERNAME, DEFAULT_ADMIN_PASSWORD); + ODatabasePool pool = new ODatabasePool(orientDB, DB, ROOT_USERNAME, ROOT_PASSWORD); ODatabaseSession oDatabaseSession = pool.acquire(); DatabaseEnvironment.setDateTimeFormat(oDatabaseSession); @@ -313,24 +301,12 @@ public class DatabaseEnvironment { OMetadata oMetadata = oDatabaseSession.getMetadata(); OSecurity oSecurity = oMetadata.getSecurity(); - logger.trace("Changing {} password", DEFAULT_ADMIN_USERNAME); - - OUser admin = oSecurity.getUser(DEFAULT_ADMIN_USERNAME); - admin.setPassword(CHANGED_ADMIN_PASSWORD); - admin.save(); logger.trace("Creating new admin named '{}'", CHANGED_ADMIN_USERNAME); ORole adminRole = oSecurity.getRole(DEFAULT_ADMIN_ROLE); OUser newAdminUser = oSecurity.createUser(CHANGED_ADMIN_USERNAME, CHANGED_ADMIN_PASSWORD, adminRole); newAdminUser.save(); - for(PermissionMode permissionMode : DEFAULT_PASSWORDS.keySet()) { - OUser oUser = oSecurity.getUser(permissionMode.toString()); - oUser.setPassword(DEFAULT_PASSWORDS.get(permissionMode)); - oUser.save(); - logger.trace("Updating password for user {}", permissionMode.toString()); - } - logger.trace( "Setting Record-level Security (see http://orientdb.com/docs/3.0.x/security/Database-Security.html#record-level-security)"); OSchema oSchema = oMetadata.getSchema();