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:org.zaproxy.zap.extension.zest.ExtensionZest.java

/**
 * Return all of the requests in the script ScriptWrapper is deliberately used to make it easier
 * to call this method by reflection/* ww w . j  a  v  a2s .c o  m*/
 *
 * @param script
 * @return
 */
public List<HttpMessage> getAllRequestsInScript(ScriptWrapper script) {
    ArrayList<HttpMessage> requests = new ArrayList<HttpMessage>();

    if (!(script instanceof ZestScriptWrapper)) {
        throw new InvalidParameterException(script.getClass().getCanonicalName());
    }

    ZestScriptWrapper sw = (ZestScriptWrapper) script;
    for (ZestStatement stmt : sw.getZestScript().getStatements()) {
        try {
            if (stmt.getElementType().equals("ZestRequest")) {
                ZestRequest req = (ZestRequest) stmt;
                HttpMessage scrMessage = ZestZapUtils.toHttpMessage(req, req.getResponse());
                requests.add(scrMessage);
            }
        } catch (Exception e) {
            logger.debug(
                    "Exception occurred while fetching HttpMessages from sequence script: " + e.getMessage());
        }
    }
    return requests;
}

From source file:com.cloud.hypervisor.vmware.mo.HypervisorHostHelper.java

private static void createNvpPortGroup(HostMO hostMo, HostVirtualSwitch vSwitch, String networkName,
        HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
    /**//from ww  w .ja v a2s  .co  m
     * No portgroup created yet for this nic
     * We need to find an unused vlan and create the pg
     * The vlan is limited to this vSwitch and the NVP vAPP,
     * so no relation to the other vlans in use in CloudStack.
     */
    String vSwitchName = vSwitch.getName();

    // Find all vlanids that we have in use
    List<Integer> usedVlans = new ArrayList<Integer>();
    for (HostPortGroup pg : hostMo.getHostNetworkInfo().getPortgroup()) {
        HostPortGroupSpec hpgs = pg.getSpec();
        if (vSwitchName.equals(hpgs.getVswitchName()))
            usedVlans.add(hpgs.getVlanId());
    }

    // Find the first free vlanid
    int nvpVlanId = 0;
    for (nvpVlanId = 1; nvpVlanId < 4095; nvpVlanId++) {
        if (!usedVlans.contains(nvpVlanId)) {
            break;
        }
    }
    if (nvpVlanId == 4095) {
        throw new InvalidParameterException(
                "No free vlan numbers on " + vSwitchName + " to create a portgroup for nic " + networkName);
    }

    // Strict security policy
    HostNetworkSecurityPolicy secPolicy = new HostNetworkSecurityPolicy();
    secPolicy.setAllowPromiscuous(Boolean.FALSE);
    secPolicy.setForgedTransmits(Boolean.FALSE);
    secPolicy.setMacChanges(Boolean.FALSE);

    // Create a portgroup with the uuid of the nic and the vlanid found above
    hostMo.createPortGroup(vSwitch, networkName, nvpVlanId, secPolicy, shapingPolicy);
}

From source file:net.sf.zekr.common.config.ApplicationConfig.java

/**
 * @param r//w w  w.  jav a 2  s . c  o  m
 * @return
 */
/*@SuppressWarnings("unchecked")
synchronized public boolean isCurrentlyInstalled(Resource r) {
   String configurationKey = "resources." + r.getType().getSimpleName();
   List idList = props.getList(configurationKey);
   if (idList.contains(r.getId()))
 return true;
   else
 return false;
}
*/
synchronized public Resource installResource(CandidateResource r, IntallationProgressListener progressListener)
        throws ZekrMessageException {
    File newInstalledFile = null;
    try {
        newInstalledFile = new File(r.getInstallationFolder() + "/" + r.getFile().getName());
        FileUtils.copyFile(r.getFile(), newInstalledFile);
        if (r.getType().equals(TranslationData.class)) {
            r.setInstalledResource(addNewTranslation(newInstalledFile));
        } else if (r.getType().equals(AudioData.class)) {
            if (r.getFile().getName().contains("offline"))//a little bit of a hack ;)
                r.setInstalledResource(
                        addNewRecitationPack(newInstalledFile, ApplicationPath.AUDIO_DIR, progressListener));
            else if (r.getFile().getName().contains("online"))
                r.setInstalledResource(addNewRecitation(newInstalledFile));
        } else
            throw new InvalidParameterException("ResourceType not been implement yet");

        /*String configurationKey = "resources." + r.getType().getSimpleName();
        List idList = props.getList(configurationKey);
        if (!idList.contains(r.getInstalledResource().getId()))
           idList.add(r.getInstalledResource().getId());
        props.setProperty(configurationKey, idList);
        saveConfig();*/
        return r.getInstalledResource();
    } catch (IOException e) {
        if (newInstalledFile != null)
            FileUtils.deleteQuietly(newInstalledFile);
        e.printStackTrace();
        throw new ZekrMessageException(e);
    }
    /*} catch (ConfigurationException e) {
       e.printStackTrace();
       throw new ZekrMessageException(e);
    }*/
}

From source file:net.sf.zekr.common.config.ApplicationConfig.java

@SuppressWarnings("rawtypes")
synchronized public void unistallResource(Resource r, IntallationProgressListener progressListener) {
    AddOnManagerUtils.unload(r);/*w  ww  . j  ava  2  s.c om*/

    if (r.getType().equals(TranslationData.class)) {
        translation.getCustomGroup().remove(r);
        List idList = props.getList("trans.custom");
        if (idList.contains(r.getId()))
            idList.remove(r.getId());
        props.setProperty("trans.custom", idList);
        saveConfig();
    } else if (r.getType().equals(AudioData.class)) {
        /*some task when un-installing recitations*/
    } else
        throw new InvalidParameterException("ResourceType not been implement yet");

    /*String configurationKey = "resources." + r.getType().getSimpleName();
    List idList = props.getList(configurationKey);
    if (idList.contains(r.getId()))
       idList.remove(r.getId());
    props.setProperty(configurationKey, idList);
    saveConfig();*/

    FileUtils.deleteQuietly(r.getFile());
    progressListener.finish(r);
}

From source file:eu.bittrade.libs.steemj.SteemJ.java

public static Asset steemToSbd(Price price, Asset steemAsset) {
    if (steemAsset == null || !steemAsset.getSymbol().equals(AssetSymbolType.STEEM)) {
        throw new InvalidParameterException("The asset needs be of SymbolType STEEM.");
    }/*from www.  j a  va2s  .  c om*/

    if (price == null) {
        return new Asset(0, AssetSymbolType.SBD);
    }

    return price.multiply(steemAsset);
}

From source file:eu.bittrade.libs.steemj.SteemJ.java

public static Asset sbdToSteem(Price price, Asset sbdAsset) {
    if (sbdAsset == null || !sbdAsset.getSymbol().equals(AssetSymbolType.SBD)) {
        throw new InvalidParameterException("The asset needs be of SymbolType STEEM.");
    }/*from  www . j  a va  2 s  .c  o m*/

    if (price == null) {
        return new Asset(0, AssetSymbolType.STEEM);
    }

    return price.multiply(sbdAsset);
}

From source file:eu.bittrade.libs.steemj.SteemJ.java

/**
 * //from w  ww.  j  ava  2s .  c  o m
 * @param accountName
 * @return
 * @throws SteemCommunicationException
 *             <ul>
 *             <li>If the server was not able to answer the request in the
 *             given time (see
 *             {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int)
 *             setResponseTimeout}).</li>
 *             <li>If there is a connection problem.</li>
 *             </ul>
 * @throws SteemResponseException
 *             <ul>
 *             <li>If the SteemJ is unable to transform the JSON response
 *             into a Java object.</li>
 *             <li>If the Server returned an error object.</li>
 *             </ul>
 */
public double calculateRemainingBandwidth(AccountName accountName)
        throws SteemCommunicationException, SteemResponseException {
    // TODO: Use getReserveRatio instead.
    ExtendedDynamicGlobalProperties extendedDynamicGlobalProperties = CondenserApi
            .getDynamicGlobalProperties(communicationHandler);
    // TODO: Use getAccountBandwidth instead.
    List<ExtendedAccount> extendedAccounts = CondenserApi.getAccounts(communicationHandler);

    if (!extendedAccounts.contains(accountName)) {
        throw new InvalidParameterException("No account has been found matching the provided account name.");
    }
    return calculateRemainingBandwidth(extendedDynamicGlobalProperties,
            extendedAccounts.get(extendedAccounts.indexOf(accountName)));
}

From source file:eu.bittrade.libs.steemj.SteemJ.java

/**
 * Use this method to up or down vote a post or a comment.
 * /*from w  w w  .java 2s  .  c o m*/
 * <b>Attention</b>
 * <ul>
 * <li>This method will write data on the blockchain. As all writing
 * operations, a private key is required to sign the transaction. For a
 * voting operation the private posting key of the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} needs to be
 * configured in the {@link SteemJConfig#getPrivateKeyStorage()
 * PrivateKeyStorage}.</li>
 * <li>This method will automatically use the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount} as the voter - If
 * no default account has been provided, this method will throw an error. If
 * you do not want to configure the voter as a default account, please use
 * the {@link #vote(AccountName, AccountName, Permlink, short)} method and
 * provide the voter account separately.</li>
 * </ul>
 * 
 * @param postOrCommentAuthor
 *            The author of the post or the comment to vote for.
 *            <p>
 *            Example:<br>
 *            <code>new AccountName("dez1337")</code>
 *            </p>
 * @param postOrCommentPermlink
 *            The permanent link of the post or the comment to vote for.
 *            <p>
 *            Example:<br>
 *            <code>new Permlink("steemj-v0-2-4-has-been-released-update-9")</code>
 *            </p>
 * @param percentage
 *            Define how much of your voting power should be used to up or
 *            down vote the post or the comment.
 *            <ul>
 *            <li>If you want to up vote the post or the comment provide a
 *            value between 1 (1.0%) and 100 (100.0%).</li>
 *            <li>If you want to down vote (as known as <b>flag</b>) the
 *            post or the comment provide a value between -1 (-1.0%) and
 *            -100 (-100.0%).</li>
 *            </ul>
 * @throws SteemCommunicationException
 *             <ul>
 *             <li>If the server was not able to answer the request in the
 *             given time (see
 *             {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int)
 *             setResponseTimeout}).</li>
 *             <li>If there is a connection problem.</li>
 *             </ul>
 * @throws SteemResponseException
 *             <ul>
 *             <li>If the SteemJ is unable to transform the JSON response
 *             into a Java object.</li>
 *             <li>If the Server returned an error object.</li>
 *             </ul>
 * @throws SteemInvalidTransactionException
 *             If there is a problem while signing the transaction.
 * @throws InvalidParameterException
 *             If one of the provided parameters does not fulfill the
 *             requirements described above.
 */
public void vote(AccountName postOrCommentAuthor, Permlink postOrCommentPermlink, short percentage)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (SteemJConfig.getInstance().getDefaultAccount().isEmpty()) {
        throw new InvalidParameterException(
                "Using the upVote method without providing an account requires to have a default account configured.");
    }

    this.vote(SteemJConfig.getInstance().getDefaultAccount(), postOrCommentAuthor, postOrCommentPermlink,
            percentage);
}

From source file:eu.bittrade.libs.steemj.SteemJ.java

/**
 * This method is equivalent to the/*from   www  .  ja v  a2s  . co  m*/
 * {@link #vote(AccountName, Permlink, short)} method, but lets you define
 * the <code>voter</code> account separately instead of using the
 * {@link SteemJConfig#getDefaultAccount() DefaultAccount}.
 * 
 * @param voter
 *            The account that should vote for the post or the comment.
 *            <p>
 *            Example<br>
 *            <code>new AccountName("steemj")</code>
 *            </p>
 * @param postOrCommentAuthor
 *            The author of the post or the comment to vote for.
 *            <p>
 *            Example:<br>
 *            <code>new AccountName("dez1337")</code>
 *            </p>
 * @param postOrCommentPermlink
 *            The permanent link of the post or the comment to vote for.
 *            <p>
 *            Example:<br>
 *            <code>new Permlink("steemj-v0-2-4-has-been-released-update-9")</code>
 *            </p>
 * @param percentage
 *            Define how much of your voting power should be used to up or
 *            down vote the post or the comment.
 *            <ul>
 *            <li>If you want to up vote the post or the comment provide a
 *            value between 1 (1.0%) and 100 (100.0%).</li>
 *            <li>If you want to down vote (as known as <b>flag</b>) the
 *            post or the comment provide a value between -1 (-1.0%) and
 *            -100 (-100.0%).</li>
 *            </ul>
 * @throws SteemCommunicationException
 *             <ul>
 *             <li>If the server was not able to answer the request in the
 *             given time (see
 *             {@link eu.bittrade.libs.steemj.configuration.SteemJConfig#setResponseTimeout(int)
 *             setResponseTimeout}).</li>
 *             <li>If there is a connection problem.</li>
 *             </ul>
 * @throws SteemResponseException
 *             <ul>
 *             <li>If the SteemJ is unable to transform the JSON response
 *             into a Java object.</li>
 *             <li>If the Server returned an error object.</li>
 *             </ul>
 * @throws SteemInvalidTransactionException
 *             If there is a problem while signing the transaction.
 * @throws InvalidParameterException
 *             If one of the provided parameters does not fulfill the
 *             requirements described above.
 */
public void vote(AccountName voter, AccountName postOrCommentAuthor, Permlink postOrCommentPermlink,
        short percentage)
        throws SteemCommunicationException, SteemResponseException, SteemInvalidTransactionException {
    if (percentage < -100 || percentage > 100 || percentage == 0) {
        throw new InvalidParameterException(
                "Please provide a percentage between -100 and 100 which is also not 0.");
    }

    VoteOperation voteOperation = new VoteOperation(voter, postOrCommentAuthor, postOrCommentPermlink,
            (short) (percentage * 100));

    ArrayList<Operation> operations = new ArrayList<>();
    operations.add(voteOperation);

    DynamicGlobalProperty globalProperties = this.getDynamicGlobalProperties();

    SignedTransaction signedTransaction = new SignedTransaction(globalProperties.getHeadBlockId(), operations,
            null);

    signedTransaction.sign();

    this.broadcastTransaction(signedTransaction);
}

From source file:org.kaaproject.kaa.server.admin.services.KaaAdminServiceImpl.java

private void setPluginRawConfigurationFromJson(PluginDto plugin, PluginType type) {
    LOG.trace("Updating plugin {} configuration using info {}", plugin, pluginsInfo.get(type));
    PluginInfoDto pluginInfo = pluginsInfo.get(type).get(plugin.getPluginClassName());
    if (pluginInfo == null) {
        LOG.error("Plugin configuration for class name {} is not found", plugin.getPluginClassName());
        throw new InvalidParameterException(
                "Plugin configuration for class name " + plugin.getPluginClassName() + " is not found");
    }/*from ww w.  j  ava  2s.  co  m*/
    byte[] rawConfiguration = GenericAvroConverter.toRawData(plugin.getJsonConfiguration(),
            pluginInfo.getFieldConfiguration().getSchema());
    plugin.setRawConfiguration(rawConfiguration);
}