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:eu.bittrade.libs.steemj.protocol.operations.EscrowTransferOperation.java

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        if (!ValidationType.SKIP_ASSET_VALIDATION.equals(validationType)) {
            if (fee.getAmount() < 0) {
                throw new InvalidParameterException("The fee cannot be negative.");
            } else if (sbdAmount.getAmount() < 0) {
                throw new InvalidParameterException("The sbd amount cannot be negative.");
            } else if (steemAmount.getAmount() < 0) {
                throw new InvalidParameterException("The steem amount cannot be negative.");
            } else if (sbdAmount.getAmount() + steemAmount.getAmount() < 0) {
                throw new InvalidParameterException("An escrow must release a non-zero amount.");
            } else if (!fee.getSymbol().equals(SteemJConfig.getInstance().getTokenSymbol())
                    && !fee.getSymbol().equals(SteemJConfig.getInstance().getDollarSymbol())) {
                throw new InvalidParameterException("The fee must be STEEM or SBD.");
            } else if (!sbdAmount.getSymbol().equals(SteemJConfig.getInstance().getDollarSymbol())) {
                throw new InvalidParameterException("The sbd amount must contain SBD.");
            } else if (!steemAmount.getSymbol().equals(SteemJConfig.getInstance().getTokenSymbol())) {
                throw new InvalidParameterException("The steem amount must contain STEEM.");
            }//from   ww  w. j av  a2 s .  co  m
        }

        if (agent.equals(from) || agent.equals(to)) {
            throw new InvalidParameterException("The agent needs to be a third party.");
        } else if (escrowExpirationDate.getDateTimeAsTimestamp() < this.getRatificationDeadlineDate()
                .getDateTimeAsTimestamp()) {
            throw new InvalidParameterException("The ratification deadline must be before escrow expiration.");
        } else if (jsonMeta != null && !jsonMeta.isEmpty() && !SteemJUtils.verifyJsonString(jsonMeta)) {
            throw new InvalidParameterException("The given String is no valid JSON");
        }
    }
}

From source file:com.dirkgassen.wator.ui.view.RollingGraphView.java

/**
 * Adds a new data point to each of the series.
 *
 * @param newValues one new data point for each of the series
 *///  ww  w  .  ja  va  2  s . c  o  m
public void addData(float[] newValues) {
    if (dataValues == null) {
        if (maxValues == -1 && ((horizontal && getWidth() == 0) || (!horizontal && getHeight() == 0))) {
            return;
        }
        dataValues = new float[maxValues == -1 ? (horizontal ? getWidth() : getHeight()) : maxValues][];
        dataTimes = new long[dataValues.length];
    }
    if (newValues.length != seriesNames.length) {
        throw new InvalidParameterException("Invalid number of new series data points: " + newValues.length
                + " (expected: " + seriesNames.length);
    }
    synchronized (this) {
        currentValue = (currentValue + 1) % dataValues.length;
        if (dataValues[currentValue] == null || dataValues[currentValue].length != newValues.length) {
            dataValues[currentValue] = new float[newValues.length];
        }
        System.arraycopy(newValues, 0, dataValues[currentValue], 0, newValues.length);
        dataTimes[currentValue] = System.currentTimeMillis();
        if ((oldestValue + 1) % dataValues.length == currentValue) {
            oldestValue = currentValue;
        }
    }
    bitMapIsInvalid = true;
    handler.post(invalidateRunner);
}

From source file:com.yunguchang.data.ApplicationRepository.java

@TransactionAttribute(REQUIRES_NEW)
public TBusApplyinfoEntity retreatDevolveApply(String applyId, String applyNo, Boolean bySync,
        PrincipalExt principalExt) {/*from w w  w .  j av  a2 s . c  o  m*/
    if (applyId == null && applyNo == null) {
        throw new InvalidParameterException("Approve info can not be null!");
    }
    TBusApplyinfoEntity applyinfoEntity;
    if (applyId != null) {
        applyinfoEntity = em.find(TBusApplyinfoEntity.class, applyId);
    } else {
        applyinfoEntity = getApplicationByNo(applyNo, principalExt);
    }
    if (applyinfoEntity == null) {
        throw logger.entityNotFound(TBusApplyinfoEntity.class, applyId);
    }
    applyinfoEntity.setIssend("0"); // 1  0 ?
    applyinfoEntity.setStatus(ApplyStatus.APPLY.toStringValue()); // 

    if (bySync != null && bySync) {
        applyinfoEntity.setUpdateBySync(true);
    } else {
        applyinfoEntity.setUpdateBySync(false);
    }

    return applyinfoEntity;
}

From source file:fr.paris.lutece.plugins.sponsoredlinks.web.SponsoredLinksJspBean.java

/**
 * Process the data capture form of a new sponsoredlinks set
 *
 * @param request The Http Request//from www  .ja  va  2 s  .  c o  m
 * @return The Jsp URL of the process result
 */
public String doCreateSet(HttpServletRequest request) {
    if ((request.getParameter(PARAMETER_CANCEL) != null)
            || !RBACService.isAuthorized(SponsoredLinkSet.RESOURCE_TYPE, RBAC.WILDCARD_RESOURCES_ID,
                    SponsoredLinksSetResourceIdService.PERMISSION_CREATE_SET, getUser())) {
        return JSP_REDIRECT_TO_MANAGE_SET;
    }

    String strTitle = request.getParameter(PARAMETER_SET_TITLE);
    String strGroupId = request.getParameter(PARAMETER_GROUP_ID);
    String[] strArrayLinks = request.getParameterValues(PARAMETER_SET_LINK_LIST);

    // Mandatory fields
    if (StringUtils.isBlank(strTitle) || StringUtils.isBlank(strGroupId) || (strArrayLinks == null)
            || (strArrayLinks.length == 0)) {
        return AdminMessageService.getMessageUrl(request, Messages.MANDATORY_FIELDS, AdminMessage.TYPE_STOP);
    }

    int nGroupId = Integer.parseInt(strGroupId);

    SponsoredLinkSet set = new SponsoredLinkSet();
    List<SponsoredLink> linkList = new ArrayList<SponsoredLink>();
    SponsoredLink currentLink;

    for (int i = strArrayLinks.length - 1; i >= 0; --i) {
        if (!strArrayLinks[i].trim().equals("\u00A0")) {
            currentLink = new SponsoredLink();
            currentLink.setOrder(i + 1);
            currentLink.setLink(strArrayLinks[i]);

            if (currentLink.isValidLink()) {
                linkList.add(currentLink);
            } else {
                AppLogService.error(new InvalidParameterException("In SponsoredLinkSet \"" + strTitle + "\" : "
                        + " SponsoredLink[" + currentLink.getOrder() + "] - " + currentLink.getLink()
                        + "> : is not a valid html link"));
            }
        }
    }

    set.setTitle(strTitle);
    set.setGroupId(nGroupId);
    set.setSponsoredLinkList(linkList);

    SponsoredLinkSetHome.create(set, getPlugin());

    // if the operation occurred well, redirects towards the list of sets
    return JSP_REDIRECT_TO_MANAGE_SET;
}

From source file:org.zaproxy.zap.extension.ascan.PolicyAllCategoryPanel.java

public void setScanPolicy(ScanPolicy scanPolicy) {
    if (!switchable) {
        throw new InvalidParameterException(
                "Cannot change policy if the panel has not been defined as switchable");
    }/*from  ww w . j  a  va  2  s. c o  m*/
    this.policy = scanPolicy;
    this.getPolicySelector().setSelectedItem(scanPolicy.getName());
    this.setThreshold(scanPolicy.getDefaultThreshold());
    this.setStrength(scanPolicy.getDefaultStrength());
    this.getAllCategoryTableModel().setPluginFactory(scanPolicy.getPluginFactory());
}

From source file:com.l2jfree.gameserver.templates.StatsSet.java

/**
 * Safe version of "set". Expected values are within [min, max]<br>
 * Add the int hold in param "value" for the key "name"
 * //from ww w.  ja va2  s .c  o  m
 * @param name String designating the key in the set
 * @param value int corresponding to the value associated with the key
 */
public void safeSet(String name, int value, int min, int max, String reference) {
    if (min > max)
        throw new InvalidParameterException("Illegal method call: minimum value > maximum value!");

    if (value < min || value >= max) {
        _log.warn(
                "Incorrect value (" + value + ") while adding " + name + " to StatsSet. Action: " + reference);
        // Don't add the incorrect value, add an allowed one!
        if (Math.abs(value - min) < Math.abs(value - max))
            set(name, min);
        else
            set(name, max);
    } else
        set(name, value);
}

From source file:org.apache.hawq.pxf.plugins.json.PxfUnit.java

/**
 * Gets an instance of Fragmenter via reflection.
 * /*from   w  w  w  .  ja  v a2s. c o  m*/
 * Searches for a constructor that has a single parameter of some BaseMetaData type
 * 
 * @return A Fragmenter instance
 * @throws Exception
 *             If something bad happens
 */
protected Fragmenter getFragmenter(InputData meta) throws Exception {

    Fragmenter fragmenter = null;

    for (Constructor<?> c : getFragmenterClass().getConstructors()) {
        if (c.getParameterTypes().length == 1) {
            for (Class<?> clazz : c.getParameterTypes()) {
                if (InputData.class.isAssignableFrom(clazz)) {
                    fragmenter = (Fragmenter) c.newInstance(meta);
                }
            }
        }
    }

    if (fragmenter == null) {
        throw new InvalidParameterException(
                "Unable to find Fragmenter constructor with a BaseMetaData parameter");
    }

    return fragmenter;

}

From source file:eu.europa.ec.fisheries.uvms.reporting.service.util.ReportDeserializer.java

private void addAssets(JsonNode asset, List<FilterDTO> filterDTOList, Long reportId) {
    if (asset != null) {
        Iterator<JsonNode> elements = asset.elements();
        while (elements.hasNext()) {
            JsonNode next = elements.next();
            FilterType type = FilterType.valueOf(next.get("type").textValue());
            switch (type) {
            case asset:
                addAssetFilterDTO(filterDTOList, reportId, next);
                break;
            case vgroup:
                addAssetGroupFilterDTO(filterDTOList, reportId, next);
                break;
            default:
                throw new InvalidParameterException("Unsupported parameter value");

            }/*w w  w  . j  ava  2s. com*/
        }
    }
}

From source file:com.cloud.network.NetworkModelImpl.java

public boolean canIpUsedForService(PublicIp publicIp, Service service, Long networkId) {
    List<PublicIpAddress> ipList = new ArrayList<PublicIpAddress>();
    ipList.add(publicIp);/* w w w .j a  va 2s .  c o  m*/
    Map<PublicIpAddress, Set<Service>> ipToServices = getIpToServices(ipList, false, true);
    Set<Service> services = ipToServices.get(publicIp);
    if (services == null || services.isEmpty()) {
        return true;
    }

    if (networkId == null) {
        networkId = publicIp.getAssociatedWithNetworkId();
    }

    // We only support one provider for one service now
    Map<Service, Set<Provider>> serviceToProviders = getServiceProvidersMap(networkId);
    // Since IP already has service to bind with, the oldProvider can't be null
    Set<Provider> newProviders = serviceToProviders.get(service);
    if (newProviders == null || newProviders.isEmpty()) {
        throw new InvalidParameterException("There is no new provider for IP " + publicIp.getAddress()
                + " of service " + service.getName() + "!");
    }
    Provider newProvider = (Provider) newProviders.toArray()[0];
    Set<Provider> oldProviders = serviceToProviders.get(services.toArray()[0]);
    Provider oldProvider = (Provider) oldProviders.toArray()[0];
    Network network = _networksDao.findById(networkId);
    NetworkElement oldElement = getElementImplementingProvider(oldProvider.getName());
    NetworkElement newElement = getElementImplementingProvider(newProvider.getName());
    if (oldElement instanceof IpDeployingRequester && newElement instanceof IpDeployingRequester) {
        IpDeployer oldIpDeployer = ((IpDeployingRequester) oldElement).getIpDeployer(network);
        IpDeployer newIpDeployer = ((IpDeployingRequester) newElement).getIpDeployer(network);
        // FIXME: I ignored this check
    } else {
        throw new InvalidParameterException("Ip cannot be applied for new provider!");
    }
    return true;
}