use of com.sun.enterprise.admin.servermgmt.pe.PEFileLayout in project Payara by payara.
the class UpgradeLogging method doUpgrade.
private void doUpgrade(Config config) {
// v3 uses logging.properties to configure the logging facility.
// move all log-service elements to logging.properties
final LogService logService = config.getLogService();
// check if null and exit
if (logService == null)
return;
try {
RepositoryConfig rc = new RepositoryConfig();
String configDir = rc.getRepositoryRoot() + File.separator + rc.getRepositoryName() + File.separator + rc.getInstanceName() + File.separator + "config";
PEFileLayout layout = new PEFileLayout(rc);
File src = new File(layout.getTemplatesDir(), PEFileLayout.LOGGING_PROPERTIES_FILE);
File dest = new File(configDir, PEFileLayout.LOGGING_PROPERTIES_FILE);
if (!dest.exists())
FileUtils.copy(src, dest);
} catch (IOException ioe) {
getLogger().log(Level.SEVERE, FAIL_CREATE_LOG_PROPS, ioe);
}
try {
// Get the logLevels
ModuleLogLevels mll = logService.getModuleLogLevels();
Map<String, String> logLevels = mll.getAllLogLevels();
String file = logService.getFile();
String payaraNotificationFile = logService.getPayaraNotificationFile();
String instanceRoot = System.getProperty("com.sun.aas.instanceRoot");
if (file.contains(instanceRoot)) {
file = file.replace(instanceRoot, "${com.sun.aas.instanceRoot}");
}
if (payaraNotificationFile.contains(instanceRoot)) {
payaraNotificationFile = payaraNotificationFile.replace(instanceRoot, "${com.sun.aas.instanceRoot}");
}
logLevels.put("file", file);
logLevels.put("payara-notification-file", payaraNotificationFile);
logLevels.put("use-system-logging", logService.getUseSystemLogging());
// this can have multiple values so need to add
logLevels.put("log-handler", logService.getLogHandler());
logLevels.put("log-filter", logService.getLogFilter());
logLevels.put("log-to-file", logService.getLogToFile());
logLevels.put("payara-notification-log-to-file", logService.getPayaraNotificationLogToFile());
logLevels.put("log-to-console", logService.getLogToConsole());
logLevels.put("log-rotation-limit-in-bytes", logService.getLogRotationLimitInBytes());
logLevels.put("payara-notification-log-rotation-limit-in-bytes", logService.getPayaraNotificationLogRotationLimitInBytes());
logLevels.put("log-rotation-timelimit-in-minutes", logService.getLogRotationTimelimitInMinutes());
logLevels.put("payara-notification-log-rotation-timelimit-in-minutes", logService.getPayaraNotificationLogRotationTimelimitInMinutes());
logLevels.put("alarms", logService.getAlarms());
logLevels.put("retain-error-statistics-for-hours", logService.getRetainErrorStatisticsForHours());
final Map<String, String> m = new HashMap<String, String>(logLevels);
ConfigSupport.apply(new SingleConfigCode<Config>() {
public Object run(Config c) throws PropertyVetoException, TransactionFailure {
try {
// update logging.properties
logConfig.updateLoggingProperties(m);
c.setLogService(null);
} catch (IOException e) {
getLogger().log(Level.SEVERE, FAIL_UPDATE_LOG_PROPS, e);
}
return null;
}
}, config);
} catch (TransactionFailure tf) {
getLogger().log(Level.SEVERE, FAIL_UPGRADE_LOG_SERVICE, tf);
throw new RuntimeException(tf);
}
}
use of com.sun.enterprise.admin.servermgmt.pe.PEFileLayout in project Payara by payara.
the class KeystoreManager method changeSSLCertificateDatabasePassword.
/**
* Changes the password of the keystore, truststore and the key password of
* the s1as alias. It is expected that the key / truststores may not exist.
* This is due to the fact that the user may have deleted them and wishes to
* set up their own key/truststore
*
* @param config
* @param storePassword
* @param oldKeyPassword
* @param newKeyPassword
*/
protected void changeSSLCertificateDatabasePassword(RepositoryConfig config, String oldPassword, String newPassword) throws RepositoryException {
final PEFileLayout layout = getFileLayout(config);
File keystore = layout.getKeyStore();
File truststore = layout.getTrustStore();
if (keystore.exists()) {
// Change the password on the keystore
changeKeystorePassword(oldPassword, newPassword, keystore);
// database password.
try {
changeS1ASAliasPassword(config, newPassword, oldPassword, newPassword);
} catch (Exception ex) {
// For now we eat all exceptions and dump to the log if the password
// alias could not be changed.
getLogger().log(Level.SEVERE, UNHANDLED_EXCEPTION, ex);
}
}
if (truststore.exists()) {
// Change the password on the truststore
changeKeystorePassword(oldPassword, newPassword, truststore);
}
}
use of com.sun.enterprise.admin.servermgmt.pe.PEFileLayout in project Payara by payara.
the class MasterPasswordFileManager method readMasterPasswordFile.
/**
* Return the master password stored in the master password keystore.
* @param config
* @throws RepositoryException
* @return
*/
public String readMasterPasswordFile(RepositoryConfig config) throws RepositoryException {
final PEFileLayout layout = getFileLayout(config);
final File pwdFile = layout.getMasterPasswordFile();
if (pwdFile.exists()) {
try {
PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(), getMasterPasswordPassword());
return p.getPasswordForAlias(MASTER_PASSWORD_ALIAS);
} catch (Exception ex) {
throw new RepositoryException(_strMgr.getString("masterPasswordFileNotRead", pwdFile), ex);
}
} else {
// Return null if the password file does not exist.
return null;
}
}
use of com.sun.enterprise.admin.servermgmt.pe.PEFileLayout in project Payara by payara.
the class RepositoryManager method createJBIInstance.
/**
* Create JBI instance.
*/
protected void createJBIInstance(String instanceName, RepositoryConfig config) throws RepositoryException {
final PEFileLayout layout = getFileLayout(config);
layout.createJBIDirectories();
final TokenValueSet tvSet = new TokenValueSet();
final String tvDelimiter = "@";
final String tJbiInstanceName = "JBI_INSTANCE_NAME";
final String tJbiInstanceRoot = "JBI_INSTANCE_ROOT";
try {
final TokenValue tvJbiInstanceName = new TokenValue(tJbiInstanceName, instanceName, tvDelimiter);
final TokenValue tvJbiInstanceRoot = new TokenValue(tJbiInstanceRoot, layout.getRepositoryDir().getCanonicalPath(), tvDelimiter);
tvSet.add(tvJbiInstanceName);
tvSet.add(tvJbiInstanceRoot);
final File src = layout.getJbiTemplateFile();
final File dest = layout.getJbiRegistryFile();
generateFromTemplate(tvSet, src, dest);
final File httpConfigSrc = layout.getHttpBcConfigTemplate();
final File httpConfigDest = layout.getHttpBcConfigFile();
// tokens will be added in a follow-up integration
final TokenValueSet httpTvSet = new TokenValueSet();
generateFromTemplate(httpTvSet, httpConfigSrc, httpConfigDest);
createHttpBCInstallRoot(layout);
createJavaEESEInstallRoot(layout);
createWSDLSLInstallRoot(layout);
} catch (Exception ioe) {
throw new RepositoryException(_strMgr.getString("jbiRegistryFileNotCreated"), ioe);
}
}
use of com.sun.enterprise.admin.servermgmt.pe.PEFileLayout in project Payara by payara.
the class RepositoryManager method validateMasterPassword.
/**
* We validate the master password by trying to open the password alias
* keystore. This means that the keystore must already exist.
*
* @param config
* @param password
* @throws RepositoryException
*/
public void validateMasterPassword(RepositoryConfig config, String password) throws RepositoryException {
final PEFileLayout layout = getFileLayout(config);
final File passwordAliases = layout.getPasswordAliasKeystore();
try {
// WBN July 2007
// we are constructing this object ONLY to see if it throws
// an Exception. We do not use the object.
new PasswordAdapter(passwordAliases.getAbsolutePath(), password.toCharArray());
} catch (IOException ex) {
throw new RepositoryException(_strMgr.getString("masterPasswordInvalid"));
} catch (Exception ex) {
throw new RepositoryException(_strMgr.getString("couldNotValidateMasterPassword", passwordAliases), ex);
}
}
Aggregations