Example usage for java.security InvalidParameterException InvalidParameterException

List of usage examples for java.security InvalidParameterException InvalidParameterException

Introduction

In this page you can find the example usage for java.security InvalidParameterException InvalidParameterException.

Prototype

public InvalidParameterException(String msg) 

Source Link

Document

Constructs an InvalidParameterException with the specified detail message.

Usage

From source file:edu.chalmers.dat255.audiobookplayer.model.Track.java

/**
 * Constructor for a track. Path to the data source as well as the length of
 * the track must be provided. The path may not be an empty string ("").
 * /*from ww  w . jav a 2 s .  c  o m*/
 * @param path
 *            Path to the track
 * @param duration
 *            Playing time of the track in ms.
 */
public Track(String path, int duration) {
    if (path != null && path.length() > 0 && duration > 0) {
        this.path = path;
        this.duration = duration;
    } else {
        throw new InvalidParameterException(
                "Attempting to create track with either null path or negative duration.");
    }
}

From source file:com.neophob.sematrix.cli.PixConClient.java

/**
 * Parses the argument.//w  w  w  . j a  v a2s.  c  o  m
 *
 * @param args the args
 * @return the parsed argument
 * @throws InvalidParameterException 
 */
protected static ParsedArgument parseArgument(String[] args) throws InvalidParameterException {

    if (args.length < 2) {
        System.out.println("No arguments specified!\n");
        throw new InvalidParameterException("No arguments specified!");
    }

    CmdLineParser parser = new CmdLineParser();
    CmdLineParser.Option host = parser.addStringOption('h', PARAM_HOST);
    CmdLineParser.Option port = parser.addIntegerOption('p', PARAM_PORT);
    CmdLineParser.Option command = parser.addStringOption('c', PARAM_COMMAND);

    String pCmd = "undefined";
    try {
        parser.parse(args);
        String pHost = (String) parser.getOptionValue(host, DEFAULT_HOST);
        int pPort = (Integer) parser.getOptionValue(port, DEFAULT_PORT);
        pCmd = (String) parser.getOptionValue(command);
        if (pCmd == null) {
            System.out.println("Unknown Command: " + ArrayUtils.toString(args));
            System.out.println("Exit now");
            throw new IllegalArgumentException("no ValidCommand specified!");
        }

        ValidCommands parsedCommand = ValidCommands.valueOf(pCmd.toUpperCase());
        String[] otherArgs = parser.getRemainingArgs();

        if (parsedCommand.getNrOfParams() < otherArgs.length) {
            String err = "Invalid parameter count, expected: " + parsedCommand.getNrOfParams() + ", provided: "
                    + otherArgs.length;
            System.out.println(err);
            throw new InvalidParameterException(err);
        }

        String param = "";
        for (String s : otherArgs) {
            param += s + " ";
        }

        return new ParsedArgument(pHost, pPort, parsedCommand, param.trim());
    } catch (UnknownOptionException e) {
        System.out.println("Invalid option defined: " + e.getMessage());
        System.out.println();
    } catch (IllegalOptionValueException e) {
        System.out.println("Invalid option value defined: " + e.getMessage());
        System.out.println();
    } catch (IllegalArgumentException e) {
        System.out.println("Invalid command defined <" + pCmd + ">: " + e.getMessage());
        System.out.println();
    }

    throw new InvalidParameterException("Something went wrong..");
}

From source file:uk.ac.ebi.mdk.io.AbstractDataOutput.java

public Integer newObjectId(Object obj) {

    if (objectIds.containsKey(obj))
        throw new InvalidParameterException("Object already has id!");

    iterator.increment();//  www  .j a va  2s . c o  m

    if (iterator.toInteger().equals(Integer.MAX_VALUE)) {
        System.err.println("Fatal error - run out of unique object ids");
        System.exit(0);
    }

    objectIds.put(obj, iterator.toInteger());
    return iterator.intValue();
}

From source file:org.hillview.sketches.JLProjection.java

public JLProjection(String[] colNames, int lowDim) {
    if (lowDim <= 0)
        throw new InvalidParameterException("LowDim has to be positive.");
    this.lowDim = lowDim;
    this.colNames = colNames;
    this.hMap = new LinkedHashMap<String, double[]>();
    for (String s : colNames)
        this.hMap.put(s, new double[this.lowDim]);
    this.highDim = 0;
    this.corrMatrix = null;
}

From source file:com.predic8.membrane.annot.bean.MCUtil.java

@SuppressWarnings("unchecked")
public static <T> T clone(T object, boolean deep) {
    try {/*  w  w  w  . j  a v a 2s .  co  m*/
        if (object == null)
            throw new InvalidParameterException("'object' must not be null.");

        Class<? extends Object> clazz = object.getClass();

        MCElement e = clazz.getAnnotation(MCElement.class);
        if (e == null)
            throw new IllegalArgumentException("'object' must be @MCElement-annotated.");

        BeanWrapperImpl dst = new BeanWrapperImpl(clazz);
        BeanWrapperImpl src = new BeanWrapperImpl(object);

        for (Method m : clazz.getMethods()) {
            if (!m.getName().startsWith("set"))
                continue;
            String propertyName = AnnotUtils.dejavaify(m.getName().substring(3));
            MCAttribute a = m.getAnnotation(MCAttribute.class);
            if (a != null) {
                dst.setPropertyValue(propertyName, src.getPropertyValue(propertyName));
            }
            MCChildElement c = m.getAnnotation(MCChildElement.class);
            if (c != null) {
                if (deep) {
                    dst.setPropertyValue(propertyName, cloneInternal(src.getPropertyValue(propertyName), deep));
                } else {
                    dst.setPropertyValue(propertyName, src.getPropertyValue(propertyName));
                }
            }
            MCOtherAttributes o = m.getAnnotation(MCOtherAttributes.class);
            if (o != null) {
                dst.setPropertyValue(propertyName, src.getPropertyValue(propertyName));
            }
            MCTextContent t = m.getAnnotation(MCTextContent.class);
            if (t != null) {
                dst.setPropertyValue(propertyName, src.getPropertyValue(propertyName));
            }
        }

        return (T) dst.getRootInstance();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:sh.isaac.api.chronicle.ObjectChronologyType.java

/**
 * Parses the.//w  w w .  j ava2 s  .  c  o  m
 *
 * @param nameOrEnumId the name or enum id
 * @param exceptionOnParseFail the exception on parse fail
 * @return the object chronology type
 */
public static ObjectChronologyType parse(String nameOrEnumId, boolean exceptionOnParseFail) {
    if (nameOrEnumId == null) {
        return null;
    }

    final String clean = nameOrEnumId.toLowerCase(Locale.ENGLISH).trim();

    if (StringUtils.isBlank(clean)) {
        return null;
    }

    for (final ObjectChronologyType ct : values()) {
        if (ct.name().toLowerCase(Locale.ENGLISH).equals(clean)
                || ct.niceName.toLowerCase(Locale.ENGLISH).equals(clean) || (ct.ordinal() + "").equals(clean)) {
            return ct;
        }
    }

    if (exceptionOnParseFail) {
        throw new InvalidParameterException("Could not determine ObjectChronologyType from " + nameOrEnumId);
    }

    return UNKNOWN_NID;
}

From source file:org.eurekastreams.commons.search.QueryParserBuilder.java

/**
 * Constructor./*w  w  w . j a va 2s .co m*/
 * 
 * @param inDefaultField
 *            the default field to use if none are provided.
 * @param inAnalyzer
 *            the Analyzer to use to parse the query string
 * @param inDefaultBooleanOperator
 *            the default boolean operator (AND, OR)
 */
public QueryParserBuilder(final String inDefaultField, final Analyzer inAnalyzer,
        final String inDefaultBooleanOperator) {
    defaultField = inDefaultField;
    analyzer = inAnalyzer;
    if (inDefaultBooleanOperator.equalsIgnoreCase("OR")) {
        defaultBooleanOperator = Operator.OR;
    } else if (inDefaultBooleanOperator.equalsIgnoreCase("AND")) {
        defaultBooleanOperator = Operator.AND;
    } else {
        throw new InvalidParameterException("Valid values for default boolean operator: [AND, OR]");
    }
}

From source file:eu.bittrade.libs.steemj.configuration.PrivateKeyStorage.java

/**
 * Get a private key of the given private key type for the given account
 * name./*from w ww  .j  a va 2 s  . co m*/
 * 
 * @param privateKeyType
 *            The type of the key to request.
 * @param accountName
 *            The account to request the key for.
 * @throws InvalidParameterException
 *             If no key could be find for the given account name.
 * @return The requested private key.
 */
public ECKey getKeyForAccount(PrivateKeyType privateKeyType, AccountName accountName) {
    List<ImmutablePair<PrivateKeyType, ECKey>> privateKeysForAccount = this.getPrivateKeysPerAccounts()
            .get(accountName);

    if (privateKeysForAccount == null) {
        throw new InvalidParameterException(privateKeyType.name() + " for the account '" + accountName
                + "' has not been added to the PrivateKeyStore.");
    }

    for (ImmutablePair<PrivateKeyType, ECKey> privateKey : privateKeysForAccount) {
        if (privateKey != null && privateKey.getLeft().equals(privateKeyType)) {
            return privateKey.getRight();
        }
    }

    throw new InvalidParameterException(privateKeyType.name() + " for the account '" + accountName
            + "' has not been added to the PrivateKeyStore.");
}

From source file:org.pentaho.platform.engine.services.solution.SolutionUrlContentGenerator.java

@Override
public void createContent() throws Exception {
    OutputStream out = null;//from  w  ww  .  j  a va  2 s  .co  m
    if (outputHandler == null) {
        error(Messages.getInstance().getErrorString("SimpleContentGenerator.ERROR_0001_NO_OUTPUT_HANDLER")); //$NON-NLS-1$
        throw new InvalidParameterException(
                Messages.getInstance().getString("SimpleContentGenerator.ERROR_0001_NO_OUTPUT_HANDLER")); //$NON-NLS-1$
    }

    IParameterProvider params = parameterProviders.get("path"); //$NON-NLS-1$

    String urlPath = params.getStringParameter("path", null); //$NON-NLS-1$

    ActionInfo pathInfo = ActionInfo.parseActionString(urlPath);

    if (pathInfo == null) {
        // there is no path so we don't know what to return
        error(Messages.getInstance().getErrorString("SolutionURLContentGenerator.ERROR_0001_NO_FILEPATH")); //$NON-NLS-1$
        return;
    }

    if (PentahoSystem.debug)
        debug("SolutionResourceContentGenerator urlPath=" + urlPath); //$NON-NLS-1$
    int type = TYPE_UNKNOWN;

    // work out what this thing is
    String filename = pathInfo.getActionName();
    String extension = ""; //$NON-NLS-1$
    int index = filename.lastIndexOf('.');
    if (index != -1) {
        extension = filename.substring(index + 1);
    }

    // is this a plugin file type?
    if (type == TYPE_UNKNOWN) {
        IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, userSession);
        if (pluginManager != null) {
            IContentGenerator contentGenerator = pluginManager.getContentGeneratorForType(extension,
                    userSession);
            if (contentGenerator != null) {
                // set up the path parameters
                IParameterProvider requestParams = parameterProviders.get(IParameterProvider.SCOPE_REQUEST);
                if (requestParams instanceof SimpleParameterProvider) {
                    ((SimpleParameterProvider) requestParams).setParameter("solution", //$NON-NLS-1$
                            pathInfo.getSolutionName());
                    ((SimpleParameterProvider) requestParams).setParameter("path", pathInfo.getPath()); //$NON-NLS-1$
                    ((SimpleParameterProvider) requestParams).setParameter("name", pathInfo.getActionName()); //$NON-NLS-1$
                    ((SimpleParameterProvider) requestParams).setParameter("action", pathInfo.getActionName()); //$NON-NLS-1$
                }
                // delegate over to the content generator for this file type
                contentGenerator.setCallbacks(callbacks);
                contentGenerator.setInstanceId(instanceId);
                contentGenerator.setItemName(itemName);
                contentGenerator.setLoggingLevel(loggingLevel);
                contentGenerator.setMessagesList(messages);
                contentGenerator.setOutputHandler(outputHandler);
                contentGenerator.setParameterProviders(parameterProviders);
                contentGenerator.setSession(userSession);
                contentGenerator.setUrlFactory(urlFactory);
                contentGenerator.createContent();
                return;
            }
        }
    }

    // get the mime-type
    String mimeType = MimeHelper.getMimeTypeFromFileName(filename);
    if (mimeType != null && mimeType.equals(MimeHelper.MIMETYPE_XACTION)) {
        mimeType = null;
    }

    // is this a static file type?
    if (urlPath.contains("/web/") && mimeType != null) { //$NON-NLS-1$
        // this is a static file type
        type = TYPE_STATIC;
    }

    if (type == TYPE_UNKNOWN) {
        // should not handle this file type
        warn(Messages.getInstance().getErrorString("SolutionURLContentGenerator.ERROR_0002_CANNOT_HANDLE_TYPE", //$NON-NLS-1$
                urlPath));
        return;
    }
    IContentItem contentItem = outputHandler.getOutputContentItem("response", "content", "", instanceId, //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
            mimeType);
    if (contentItem == null) {
        error(Messages.getInstance().getErrorString("SimpleContentGenerator.ERROR_0002_NO_CONTENT_ITEM")); //$NON-NLS-1$
        throw new InvalidParameterException(
                Messages.getInstance().getString("SimpleContentGenerator.ERROR_0002_NO_CONTENT_ITEM")); //$NON-NLS-1$
    }

    contentItem.setMimeType(mimeType);

    out = contentItem.getOutputStream(itemName);
    if (out == null) {
        error(Messages.getInstance().getErrorString("SimpleContentGenerator.ERROR_0003_NO_OUTPUT_STREAM")); //$NON-NLS-1$
        throw new InvalidParameterException(
                Messages.getInstance().getString("SimpleContentGenerator.ERROR_0003_NO_OUTPUT_STREAM")); //$NON-NLS-1$
    }

    // TODO support cache control settings

    ISolutionRepository repo = PentahoSystem.get(ISolutionRepository.class, userSession);
    InputStream in = repo.getResourceInputStream(urlPath, false, ISolutionRepository.ACTION_EXECUTE);
    if (in == null) {
        error(Messages.getInstance().getErrorString("SolutionURLContentGenerator.ERROR_0003_RESOURCE_NOT_FOUND", //$NON-NLS-1$
                urlPath));
        return;
    }

    try {
        byte buffer[] = new byte[4096];
        int n = in.read(buffer);
        while (n != -1) {
            out.write(buffer, 0, n);
            n = in.read(buffer);
        }
    } finally {
        out.close();
    }

}

From source file:org.transdroid.core.gui.navigation.SetTrackersDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (currentTrackers == null)
        throw new InvalidParameterException(
                "Please first set the current trackers text using setCurrentTrackers before opening the dialog.");
    if (onTrackersUpdatedListener == null)
        throw new InvalidParameterException(
                "Please first set the callback listener using setOnTrackersUpdated before opening the dialog.");
    final View trackersFrame = getActivity().getLayoutInflater().inflate(R.layout.dialog_trackers, null, false);
    final EditText trackersText = (EditText) trackersFrame.findViewById(R.id.trackers_edit);
    trackersText.setText(currentTrackers);
    return new AlertDialog.Builder(getActivity()).setView(trackersFrame)
            .setPositiveButton(R.string.status_update, new OnClickListener() {
                @Override//  w  w w.  j  av a2s .co m
                public void onClick(DialogInterface dialog, int which) {
                    // User is done editing and requested to update given the text input
                    onTrackersUpdatedListener
                            .onTrackersUpdated(Arrays.asList(trackersText.getText().toString().split("\n")));
                }
            }).setNegativeButton(android.R.string.cancel, null).show();
}