use of com.sun.enterprise.admin.servermgmt.pe.PEFileLayout in project Payara by payara.
the class MasterPasswordFileManager method deleteMasterPasswordFile.
protected void deleteMasterPasswordFile(RepositoryConfig config) {
final PEFileLayout layout = getFileLayout(config);
final File pwdFile = layout.getMasterPasswordFile();
FileUtils.deleteFile(pwdFile);
}
use of com.sun.enterprise.admin.servermgmt.pe.PEFileLayout in project Payara by payara.
the class MasterPasswordFileManager method createMasterPasswordFile.
/**
* Create the master password keystore. This routine can also modify the master password
* if the keystore already exists
* @param config
* @param masterPassword
* @throws RepositoryException
*/
protected void createMasterPasswordFile(RepositoryConfig config, String masterPassword) throws RepositoryException {
final PEFileLayout layout = getFileLayout(config);
final File pwdFile = layout.getMasterPasswordFile();
try {
PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(), getMasterPasswordPassword());
p.setPasswordForAlias(MASTER_PASSWORD_ALIAS, masterPassword.getBytes());
FileProtectionUtility.chmod0600(pwdFile);
} catch (Exception ex) {
throw new RepositoryException(_strMgr.getString("masterPasswordFileNotCreated", pwdFile), ex);
}
}
use of com.sun.enterprise.admin.servermgmt.pe.PEFileLayout in project Payara by payara.
the class RepositoryManager method changePasswordAliasKeystorePassword.
/*
* public void validateAdminUserAndPassword(RepositoryConfig config, String
* user, String password) throws RepositoryException { try { //Read in
* domain.xml. This will fail with a ConfigException if there is no
* domain.xml final PEFileLayout layout = getFileLayout(config);
* ConfigContext configContext = getConfigContext(config); //Fetch the name
* of the realm for the DAS system jmx connector String dasName =
* ServerHelper.getDAS(configContext).getName(); JmxConnector conn =
* ServerHelper.getServerSystemConnector(configContext, dasName); String
* realmName = conn.getAuthRealmName(); SecurityService security =
* ServerHelper.getConfigForServer(configContext,
* dasName).getSecurityService(); //Load in the file realm //Before loading
* the realm, we must ensure that com.sun.aas.instanceRoot //is set
* correcty, since the keyfile is most likely referenced using this. //In
* addition java.security.auth.login.config must be setup. String oldRoot =
* System.getProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY);
* String oldConf = System.getProperty("java.security.auth.login.config");
* GFSystem.setProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY,
* layout.getRepositoryDir().getAbsolutePath());
* GFSystem.setProperty("java.security.auth.login.config",
* layout.getLoginConf().getAbsolutePath());
* RealmConfig.createRealms(realmName, new AuthRealm[]
* {security.getAuthRealmByName(realmName)}); //Restore previous values just
* in case. if (oldRoot != null) {
* GFSystem.setProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY,
* oldRoot); } if (oldConf != null) {
* GFSystem.setProperty("java.security.auth.login.config", oldConf); }
* //Finally do the authentication of user and password final
* ASJMXAuthenticator authenticator = new ASJMXAuthenticator();
* authenticator.setRealmName(realmName); authenticator.setLoginDriver(new
* ASLoginDriverImpl()); authenticator.authenticate(new String[] {user,
* password}); } catch (Exception ex) { throw new RepositoryException(
* _strMgr.getString("couldNotValidateMasterPassword", user), ex); } }
*/
/**
* Change the password protecting the password alias keystore
*
* @param config
* @param oldPassword old password
* @param newPassword new password
* @throws RepositoryException
*/
protected void changePasswordAliasKeystorePassword(RepositoryConfig config, String oldPassword, String newPassword) throws RepositoryException {
final PEFileLayout layout = getFileLayout(config);
final File passwordAliases = layout.getPasswordAliasKeystore();
// Change the password of the keystore alias file
if (passwordAliases.exists()) {
try {
PasswordAdapter p = new PasswordAdapter(passwordAliases.getAbsolutePath(), oldPassword.toCharArray());
p.changePassword(newPassword.toCharArray());
} catch (Exception ex) {
throw new RepositoryException(_strMgr.getString("passwordAliasPasswordNotChanged", passwordAliases), ex);
}
}
}
use of com.sun.enterprise.admin.servermgmt.pe.PEFileLayout in project Payara by payara.
the class RepositoryManager method createMQInstance.
/**
* Create MQ instance.
*/
protected void createMQInstance(RepositoryConfig config) throws RepositoryException {
final PEFileLayout layout = getFileLayout(config);
final File broker = layout.getImqBrokerExecutable();
final File mqVarHome = layout.getImqVarHome();
try {
FileUtils.mkdirsMaybe(mqVarHome);
final List<String> cmdInput = new ArrayList<String>();
cmdInput.add(broker.getAbsolutePath());
cmdInput.add("-init");
cmdInput.add("-varhome");
cmdInput.add(mqVarHome.getAbsolutePath());
ProcessExecutor pe = new ProcessExecutor(cmdInput.toArray(new String[cmdInput.size()]));
pe.execute(false, false);
} catch (Exception ioe) {
/*
* Dont do anything. * IMQ instance is created just to make sure
* that Off line IMQ commands can be executed, even before starting
* the broker. A typical scenario is while on-demand startup is off,
* user might try to do imqusermgr. Here broker may not have
* started.
*
* Failure in creating the instance doesnt need to abort domain
* creation.
*/
}
}
use of com.sun.enterprise.admin.servermgmt.pe.PEFileLayout in project Payara by payara.
the class RepositoryManager method createTimerDbn.
/**
* Create the timer database dbn file.
*/
protected void createTimerDbn(RepositoryConfig config) throws RepositoryException {
final PEFileLayout layout = getFileLayout(config);
final File src = layout.getTimerDbnTemplate();
final File dest = layout.getTimerDbn();
try {
FileUtils.copy(src, dest);
} catch (IOException ioe) {
throw new RepositoryException(_strMgr.getString("timerDbnNotCreated"), ioe);
}
}
Aggregations