--- /dev/null
+/*
+ * The Shibboleth License, Version 1. Copyright (c) 2002 University Corporation for Advanced Internet Development, Inc.
+ * All rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met: Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution, if any, must include the following acknowledgment: "This product includes software
+ * developed by the University Corporation for Advanced Internet Development <http://www.ucaid.edu>Internet2 Project.
+ * Alternately, this acknowledegement may appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear. Neither the name of Shibboleth nor the names of its contributors, nor Internet2, nor
+ * the University Corporation for Advanced Internet Development, Inc., nor UCAID may be used to endorse or promote
+ * products derived from this software without specific prior written permission. For written permission, please contact
+ * shibboleth@shibboleth.org Products derived from this software may not be called Shibboleth, Internet2, UCAID, or the
+ * University Corporation for Advanced Internet Development, nor may Shibboleth appear in their name, without prior
+ * written permission of the University Corporation for Advanced Internet Development. THIS SOFTWARE IS PROVIDED BY THE
+ * COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE
+ * DISCLAIMED AND THE ENTIRE RISK OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE. IN NO
+ * EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC.
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package edu.internet2.middleware.shibboleth.utils.ant;
+
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.input.InputRequest;
+import org.apache.tools.ant.taskdefs.condition.Condition;
+
+/**
+ * Extended version of <code>org.apache.tools.ant.taskdefs.Input</code>
+ *
+ * @author Will Norris (wnorris@memphis.edu)
+ */
+public class XInput extends Task implements Condition {
+
+ private Boolean caseSensitive = new Boolean(true);
+ private String validArgs = null;
+ private String message = "";
+ private String addproperty = null;
+ private String defaultValue = null;
+ private String type = "standard";
+ private Vector options = new Vector();
+ private String value = null;
+
+ public void setCaseSensitive(Boolean b) {
+
+ this.caseSensitive = b;
+ }
+
+ public Boolean getCaseSensitive() {
+
+ return this.caseSensitive;
+ }
+
+ /**
+ * Defines valid input parameters as comma separated strings. If set, input task will reject any input not defined
+ * as accepted and requires the user to reenter it. Validargs are case sensitive. If you want 'a' and 'A' to be
+ * accepted you need to define both values as accepted arguments.
+ *
+ * @param validargs
+ * A comma separated String defining valid input args.
+ */
+ public void setValidargs(String validArgs) {
+
+ this.validArgs = validArgs;
+ }
+
+ /**
+ * Defines the name of a property to be created from input. Behaviour is according to property task which means that
+ * existing properties cannot be overridden.
+ *
+ * @param addproperty
+ * Name for the property to be created from input
+ */
+ public void setAddproperty(String addproperty) {
+
+ this.addproperty = addproperty;
+ }
+
+ /**
+ * Sets the Message which gets displayed to the user during the build run.
+ *
+ * @param message
+ * The message to be displayed.
+ */
+ public void setMessage(String message) {
+
+ this.message = message;
+ }
+
+ /**
+ * Defines the default value of the property to be created from input. Property value will be set to default if not
+ * input is received.
+ *
+ * @param defaultvalue
+ * Default value for the property if no input is received
+ */
+ public void setDefaultvalue(String defaultValue) {
+
+ this.defaultValue = defaultValue;
+ }
+
+ public void setType(String type) {
+
+ this.type = type;
+ }
+
+ public void addConfiguredXoption(XInputOption option) {
+
+ if (option.getCaseSensitive() == null) {
+ option.setCaseSensitive(getCaseSensitive());
+ }
+ if (defaultValue != null && option.acceptsInput(defaultValue)) {
+ option.setIsDefault(true);
+ }
+
+ options.add(option);
+ }
+
+ /**
+ * Set a multiline message.
+ *
+ * @param msg
+ * The message to be displayed.
+ */
+ public void addText(String msg) {
+
+ message += getProject().replaceProperties(msg);
+ }
+
+ /**
+ * No arg constructor.
+ */
+ public XInput() {
+
+ }
+
+ /**
+ * Actual method executed by ant.
+ *
+ * @throws BuildException
+ */
+ public void execute() throws BuildException {
+
+ if (addproperty != null && getProject().getProperty(addproperty) != null) {
+ log("skipping " + getTaskName() + " as property " + addproperty + " has already been set.");
+ return;
+ }
+
+ InputRequest request = null;
+
+ if (type.equals("menu")) {
+ getProject().setInputHandler(new XMenuInputHandler());
+ request = new XMultipleChoiceInputRequest(message.trim(), options);
+ } else if (type.equals("confirm")) {
+ setCaseSensitive(new Boolean(false));
+ addConfiguredXoption(new XInputOption("y", "y,yes,t,true", "y"));
+ addConfiguredXoption(new XInputOption("n", "n,no,f,false", "n"));
+
+ getProject().setInputHandler(new XInputHandler());
+ request = new XMultipleChoiceInputRequest(message.trim(), options);
+ } else {
+ getProject().setInputHandler(new XInputHandler());
+ request = new XMultipleChoiceInputRequest(message.trim(), options);
+ }
+
+ getProject().getInputHandler().handleInput(request);
+
+ value = request.getInput();
+ if ((value == null || value.trim().length() == 0) && defaultValue != null) {
+ value = defaultValue;
+ }
+ if (addproperty != null && value != null) {
+ getProject().setNewProperty(addproperty, value);
+ }
+ }
+
+ public boolean eval() {
+
+ if (!type.equals("confirm")) { throw new BuildException(); }
+
+ execute();
+ return value.equals("y");
+ }
+
+}
--- /dev/null
+/*
+ * The Shibboleth License, Version 1. Copyright (c) 2002 University Corporation for Advanced Internet Development, Inc.
+ * All rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met: Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution, if any, must include the following acknowledgment: "This product includes software
+ * developed by the University Corporation for Advanced Internet Development <http://www.ucaid.edu>Internet2 Project.
+ * Alternately, this acknowledegement may appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear. Neither the name of Shibboleth nor the names of its contributors, nor Internet2, nor
+ * the University Corporation for Advanced Internet Development, Inc., nor UCAID may be used to endorse or promote
+ * products derived from this software without specific prior written permission. For written permission, please contact
+ * shibboleth@shibboleth.org Products derived from this software may not be called Shibboleth, Internet2, UCAID, or the
+ * University Corporation for Advanced Internet Development, nor may Shibboleth appear in their name, without prior
+ * written permission of the University Corporation for Advanced Internet Development. THIS SOFTWARE IS PROVIDED BY THE
+ * COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE
+ * DISCLAIMED AND THE ENTIRE RISK OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE. IN NO
+ * EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC.
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package edu.internet2.middleware.shibboleth.utils.ant;
+
+import java.util.Iterator;
+
+import org.apache.tools.ant.input.DefaultInputHandler;
+import org.apache.tools.ant.input.InputRequest;
+
+/**
+ * Extended version of <code>org.apache.tools.ant.input.DefaultInputHandler</code>.
+ *
+ * @author Will Norris (wnorris@memphis.edu)
+ */
+public class XInputHandler extends DefaultInputHandler {
+
+ public XInputHandler() {
+
+ super();
+
+ }
+
+ protected String getPrompt(InputRequest request) {
+
+ String prompt = request.getPrompt();
+ if (request instanceof XMultipleChoiceInputRequest) {
+ StringBuffer sb = new StringBuffer("\n" + prompt);
+ sb.append(" [");
+ Iterator i = ((XMultipleChoiceInputRequest) request).getOptions().iterator();
+ boolean first = true;
+ while (i.hasNext()) {
+ if (!first) {
+ sb.append(",");
+ }
+ XInputOption o = (XInputOption) i.next();
+ sb.append(o.isDefault() ? o.displayName().toUpperCase() : o.displayName());
+ first = false;
+ }
+ sb.append("]");
+ prompt = sb.toString();
+ }
+ return prompt;
+ }
+
+}
--- /dev/null
+/*
+ * The Shibboleth License, Version 1. Copyright (c) 2002 University Corporation for Advanced Internet Development, Inc.
+ * All rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met: Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution, if any, must include the following acknowledgment: "This product includes software
+ * developed by the University Corporation for Advanced Internet Development <http://www.ucaid.edu>Internet2 Project.
+ * Alternately, this acknowledegement may appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear. Neither the name of Shibboleth nor the names of its contributors, nor Internet2, nor
+ * the University Corporation for Advanced Internet Development, Inc., nor UCAID may be used to endorse or promote
+ * products derived from this software without specific prior written permission. For written permission, please contact
+ * shibboleth@shibboleth.org Products derived from this software may not be called Shibboleth, Internet2, UCAID, or the
+ * University Corporation for Advanced Internet Development, nor may Shibboleth appear in their name, without prior
+ * written permission of the University Corporation for Advanced Internet Development. THIS SOFTWARE IS PROVIDED BY THE
+ * COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE
+ * DISCLAIMED AND THE ENTIRE RISK OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE. IN NO
+ * EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC.
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package edu.internet2.middleware.shibboleth.utils.ant;
+
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.util.StringUtils;
+
+/**
+ * @author Will Norris (wnorris@memphis.edu)
+ */
+public class XInputOption extends ProjectComponent {
+
+ private Boolean caseSensitive = null;
+ private String value = "";
+ private Vector validArgs = null;
+ private String displayName = null;
+ private boolean isDefault = false;
+
+ public XInputOption() {
+
+ super();
+ }
+
+ public XInputOption(String value, String validargs, String displayName) {
+
+ setValue(value);
+ setValidArgs(validargs);
+ addText(displayName);
+ }
+
+ public void setCasesensitive(boolean b) {
+
+ setCaseSensitive(new Boolean(b));
+ }
+
+ public void setCaseSensitive(Boolean b) {
+
+ this.caseSensitive = b;
+ }
+
+ public Boolean getCaseSensitive() {
+
+ return this.caseSensitive;
+ }
+
+ public void setValue(String value) {
+
+ this.value = value;
+ }
+
+ public String getValue() {
+
+ if (value == null || value.equals("")) { return displayName(); }
+
+ return this.value;
+ }
+
+ public void setValidArgs(String validargs) {
+
+ this.validArgs = StringUtils.split(validargs, ',');
+ }
+
+ public Vector getValidArgs() {
+
+ if (validArgs != null) {
+ return this.validArgs;
+ } else {
+ Vector v = new Vector();
+ v.add(getValue());
+ return v;
+ }
+ }
+
+ public void addText(String text) {
+
+ this.displayName = text;
+ }
+
+ public String displayName() {
+
+ return displayName;
+ }
+
+ public void setIsDefault(boolean b) {
+
+ this.isDefault = b;
+ }
+
+ public boolean isDefault() {
+
+ return this.isDefault;
+ }
+
+ public boolean acceptsInput(String input) {
+
+ if (input.equals("") && isDefault()) { return true; }
+
+ Iterator i = getValidArgs().iterator();
+ while (i.hasNext()) {
+ String arg = (String) i.next();
+ if (getCaseSensitive().booleanValue()) {
+ if (arg.equals(input)) { return true; }
+ } else {
+ if (arg.equalsIgnoreCase(input)) { return true; }
+ }
+ }
+ return false;
+ }
+}
--- /dev/null
+/*
+ * The Shibboleth License, Version 1. Copyright (c) 2002 University Corporation for Advanced Internet Development, Inc.
+ * All rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met: Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution, if any, must include the following acknowledgment: "This product includes software
+ * developed by the University Corporation for Advanced Internet Development <http://www.ucaid.edu>Internet2 Project.
+ * Alternately, this acknowledegement may appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear. Neither the name of Shibboleth nor the names of its contributors, nor Internet2, nor
+ * the University Corporation for Advanced Internet Development, Inc., nor UCAID may be used to endorse or promote
+ * products derived from this software without specific prior written permission. For written permission, please contact
+ * shibboleth@shibboleth.org Products derived from this software may not be called Shibboleth, Internet2, UCAID, or the
+ * University Corporation for Advanced Internet Development, nor may Shibboleth appear in their name, without prior
+ * written permission of the University Corporation for Advanced Internet Development. THIS SOFTWARE IS PROVIDED BY THE
+ * COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE
+ * DISCLAIMED AND THE ENTIRE RISK OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE. IN NO
+ * EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC.
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package edu.internet2.middleware.shibboleth.utils.ant;
+
+import org.apache.tools.ant.input.InputRequest;
+
+/**
+ * Extended version of <code>org.apache.tools.ant.input.InputRequest</code>
+ *
+ * @author Will Norris (wnorris@memphis.edu)
+ */
+public class XInputRequest extends InputRequest {
+
+ private String prompt;
+ private String input;
+
+ /**
+ * @param prompt
+ * The prompt to show to the user. Must not be null.
+ */
+ public XInputRequest(String prompt) {
+
+ super(prompt);
+ if (prompt == null) { throw new IllegalArgumentException("prompt must not be null"); }
+
+ this.prompt = prompt;
+ }
+
+ /**
+ * Retrieves the prompt text.
+ */
+ public String getPrompt() {
+
+ return prompt;
+ }
+
+ /**
+ * Sets the user provided input.
+ */
+ public void setInput(String input) {
+
+ this.input = input;
+ }
+
+ /**
+ * Is the user input valid?
+ */
+ public boolean isInputValid() {
+
+ return true;
+ }
+
+ /**
+ * Retrieves the user input.
+ */
+ public String getInput() {
+
+ return input;
+ }
+
+}
--- /dev/null
+/*
+ * The Shibboleth License, Version 1. Copyright (c) 2002 University Corporation for Advanced Internet Development, Inc.
+ * All rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met: Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution, if any, must include the following acknowledgment: "This product includes software
+ * developed by the University Corporation for Advanced Internet Development <http://www.ucaid.edu>Internet2 Project.
+ * Alternately, this acknowledegement may appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear. Neither the name of Shibboleth nor the names of its contributors, nor Internet2, nor
+ * the University Corporation for Advanced Internet Development, Inc., nor UCAID may be used to endorse or promote
+ * products derived from this software without specific prior written permission. For written permission, please contact
+ * shibboleth@shibboleth.org Products derived from this software may not be called Shibboleth, Internet2, UCAID, or the
+ * University Corporation for Advanced Internet Development, nor may Shibboleth appear in their name, without prior
+ * written permission of the University Corporation for Advanced Internet Development. THIS SOFTWARE IS PROVIDED BY THE
+ * COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE
+ * DISCLAIMED AND THE ENTIRE RISK OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE. IN NO
+ * EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC.
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package edu.internet2.middleware.shibboleth.utils.ant;
+
+import java.util.Iterator;
+
+import org.apache.tools.ant.input.DefaultInputHandler;
+import org.apache.tools.ant.input.InputRequest;
+
+/**
+ * Input handler to display of a multiple choice menu
+ *
+ * @author Will Norris (wnorris@memphis.edu)
+ */
+public class XMenuInputHandler extends DefaultInputHandler {
+
+ /**
+ *
+ */
+ public XMenuInputHandler() {
+
+ super();
+ }
+
+ protected String getPrompt(InputRequest request) {
+
+ String prompt = request.getPrompt();
+ if (request instanceof XMultipleChoiceInputRequest) {
+ StringBuffer sb = new StringBuffer("\n" + prompt);
+ sb.append("\n");
+ Iterator i = ((XMultipleChoiceInputRequest) request).getOptions().iterator();
+ boolean first = true;
+ int count = 0;
+ while (i.hasNext()) {
+ if (!first) {
+ sb.append("\n");
+ }
+ count++;
+ XInputOption o = (XInputOption) i.next();
+ sb.append(" " + count + ") " + o.displayName());
+ if (o.isDefault()) {
+ sb.append(" (default)");
+ }
+ first = false;
+ }
+ prompt = sb.toString();
+ }
+ return prompt;
+ }
+
+}
--- /dev/null
+/*
+ * The Shibboleth License, Version 1. Copyright (c) 2002 University Corporation for Advanced Internet Development, Inc.
+ * All rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted
+ * provided that the following conditions are met: Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution, if any, must include the following acknowledgment: "This product includes software
+ * developed by the University Corporation for Advanced Internet Development <http://www.ucaid.edu>Internet2 Project.
+ * Alternately, this acknowledegement may appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear. Neither the name of Shibboleth nor the names of its contributors, nor Internet2, nor
+ * the University Corporation for Advanced Internet Development, Inc., nor UCAID may be used to endorse or promote
+ * products derived from this software without specific prior written permission. For written permission, please contact
+ * shibboleth@shibboleth.org Products derived from this software may not be called Shibboleth, Internet2, UCAID, or the
+ * University Corporation for Advanced Internet Development, nor may Shibboleth appear in their name, without prior
+ * written permission of the University Corporation for Advanced Internet Development. THIS SOFTWARE IS PROVIDED BY THE
+ * COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE
+ * DISCLAIMED AND THE ENTIRE RISK OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE. IN NO
+ * EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC.
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package edu.internet2.middleware.shibboleth.utils.ant;
+
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.apache.tools.ant.input.InputRequest;
+
+/**
+ * @author Will Norris (wnorris@memphis.edu)
+ */
+public class XMultipleChoiceInputRequest extends InputRequest {
+
+ private Vector options = null;
+
+ public XMultipleChoiceInputRequest(String prompt, Vector options) {
+
+ super(prompt);
+ if (options == null) { throw new IllegalArgumentException("choices must not be null"); }
+ this.options = options;
+ }
+
+ public Vector getOptions() {
+
+ return options;
+ }
+
+ /**
+ * @return The possible values.
+ */
+ public Vector getChoices() {
+
+ Vector choices = new Vector();
+
+ Iterator i = options.iterator();
+ while (i.hasNext()) {
+ XInputOption o = (XInputOption) i.next();
+ choices.add(o.displayName());
+ }
+
+ return choices;
+ }
+
+ /**
+ * @return true if the input is one of the allowed values.
+ */
+ public boolean isInputValid() {
+
+ // first check if any XInputOptions will accept the input
+ Iterator i = options.iterator();
+ while (i.hasNext()) {
+ XInputOption o = (XInputOption) i.next();
+ if (o.acceptsInput(getInput())) {
+ setInput(o.getValue());
+ return true;
+ }
+ }
+
+ // next check if they tried to input a menu item number
+ try {
+ Integer input = new Integer(getInput());
+ if (input.intValue() > 0 && input.intValue() <= options.size()) {
+ XInputOption o = (XInputOption) options.get(input.intValue() - 1);
+ setInput(o.getValue());
+ return true;
+ }
+ } catch (NumberFormatException nfe) {
+ // input was not a number
+ }
+
+ return false;
+ }
+
+}