MasterPasswordFileManagerpublic class MasterPasswordFileManager extends KeystoreManager The RepositoryManager serves as a common base class for the following
PEDomainsManager, PEInstancesManager, AgentManager (the SE Node Agent).
Its purpose is to abstract out any shared functionality related to
lifecycle management of domains, instances and node agents. This includes
creation, deletion, listing, and starting and stopping. |
Fields Summary |
---|
private static final String | MASTER_PASSWORD_ALIAS | private static final String | ENCODED_CHARSET | private static final int | SALT_SIZE | private static final com.sun.enterprise.util.i18n.StringManager | _strMgr |
Constructors Summary |
---|
public MasterPasswordFileManager()Creates a new instance of RepositoryManager
super();
|
Methods Summary |
---|
protected void | changeMasterPasswordInMasterPasswordFile(RepositoryConfig config, java.lang.String newPassword, boolean saveMasterPassword)Changes the master password in the master password file
deleteMasterPasswordFile(config);
if (saveMasterPassword) {
createMasterPasswordFile(config, newPassword);
}
| protected void | createMasterPasswordFile(RepositoryConfig config, java.lang.String masterPassword)Create the master password keystore. This routine can also modify the master password
if the keystore already exists
final PEFileLayout layout = getFileLayout(config);
final File pwdFile = layout.getMasterPasswordFile();
try {
PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(),
getMasterPasswordPassword(config));
p.setPasswordForAlias(MASTER_PASSWORD_ALIAS, masterPassword.getBytes());
chmod("600", pwdFile);
} catch (Exception ex) {
throw new RepositoryException(_strMgr.getString("masterPasswordFileNotCreated", pwdFile),
ex);
}
| protected void | deleteMasterPasswordFile(RepositoryConfig config)
final PEFileLayout layout = getFileLayout(config);
final File pwdFile = layout.getMasterPasswordFile();
pwdFile.delete();
| private char[] | getMasterPasswordPassword(RepositoryConfig config)
//XXX fixed String
return MASTER_PASSWORD_ALIAS.toCharArray();
| public java.lang.String | readMasterPasswordFile(RepositoryConfig config)Return the master password stored in the master password keystore.
final PEFileLayout layout = getFileLayout(config);
final File pwdFile = layout.getMasterPasswordFile();
if (pwdFile.exists()) {
try {
PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(),
getMasterPasswordPassword(config));
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;
}
|
|