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

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)
            && (this.getChallenged() == this.getChallenger())) {
        throw new InvalidParameterException(
                "The challenged account and the challenger account can't be the same account.");
    }//from  ww w.  j  ava 2s .  c  o  m
}

From source file:ubic.gemma.web.controller.common.description.bibref.BibliographicReferenceControllerImpl.java

@Override
public BibliographicReferenceValueObject load(Long id) {
    if (id == null) {
        throw new IllegalArgumentException("ID cannot be null");
    }/*from w  w w .jav  a 2  s.  c om*/
    Collection<Long> ids = new ArrayList<>();
    ids.add(id);
    JsonReaderResponse<BibliographicReferenceValueObject> returnVal = this.loadMultiple(ids);
    if (returnVal.getRecords() != null && !returnVal.getRecords().isEmpty()) {
        return returnVal.getRecords().iterator().next();
    }
    throw new InvalidParameterException("Error retrieving bibliographic reference for id = " + id);

}

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

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

        if (!ValidationType.SKIP_ASSET_VALIDATION.equals(validationType)) {
            if (!amount.getSymbol().equals(SteemJConfig.getInstance().getTokenSymbol())
                    && !amount.getSymbol().equals(SteemJConfig.getInstance().getDollarSymbol())) {
                throw new InvalidParameterException("The amount must be of type STEEM or SBD.");
            } else if (amount.getAmount() <= 0) {
                throw new InvalidParameterException("Must transfer a nonzero amount.");
            }//from w ww. j  a  va 2 s  .  co m
        }

        if (memo.length() > 2048) {
            throw new InvalidParameterException("The memo is too long. Only 2048 characters are allowed.");
        }
    }
}

From source file:com.google.code.ssm.aop.CacheBase.java

protected void verifyReturnTypeIsNoVoid(final Method method, final Class<?> annotationClass) {
    if (method.getReturnType().equals(void.class)) {
        throw new InvalidParameterException(String.format("Annotation [%s] is defined on void method  [%s]",
                annotationClass, method.getName()));
    }//from   w  w  w  .  j a  va2  s.  c  o  m
}

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

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType) && currentResetAccount.equals(resetAccount)) {
        throw new InvalidParameterException(
                "The current reset account can't be set to the same account as the new reset account.");
    }//from   www. j a  va2s  . c  o  m
}

From source file:org.moe.cli.executor.CocoaPodsExecutor.java

@Override
public void execute() throws IOException, OperationsException, InterruptedException,
        InvalidParameterSpecException, CompressorException, ArchiveException, URISyntaxException,
        CheckArchitectureException, UnsupportedTypeException, WrapNatJGenException {

    File podFile = new File(pod);
    if (podFile.exists()) {
        SpecObject spec = getSpecObject(podFile);

        //update self dependency
        if (spec.getSizeSubspecs() > 0) {
            Map<String, List<String>> specDependencies = spec.getDependencies();
            for (Map.Entry<String, List<String>> entry : specDependencies.entrySet()) {
                if (entry.getKey().startsWith(spec.getName() + "/")) {
                    int depIdx = entry.getKey().indexOf("/");
                    spec.addSubspec(entry.getKey().substring(depIdx + 1).trim());
                }/*from   w  w w  .  j a v a 2s .  com*/
            }
        } else if (spec.getSizeSubspecs() == 0
                && (spec.getDefaultSubspecs() == null || spec.getDefaultSubspecs().size() == 0)) {
            Map<String, List<String>> specDependencies = spec.getDependencies();
            for (Map.Entry<String, List<String>> entry : specDependencies.entrySet()) {
                String nameSubspec = null;
                if (entry.getKey().startsWith(spec.getName() + "/")) {
                    int depIdx = entry.getKey().indexOf("/");
                    nameSubspec = entry.getKey().substring(depIdx + 1).trim();
                    spec.addSubspec(nameSubspec);
                }
            }
        }

        IExecutor executor = null;
        String source = spec.getSource().get("http");
        if (source == null) {
            String git = spec.getSource().get("git");
            String tag = spec.getSource().get("tag");

            //remove .git
            git = git.substring(0, git.length() - 4);
            source = String.format("%s/archive/%s.zip", git, tag);
        }

        //handle jspec repository
        if (javaSource == null && jpodSpecRepo != null) {
            JSpecObject jspec = JSpecObject.getJSpecObject(spec, jpodSpecRepo);
            if (jspec != null) {
                javaSource = jspec.getSource();
            }
        }

        if (source != null
                && (spec.getVendoredFrameworks().size() != 0 || spec.getVendoredLibraries().size() != 0)) {
            PrebuildCocoaPodsManager manager = new PrebuildCocoaPodsManager();
            executor = manager.processCocoapods(source, spec, packageName, javaSource, outputJar);

            Map<String, List<String>> localDependencies = spec.getDependencies();
            for (Map.Entry<String, List<String>> entry : localDependencies.entrySet()) {
                if (!entry.getKey().startsWith(spec.getName() + "/")
                        && !dependencies.contains(entry.getKey())) {

                    //create dependency spec
                    String podName = entry.getKey();
                    String subspec = null;
                    if (podName.contains("/")) {
                        int depIdx = podName.indexOf("/");
                        subspec = podName.substring(depIdx + 1);
                        podName = podName.substring(0, depIdx);
                    }

                    File depPodFile = new File(podFile.getParentFile(), podName + "Pod");
                    PrintWriter writer = new PrintWriter(depPodFile);
                    try {
                        writer.println("pod:" + podName);
                        String version = entry.getValue().get(0);
                        writer.println("version:" + (version == null ? "" : version));
                        writer.println("subspec:" + (subspec == null ? "" : subspec));
                    } finally {
                        writer.close();
                    }
                    File tmpOut = new File(outputJar);
                    File depOutJar = new File(tmpOut.getParent(), podName + ".jar");

                    String depPackageName = packageName + "." + entry.getKey();
                    Set<String> cummonDep = new HashSet<String>(dependencies);
                    cummonDep.addAll(localDependencies.keySet());
                    CocoaPodsExecutor depExecutor = new CocoaPodsExecutor(depPodFile.getPath(),
                            depOutJar.getPath(), null, jpodSpecRepo, depPackageName.toLowerCase(), cummonDep);
                    depExecutor.execute();
                }
            }
        } else {
            SourceCocoaPodsManager manager = new SourceCocoaPodsManager();
            executor = manager.processCocoapods(null, spec, packageName, javaSource, outputJar);
        }

        if (executor != null) {
            executor.execute();
        } else {
            throw new InvalidParameterException("Unsupported pod source");
        }

    } else {
        throw new InvalidParameterException(
                String.format("Specify correct path in %s parameter", OptionsHandler.POD.getLongOpt()));
    }

}

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

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        if (!ValidationType.SKIP_ASSET_VALIDATION.equals(validationType)) {
            if (!vestingShares.getSymbol().equals(SteemJConfig.getInstance().getVestsSymbol())) {
                throw new InvalidParameterException("Can only delegate VESTS.");
            } else if (vestingShares.getAmount() <= 0) {
                throw new InvalidParameterException("Can't delegate a negative amount of VESTS.");
            }//from  w  ww  .java 2 s. co  m
        }

        if (this.getDelegator().equals(this.getDelegatee())) {
            throw new InvalidParameterException(
                    "The delegatee account can't be equal to the delegator account.");
        }
    }
}

From source file:org.flite.cach3.aop.ReadThroughMultiCacheAdvice.java

public static MapHolder convertIdObjectsToKeyMap(final List<Object> idObjects, final String namespace,
        final String prefix, final String template, final VelocityContextFactory factory,
        final CacheKeyMethodStore methodStore, final Object[] args) throws Exception {
    final MapHolder holder = new MapHolder();
    for (int ix = 0; ix < idObjects.size(); ix++) {
        final Object obj = idObjects.get(ix);
        if (obj == null) {
            throw new InvalidParameterException("One of the passed in key objects is null");
        }// w ww .  j  a  v a 2 s.com

        final String base;
        if (StringUtils.isBlank(template)) {
            final Method method = getKeyMethod(obj, methodStore);
            base = generateObjectId(method, obj);
        } else {
            final VelocityContext context = factory.getNewExtendedContext();
            context.put("args", args);
            context.put("index", ix);
            context.put("indexObject", obj);

            final StringWriter writer = new StringWriter(250);
            Velocity.evaluate(context, writer, ReadThroughMultiCacheAdvice.class.getSimpleName(), template);
            base = writer.toString();
            if (template.equals(base)) {
                throw new InvalidParameterException("Calculated key is equal to the velocityTemplate.");
            }
        }
        final String key = buildCacheKey(base, namespace, prefix);

        if (holder.getObj2Key().get(obj) == null) {
            holder.getObj2Key().put(obj, key);
            holder.getObj2Base().put(obj, base);
        }
        if (holder.getKey2Obj().get(key) == null) {
            holder.getKey2Obj().put(key, obj);
        }
    }

    return holder;
}

From source file:com.mobdb.android.MobDB.java

/**
 * Send's Multiple SQL statements in one request
 * @param appKey String value Application key
 * @param multiRequest MultiRequest object
 * @param bargraph String value for Analytics tag name
 * @param secure boolean value to set SSL communication
 * @param listener MobDBResponseListener object
 * @throws InvalidParameterException/*ww w.  ja v a 2s. c  om*/
 */
public synchronized void execute(String appKey, MultiRequest multiRequest, String bargraph, boolean secure,
        MobDBResponseListener listener) throws InvalidParameterException {

    try {
        execute(appKey, multiRequest.getQueryString(), null, bargraph, secure, listener);
    } catch (Exception e) {
        // TODO: handle exception
        throw new InvalidParameterException(e.toString());
    }

}

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

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        if (this.getSecondBlock().getWitness().equals(firstBlock.getWitness())) {
            throw new InvalidParameterException(
                    "The first block witness needs to be the same than the second block witness.");
        } else if (this.getSecondBlock().getTimestamp().equals(firstBlock.getTimestamp())) {
            throw new InvalidParameterException(
                    "The first block timestamp needs to be the same than the second block timestamp.");
        }//from   w  w w  .  j a  va2 s  .c o m
        /*
         * TODO: Implement additional checks:
         * 
         * 1. first_block.signee() == second_block.signee() 2.
         * first_block.id() != second_block.id()
         * 
         * Both checks require that the SignedBlockHeader has the signee()
         * and the id().
         */
    }
}