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:net.sf.zekr.engine.addonmgr.AddOnManagerUtils.java

private static String getUserIntallationFolder(Resource resource) {
    if (AudioData.class.equals(resource.getType()))
        return ApplicationPath.AUDIO_DIR;
    else if (TranslationData.class.equals(resource.getType()))
        return ApplicationPath.TRANSLATION_DIR;
    else//w  w w  .  jav  a 2  s  .  c o m
        throw new InvalidParameterException("ResourceType not handled");
}

From source file:com.baasbox.dao.UserDao.java

public ODocument create(String username, String password, String role) throws UserAlreadyExistsException {
    OrientGraph db = DbHelper.getOrientGraphConnection();
    if (existsUserName(username))
        throw new UserAlreadyExistsException("Error signing up");
    OUser user = null;/* w w  w.  j  a va 2  s .c  o  m*/
    if (role == null)
        user = db.getRawGraph().getMetadata().getSecurity().createUser(username, password,
                new String[] { DefaultRoles.REGISTERED_USER.toString() });
    else {
        ORole orole = RoleDao.getRole(role);
        if (orole == null)
            throw new InvalidParameterException("Role " + role + " does not exists");
        user = db.getRawGraph().getMetadata().getSecurity().createUser(username, password,
                new String[] { role });
    }

    ODocument doc = new ODocument(this.MODEL_NAME);
    ODocument vertex = db.addVertex("class:" + CLASS_VERTEX_NAME, FIELD_TO_DOCUMENT_FIELD, doc).getRecord();
    doc.field(FIELD_LINK_TO_VERTEX, vertex);
    doc.field(FIELD_CREATION_DATE, new Date());

    doc.field(USER_LINK, user.getDocument().getIdentity());
    //since 0.9.4 each username has also an id
    doc.field(BaasBoxPrivateFields.ID.toString(), UUID.randomUUID().toString());

    doc.save();
    return doc;
}

From source file:eu.bittrade.libs.steemj.protocol.Asset.java

/**
 * Set the amount of this asset./*from  w  ww .  j av  a 2  s.  c om*/
 * 
 * @param amount
 *            The amount.
 */
public void setAmount(BigDecimal amount) {
    if (amount.scale() > this.getPrecision()) {
        throw new InvalidParameterException("The provided 'amount' has a 'scale' of " + amount.scale()
                + ", but needs to have a 'scale' of " + this.getPrecision() + " when " + this.getSymbol().name()
                + " is used as a AssetSymbolType.");
    }

    this.amount = amount.multiply(BigDecimal.valueOf(Math.pow(10, this.getPrecision()))).longValue();
}

From source file:eu.bittrade.libs.steemj.base.models.ChainProperties.java

/**
 * Set the <code>maximumBlockSize</code> which is used by the network to
 * tune rate limiting and capacity.//from   ww w. j a  v a  2 s .  c  om
 * 
 * @param maximumBlockSize
 *            The maximum block size to set.
 * @throws InvalidParameterException
 *             If the maximum block size is less than the minimal block size
 *             (65536).
 */
public void setMaximumBlockSize(long maximumBlockSize) {
    if (maximumBlockSize < 65536) {
        throw new InvalidParameterException(
                "The maximum block size needs to be greater than 65536 (minum block size).");
    }
    this.maximumBlockSize = maximumBlockSize;
}

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

static AnnotationInfo getAnnotationInfo(final L2InvalidateAssignCache annotation,
        final String targetMethodName) {
    final AnnotationInfo result = new AnnotationInfo();

    if (annotation == null) {
        throw new InvalidParameterException(
                String.format("No annotation of type [%s] found.", L2InvalidateAssignCache.class.getName()));
    }/*from  ww w. j  a va 2 s .c  o  m*/

    final String namespace = annotation.namespace();
    if (AnnotationConstants.DEFAULT_STRING.equals(namespace) || namespace == null || namespace.length() < 1) {
        throw new InvalidParameterException(
                String.format("Namespace for annotation [%s] must be defined on [%s]",
                        L2InvalidateAssignCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Namespace(namespace));

    final String assignKey = annotation.assignedKey();
    if (AnnotationConstants.DEFAULT_STRING.equals(assignKey) || assignKey == null || assignKey.length() < 1) {
        throw new InvalidParameterException(
                String.format("AssignedKey for annotation [%s] must be defined on [%s]",
                        L2InvalidateAssignCache.class.getName(), targetMethodName));
    }
    result.add(new AType.AssignKey(assignKey));

    return result;
}

From source file:org.zaproxy.zap.model.StandardParameterParser.java

@Override
public Map<String, String> getParams(HttpMessage msg, HtmlParameter.Type type) {
    Map<String, String> map = new HashMap<String, String>();
    if (msg == null) {
        return map;
    }/*from   w  ww .j  ava 2 s  .com*/
    try {
        switch (type) {
        case form:
            return this.parse(msg.getRequestBody().toString());
        case url:
            return this.parse(msg.getRequestHeader().getURI().getQuery());
        default:
            throw new InvalidParameterException("Type not supported: " + type);
        }
    } catch (URIException e) {
        log.error(e.getMessage(), e);
    }
    return map;
}

From source file:com.aliyun.odps.ship.DShip.java

public static void resume(String[] args)
        throws TunnelException, IOException, ParseException, InvalidParameterException, ODPSConsoleException {
    System.out.println("start resume");
    OptionsBuilder.buildResumeOption(args);
    String sid = DshipContext.INSTANCE.get(Constants.SESSION_ID);
    System.out.println(sid);/*from w w  w . j  a  v a  2 s.com*/
    SessionHistory sh = null;
    if (sid == null) {
        sh = SessionHistoryManager.getLatest();
        sid = sh.getSid();
        System.out.println(sid);
    } else {
        Util.checkSession(sid);
        sh = SessionHistoryManager.createSessionHistory(sid);
    }

    sh.loadContext();
    String type = DshipContext.INSTANCE.get(Constants.COMMAND_TYPE);
    if (type == null || !type.equals("upload")) {
        throw new InvalidParameterException(
                Constants.ERROR_INDICATOR + "not support resume for '" + type + "'");
    }

    sh.log("start resume");

    DshipUpload uploader = new DshipUpload();
    uploader.upload();
    sh.log("resume complete");
}

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

public static Object getIndexObject(final boolean allowRetVal, final int index, final Object retVal,
        final Object[] args, final String methodString) throws Exception {
    if (index < -1 || (index == -1 && !allowRetVal)) {
        throw new InvalidParameterException(String.format("An index of %s is invalid", index));
    }//from   w w w . j  a v  a2 s.c  o m
    if (args.length <= index) {
        throw new InvalidParameterException(String
                .format("An index of %s is too big for the number of arguments in [%s]", index, methodString));
    }
    final Object indexObject = index == -1 ? retVal : args[index];
    if (indexObject == null) {
        throw new InvalidParameterException(
                String.format("The argument passed into [%s] at index %s is null.", methodString, index));
    }
    return indexObject;
}

From source file:org.cesecore.authorization.rules.AccessRuleData.java

/**
 * Creates a new instance of AccessRule/* w  w  w. ja  v a 2s  .  c  o m*/
 * 
 * @param roleName 
 *            The name of the Role to which this rule belongs. Used to generate primary key.
 * @param accessruleName
 *          The rule that this AccessRule should represent.
 * @param internalState
 *            The rule's state.
 * @param recursive
 *            True if the rule is recursive.
 */
public AccessRuleData(final String roleName, final String accessRuleName, final AccessRuleState internalState,
        boolean isRecursive) {
    if (roleName == null) {
        throw new InvalidParameterException("Illegal to create an access rule with roleName == null");
    } else {
        this.primaryKey = generatePrimaryKey(roleName, accessRuleName);
    }
    if (accessRuleName == null) {
        throw new InvalidParameterException("Illegal to create an access rule with accessruleName == null");
    } else {
        this.accessRuleName = accessRuleName.trim();
    }
    if (internalState == null) {
        throw new InvalidParameterException("Illegal to create an access rule with internalState == null");
    } else {
        this.internalState = internalState;
    }
    setRecursive(isRecursive);

}

From source file:eu.bittrade.libs.steemj.protocol.Price.java

/**
 * Multiply this price instance with an <code>Asset</code> instance.
 * /*from w  w w. ja  v  a 2  s .  c o  m*/
 * @param asset
 *            The asset to multiply.
 * @return The <code>asset</code> multiplied with this price.
 */
public Asset multiply(Asset asset) {
    if (asset == null) {
        throw new InvalidParameterException("The asset can't be null");
    } else if (asset.getSymbol().equals(this.getBase().getSymbol())) {
        if (this.getBase().getAmount() == 0) {
            throw new InvalidParameterException("Can't multiply as the price base is 0.");
        }

        return new Asset(
                (long) ((asset.getAmount() * this.getQuote().getAmount()) / this.getBase().getAmount()),
                this.getQuote().getSymbol());
    } else if (asset.getSymbol().equals(this.getQuote().getSymbol())) {
        if (this.getQuote().getAmount() == 0) {
            throw new InvalidParameterException("Can't multiply as the price quote is 0.");
        }

        return new Asset(
                (long) ((asset.getAmount() * this.getBase().getAmount()) / this.getQuote().getAmount()),
                this.getBase().getSymbol());
    } else {
        throw new InvalidParameterException(
                "The provided asset does not fulfill the requirements to perform the multiply operation.");
    }
}