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

hudson.cli.handlers.RequiresAuthenticationOptionHandler Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2013 Hudson.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Hudson - initial API and implementation and/or initial documentation
 */

package hudson.cli.handlers;

import hudson.model.TopLevelItem;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.OptionDef;
import org.kohsuke.args4j.spi.OptionHandler;
import org.kohsuke.args4j.spi.Setter;

/**
 * Works around a design flaw in option handlers. Certain parameters may require
 * an authenticated user to succeed; other parameters, e.g., --username and
 * --password are used to authenticate users.
 * Thus, parseArguments may require authentication and be required by
 * authentication.
 * @author Bob Foster
 */
public abstract class RequiresAuthenticationOptionHandler extends OptionHandler  {

    public RequiresAuthenticationOptionHandler(CmdLineParser parser, OptionDef option, Setter setter) {
        super(parser, option, setter);
    }
    
    private static boolean isAuthenticated;
    
    public static boolean isAuthenticated() {
        return isAuthenticated;
    }
    
    public static void setIsAuthenticated(boolean isAuthenticated) {
        RequiresAuthenticationOptionHandler.isAuthenticated = isAuthenticated;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy