Methods Summary |
---|
private void | backup(java.lang.String filePath)
String backupFilePath = filePath + ".bak";
utils.copyFile(filePath, backupFilePath);
recoveryList.add(filePath);
|
private boolean | backupJksCerts()
try {
backup(targetJksPath);
backup(targetCaJksPath);
} catch (Exception e) {
logger.log(Level.SEVERE, stringManager.getString("enterprise.tools.upgrade.certconversion.could_not_migrate_certificates",e));
return false;
}
return true;
|
private boolean | backupNssCerts()
try {
backup(targetNssPath);
backup(targetCaNssPath);
} catch (Exception e) {
//if there is an exception, don't do anything
//logger.log(Level.SEVERE, stringManager.getString("enterprise.tools.upgrade.certconversion.could_not_migrate_certificates",e));
//return false;
}
return true;
|
private void | configureJks()
//set keystore.type=jks
String securityFile = JAVA_HOME + File.separator + "lib" + File.separator + "security" + File.separator + "java.security";
File security = getSecurityFile();
if(!security.exists()){
logger.warning(stringManager.getString("enterprise.tools.upgrade.certconversion.errorConfiguringJKS"));
return;
}
//TODO
|
private void | configureNss()
File security = getSecurityFile();
if(!security.exists()){
logger.warning(stringManager.getString("enterprise.tools.upgrade.certconversion.errorConfiguringNSS"));
return;
}
//TODO
|
private boolean | copyJksCerts()
try {
UpgradeUtils.copyFile(sourceJksPath, targetJksPath);
UpgradeUtils.copyFile(sourceCaJksPath, targetCaJksPath);
} catch (Exception e) {
logger.log(Level.SEVERE, stringManager.getString("enterprise.tools.upgrade.certconversion.could_not_migrate_certificates",e));
return false;
}
return true;
|
private boolean | copyNssCerts()
try {
UpgradeUtils.copyFile(sourceNssPath, targetNssPath);
UpgradeUtils.copyFile(sourceCaNssPath, targetCaNssPath);
} catch (Exception e) {
logger.log(Level.SEVERE, stringManager.getString("enterprise.tools.upgrade.certconversion.could_not_migrate_certificates",e));
return false;
}
return true;
|
public java.lang.String | getName()
return stringManager.getString("enterprise.tools.upgrade.certconversion.moduleName");
|
private java.io.File | getSecurityFile()
String securityFile = JAVA_HOME + File.separator + "lib" + File.separator + "security" + File.separator + "java.security";
return new File(securityFile);
|
private boolean | jksToJks()
backupJksCerts();
return copyJksCerts();
|
private boolean | jksToNss()
configureJks();
return copyJksCerts();
|
private boolean | nssToJks()
configureNss();
return copyNssCerts();
|
private boolean | nssToNss()
backupNssCerts();
return copyNssCerts();
|
public void | recovery(com.sun.enterprise.tools.upgrade.common.CommonInfoModel commonInfo)
Enumeration e = recoveryList.elements();
while(e.hasMoreElements()){
String recoverPath = (String)e.nextElement();
String backupPath = recoverPath + ".bak";
try {
utils.copyFile(backupPath, recoverPath);
new File(backupPath).delete();
} catch (IOException ioe) {
logger.log(Level.SEVERE, stringManager.getString("enterprise.tools.upgrade.certconversion.could_not_migrate_certificates",ioe.getMessage()),new Object[]{recoverPath,ioe});
}
}
|
public boolean | upgrade(com.sun.enterprise.tools.upgrade.common.CommonInfoModel cmi)
cim = cmi;
logger.log(Level.INFO, stringManager.getString("enterprise.tools.upgrade.certconversion.start_certificate_migration",cmi.getCurrentDomain()));
targetJksPath = cim.getTargetJKSKeyStorePath();
sourceJksPath = cim.getSourceJKSKeyStorePath();
targetCaJksPath = cim.getTargetTrustedJKSKeyStorePath();
sourceCaJksPath = cim.getSourceTrustedJKSKeyStorePath();
String sourceConfigPath = cim.getSourceDomainPath()+ File.separator + "config";
String targetConfigPath = cim.getTargetConfig();
targetNssPath = targetConfigPath + File.separator + NSS_CERTS;
sourceNssPath = sourceConfigPath + File.separator + NSS_CERTS;
targetCaNssPath = targetConfigPath + File.separator + CA_NSS_CERTS;
if (cim.getSourceVersionAndEdition().equals(UpgradeConstants.VERSION_AS7X_PE)) {
sourceCaNssPath = sourceConfigPath + File.separator + CA_70_CERTS;
} else {
sourceCaNssPath = sourceConfigPath + File.separator + CA_NSS_CERTS;
}
utils = UpgradeUtils.getUpgradeUtils(cim);
//String tv = cim.getTargetVersionAndEdition();
String sv = cim.getSourceEdition();//cim.getSourceVersionAndEdition();
//8.0PE and 8.1PE have JKS certs
if(sv.equals(UpgradeConstants.EDITION_PE)) {
// if(sv.equals(UpgradeConstants.VERSION_AS80_PE) || sv.equals(UpgradeConstants.VERSION_AS81_PE)) {
//PE source upgrade will always create a domain with developer profile.
return jksToJks();
/*if(tv.equals(UpgradeConstants.VERSION_AS90_PE)) {
return jksToJks();
}
else if ( tv.equals(UpgradeConstants.VERSION_AS91_EE) ){
return jksToNss();
}*/
}
//7.0PE, 7.1SE, 7.1EE, 8.0EE and 8.1EE have NSS certs
//7.x not supported.
//if(sv.equals(UpgradeConstants.VERSION_AS81_EE)) {
//EE source will always create a domain with enterprise profile
if(sv.equals(UpgradeConstants.EDITION_EE)) {
//Not a valid upgrade since EE source to a developer profile not supported.
//Target will be an enterprise profile always.
return nssToNss();
/*if(tv.equals(UpgradeConstants.VERSION_AS90_PE)) {
return nssToJks();
} else if ( tv.equals(UpgradeConstants.VERSION_AS91_EE) ){
return nssToNss();
}*/
}
return false;
|