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:com.customdatepicker.date.MonthView.java

/**
 * Sets all the parameters for displaying this week. The only required
 * parameter is the week number. Other parameters have a default value and
 * will only update if a new value is included, except for focus month,
 * which will always default to no focus month if no value is passed in.
 *///from w  w  w .  j a  va2 s .c om
public void setMonthParams(int selectedDay, int year, int month, int weekStart) {
    if (month == -1 && year == -1) {
        throw new InvalidParameterException("You must specify month and year for this view");
    }

    mSelectedDay = selectedDay;

    // Allocate space for caching the day numbers and focus values
    mMonth = month;
    mYear = year;

    // Figure out what day today is
    //final Time today = new Time(Time.getCurrentTimezone());
    //today.setToNow();
    final Calendar today = Calendar.getInstance(mController.getTimeZone());
    mHasToday = false;
    mToday = -1;

    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

    if (weekStart != -1) {
        mWeekStart = weekStart;
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }

    mNumCells = mCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();

    // Invalidate cached accessibility information.
    mTouchHelper.invalidateRoot();
}

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

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        if (this.getRecentOwnerAuthority().equals(newOwnerAuthority)) {
            throw new InvalidParameterException(
                    "Cannot set new owner authority to the recent owner authority.");
        } else if (newOwnerAuthority.isImpossible()) {
            throw new InvalidParameterException("The new owner authority cannot be impossible.");
        } else if (recentOwnerAuthority.isImpossible()) {
            throw new InvalidParameterException("The recent owner authority cannot be impossible.");
        } else if (newOwnerAuthority.getWeightThreshold() != 1) {
            throw new InvalidParameterException("The new owner authority cannot be trivial.");
        }//from w  w  w .  ja v a 2 s  .co m
    }
}

From source file:at.gv.egiz.bku.slcommands.impl.cms.Signature.java

private byte[] getContent(CMSDataObjectOptionalMetaType dataObject, URLDereferencer urlDereferencer)
        throws InvalidParameterException, SLCommandException, IOException {
    byte[] data = dataObject.getContent().getBase64Content();
    if (data == null) {
        String reference = dataObject.getContent().getReference();
        if (reference == null)
            throw new SLCommandException(4003);
        InputStream is = urlDereferencer.dereference(reference).getStream();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        for (int i = is.read(buffer); i > -1; i = is.read(buffer)) {
            baos.write(buffer, 0, i);//from   w w  w .  jav  a  2s  .co  m
        }
        data = baos.toByteArray();
        is.close();
    }
    this.signedDocument = data.clone();

    this.excludedByteRange = dataObject.getExcludedByteRange();
    if (this.excludedByteRange == null)
        return data;

    int from = this.excludedByteRange.getFrom().intValue();
    int to = this.excludedByteRange.getTo().intValue();
    if (from > data.length || to > data.length || from > to)
        throw new InvalidParameterException("ExcludedByteRange contains invalid data: [" + from + "-" + to
                + "], Content length: " + data.length);

    // Fill ExcludedByteRange with 0s for document to display in viewer
    Arrays.fill(this.signedDocument, from, to + 1, (byte) 0);

    // Remove ExcludedByteRange from data to be signed
    byte[] first = null;
    byte[] second = null;
    if (from > 0)
        first = Arrays.copyOfRange(data, 0, from);
    if ((to + 1) < data.length)
        second = Arrays.copyOfRange(data, to + 1, data.length);
    data = ArrayUtils.addAll(first, second);
    log.debug("ExcludedByteRange [" + from + "-" + to + "], Content length: " + data.length);
    return data;
}

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

/**
 * Add the HistoryReference into the SiteMap.
 * This method will rely on reading message from the History table.
 * Note that this method must only be called on the EventDispatchThread
 * @param ref/*  w w w .  j a  v  a 2  s.c o  m*/
 */
public synchronized SiteNode addPath(HistoryReference ref) {
    if (Constant.isLowMemoryOptionSet()) {
        throw new InvalidParameterException("SiteMap should not be accessed when the low memory option is set");
    }

    HttpMessage msg = null;
    try {
        msg = ref.getHttpMessage();
    } catch (Exception e) {
        // ZAP: Added error
        log.error(e.getMessage(), e);
        return null;
    }

    return addPath(ref, msg);
}

From source file:com.abiquo.api.tasks.util.DatacenterTaskBuilder.java

/**
 * Return the {@link JobType} that is related to this {@link VirtualMachineStateTransition}. <br>
 * <br>/*from ww w  .  jav a 2s. c o m*/
 * Null if empty.
 * 
 * @param machineStateTransition the current.
 * @return JobType
 */
public JobType getTaskTypeFromTransition(final VirtualMachineStateTransition machineStateTransition) {
    switch (machineStateTransition) {
    case CONFIGURE: {
        return JobType.CONFIGURE;
    }
    case DECONFIGURE: {
        return JobType.DECONFIGURE;
    }
    case POWEROFF: {
        return JobType.POWER_OFF;
    }
    case POWERON: {
        return JobType.POWER_ON;
    }
    case PAUSE: {
        return JobType.PAUSE;
    }
    case RESUME: {
        return JobType.RESET;
    }
    case SNAPSHOT: {
        return JobType.SNAPSHOT;
    }
    case RECONFIGURE: {
        return JobType.RECONFIGURE;
    }
    case RESET: {
        return JobType.RESET;
    }
    default: {
        throw new InvalidParameterException("Error unknown transition: " + machineStateTransition);
    }
    }
}

From source file:org.zaproxy.zap.extension.autoupdate.OptionsParamCheckForUpdates.java

private void setDownloadDirectory(File downloadDirectory, boolean save) throws InvalidParameterException {
    if (!Constant.FOLDER_LOCAL_PLUGIN.equals(downloadDirectory.getAbsolutePath())) {
        // Check its one of the extra addon dirs
        boolean found = false;
        for (File f : this.addonDirectories) {
            if (f.equals(downloadDirectory)) {
                found = true;//from w  w  w.j av a 2 s.  c  o  m
                break;
            }
        }
        if (!found) {
            throw new InvalidParameterException(
                    "Directory must be the default one or one of the addonDirectories "
                            + downloadDirectory.getAbsolutePath());
        }
    }
    if (!downloadDirectory.canWrite()) {
        throw new InvalidParameterException(
                "No write access to directory " + downloadDirectory.getAbsolutePath());
    }

    this.downloadDirectory = downloadDirectory;
    if (save) {
        getConfig().setProperty(DOWNLOAD_DIR, downloadDirectory.getAbsolutePath());
    }
}

From source file:app.android.datetimepicker.date.SimpleMonthView.java

/**
 * Sets all the parameters for displaying this week. The only required
 * parameter is the week number. Other parameters have a default value and
 * will only update if a new value is included, except for focus month,
 * which will always default to no focus month if no value is passed in. See
 * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
 *
 * @param params A map of the new parameters, see
 *            {@link #VIEW_PARAMS_HEIGHT}
 *//*from w  w  w.j  a  v  a 2 s . c o m*/
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify the month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }

    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);

    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;

    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }

    mNumCells = Utils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();

    // Invalidate cached accessibility information.
    mTouchHelper.invalidateRoot();
}

From source file:be.fedict.trust.crl.CrlTrustLinker.java

private static URI toURI(String str) {
    try {/*  ww w .  java  2  s  .c o m*/
        URI uri = new URI(str);
        return uri;
    } catch (URISyntaxException e) {
        throw new InvalidParameterException("CRL URI syntax error: " + e.getMessage());
    }
}

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

protected <L extends CacheListener> List<L> getPertinentListeners(final Class<L> clazz, final String namespace)
        throws Exception {
    if (clazz == null) {
        throw new InvalidParameterException("Clazz type must be defined.");
    }//from  w w  w .  j  av a2 s.c om
    if (namespace == null || namespace.length() == 0) {
        throw new InvalidParameterException("Namespace must be defined.");
    }

    final List<L> results = new ArrayList<L>();
    final List<L> baseList = state.getListeners(clazz);
    if (baseList != null && !baseList.isEmpty()) {
        for (final L base : baseList) {
            if (base.getNamespacesOfInterest() == null || base.getNamespacesOfInterest().isEmpty()
                    || base.getNamespacesOfInterest().contains(namespace)) {
                results.add(base);
            }
        }
    }

    return results;
}

From source file:com.android.yijiang.kzx.widget.betterpickers.calendardatepicker.SimpleMonthView.java

/**
 * Sets all the parameters for displaying this week. The only required parameter is the week number. Other
 * parameters have a default value and will only update if a new value is included, except for focus month, which
 * will always default to no focus month if no value is passed in. See {@link #VIEW_PARAMS_HEIGHT} for more info on
 * parameters./*from  ww  w . j av a2  s . co m*/
 *
 * @param params A map of the new parameters, see {@link #VIEW_PARAMS_HEIGHT}
 * @param tz The time zone this view should reference times in
 */
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify the month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }

    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);

    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;

    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }

    mNumCells = Utils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();

    // Invalidate cached accessibility information.
    mNodeProvider.invalidateParent();
}