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.predic8.membrane.core.http.Header.java

/**
 * @param keepAliveHeaderValue the value of the "Keep-Alive" header, see http://www.w3.org/Protocols/HTTP/1.1/draft-ietf-http-v11-spec-01.html#Keep-Alive
 * @param paramName either {@link #TIMEOUT} or {@link #MAX}.
 * @return the extracted parameter value of the "Keep-Alive" header
 *///from   w w  w.  j a  va  2  s  .co  m
public static long parseKeepAliveHeader(String keepAliveHeaderValue, String paramName) {
    Pattern p;
    if (paramName == TIMEOUT) {
        p = timeoutPattern;
    } else if (paramName == MAX) {
        p = maxPattern;
    } else {
        throw new InvalidParameterException("paramName must be one of Header.TIMEOUT and .MAX .");
    }
    Matcher m = p.matcher(keepAliveHeaderValue);
    if (!m.find())
        return -1;
    return Long.parseLong(m.group(1));
}

From source file:org.openqa.grid.internal.BaseRemoteProxy.java

/**
 * Takes a registration request and return the RemoteProxy associated to it. It can be any class
 * extending RemoteProxy.//from w  w w.  j a  v a2  s. c om
 *
 * @param request  The request
 * @param registry The registry to use
 * @return a new instance built from the request.
 */
@SuppressWarnings("unchecked")
public static <T extends RemoteProxy> T getNewInstance(RegistrationRequest request, Registry registry) {
    try {
        String proxyClass = request.getRemoteProxyClass();
        if (proxyClass == null) {
            log.fine("No proxy class. Using default");
            proxyClass = BaseRemoteProxy.class.getCanonicalName();
        }
        Class<?> clazz = Class.forName(proxyClass);
        log.fine("Using class " + clazz.getName());
        Object[] args = new Object[] { request, registry };
        Class<?>[] argsClass = new Class[] { RegistrationRequest.class, Registry.class };
        Constructor<?> c = clazz.getConstructor(argsClass);
        Object proxy = c.newInstance(args);
        if (proxy instanceof RemoteProxy) {
            ((RemoteProxy) proxy).setupTimeoutListener();
            return (T) proxy;
        } else {
            throw new InvalidParameterException("Error: " + proxy.getClass() + " isn't a remote proxy");
        }

    } catch (InvocationTargetException e) {
        log.log(Level.SEVERE, e.getTargetException().getMessage(), e.getTargetException());
        throw new InvalidParameterException("Error: " + e.getTargetException().getMessage());

    } catch (Exception e) {
        log.log(Level.SEVERE, e.getMessage(), e);
        throw new InvalidParameterException("Error: " + e.getMessage());
    }
}

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

/**
 * Add the HistoryReference with the corresponding HttpMessage into the SiteMap.
 * This method saves the msg to be read from the reference table.  Use 
 * this method if the HttpMessage is known.
 * Note that this method must only be called on the EventDispatchThread
 * @param msg/*from  w  w  w. ja  v  a 2s .c  o  m*/
 * @return 
 */
public SiteNode addPath(HistoryReference ref, HttpMessage msg) {
    if (Constant.isLowMemoryOptionSet()) {
        throw new InvalidParameterException("SiteMap should not be accessed when the low memory option is set");
    }

    if (View.isInitialised() && Constant.isDevBuild() && !EventQueue.isDispatchThread()) {
        // In developer mode log an error if we're not on the EDT
        // Adding to the site tree on GUI ('initial') threads causes problems
        log.error("SiteMap.addPath not on EDT " + Thread.currentThread().getName(), new Exception());
    }

    URI uri = msg.getRequestHeader().getURI();
    log.debug("addPath " + uri.toString());

    SiteNode parent = (SiteNode) getRoot();
    SiteNode leaf = null;
    String folder = "";

    try {

        String host = getHostName(uri);

        // add host
        parent = findAndAddChild(parent, host, ref, msg);

        List<String> path = model.getSession().getTreePath(msg);
        for (int i = 0; i < path.size(); i++) {
            folder = path.get(i);
            if (folder != null && !folder.equals("")) {
                if (i == path.size() - 1) {
                    leaf = findAndAddLeaf(parent, folder, ref, msg);
                    ref.setSiteNode(leaf);
                } else {
                    parent = findAndAddChild(parent, folder, ref, msg);
                }
            }
        }
        if (leaf == null) {
            // No leaf found, which means the parent was really the leaf
            // The parent will have been added with a 'blank' href, so replace it with the real one
            parent.setHistoryReference(ref);
            leaf = parent;
        }

    } catch (Exception e) {
        // ZAP: Added error
        log.error("Exception adding " + uri.toString() + " " + e.getMessage(), e);
    }

    if (hrefMap.get(ref.getHistoryId()) == null) {
        hrefMap.put(ref.getHistoryId(), leaf);
    }

    return leaf;
}

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

static AnnotationInfo getAnnotationInfo(final ReadThroughMultiCache annotation, final String targetMethodName,
        final int jitterDefault) {
    final AnnotationInfo result = new AnnotationInfo();

    if (annotation == null) {
        throw new InvalidParameterException(
                String.format("No annotation of type [%s] found.", ReadThroughMultiCache.class.getName()));
    }// w  ww. j  av  a  2s .  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]",
                        ReadThroughMultiCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Namespace(namespace));

    final String keyPrefix = annotation.keyPrefix();
    if (!AnnotationConstants.DEFAULT_STRING.equals(keyPrefix)) {
        if (StringUtils.isBlank(keyPrefix)) {
            throw new InvalidParameterException(String.format(
                    "KeyPrefix for annotation [%s] must not be defined as an empty string on [%s]",
                    ReadThroughMultiCache.class.getName(), targetMethodName));
        }
        result.add(new AType.KeyPrefix(keyPrefix));
    }

    final Integer keyIndex = annotation.keyIndex();
    if (keyIndex < 0) {
        throw new InvalidParameterException(
                String.format("KeyIndex for annotation [%s] must be 0 or greater on [%s]",
                        ReadThroughMultiCache.class.getName(), targetMethodName));
    }
    result.add(new AType.KeyIndex(keyIndex));

    final String keyTemplate = annotation.keyTemplate();
    if (!AnnotationConstants.DEFAULT_STRING.equals(keyTemplate)) {
        if (StringUtils.isBlank(keyTemplate)) {
            throw new InvalidParameterException(String.format(
                    "KeyTemplate for annotation [%s] must not be defined as an empty string on [%s]",
                    ReadThroughMultiCache.class.getName(), targetMethodName));
        }
        result.add(new AType.KeyTemplate(keyTemplate));
    }

    final int expiration = annotation.expiration();
    if (expiration < 0) {
        throw new InvalidParameterException(
                String.format("Expiration for annotation [%s] must be 0 or greater on [%s]",
                        ReadThroughMultiCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Expiration(expiration));

    final int jitter = annotation.jitter();
    if (jitter < -1 || jitter > 99) {
        throw new InvalidParameterException(
                String.format("Jitter for annotation [%s] must be -1 <= jitter <= 99 on [%s]",
                        ReadThroughMultiCache.class.getName(), targetMethodName));
    }
    result.add(new AType.Jitter(jitter == -1 ? jitterDefault : jitter));

    return result;
}

From source file:com.android.datetimepicker.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. 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  av  a  2s.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 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:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.list.TaskListFragment.java

@Override
public void onCreate(Bundle savedState) {
    super.onCreate(savedState);

    setHasOptionsMenu(true);//from  w w w . j  av a2 s  . c o m

    selectedItemHandler = new SelectedItemHandler((AppCompatActivity) getActivity(), this);

    syncStatusReceiver = new SyncStatusMonitor();

    if (getArguments().getLong(LIST_ID, -1) == -1) {
        throw new InvalidParameterException("Must designate a list to open!");
    }
    mListId = getArguments().getLong(LIST_ID, -1);

    // Start loading data
    mAdapter = new SimpleSectionsAdapter(this, getActivity());

    // Set a drag listener
    // TODO jonas
    /*mAdapter.setDropListener(new DropListener() {
      @Override
      public void drop(int from, int to) {
        Log.d("nononsenseapps drag", "Position from " + from + " to " + to);
            
        final Task fromTask = new Task((Cursor) mAdapter.getItem(from));
        final Task toTask = new Task((Cursor) mAdapter.getItem(to));
            
        fromTask.moveTo(getActivity().getContentResolver(), toTask);
      }
    });*/
}

From source file:org.ejbca.core.ejb.ocsp.OcspKeyRenewalSessionBean.java

/**
 * Get user data for the EJBCA user that will be used when creating the cert for the new key.
 * @param signingCertificate The OCSP signing certificate to get the end entity for
 * @param caId the ID of the OCSP signing certificate issuing CA
 * /* w  ww . ja  v  a 2s .  co  m*/
 * @return the data
 */
private UserDataVOWS getUserDataVOWS(EjbcaWS ejbcaWS, final X509Certificate signingCertificate,
        final int caId) {
    final UserMatch match = new UserMatch();
    final String subjectDN = CertTools.getSubjectDN(signingCertificate);
    final String caName = getCAName(ejbcaWS, caId);
    if (caName == null) {
        throw new InvalidParameterException("No CA found for ID: " + caId);
    }
    match.setMatchtype(BasicMatch.MATCH_TYPE_EQUALS);
    match.setMatchvalue(subjectDN);
    match.setMatchwith(org.ejbca.util.query.UserMatch.MATCH_WITH_DN);
    final List<UserDataVOWS> users;
    try {
        users = ejbcaWS.findUser(match);
    } catch (Exception e) {
        log.error("WS not working", e);
        return null;
    }
    if (users == null || users.size() < 1) {
        log.error(intres.getLocalizedMessage("ocsp.no.user.with.subject.dn", subjectDN));
        return null;
    }
    log.debug("at least one user found for cert with DN: " + subjectDN + " Trying to match it with CA name: "
            + caName);
    UserDataVOWS result = null;
    for (UserDataVOWS userData : users) {
        if (caName.equals(userData.getCaName())) {
            result = userData;
            break;
        }
    }
    if (result == null) {
        log.error("No user found for certificate '" + subjectDN + "' on CA '" + caName + "'.");
        return null;
    }
    return result;
}

From source file:org.apache.flink.api.java.operators.CoGroupOperator.java

private static <I1, I2, K, OUT> PlanRightUnwrappingCoGroupOperator<I1, I2, OUT, K> translateSelectorFunctionCoGroupRight(
        int[] logicalKeyPositions1, SelectorFunctionKeys<I2, ?> rawKeys2, CoGroupFunction<I1, I2, OUT> function,
        TypeInformation<I1> inputType1, TypeInformation<OUT> outputType, String name, Operator<I1> input1,
        Operator<I2> input2) {/*from   w  w w  . j a  va 2s  .c om*/
    if (!inputType1.isTupleType()) {
        throw new InvalidParameterException("Should not happen.");
    }

    @SuppressWarnings("unchecked")
    final SelectorFunctionKeys<I2, K> keys2 = (SelectorFunctionKeys<I2, K>) rawKeys2;
    final TypeInformation<Tuple2<K, I2>> typeInfoWithKey2 = KeyFunctions.createTypeWithKey(keys2);
    final Operator<Tuple2<K, I2>> keyedInput2 = KeyFunctions.appendKeyExtractor(input2, keys2);

    final PlanRightUnwrappingCoGroupOperator<I1, I2, OUT, K> cogroup = new PlanRightUnwrappingCoGroupOperator<>(
            function, logicalKeyPositions1, keys2, name, outputType, inputType1, typeInfoWithKey2);

    cogroup.setFirstInput(input1);
    cogroup.setSecondInput(keyedInput2);

    return cogroup;
}

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

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        if (title.length() > 255) {
            throw new InvalidParameterException("The title can't have more than 255 characters.");
        } else if (!SteemJUtils.verifyJsonString(jsonMetadata)) {
            throw new InvalidParameterException("The given String is no valid JSON");
        }/* w  ww  .j  ava  2  s  .c  om*/
    }
}

From source file:com.facebook.presto.accumulo.AccumuloClient.java

private static List<AccumuloColumnHandle> getColumnHandles(ConnectorTableMetadata meta, String rowIdColumn) {
    // Get the column mappings from the table property or auto-generate columns if not defined
    Map<String, Pair<String, String>> mapping = AccumuloTableProperties.getColumnMapping(meta.getProperties())
            .orElse(autoGenerateMapping(meta.getColumns(),
                    AccumuloTableProperties.getLocalityGroups(meta.getProperties())));

    // The list of indexed columns
    Optional<List<String>> indexedColumns = AccumuloTableProperties.getIndexColumns(meta.getProperties());

    // And now we parse the configured columns and create handles for the metadata manager
    ImmutableList.Builder<AccumuloColumnHandle> cBuilder = ImmutableList.builder();
    for (int ordinal = 0; ordinal < meta.getColumns().size(); ++ordinal) {
        ColumnMetadata cm = meta.getColumns().get(ordinal);

        // Special case if this column is the row ID
        if (cm.getName().equalsIgnoreCase(rowIdColumn)) {
            cBuilder.add(new AccumuloColumnHandle(rowIdColumn, Optional.empty(), Optional.empty(), cm.getType(),
                    ordinal, "Accumulo row ID", false));
        } else {/*ww w. j  a  v  a 2s  .  c om*/
            if (!mapping.containsKey(cm.getName())) {
                throw new InvalidParameterException(
                        format("Misconfigured mapping for presto column %s", cm.getName()));
            }

            // Get the mapping for this column
            Pair<String, String> famqual = mapping.get(cm.getName());
            boolean indexed = indexedColumns.isPresent()
                    && indexedColumns.get().contains(cm.getName().toLowerCase(Locale.ENGLISH));
            String comment = format("Accumulo column %s:%s. Indexed: %b", famqual.getLeft(), famqual.getRight(),
                    indexed);

            // Create a new AccumuloColumnHandle object
            cBuilder.add(new AccumuloColumnHandle(cm.getName(), Optional.of(famqual.getLeft()),
                    Optional.of(famqual.getRight()), cm.getType(), ordinal, comment, indexed));
        }
    }

    return cBuilder.build();
}