Search in sources :

Example 6 with PEFileLayout

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);
}
Also used : PEFileLayout(com.sun.enterprise.admin.servermgmt.pe.PEFileLayout) File(java.io.File)

Example 7 with PEFileLayout

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);
    }
}
Also used : PEFileLayout(com.sun.enterprise.admin.servermgmt.pe.PEFileLayout) PasswordAdapter(com.sun.enterprise.security.store.PasswordAdapter) File(java.io.File)

Example 8 with PEFileLayout

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);
        }
    }
}
Also used : PEFileLayout(com.sun.enterprise.admin.servermgmt.pe.PEFileLayout) PasswordAdapter(com.sun.enterprise.security.store.PasswordAdapter) ZipFile(com.sun.enterprise.util.zip.ZipFile)

Example 9 with PEFileLayout

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.
             */
    }
}
Also used : PEFileLayout(com.sun.enterprise.admin.servermgmt.pe.PEFileLayout) ZipFile(com.sun.enterprise.util.zip.ZipFile)

Example 10 with PEFileLayout

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);
    }
}
Also used : PEFileLayout(com.sun.enterprise.admin.servermgmt.pe.PEFileLayout) ZipFile(com.sun.enterprise.util.zip.ZipFile)

Aggregations

PEFileLayout (com.sun.enterprise.admin.servermgmt.pe.PEFileLayout)15 ZipFile (com.sun.enterprise.util.zip.ZipFile)8 File (java.io.File)6 PasswordAdapter (com.sun.enterprise.security.store.PasswordAdapter)5 IOException (java.io.IOException)3 TokenValue (com.sun.enterprise.admin.util.TokenValue)2 TokenValueSet (com.sun.enterprise.admin.util.TokenValueSet)2 SmartFile (com.sun.enterprise.universal.io.SmartFile)2 ExecException (com.sun.enterprise.util.ExecException)2 FileNotFoundException (java.io.FileNotFoundException)2 KeyStoreException (java.security.KeyStoreException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 CertificateException (java.security.cert.CertificateException)2 CertificateExpiredException (java.security.cert.CertificateExpiredException)2 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)2 RepositoryConfig (com.sun.enterprise.admin.servermgmt.RepositoryConfig)1 PropertyVetoException (java.beans.PropertyVetoException)1 FileInputStream (java.io.FileInputStream)1 KeyStore (java.security.KeyStore)1 ArrayList (java.util.ArrayList)1