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:uk.ac.ebi.mdk.apps.CommandLineMain.java

/**
 * Convenience method for accessing a file from the parsed options. Note the method does not check if
 * the file exists//w ww .j  a  v a2 s  .c  o m
 *
 * @param option
 *
 * @return
 *
 * @throws IllegalArgumentException
 */
public File getFile(String option, String defaultFilePrefix, String defaultExtension)
        throws IllegalArgumentException {

    if (getCommandLine().hasOption(option)) {
        return new File(getCommandLine().getOptionValue(option));
    } else {
        try {
            return File.createTempFile(defaultFilePrefix, defaultExtension);
        } catch (IOException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }
    }
    throw new InvalidParameterException("Could not get file option");
}

From source file:com.todoroo.astrid.voice.VoiceInputAssistant.java

/**
 * The param requestCode is used to differentiate between multiple
 * microphone-buttons on a single fragment.
 * Use the this constructor to specify your own requestCode in
 * this case for every additional use on a fragment.
 * If you only use one microphone-button on a fragment,
 * you can leave it to its default, VOICE_RECOGNITION_REQUEST_CODE.
 *
 *
 * @param fragment/*from  ww  w.j  a  va  2 s . com*/
 * @param voiceButton
 * @param textField
 * @param requestCode has to be unique in a single fragment-context,
 *   dont use VOICE_RECOGNITION_REQUEST_CODE, this is reserved for the other constructor
 */
public VoiceInputAssistant(ImageButton voiceButton, int requestCode) {
    this(voiceButton);
    if (requestCode == VOICE_RECOGNITION_REQUEST_CODE)
        throw new InvalidParameterException(
                "You have to specify a unique requestCode for this VoiceInputAssistant!");
    this.requestCode = requestCode;
}

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

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

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

    return result;
}

From source file:eu.bittrade.libs.steemj.plugins.apis.follow.models.operations.ReblogOperation.java

@Override
public void validate(ValidationType validationType) {
    if (!ValidationType.SKIP_VALIDATION.equals(validationType)) {
        if (this.getAccount() == null) {
            throw new InvalidParameterException("The account cannot be null.");
        } else if (this.getAuthor() == null) {
            throw new InvalidParameterException("The author account cannot be null.");
        } else if (this.getPermlink() == null) {
            throw new InvalidParameterException("The permlink account cannot be null.");
        } else if (this.getAccount().equals(this.getAuthor())) {
            throw new InvalidParameterException("You cannot reblog your own content.");
        }/*ww  w.  j  a  v a 2  s .  c  o m*/
    }
}

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

public void setAccessRuleName(final String accessRuleName) {
    if (accessRuleName == null) {
        throw new InvalidParameterException("Illegal to create an access rule with accessruleName == null");
    }//from ww w  .j a va2 s.co m
    this.accessRuleName = accessRuleName.trim();
}

From source file:de.uzk.hki.da.convert.ConverterService.java

/**
 * Executes a conversion routine. Therefore creates an instance of the java class mentioned in the ConversionInstruction ci.
 * Checks whether the resulting file exists and is not a null byte file.
 * @throws IOException //from w  w w  . ja v  a 2s.c o  m
 * 
 * @throws RuntimeException if resulting file doesn't exit or is null byte file.
 */
private List<Event> executeConversionInstruction(WorkArea wa, ConversionInstruction ci, Object object)
        throws IOException {
    if (ci.getConversion_routine() == null)
        throw new InvalidParameterException("ConversionRoutine not set in ConversionInstruction");

    final ConversionStrategy strategy;
    try {
        strategy = getStrategy(ci.getConversion_routine().getType());
    } catch (Exception e) {
        throw new RuntimeException(
                "Critical Error: Could not create strategy of type: " + ci.getConversion_routine().getType()
                        + ". Please inform the DA-Admin to view the settings for the conversionRoutine "
                        + ci.getConversion_routine().getName(),
                e);
    }

    logger.info("Preparing conversion of: " + ci.getSource_file() + "\"->\"" + ci.getTarget_folder() + "\" "
            + "(CI with id \"" + ci.getId() + "\" will be executed with " + ci.getConversion_routine().getName()
            + " which is of type " + strategy.getClass().toString() + ").");

    strategy.setCLIConnector(new CommandLineConnector());
    strategy.setObject(object);
    strategy.setParam(ci.getConversion_routine().getParams());
    strategy.setKnownFormatCommandLineErrors(knownFormatCmdLineErrors);
    List<Event> results;
    // TODO remove try catch. evaluate in convertbatch and not in convertfile
    try {
        results = strategy.convertFile(wa, ci);
    } catch (FileNotFoundException e) {
        throw new RuntimeException("Resulting file of conversion strategy does not exist", e);
    }
    return results;
}

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

@Override
public void setMatchType(Integer matchType) {
    if (matchType == null) {
        throw new InvalidParameterException("Invalid to set matchType == null");
    }/* w ww  . j  a  v  a2  s  . c om*/
    this.matchType = AccessMatchType.matchFromDatabase(matchType);
}

From source file:org.obm.push.protocol.data.CalendarEncoder.java

public void encode(Device device, Element p, IApplicationData data, boolean isResponse) {

    MSEvent ev = (MSEvent) data;//ww w  .ja v  a2  s  .co m

    TimeZone timeZone = ev.getTimeZone();

    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));

    if (null != timeZone) {
        s(p, ASCalendar.TIME_ZONE.asASValue(), encodedTimeZoneAsString(timeZone, Locale.getDefault()));
    }

    s(p, ASCalendar.DTSTAMP.asASValue(), ev.getDtStamp() != null ? ev.getDtStamp() : new Date(), sdf);

    s(p, ASCalendar.START_TIME.asASValue(), ev.getStartTime(), sdf);
    s(p, ASCalendar.SUBJECT.asASValue(), ev.getSubject());

    MSEventUid eventUid = ev.getUid();
    if (eventUid != null) {
        s(p, ASCalendar.UID.asASValue(), eventUid.serializeToString());
    } else {
        throw new InvalidParameterException("a MSEvent must have an UID");
    }
    if (ev.getOrganizerEmail() != null) {
        s(p, ASCalendar.ORGANIZER_NAME.asASValue(), ev.getOrganizerName());
        s(p, ASCalendar.ORGANIZER_EMAIL.asASValue(), ev.getOrganizerEmail());
    }

    if (device.checkHint("hint.loadAttendees", true)) {
        if (ev.getAttendees().size() > 0) {
            Element at = DOMUtils.createElement(p, ASCalendar.ATTENDEES.asASValue());
            for (MSAttendee ma : ev.getAttendees()) {
                Element ae = DOMUtils.createElement(at, ASCalendar.ATTENDEE.asASValue());
                s(ae, ASCalendar.ATTENDEE_EMAIL.asASValue(), ma.getEmail());

                if (ma.getName() == null || ma.getName().trim().length() == 0) {
                    String mail = ma.getEmail();
                    int idx = mail.indexOf('@');
                    if (idx > 0) {
                        mail = mail.substring(0, mail.indexOf('@')).replace(".", " ");
                    }
                    ma.setName(mail);
                }

                s(ae, ASCalendar.ATTENDEE_NAME.asASValue(), ma.getName());

                s(ae, ASCalendar.ATTENDEE_STATUS.asASValue(), ma.getAttendeeStatus().asSpecificationValue());
                s(ae, ASCalendar.ATTENDEE_TYPE.asASValue(), ma.getAttendeeType().getId());
            }
        }
    }

    s(p, ASCalendar.LOCATION.asASValue(), ev.getLocation());
    s(p, ASCalendar.END_TIME.asASValue(), ev.getEndTime(), sdf);

    encodeBody(p, ev.getDescription());

    encodeCategories(p, ev.getCategories());

    if (ev.getRecurrence() != null) {
        encodeRecurrence(p, ev, sdf, timeZone);
    }

    s(p, ASCalendar.SENSITIVITY.asASValue(), ev.getSensitivity().asIntString());
    s(p, ASCalendar.BUSY_STATUS.asASValue(), ev.getBusyStatus().asIntString());
    if (ev.getAllDayEvent()) {
        s(p, ASCalendar.ALL_DAY_EVENT.asASValue(), (ev.getAllDayEvent() ? "1" : "0"));
    } else {
        s(p, ASCalendar.ALL_DAY_EVENT.asASValue(), "0");
    }

    List<MSEventException> exceptions = Objects.firstNonNull(ev.getExceptions(),
            ImmutableList.<MSEventException>of());
    encodeExceptions(device, ev, p, exceptions, sdf);

    if (device.checkHint("hint.loadAttendees", true) && ev.getAttendees().size() > 1) {
        s(p, ASCalendar.MEETING_STATUS.asASValue(), CalendarMeetingStatus.IS_A_MEETING.asIntString());
    } else {
        s(p, ASCalendar.MEETING_STATUS.asASValue(), CalendarMeetingStatus.IS_NOT_A_MEETING.asIntString());
    }

    if (isResponse && device.getProtocolVersion().compareTo(ProtocolVersion.V120) > 0) {
        s(p, "AirSyncBase:NativeBodyType", Type.PLAIN_TEXT.toString());
    }

    if (ev.getReminder() != null) {
        s(p, ASCalendar.REMINDER_MINS_BEFORE.asASValue(), ev.getReminder().toString());
    }

    // DOMUtils.createElement(p, "Calendar:Compressed_RTF");

}

From source file:org.flite.cach3.config.Cach3State.java

@ManagedAttribute
public void setJitterDefault(int jitterDefault) {
    if (jitterDefault < 0 || jitterDefault > 99) {
        throw new InvalidParameterException("Parameter 'jitterDefault' must be between 0 and 99.");
    }//  w  w w. j  a  v  a 2 s .  c om
    this.jitterDefault = jitterDefault;
}

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

/**
 * Send's UPDATE SQL request to mobDB //www.  j  a  v  a 2s.c  o  m
 * @param appKey String value Application key
 * @param updateRowdata UpdateRowData object
 * @param bargraph String value for Analytics tag name
 * @param secure boolean value to set SSL communication
 * @param listener MobDBResponseListener object
 * @throws InvalidParameterException
 */
public synchronized void execute(String appKey, UpdateRowData updateRowdata, String bargraph, boolean secure,
        MobDBResponseListener listener) throws InvalidParameterException {
    try {
        execute(appKey, new String[] { updateRowdata.getQueryString() }, updateRowdata.getParameters(),
                bargraph, secure, listener);
    } catch (Exception e) {
        // TODO: handle exception
        throw new InvalidParameterException(e.toString());
    }
}