Avoid duplicate constants.
This commit is contained in:
parent
c45c452c83
commit
bc33640c98
3 changed files with 22 additions and 25 deletions
|
|
@ -27,9 +27,6 @@ public class Constants {
|
||||||
/** The Constant APP_NAME. */
|
/** The Constant APP_NAME. */
|
||||||
public static final String APP_NAME = "vm-runner";
|
public static final String APP_NAME = "vm-runner";
|
||||||
|
|
||||||
/** The Constant COMP_DISPLAY_SECRETS. */
|
|
||||||
public static final String COMP_DISPLAY_SECRET = "display-secret";
|
|
||||||
|
|
||||||
/** The Constant VM_OP_NAME. */
|
/** The Constant VM_OP_NAME. */
|
||||||
public static final String VM_OP_NAME = "vm-operator";
|
public static final String VM_OP_NAME = "vm-operator";
|
||||||
|
|
||||||
|
|
@ -41,4 +38,20 @@ public class Constants {
|
||||||
|
|
||||||
/** The Constant VM_OP_KIND_VM_POOL. */
|
/** The Constant VM_OP_KIND_VM_POOL. */
|
||||||
public static final String VM_OP_KIND_VM_POOL = "VmPool";
|
public static final String VM_OP_KIND_VM_POOL = "VmPool";
|
||||||
|
|
||||||
|
/** The Constant COMP_DISPLAY_SECRETS. */
|
||||||
|
public static final String COMP_DISPLAY_SECRET = "display-secret";
|
||||||
|
|
||||||
|
/** The Constant DATA_DISPLAY_PASSWORD. */
|
||||||
|
public static final String DATA_DISPLAY_PASSWORD = "display-password";
|
||||||
|
|
||||||
|
/** The Constant DATA_PASSWORD_EXPIRY. */
|
||||||
|
public static final String DATA_PASSWORD_EXPIRY = "password-expiry";
|
||||||
|
|
||||||
|
/** The Constant DATA_DISPLAY_USER. */
|
||||||
|
public static final String DATA_DISPLAY_USER = "display-user";
|
||||||
|
|
||||||
|
/** The Constant DATA_DISPLAY_LOGIN. */
|
||||||
|
public static final String DATA_DISPLAY_LOGIN = "login-user";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,28 +18,12 @@
|
||||||
|
|
||||||
package org.jdrupes.vmoperator.manager;
|
package org.jdrupes.vmoperator.manager;
|
||||||
|
|
||||||
// TODO: Auto-generated Javadoc
|
|
||||||
/**
|
/**
|
||||||
* Some constants.
|
* Some constants.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("PMD.DataClass")
|
@SuppressWarnings("PMD.DataClass")
|
||||||
public class Constants extends org.jdrupes.vmoperator.common.Constants {
|
public class Constants extends org.jdrupes.vmoperator.common.Constants {
|
||||||
|
|
||||||
/** The Constant COMP_DISPLAY_SECRET. */
|
|
||||||
public static final String COMP_DISPLAY_SECRET = "display-secret";
|
|
||||||
|
|
||||||
/** The Constant DATA_DISPLAY_PASSWORD. */
|
|
||||||
public static final String DATA_DISPLAY_PASSWORD = "display-password";
|
|
||||||
|
|
||||||
/** The Constant DATA_PASSWORD_EXPIRY. */
|
|
||||||
public static final String DATA_PASSWORD_EXPIRY = "password-expiry";
|
|
||||||
|
|
||||||
/** The Constant DATA_DISPLAY_USER. */
|
|
||||||
public static final String DATA_DISPLAY_USER = "display-user";
|
|
||||||
|
|
||||||
/** The Constant DATA_DISPLAY_LOGIN. */
|
|
||||||
public static final String DATA_DISPLAY_LOGIN = "login-user";
|
|
||||||
|
|
||||||
/** The Constant STATE_RUNNING. */
|
/** The Constant STATE_RUNNING. */
|
||||||
public static final String STATE_RUNNING = "Running";
|
public static final String STATE_RUNNING = "Running";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import static org.jdrupes.vmoperator.common.Constants.DATA_DISPLAY_PASSWORD;
|
||||||
|
import static org.jdrupes.vmoperator.common.Constants.DATA_PASSWORD_EXPIRY;
|
||||||
import org.jdrupes.vmoperator.runner.qemu.commands.QmpSetDisplayPassword;
|
import org.jdrupes.vmoperator.runner.qemu.commands.QmpSetDisplayPassword;
|
||||||
import org.jdrupes.vmoperator.runner.qemu.commands.QmpSetPasswordExpiry;
|
import org.jdrupes.vmoperator.runner.qemu.commands.QmpSetPasswordExpiry;
|
||||||
import org.jdrupes.vmoperator.runner.qemu.events.ConfigureQemu;
|
import org.jdrupes.vmoperator.runner.qemu.events.ConfigureQemu;
|
||||||
|
|
@ -40,8 +42,6 @@ import org.jgrapes.util.events.WatchFile;
|
||||||
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
|
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
|
||||||
public class DisplayController extends Component {
|
public class DisplayController extends Component {
|
||||||
|
|
||||||
public static final String DISPLAY_PASSWORD_FILE = "display-password";
|
|
||||||
public static final String PASSWORD_EXPIRY_FILE = "password-expiry";
|
|
||||||
private String currentPassword;
|
private String currentPassword;
|
||||||
private String protocol;
|
private String protocol;
|
||||||
private final Path configDir;
|
private final Path configDir;
|
||||||
|
|
@ -57,7 +57,7 @@ public class DisplayController extends Component {
|
||||||
public DisplayController(Channel componentChannel, Path configDir) {
|
public DisplayController(Channel componentChannel, Path configDir) {
|
||||||
super(componentChannel);
|
super(componentChannel);
|
||||||
this.configDir = configDir;
|
this.configDir = configDir;
|
||||||
fire(new WatchFile(configDir.resolve(DISPLAY_PASSWORD_FILE)));
|
fire(new WatchFile(configDir.resolve(DATA_DISPLAY_PASSWORD)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -83,7 +83,7 @@ public class DisplayController extends Component {
|
||||||
@Handler
|
@Handler
|
||||||
@SuppressWarnings("PMD.EmptyCatchBlock")
|
@SuppressWarnings("PMD.EmptyCatchBlock")
|
||||||
public void onFileChanged(FileChanged event) {
|
public void onFileChanged(FileChanged event) {
|
||||||
if (event.path().equals(configDir.resolve(DISPLAY_PASSWORD_FILE))) {
|
if (event.path().equals(configDir.resolve(DATA_DISPLAY_PASSWORD))) {
|
||||||
updatePassword();
|
updatePassword();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +100,7 @@ public class DisplayController extends Component {
|
||||||
|
|
||||||
private boolean setDisplayPassword() {
|
private boolean setDisplayPassword() {
|
||||||
String password;
|
String password;
|
||||||
Path dpPath = configDir.resolve(DISPLAY_PASSWORD_FILE);
|
Path dpPath = configDir.resolve(DATA_DISPLAY_PASSWORD);
|
||||||
if (dpPath.toFile().canRead()) {
|
if (dpPath.toFile().canRead()) {
|
||||||
logger.finer(() -> "Found display password");
|
logger.finer(() -> "Found display password");
|
||||||
try {
|
try {
|
||||||
|
|
@ -125,7 +125,7 @@ public class DisplayController extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPasswordExpiry() {
|
private void setPasswordExpiry() {
|
||||||
Path pePath = configDir.resolve(PASSWORD_EXPIRY_FILE);
|
Path pePath = configDir.resolve(DATA_PASSWORD_EXPIRY);
|
||||||
if (!pePath.toFile().canRead()) {
|
if (!pePath.toFile().canRead()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue