use of com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager in project Payara by payara.
the class CreateDomainCommand method executeCommand.
@Override
protected int executeCommand() throws CommandException, CommandValidationException {
// Domain validation upfront (i.e. before we prompt)
try {
DomainsManager manager = new PEDomainsManager();
DomainConfig config = new DomainConfig(domainName, domainDir);
manager.validateDomain(config, false);
verifyPortBase();
} catch (DomainException e) {
throw new CommandException(STRINGS.get("CouldNotCreateDomain", domainName), e);
}
/*
* The admin user is specified with the --user program option. If not specified (because the user hit Enter at the
* prompt), we use the default, which allows unauthenticated login.
*/
adminUser = programOpts.getUser();
if (!ok(adminUser)) {
adminUser = DEFAULT_ADMIN_USER;
adminPassword = DEFAULT_ADMIN_PASSWORD;
} else if (noPassword) {
adminPassword = DEFAULT_ADMIN_PASSWORD;
} else {
char[] pwdArr = getAdminPassword();
adminPassword = pwdArr != null ? new String(pwdArr) : null;
}
if (saveMasterPassword) {
useMasterPassword = true;
}
if (masterPassword == null) {
if (useMasterPassword) {
char[] mpArr = getMasterPassword();
masterPassword = mpArr != null ? new String(mpArr) : null;
} else {
masterPassword = DEFAULT_MASTER_PASSWORD;
}
}
try {
// Verify admin port is valid if specified on command line
if (adminPort != null) {
verifyPortIsValid(adminPort);
}
if (hazelcastDasPort != null) {
verifyPortIsValid(hazelcastDasPort);
}
if (hazelcastStartPort != null) {
verifyPortIsValid(hazelcastStartPort);
}
// Instance option is entered then verify instance port is valid
if (instancePort != null) {
verifyPortIsValid(instancePort);
}
// Saving the login information happens inside this method
createTheDomain(domainDir, domainProperties);
} catch (Exception e) {
throw new CommandException(STRINGS.get("CouldNotCreateDomain", domainName), e);
}
return 0;
}
use of com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager in project Payara by payara.
the class DeleteDomainCommand method executeCommand.
@Override
protected int executeCommand() throws CommandException {
try {
DomainConfig domainConfig = new DomainConfig(getDomainName(), getDomainsDir().getPath());
checkRunning();
checkRename();
DomainsManager manager = new PEDomainsManager();
manager.deleteDomain(domainConfig);
// By default, do as what v2 does -- don't delete the entry -
// might need a revisit (Kedar: 09/16/2009)
// deleteLoginInfo();
} catch (Exception e) {
throw new CommandException(e.getLocalizedMessage());
}
logger.fine(STRINGS.get("DomainDeleted", getDomainName()));
return 0;
}
use of com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager in project Payara by payara.
the class ChangeMasterPasswordCommandDAS method executeCommand.
@Override
protected int executeCommand() throws CommandException {
try {
HostAndPort adminAddress = getAdminAddress();
if (isRunning(adminAddress.getHost(), adminAddress.getPort()))
throw new CommandException(STRINGS.get("domain.is.running", getDomainName(), getDomainRootDir()));
DomainConfig domainConfig = new DomainConfig(getDomainName(), getDomainsDir().getAbsolutePath());
PEDomainsManager manager = new PEDomainsManager();
String mp = super.readFromMasterPasswordFile();
if (mp == null) {
mp = passwords.get("AS_ADMIN_MASTERPASSWORD");
if (mp == null) {
char[] mpCharArr = super.readPassword(STRINGS.get("current.mp"));
mp = mpCharArr != null ? new String(mpCharArr) : null;
}
}
if (mp == null)
throw new CommandException(STRINGS.get("no.console"));
if (!super.verifyMasterPassword(mp))
throw new CommandException(STRINGS.get("incorrect.mp"));
char[] nmpCharArr = getPassword("newmasterpassword", STRINGS.get("new.mp"), STRINGS.get("new.mp.again"), true);
String nmp = nmpCharArr != null ? new String(nmpCharArr) : null;
if (nmp == null)
throw new CommandException(STRINGS.get("no.console"));
// FIXES GLASSFISH-21017
if (nmp.length() < 6) {
throw new CommandException(STRINGS.get("password.too.short"));
}
domainConfig.put(DomainConfig.K_MASTER_PASSWORD, mp);
domainConfig.put(DomainConfig.K_NEW_MASTER_PASSWORD, nmp);
domainConfig.put(DomainConfig.K_SAVE_MASTER_PASSWORD, savemp);
manager.changeMasterPassword(domainConfig);
try {
if (dataGridEncryptionEnabled()) {
logger.warning("Data grid encryption is enabled - " + "you will need to regenerate the encryption key");
}
} catch (IOException | XMLStreamException exception) {
logger.warning("Could not determine if data grid encryption is enabled - " + "you will need to regenerate the encryption key if it is");
}
try {
checkAdditionalTrustAndKeyStores();
} catch (IOException | XMLStreamException exception) {
logger.warning("Could not determine if there were additional Key Stores or Trust stores, if the master-password has been updated, the password for the additional stores need updating in order to continue using them.");
}
return 0;
} catch (Exception e) {
throw new CommandException(e.getMessage(), e);
}
}
use of com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager in project Payara by payara.
the class ListDomainsCommand method getDomains.
/**
* Get a list of domains and their status
* @return Map<String, Boolean> of domain and status
* @throws IOException
* @throws DomainException
* @throws CommandException
*/
protected Map<String, Boolean> getDomains() throws IOException, DomainException, CommandException {
Map<String, Boolean> runningDomains = new HashMap<>();
File domainsDirFile = ok(domainDirParam) ? new File(domainDirParam) : DomainDirs.getDefaultDomainsDir();
DomainConfig domainConfig = new DomainConfig(null, domainsDirFile.getAbsolutePath());
DomainsManager manager = new PEDomainsManager();
String[] domainsList = manager.listDomains(domainConfig);
// no prompting for passwords
programOpts.setInteractive(false);
for (String domain : domainsList) {
runningDomains.put(domain, getStatus(domain).status);
}
return runningDomains;
}
use of com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager in project Payara by payara.
the class ListDomainsCommand method executeCommand.
@Override
protected int executeCommand() throws CommandException, CommandValidationException {
try {
File domainsDirFile = ok(domainDirParam) ? new File(domainDirParam) : DomainDirs.getDefaultDomainsDir();
DomainConfig domainConfig = new DomainConfig(null, domainsDirFile.getAbsolutePath());
DomainsManager manager = new PEDomainsManager();
String[] domainsList = manager.listDomains(domainConfig);
// no prompting for passwords
programOpts.setInteractive(false);
if (domainsList.length > 0) {
if (longOpt) {
String[] headings = { "DOMAIN", "ADMIN_HOST", "ADMIN_PORT", "RUNNING", "RESTART_REQUIRED" };
ColumnFormatter cf = header ? new ColumnFormatter(headings) : new ColumnFormatter();
for (String dn : domainsList) {
DomainInfo di = getStatus(dn);
cf.addRow(new Object[] { dn, di.adminAddr.getHost(), di.adminAddr.getPort(), di.status, di.restartRequired });
}
logger.info(cf.toString());
} else {
for (String dn : domainsList) {
logger.info(getStatus(dn).statusMsg);
}
}
} else {
logger.fine(STRINGS.get("NoDomainsToList"));
}
} catch (Exception ex) {
throw new CommandException(ex.getLocalizedMessage());
}
return 0;
}
Aggregations