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.hillview.sketches.JLProjection.java

public double getNorm(String s) {
    if (!this.hMap.containsKey(s))
        throw new InvalidParameterException("No sketch found for column: " + s);
    if (this.highDim <= 0)
        throw new InvalidParameterException("Dimension must be positive.");
    double sum = 0;
    double a[] = this.hMap.get(s);
    for (int i = 0; i < this.lowDim; i++)
        sum += Math.pow(a[i], 2);
    return Math.sqrt(sum / (this.lowDim * this.highDim));
}

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

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

    if (annotation == null) {
        throw new InvalidParameterException(
                String.format("No annotation of type [%s] found.", L2UpdateAssignCache.class.getName()));
    }//from  w w w  .  ja v  a2s.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]",
                        L2UpdateAssignCache.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]",
                        L2UpdateAssignCache.class.getName(), targetMethodName));
    }
    result.add(new AType.AssignKey(assignKey));

    final int dataIndex = annotation.dataIndex();
    if (dataIndex < -1) {
        throw new InvalidParameterException(
                String.format("DataIndex for annotation [%s] must be -1 or greater on [%s]",
                        L2UpdateAssignCache.class.getName(), targetMethodName));
    }
    result.add(new AType.DataIndex(dataIndex));

    final Duration window = annotation.window();
    if (window == Duration.UNDEFINED) {
        throw new InvalidParameterException(
                String.format("Window for annotation [%s] must be a defined value on [%s]",
                        L2UpdateAssignCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Window(window));

    return result;
}

From source file:org.cesecore.authorization.user.AccessUserAspectData.java

/** This constructor for internal use only */
public AccessUserAspectData(final String roleName, final int caId, final int matchWith, final String tokenType,
        final AccessMatchType matchType, final String matchValue) {
    if (roleName == null) {
        throw new InvalidParameterException(
                "Attempted to create an AccessUserAspectData with roleName == null");
    }// www.java 2  s  .  co  m
    if (matchType == null) {
        throw new InvalidParameterException(
                "Attempted to create an AccessUserAspectData with matchType == null");
    } else {
        this.matchType = matchType;
    }
    if (matchValue == null) {
        throw new InvalidParameterException(
                "Attempted to create an AccessUserAspectData with matchValue == null");
    } else {
        this.matchValue = matchValue;
    }
    if (tokenType == null) {
        throw new InvalidParameterException(
                "Attempted to create an AccessUserAspectData with tokenType == null");
    } else {
        this.tokenType = tokenType;
    }

    this.matchWith = matchWith;
    this.caId = caId;
    this.primaryKey = generatePrimaryKey(roleName, caId, matchWith, matchType, matchValue, tokenType);
    this.legacyPrimaryKey = generatePrimaryKeyOld(roleName, caId, matchWith, matchType, matchValue);
}

From source file:edu.nchu.cs.dmlab.firemap.mjpeg.RecMicToMp3.java

/**
 * /* w  w  w  .jav  a  2  s.com*/
 * @param filePath
 *            save mp3 file
 * @param sampleRate
 */
public RecMicToMp3(String filePath, int sampleRate, MainRecordActivity activity) {
    if (sampleRate <= 0) {
        throw new InvalidParameterException("Invalid sample rate specified.");
    }
    this.mFile = new File(filePath);
    this.mSampleRate = sampleRate;
    this.activity = activity;
}

From source file:eu.bittrade.libs.steemj.plugins.apis.tags.models.DiscussionQuery.java

/**
 * @param limit/*from   w w  w  .java  2s  .c  o m*/
 *            the limit to set
 * 
 * @throws InvalidParameterException
 *             If the given <code>limit</code> is higher than 100.
 */
public void setLimit(int limit) {
    if (limit > 100) {
        throw new InvalidParameterException("The limit needs to be smaller than 100.");
    }

    this.limit = limit;
}

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

/**
 * Creates a new instance of AccessRule//from   w  ww  .  ja v  a  2  s.  c o m
 * 
 * @param primaryKey
 *            Primary key for this rule. Can be generated using the static method {@link AccessRuleData#generatePrimaryKey(String, String)}
 * @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(int primaryKey, final String accessRuleName, final AccessRuleState internalState,
        boolean isRecursive) {
    if (accessRuleName == null) {
        throw new InvalidParameterException("Illegal to create an access rule with accessruleName == null");
    } else if (internalState == null) {
        throw new InvalidParameterException("Illegal to create an access rule with internalState == null");
    }
    this.primaryKey = primaryKey;
    this.accessRuleName = accessRuleName.trim();
    this.internalState = internalState;
    setRecursive(isRecursive);
}

From source file:com.richtodd.android.quiltdesign.block.PaperPiecedBlock.java

public void setWidth(float width) {
    if (width < 0)
        throw new InvalidParameterException("Invalid width " + width);

    m_width = width;//  w  w w . j  a v a  2s .c o  m
}

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

/**
 * Set the account name of this instance.
 * /*w  w w  .  j a va 2s.  c o m*/
 * @param name
 *            An account name in its String representation. The account name
 *            can either be empty or needs to have a length between 3 and 16
 *            characters. If provided, the account name has to follow
 *            specific rules:
 *            <ul>
 *            <li>The account name must start with: a-z</li>
 *            <li>Followed by: a-z,0-9,-</li>
 *            <li>End with: a-z, 0-9</li>
 *            </ul>
 *            If the account name contains a '.', the rules above are only
 *            checked for the characters before the first '.' occurred.
 * @throws InvalidParameterException
 *             If the account does not fulfill the requirements describes
 *             above.
 */
public void setName(String name) {
    if (name == null) {
        this.name = "";
    } else {
        if (!name.isEmpty()) {
            if (name.length() < 3 || name.length() > 16) {
                throw new InvalidParameterException(
                        "An account name needs to have a minimum length of 3 and a maximum length of 16.");
            } else if (!name.split("\\.")[0].matches("^[a-z]{1}[a-z0-9\\-]{1,14}[a-z0-9]{1}")) {
                /*
                 * It looks like only values infront of a "." are validated.
                 * Those characters in front of a dot must fullfil the
                 * following rules: The first char needs to be one of "a-z"
                 * while a "-" and "0-9" are allowed for further chars.
                 */
                throw new InvalidParameterException("The given account name '" + name
                        + "' contains unsupported characters. The first character needs to be one"
                        + " of 'a-z', characters in the middle can be 'a-z', '0,9' and a '-' and the last character of the "
                        + "name has to be one of 'a-z' and '0-9'.");
            }
        }

        this.name = name;
    }
}

From source file:net.sf.zekr.engine.addonmgr.AddOnManagerUtils.java

@SuppressWarnings("rawtypes")
private static ResourceManager getResourceManager(Class resourceType) {
    if (AudioData.class.equals(resourceType))
        return ApplicationConfig.getInstance().getAudio();
    else if (TranslationData.class.equals(resourceType))
        return ApplicationConfig.getInstance().getTranslation();
    else// w  w  w.ja va  2 s.  c  om
        throw new InvalidParameterException("ResourceType not handled");
}

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

@Override
public void validate(ValidationType validationType) {
    if (!validationType.equals(ValidationType.SKIP_VALIDATION)) {
        if (this.getBeneficiaries().isEmpty()) {
            throw new InvalidParameterException("Must specify at least one beneficiary.");
        } else if (this.getBeneficiaries().size() >= 128) {
            // Require size serialization fits in one byte.
            throw new InvalidParameterException("Cannot specify more than 127 beneficiaries.");
        }/*from   w ww.  j  a  v a 2  s.  c  om*/

        // TODO: Verify if the list is sorted correctly.
        // FC_ASSERT( beneficiaries[i - 1] < beneficiaries[i], "Benficiaries
        // must be specified in sorted order (account ascending)" );

        int sum = 0;
        for (BeneficiaryRouteType beneficiaryRouteType : this.getBeneficiaries()) {
            sum += beneficiaryRouteType.getWeight();
            if (sum > 10000) {
                throw new InvalidParameterException("Cannot allocate more than 100% of rewards to a comment");
            }
        }
    }
}