All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.anrisoftware.sscontrol.scripts.localuser.LocalChangePassword Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2014-2015 Erwin Müller 
 *
 * This file is part of sscontrol-scripts-unix.
 *
 * sscontrol-scripts-unix is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * sscontrol-scripts-unix is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with sscontrol-scripts-unix. If not, see .
 */
package com.anrisoftware.sscontrol.scripts.localuser;

import java.util.Map;
import java.util.concurrent.Callable;

import javax.inject.Inject;

import com.anrisoftware.globalpom.exec.api.ProcessTask;
import com.anrisoftware.globalpom.exec.scriptprocess.ScriptExecFactory;
import com.anrisoftware.globalpom.threads.api.Threads;
import com.anrisoftware.resources.templates.api.TemplateResource;
import com.anrisoftware.resources.templates.api.Templates;
import com.anrisoftware.resources.templates.api.TemplatesFactory;
import com.google.inject.assistedinject.Assisted;

/**
 * Changing the password of the local user.
 * 
 * @author Erwin Mueller, [email protected]
 * @since 1.0
 */
public class LocalChangePassword implements Callable {

    private final LocalChangePasswordLogger log;

    private final Map args;

    private final Threads threads;

    private final Object parent;

    @Inject
    private TemplatesFactory templatesFactory;

    @Inject
    private ScriptExecFactory scriptExecFactory;

    /**
     * @see LocalChangePasswordFactory#create(Map, Object, Threads)
     */
    @Inject
    LocalChangePassword(LocalChangePasswordLogger log,
            @Assisted Map args, @Assisted Object parent,
            @Assisted Threads threads) {
        this.log = log;
        this.args = args;
        this.parent = parent;
        this.threads = threads;
        log.userName(args);
        log.password(args);
        log.command(args);
    }

    @Override
    public LocalChangePassword call() throws Exception {
        Templates templates = templatesFactory.create("ScriptsUnixTemplates");
        TemplateResource templateResource = templates.getResource("changepass");
        String name = "unix";
        ProcessTask task = scriptExecFactory.create(args, parent, threads,
                templateResource, name).call();
        log.passwordChanged(parent, task, args);
        return this;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy