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.AccountCreateWithDelegationOperation.java

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        super.validate(validationType);

        if (!ValidationType.SKIP_ASSET_VALIDATION.equals(validationType)) {
            if (!delegation.getSymbol().equals(SteemJConfig.getInstance().getVestsSymbol())) {
                throw new InvalidParameterException("The delegation must have the symbol type VESTS.");
            } else if (delegation.getAmount() < 0) {
                throw new InvalidParameterException("The delegation must be a postive amount.");
            }//from   w  w w  . j  a  va2s. c  o m
        }
    }
}

From source file:eu.bittrade.libs.steemj.protocol.operations.SetWithdrawVestingRouteOperation.java

@Override
public void validate(ValidationType validationType) {
    if ((!ValidationType.SKIP_VALIDATION.equals(validationType)) && (percent < 0 || percent > 10000)) {
        throw new InvalidParameterException(
                "The given percentage must be a postive number between 0 and 10000 which is equivalent to 0.00%-100.00%.");
    }// ww w  . ja v a  2 s  .c  o  m
}

From source file:org.easyxml.xml.Element.java

/**
 * // ww w. j a  v  a2s  . com
 * Set the parent Element after detecting looping reference, and update the
 * Children map to keep reference of the new child element.
 * 
 * @param parent
 */

public void setParent(Element parent) {

    // Check to prevent looping reference

    Element itsParent = parent.getParent();

    while (itsParent != null) {

        if (itsParent == this)

            throw new InvalidParameterException("The parent cannot be a descendant of this element!");

        itsParent = itsParent.getParent();

    }

    this.parent = parent;

    Element container = this;

    String path = this.name;

    while (container.getParent() != null) {

        container = container.getParent();

        Map<String, List<Element>> upperChildren = container.getChildren();

        if (upperChildren == null) {

            upperChildren = new LinkedHashMap<String, List<Element>>();

        }

        if (!upperChildren.containsKey(path)) {

            List<Element> newList = new ArrayList<Element>();

            newList.add(this);

            upperChildren.put(path, newList);

        } else {

            List<Element> upperList = upperChildren.get(path);

            if (!upperList.contains(this)) {

                upperList.add(this);

            }

        }

        //Append this.children to parent.children with adjusted path
        if (this.children != null) {
            for (Map.Entry<String, List<Element>> entry : this.children.entrySet()) {
                String childPath = String.format("%s%s%s", path, Element.DefaultElementPathSign,
                        entry.getKey());
                if (!upperChildren.containsKey(childPath)) {
                    List<Element> newList = new ArrayList<Element>(entry.getValue());
                    upperChildren.put(childPath, newList);

                } else {
                    List<Element> upperList = upperChildren.get(childPath);
                    upperList.addAll(entry.getValue());
                }

            }

        }

        String containerName = container.getName();

        path = containerName + DefaultElementPathSign + path;

    }

}

From source file:eu.bittrade.libs.steemj.protocol.operations.CustomJsonOperation.java

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        if (requiredPostingAuths.isEmpty() && requiredAuths.isEmpty()) {
            throw new InvalidParameterException(
                    "At least one authority type (POSTING or ACTIVE) needs to be provided.");
        } else if (id.length() > 32) {
            throw new InvalidParameterException("The ID must be less than 32 characters long.");
        } else if (json != null && !json.isEmpty() && !SteemJUtils.verifyJsonString(json)) {
            throw new InvalidParameterException("The given String is no valid JSON");
        }//  w  w  w  .j a  va 2s.  c o m
    }
}

From source file:com.baasbox.service.storage.DocumentService.java

public static ODocument update(String collectionName, String rid, JsonNode bodyJson, PartsParser pp)
        throws MissingNodeException, InvalidCollectionException, InvalidModelException, ODatabaseException,
        IllegalArgumentException, DocumentNotFoundException {
    ODocument od = get(rid);//from   w w w. j a v a 2 s  . c  o  m
    if (od == null)
        throw new InvalidParameterException(rid + " is not a valid document");
    ObjectMapper mapper = new ObjectMapper();
    StringBuffer q = new StringBuffer("");

    if (!pp.isMultiField() && !pp.isArray()) {
        q.append("update ").append(collectionName).append(" set ").append(pp.treeFields()).append(" = ")
                .append(bodyJson.get("data").toString());

    } else {
        q.append("update ").append(collectionName).append(" merge ");
        String content = od.toJSON();
        ObjectNode json = null;
        try {
            json = (ObjectNode) mapper.readTree(content.toString());
        } catch (Exception e) {
            throw new RuntimeException("Unable to modify inline json");
        }
        JsonTree.write(json, pp, bodyJson.get("data"));
        q.append(json.toString());
    }
    q.append(" where @rid = ").append(rid);
    try {
        DocumentDao.getInstance(collectionName).updateByQuery(q.toString());
    } catch (OSecurityException e) {
        throw e;
    } catch (InvalidCriteriaException e) {
        throw new RuntimeException(e);
    }
    od = get(collectionName, rid);
    return od;
}

From source file:com.wit.and.dialog.internal.xml.XmlDialogInflater.java

/**
 * <p>/*from   w ww. j a v a2  s .c  om*/
 * Inflates dialog fragment instance form the given XML dialogs set resource using one
 * of the registered XML dialog parsers.
 * </p>
 *
 * @param dialogID  Id of dialog in the given <var>xmlSetRes</var> to inflate.
 * @param xmlSetRes Resource of XML file placed in the application resources. All XML dialogs in this XML file
 *                  must be placed inside <b>&lt;Dialogs&gt&lt;/Dialogs&gt;</b> root tag.
 * @return New instance of {@link DialogFragment} or its derived classes, depends on the XML dialog
 * root tag.
 * @throws XmlDialogInflater.UnsupportedXmlDialogTagException
 * @throws java.security.InvalidParameterException
 * @throws java.lang.IllegalStateException
 * @see #registerParser(Class, String)
 */
public DialogFragment inflateDialog(int dialogID, int xmlSetRes) {
    XmlResourceParser xmlParser = mResources.getXml(xmlSetRes);
    if (xmlParser == null)
        return null;

    DialogFragment dialog = null;

    long time;
    if (DEBUG) {
        time = System.currentTimeMillis();
    }

    try {
        int xmlEvent;
        boolean dialogsTagResolved = false;

        while ((xmlEvent = xmlParser.getEventType()) != XmlResourceParser.END_DOCUMENT) {
            switch (xmlEvent) {
            case XmlResourceParser.START_DOCUMENT:
                break;
            case XmlResourceParser.START_TAG:
                String tag = xmlParser.getName();

                if (!dialogsTagResolved) {
                    // Check valid root tag.
                    if (!tag.equals(DIALOGS_SET_ROOT_TAG)) {
                        throw new UnsupportedXmlDialogTagException(
                                "Only 'Dialogs' tag is allowed as root tag of XML dialogs set.");
                    }
                    dialogsTagResolved = true;
                } else {
                    // Check for empty dialog.
                    if (xmlParser.getAttributeCount() == 0) {
                        throw new IllegalStateException("Empty dialogs are not allowed.");
                    }

                    // Find the dialog with requested id.
                    // Note, that first attribute of each dialog must be its "id" to preserve
                    // fast parsing of xml file.
                    final int attr = xmlParser.getAttributeNameResource(0);
                    if (attr != android.R.attr.id) {
                        throw new InvalidParameterException(
                                "First attribute of XML dialog must be always 'android:id'.");
                    }

                    // Finally check the dialog id.
                    final int id = xmlParser.getAttributeResourceValue(0, 0);
                    if (dialogID == id) {
                        dialog = parseDialogInner(xmlParser);
                    }
                }
                break;
            }
            if (dialog != null) {
                break;
            }
            xmlParser.next();
        }
    } catch (XmlPullParserException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    if (DEBUG) {
        Log.d(TAG, "Parsing of XML dialog from dialogs set in "
                + Long.toString(System.currentTimeMillis() - time) + "ms");
    }

    return dialog;
}

From source file:com.vmware.photon.controller.common.dcp.ServiceHostUtils.java

/**
 * Starts a service specified by the class type on the host.
 *
 * @param host/*from ww  w. ja  v a  2 s.c  om*/
 * @param service
 * @throws InstantiationException
 * @throws IllegalAccessException
 */
public static void startService(ServiceHost host, Class service)
        throws InstantiationException, IllegalAccessException {
    checkArgument(host != null, "host cannot be null");
    checkArgument(service != null, "service cannot be null");

    Service instance = (Service) service.newInstance();

    final URI serviceUri = UriUtils.buildUri(host, service);
    if (serviceUri == null) {
        throw new InvalidParameterException(
                String.format("No SELF_LINK field in class %s", service.getCanonicalName()));
    }

    Operation.CompletionHandler completionHandler = new Operation.CompletionHandler() {
        @Override
        public void handle(Operation operation, Throwable throwable) {
            if (throwable != null) {
                logger.debug("Start service {[]} failed: {}", serviceUri, throwable);
            }
        }
    };

    Operation op = Operation.createPost(serviceUri).setCompletion(completionHandler);
    host.startService(op, instance);
}

From source file:org.codelabor.system.file.web.servlet.FileUploadServlet.java

@Override
public void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {//from w  w w . j  a v  a2s .c  om
        String parameterValue = request.getParameter(parameterName);
        switch (Parameter.valueOf(parameterValue)) {
        case upload:
            upload(request, response);
            break;
        case download:
            download(request, response);
            break;
        case view:
            view(request, response);
            break;
        case list:
            list(request, response);
            break;
        case delete:
            delete(request, response);
            break;
        case read:
            read(request, response);
            break;
        default:
            logger.error("Invalid parameter: {}", parameterValue);
            throw new InvalidParameterException(parameterValue);
        }
    } catch (IOException e) {
        e.printStackTrace();
        logger.error(e.getMessage());
        throw new IOException(e);
    } catch (Exception e) {
        e.printStackTrace();
        logger.error(e.getMessage());
        throw new ServletException(e);
    }
}

From source file:org.parosproxy.paros.model.SiteMap.java

public synchronized SiteNode findNode(URI uri, String method, String postData) {
    if (Constant.isLowMemoryOptionSet()) {
        throw new InvalidParameterException("SiteMap should not be accessed when the low memory option is set");
    }// ww w  .java 2  s . com
    SiteNode resultNode = null;
    String folder = "";

    try {
        String host = getHostName(uri);

        // no host yet
        resultNode = findChild((SiteNode) getRoot(), host);
        if (resultNode == null) {
            return null;
        }

        List<String> path = model.getSession().getTreePath(uri);
        for (int i = 0; i < path.size(); i++) {
            folder = path.get(i);

            if (folder != null && !folder.equals("")) {
                if (i == path.size() - 1) {
                    String leafName = getLeafName(folder, uri, method, postData);
                    resultNode = findChild(resultNode, leafName);
                } else {
                    resultNode = findChild(resultNode, folder);
                    if (resultNode == null) {
                        return null;
                    }
                }
            }
        }
    } catch (URIException e) {
        log.error(e.getMessage(), e);
    }

    return resultNode;
}

From source file:com.sayar.requests.RequestArguments.java

/**
 * Setter for the Resource Url./*  ww w  . j  a v a  2  s  .c om*/
 * 
 * @param url
 */
public void setUrl(final String url) {
    if (!this.validUrl(url)) {
        throw new InvalidParameterException("URL is invalid.");
    }
    this.url = url;
}