use of com.sun.enterprise.security.store.PasswordAdapter in project Payara by payara.
the class DomainSecurity method createPasswordAliasKeystore.
/**
* Create the password alias keystore (initially empty)
*
* @param pwFile File to store encrypted password.
* @param password password protecting the keystore
* @throws RepositoryException if any error occurs in creation.
*/
void createPasswordAliasKeystore(File pwFile, String password) throws RepositoryException {
try {
PasswordAdapter p = new PasswordAdapter(pwFile.getAbsolutePath(), password.toCharArray());
p.writeStore();
} catch (Exception ex) {
throw new RepositoryException(_strMgr.getString("passwordAliasKeystoreNotCreated", pwFile), ex);
}
}
use of com.sun.enterprise.security.store.PasswordAdapter in project Payara by payara.
the class ChangeNodeMasterPasswordCommand method createMasterPasswordFile.
/**
* Create the master password keystore. This routine can also modify the master password
* if the keystore already exists
*
* @throws CommandException
*/
protected void createMasterPasswordFile() throws CommandException {
final File pwdFile = new File(this.getServerDirs().getAgentDir(), MASTER_PASSWORD_ALIAS);
try {
PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(), MASTER_PASSWORD_ALIAS.toCharArray());
p.setPasswordForAlias(MASTER_PASSWORD_ALIAS, newPassword.getBytes());
FileProtectionUtility.chmod0600(pwdFile);
} catch (Exception ex) {
throw new CommandException(strings.get("masterPasswordFileNotCreated", pwdFile), ex);
}
}
use of com.sun.enterprise.security.store.PasswordAdapter in project Payara by payara.
the class CreateLocalInstanceCommand method createMasterPasswordFile.
/**
* Create the master password keystore. This routine can also modify the master password
* if the keystore already exists
* @param masterPassword
* @throws CommandException
*/
protected void createMasterPasswordFile(String masterPassword) throws CommandException {
final File pwdFile = new File(this.getServerDirs().getAgentDir(), MASTER_PASSWORD_ALIAS);
try {
PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(), MASTER_PASSWORD_ALIAS.toCharArray());
p.setPasswordForAlias(MASTER_PASSWORD_ALIAS, masterPassword.getBytes());
FileProtectionUtility.chmod0600(pwdFile);
} catch (Exception ex) {
throw new CommandException(Strings.get("masterPasswordFileNotCreated", pwdFile), ex);
}
}
use of com.sun.enterprise.security.store.PasswordAdapter in project Payara by payara.
the class MasterPasswordFileManager method changeMasterPasswordInMasterPasswordFile.
/**
* Changes the master password in the master password file
* @param saveMasterPassword
* @param config
* @param newPassword
* @throws RepositoryException
*/
public void changeMasterPasswordInMasterPasswordFile(File pwdFile, String newPassword, boolean saveMasterPassword) throws RepositoryException {
FileUtils.deleteFile(pwdFile);
if (saveMasterPassword) {
try {
PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(), getMasterPasswordPassword());
p.setPasswordForAlias(MASTER_PASSWORD_ALIAS, newPassword.getBytes());
FileProtectionUtility.chmod0600(pwdFile);
} catch (Exception ex) {
throw new RepositoryException(_strMgr.getString("masterPasswordFileNotCreated", pwdFile), ex);
}
}
}
use of com.sun.enterprise.security.store.PasswordAdapter 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;
}
}
Aggregations