001package systems.dmx.accesscontrol.migrations;
002
003import systems.dmx.accesscontrol.AccessControlService;
004
005import systems.dmx.core.service.Inject;
006import systems.dmx.core.service.Migration;
007import systems.dmx.core.service.accesscontrol.Credentials;
008
009
010
011/**
012 * Creates the "admin" user account.
013 * Runs only in CLEAN_INSTALL mode.
014 * <p>
015 * Note: when UPDATEing to 4.5 the "admin" user account already exists.
016 * It was created via postInstall() hook (which is obsolete in 4.5)
017 * <p>
018 * Part of DM 4.7
019 * <p>
020 * Moved from migration 4 to migration 10 as the "Login enabled" config
021 * topic type (created in migration 9) must exist already.
022 */
023public class Migration10 extends Migration {
024
025    // ---------------------------------------------------------------------------------------------- Instance Variables
026
027    @Inject
028    private AccessControlService acService;
029
030    // -------------------------------------------------------------------------------------------------- Public Methods
031
032    @Override
033    public void run() {
034        acService.createUserAccount(new Credentials(
035            AccessControlService.ADMIN_USERNAME,
036            AccessControlService.ADMIN_INITIAL_PASSWORD
037        ));
038    }
039}