Search in sources :

Example 1 with StoreException

use of com.sun.appserv.management.client.prefs.StoreException in project Payara by payara.

the class RemoteCLICommand method initializeAuth.

private void initializeAuth() throws CommandException {
    LoginInfo li = null;
    try {
        LoginInfoStore store = LoginInfoStoreFactory.getDefaultStore();
        li = store.read(programOpts.getHost(), programOpts.getPort());
        if (li == null)
            return;
    } catch (StoreException se) {
        logger.finer("Login info could not be read from ~/.asadminpass file");
        return;
    }
    /*
         * If we don't have a user name, initialize it from .asadminpass.
         * In that case, also initialize the password unless it was
         * already specified (overriding what's in .asadminpass).
         *
         * If we already have a user name, and it's the same as what's
         * in .asadminpass, and we don't have a password, use the password
         * from .asadminpass.
         */
    if (programOpts.getUser() == null) {
        // not on command line and in .asadminpass
        if (logger.isLoggable(Level.FINER))
            logger.finer("Getting user name from ~/.asadminpass: " + li.getUser());
        programOpts.setUser(li.getUser());
        if (programOpts.getPassword() == null) {
            // not in passwordfile and in .asadminpass
            logger.finer("Getting password from ~/.asadminpass");
            programOpts.setPassword(li.getPassword(), ProgramOptions.PasswordLocation.LOGIN_FILE);
        }
    } else if (programOpts.getUser().equals(li.getUser())) {
        if (programOpts.getPassword() == null) {
            // not in passwordfile and in .asadminpass
            logger.finer("Getting password from ~/.asadminpass");
            programOpts.setPassword(li.getPassword(), ProgramOptions.PasswordLocation.LOGIN_FILE);
        }
    }
}
Also used : LoginInfo(com.sun.appserv.management.client.prefs.LoginInfo) LoginInfoStore(com.sun.appserv.management.client.prefs.LoginInfoStore) StoreException(com.sun.appserv.management.client.prefs.StoreException)

Example 2 with StoreException

use of com.sun.appserv.management.client.prefs.StoreException in project Payara by payara.

the class RemoteCommand method initializeAuth.

private void initializeAuth() throws CommandException {
    LoginInfo li = null;
    try {
        LoginInfoStore store = LoginInfoStoreFactory.getDefaultStore();
        li = store.read(programOpts.getHost(), programOpts.getPort());
        if (li == null)
            return;
    } catch (StoreException se) {
        logger.finer("Login info could not be read from ~/.asadminpass file");
        return;
    }
    /*
         * If we don't have a user name, initialize it from .asadminpass.
         * In that case, also initialize the password unless it was
         * already specified (overriding what's in .asadminpass).
         *
         * If we already have a user name, and it's the same as what's
         * in .asadminpass, and we don't have a password, use the password
         * from .asadminpass.
         */
    if (programOpts.getUser() == null) {
        // not on command line and in .asadminpass
        if (logger.isLoggable(Level.FINER))
            logger.finer("Getting user name from ~/.asadminpass: " + li.getUser());
        programOpts.setUser(li.getUser());
        if (programOpts.getPassword() == null) {
            // not in passwordfile and in .asadminpass
            logger.finer("Getting password from ~/.asadminpass");
            programOpts.setPassword(li.getPassword(), ProgramOptions.PasswordLocation.LOGIN_FILE);
        }
    } else if (programOpts.getUser().equals(li.getUser())) {
        if (programOpts.getPassword() == null) {
            // not in passwordfile and in .asadminpass
            logger.finer("Getting password from ~/.asadminpass");
            programOpts.setPassword(li.getPassword(), ProgramOptions.PasswordLocation.LOGIN_FILE);
        }
    }
}
Also used : LoginInfo(com.sun.appserv.management.client.prefs.LoginInfo) LoginInfoStore(com.sun.appserv.management.client.prefs.LoginInfoStore) StoreException(com.sun.appserv.management.client.prefs.StoreException)

Aggregations

LoginInfo (com.sun.appserv.management.client.prefs.LoginInfo)2 LoginInfoStore (com.sun.appserv.management.client.prefs.LoginInfoStore)2 StoreException (com.sun.appserv.management.client.prefs.StoreException)2