Package org.glassfish.security.common

Examples of org.glassfish.security.common.FileRealmHelper


            String adminKeyFile = launcher.getAdminRealmKeyFile();

            if (adminKeyFile != null) {
                //This is a FileRealm, instantiate it.
                FileRealmHelper helper = new FileRealmHelper(adminKeyFile);

                //Authenticate the old password
                String[] groups = helper.authenticate(programOpts.getUser(), password.toCharArray());
                if (groups == null) {
                    throw new CommandException(strings.get("InvalidCredentials", programOpts.getUser()));
                }
                helper.updateUser(programOpts.getUser(), programOpts.getUser(), newpassword.toCharArray(), null);
                helper.persist();
                return SUCCESS;

            } else {
                //Cannot change password locally for non file realms
                throw new CommandException(strings.get("NotFileRealmCannotChangeLocally"));
View Full Code Here


     */
    private void doAdminPasswordCheck() throws CommandException {
        String arfile = launcher.getAdminRealmKeyFile();
        if (arfile != null) {
            try {
                FileRealmHelper ar = new FileRealmHelper(arfile);
                if (!ar.hasAuthenticatableUser()) {
                    // Prompt for the password for the first user and set it
                    Set<String> names = ar.getUserNames();
                    if (names == null || names.isEmpty()) {
                        throw new CommandException("no admin users");
                    }
                    String auser = names.iterator().next();
                    ParamModelData npwo = new ParamModelData(newpwName, String.class, false, null);
                    npwo.prompt = strings.get("new.adminpw", auser);
                    npwo.promptAgain = strings.get("new.adminpw.again", auser);
                    npwo.param._password = true;
                    logger.info(strings.get("new.adminpw.prompt"));
                    String npw = super.getPassword(npwo, null, true);
                    if (npw == null) {
                        throw new CommandException(strings.get("no.console"));
                    }
                    ar.updateUser(auser, auser, npw.toCharArray(), null);
                    ar.persist();
                }
            } catch (IOException ioe) {
                throw new CommandException(ioe);
            }
        }
View Full Code Here

    */
    private void modifyKeyFile(File keyFile, String user, String password) throws
        IOException
    {
        final String keyFilePath = keyFile.getAbsolutePath();
        final FileRealmHelper fileRealm = new FileRealmHelper(keyFilePath);
        final String[] group =
            new String[]{AdminConstants.DOMAIN_ADMIN_GROUP_NAME};
        fileRealm.addUser(user, password.toCharArray(), group);
        fileRealm.persist();
    }
View Full Code Here

     */
    private void doAdminPasswordCheck() throws CommandException {
        String arfile = launcher.getAdminRealmKeyFile();
        if (arfile != null) { 
            try {
                FileRealmHelper ar = new FileRealmHelper(arfile);
                if (!ar.hasAuthenticatableUser()) {
                    // Prompt for the password for the first user and set it
                    Set<String> names = ar.getUserNames();
                    if (names == null || names.isEmpty()) {
                        throw new CommandException("no admin users");
                    }
                    String auser = names.iterator().next();
                    ParamModelData npwo = new ParamModelData(newpwName, String.class, false, null);
                    npwo.description = strings.get("new.adminpw", auser);
                    npwo.param._password = true;
                    logger.info(strings.get("new.adminpw.prompt"));
                    String npw = super.getPassword(npwo, null, true);
                    if (npw == null) {
                        throw new CommandException(strings.get("no.console"));
                    }
                    ar.updateUser(auser, auser, npw.toCharArray(), null);
                    ar.persist();
                }
            } catch (IOException ioe) {
                throw new CommandException(ioe);
            }
        }
View Full Code Here

            String adminKeyFile = launcher.getAdminRealmKeyFile();

            if (adminKeyFile != null) {
                //This is a FileRealm, instantiate it.
                FileRealmHelper helper = new FileRealmHelper(adminKeyFile);

                //Authenticate the old password
                String[] groups = helper.authenticate(programOpts.getUser(), password.toCharArray());
                if (groups == null) {
                    throw new CommandException(strings.get("InvalidCredentials", programOpts.getUser()));
                }
                helper.updateUser(programOpts.getUser(), programOpts.getUser(), newpassword.toCharArray(), null);
                helper.persist();
                return SUCCESS;

            } else {
                //Cannot change password locally for non file realms
                throw new CommandException(strings.get("NotFileRealmCannotChangeLocally"));
View Full Code Here

     * uses.
     */
    private void modifyKeyFile(File keyFile, String user, String password) throws
            IOException {
        final String keyFilePath = keyFile.getAbsolutePath();
        final FileRealmHelper fileRealm = new FileRealmHelper(keyFilePath);
        final String[] group =
                new String[]{AdminConstants.DOMAIN_ADMIN_GROUP_NAME};
        fileRealm.addUser(user, password.toCharArray(), group);
        fileRealm.persist();
    }
View Full Code Here

     * @param password Password.
     */
    void processAdminKeyFile(File keyFile, String user, String password)
            throws IOException {
        final String keyFilePath = keyFile.getAbsolutePath();
        final FileRealmHelper fileRealm = new FileRealmHelper(keyFilePath);
        final String[] group =   new String[]{AdminConstants.DOMAIN_ADMIN_GROUP_NAME};
        fileRealm.addUser(user, password.toCharArray(), group);
        fileRealm.persist();
    }
View Full Code Here

            String adminKeyFile = launcher.getAdminRealmKeyFile();

            if (adminKeyFile != null) {
                //This is a FileRealm, instantiate it.
                FileRealmHelper helper = new FileRealmHelper(adminKeyFile);

                //Authenticate the old password if the user does not have  RESET
                if(helper.hasAuthenticatableUser()) {
                    String[] groups = helper.authenticate(programOpts.getUser(), ((String) passwords.get(oldpwName)).toCharArray());
                    if (groups == null) {
                        throw new CommandException(strings.get("InvalidCredentials", programOpts.getUser()));
                    }
                }
                helper.updateUser(programOpts.getUser(), programOpts.getUser(), ((String) passwords.get(newpwName)).toCharArray(), null);
                helper.persist();
                return SUCCESS;

            } else {
                //Cannot change password locally for non file realms
                throw new CommandException(strings.get("NotFileRealmCannotChangeLocally"));
View Full Code Here

     */
    private void doAdminPasswordCheck() throws CommandException {
        String arfile = launcher.getAdminRealmKeyFile();
        if (arfile != null) { 
            try {
                FileRealmHelper ar = new FileRealmHelper(arfile);
                if (!ar.hasAuthenticatableUser()) {
                    // Prompt for the password for the first user and set it
                    Set<String> names = ar.getUserNames();
                    if (names == null || names.isEmpty()) {
                        throw new CommandException("no admin users");
                    }
                    String auser = names.iterator().next();
                    ParamModelData npwo = new ParamModelData(newpwName, String.class, false, null);
                    npwo.description = strings.get("new.adminpw", auser);
                    npwo.param._password = true;
                    logger.info(strings.get("new.adminpw.prompt"));
                    String npw = super.getPassword(npwo, null, true);
                    if (npw == null) {
                        throw new CommandException(strings.get("no.console"));
                    }
                    ar.updateUser(auser, auser, npw.toCharArray(), null);
                    ar.persist();
                }
            } catch (IOException ioe) {
                throw new CommandException(ioe);
            }
        }
View Full Code Here

       try {
            if (Util.isEmbeddedServer()) {
                String embeddedFilePath = Util.writeConfigFileToTempDir(file).getAbsolutePath();
                file = embeddedFilePath;
            }
            helper = new FileRealmHelper(file);
        } catch (IOException ioe) {
            String msg = sm.getString("filerealm.noaccess", ioe.toString());
            throw new BadRealmException(msg);
        }
    }
View Full Code Here

TOP

Related Classes of org.glassfish.security.common.FileRealmHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.