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() 

Source Link

Document

Constructs an InvalidParameterException with no detail message.

Usage

From source file:com.bynder.sdk.util.Utils.java

/**
 * Builds a {@link Map} from a API response string containing a key and value separated by a
 * &./*  w w w.  j  a  v a  2 s  .  co  m*/
 *
 * @param response Response string returned by the API.
 *
 * @return {@link Map} with key and value pair.
 */
public static Map<String, String> buildMapFromResponse(final String response) {
    Map<String, String> map = new HashMap<>();
    String[] keyValuePairs = response.split(STR_AND);

    for (String pair : keyValuePairs) {
        String[] keyValue = pair.split(STR_EQUALS);
        if (keyValue.length == 2) {
            map.put(keyValue[0], keyValue[1]);
        } else {
            throw new InvalidParameterException();
        }
    }
    return map;
}

From source file:XSDDateTime.java

public static String getDateTime(Calendar cal) {
    if (!cal.getTimeZone().equals(TimeZone.getTimeZone("GMT+00:00"))) {
        throw new InvalidParameterException();
    }/* w w w . j a  va  2  s .c  o  m*/
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH);
    month++;
    String monthString = pad(month);
    int day = cal.get(Calendar.DAY_OF_MONTH);
    String dayString = pad(day);
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    String hourString = pad(hour);
    int minutes = cal.get(Calendar.MINUTE);
    String minutesString = pad(minutes);
    int seconds = cal.get(Calendar.SECOND);
    String secondsString = pad(seconds);

    return year + "-" + monthString + "-" + dayString + "T" + hourString + ":" + minutesString + ":"
            + secondsString + "Z";
}

From source file:com.z3r0byte.magis.GradesSubjectActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_grades_subject);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        Gson gson = new Gson();
        study = gson.fromJson(extras.getString("Study"), Study.class);
        subject = gson.fromJson(extras.getString("Subject"), SubSubject.class);
    } else {//  w w w . j  ava2 s .c o  m
        Log.e(TAG, "onCreate: No valid Magister!", new InvalidParameterException());
        Toast.makeText(this, R.string.err_unknown, Toast.LENGTH_SHORT).show();
        finish();
    }
    mMagister = GlobalMagister.MAGISTER;

    mToolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.Toolbar);
    mToolbar.setTitle(subject.name);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);

    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.layout_refresh);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary, R.color.setup_color_3,
            R.color.setup_color_5);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Log.d(TAG, "onRefresh: Refreshing!");
            loadGrades();
        }
    });
    mSwipeRefreshLayout.setRefreshing(true);

    grades = new Grade[0];

    listView = (ListView) findViewById(R.id.list_grades);
    mGradesAdapter = new GradesAdapter(this, grades, false);
    listView.setAdapter(mGradesAdapter);

    loadGrades();
}

From source file:nl.han.ica.core.issue.solver.EncapsulateFieldSolver.java

private void refactorNodes(List<ASTNode> nodes) throws InvalidParameterException {
    for (ASTNode node : nodes) {
        if (node instanceof FieldDeclaration) {
            refactorFieldDeclaration((FieldDeclaration) node);
        } else if (node instanceof QualifiedName) {
            refactorQualifiedNames((QualifiedName) node);
        } else {/*  w w  w . j a  v a2s. c o  m*/
            throw new InvalidParameterException();
        }
    }
}

From source file:org.mifosplatform.infrastructure.core.serialization.FromJsonHelper.java

public void checkForUnsupportedParameters(final JsonObject object, final Set<String> supportedParams) {
    if (object == null) {
        throw new InvalidParameterException();
    }//from  w w w.j  av  a 2  s . co  m

    final Set<Entry<String, JsonElement>> entries = object.entrySet();
    final List<String> unsupportedParameterList = new ArrayList<String>();

    for (final Entry<String, JsonElement> providedParameter : entries) {
        if (!supportedParams.contains(providedParameter.getKey())) {
            unsupportedParameterList.add(providedParameter.getKey());
        }
    }

    if (!unsupportedParameterList.isEmpty()) {
        throw new UnsupportedParameterException(unsupportedParameterList);
    }
}

From source file:eu.gusak.orion.php.servlets.PhpServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    traceRequest(req);/*from ww  w  . j a  v a 2 s .  c o m*/
    String pathString = req.getPathInfo();
    if (pathString == null || pathString.equals("/")) { //$NON-NLS-1$
        handleException(resp, "No mode defined in request URI", new InvalidParameterException());
        return;
    }
    IPath path = new Path(pathString);
    if (path.segmentCount() != 2) { // /index.html is being added
        handleException(resp, "No mode defined in request URI", new InvalidParameterException());
        return;
    }

    String mode = path.segment(0);

    if (mode.equals("contentassist")) {
        doGetContentAssist(req, resp);
    } else if (mode.equals("codevalidation")) {
        doGetCodeValidation(req, resp);
    } else {
        handleException(resp, "Unknown mode provided in request URI", new InvalidParameterException());
        return;
    }
}

From source file:com.fjoglar.etsitnoticias.view.adapter.AboutViewPagerAdapter.java

private View getPage(int position, final ViewGroup parent) {
    switch (position) {
    case 0:/* ww w .ja  va2  s .c om*/
        if (aboutEtsitNews == null) {
            aboutEtsitNews = layoutInflater.inflate(R.layout.about_etsit_news, parent, false);
            ButterKnife.bind(this, aboutEtsitNews);

            infoVersionName.setText(mContext.getString(R.string.info_version_name, BuildConfig.VERSION_NAME));
            githubLink.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Navigator.getInstance().openUrl(parent.getContext(), GITHUB_LINK);
                }
            });
        }
        return aboutEtsitNews;
    case 1:
        if (aboutImages == null) {
            aboutImages = layoutInflater.inflate(R.layout.about_images, parent, false);
        }
        return aboutImages;
    case 2:
        if (aboutLibs == null) {
            aboutLibs = layoutInflater.inflate(R.layout.about_libs, parent, false);
            ButterKnife.bind(this, aboutLibs);

            recyclerLibs.setAdapter(new LibraryAdapter());
        }
        return aboutLibs;
    }
    throw new InvalidParameterException();
}

From source file:com.gst.infrastructure.core.serialization.FromJsonHelper.java

public void checkForUnsupportedParameters(final JsonObject object, final Set<String> supportedParams) {
    if (object == null) {
        throw new InvalidParameterException();
    }/*ww  w  . ja v a  2s. com*/

    final Set<Entry<String, JsonElement>> entries = object.entrySet();
    final List<String> unsupportedParameterList = new ArrayList<>();

    for (final Entry<String, JsonElement> providedParameter : entries) {
        if (!supportedParams.contains(providedParameter.getKey())) {
            unsupportedParameterList.add(providedParameter.getKey());
        }
    }

    if (!unsupportedParameterList.isEmpty()) {
        throw new UnsupportedParameterException(unsupportedParameterList);
    }
}

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

/**
 * End builder-method to get the {@link Task} for Redis persistence.
 * //from   w w w  . j av  a 2s  .co  m
 * @return The {@link Task} for Redis persistence
 */
public Task buildAsyncTask(final String ownerId, final TaskType taskType) {
    if (StringUtils.isBlank(ownerId) || taskType == null) {
        throw new InvalidParameterException();
    }

    this.asyncTask.setOwnerId(ownerId);
    this.asyncTask.setType(taskType);

    for (Job job : this.asyncTask.getJobs()) {
        String jobName = format(job.getType().name(), false);
        String taskName = format(this.asyncTask.getType().name(), true);
        String ownerName = format(this.asyncTask.getType().getOwnerType().name(), false);

        job.setDescription(
                String.format("%s task's %s on %s with id %s", taskName, jobName, ownerName, ownerId));
    }

    return this.asyncTask;
}

From source file:eu.gusak.orion.php.servlets.PhpServlet.java

private void doGetContentAssist(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    // Load script source
    String script = req.getParameter("script");
    if (script == null) {
        handleException(resp, "No script parameter provided", new InvalidParameterException());
        return;//ww  w  .  j  a va  2 s  .  co  m
    }
    OrionPhpPlugin.debug("Script: " + script);

    // Read the offset (position of cursor in the editor)
    int offset = 0;
    String offsetString = req.getParameter("offset");
    try {
        offset = Integer.parseInt(offsetString);
    } catch (NumberFormatException e) {
        handleException(resp, "No offset parameter provided", e);
        return;
    }
    OrionPhpPlugin.debug("Offset: " + offset);

    // Read the prefix (to compute offsets for parameters in Linked Mode)
    String prefix = req.getParameter("prefix");
    if (prefix == null) {
        handleException(resp, "No prefix parameter provided", new InvalidParameterException());
        return;
    }
    OrionPhpPlugin.debug("Prefix: " + prefix);

    // Set PHP Version if defined
    String versionString = req.getParameter("phpversion");
    PHPVersion phpVersion = PHPVersion.PHP5_3;
    if (versionString != null) {
        try {
            int versionInt = Integer.parseInt(versionString);

            switch (versionInt) {
            case 4:
                phpVersion = PHPVersion.PHP4;
                break;
            case 5:
                phpVersion = PHPVersion.PHP5;
                break;
            default:
                phpVersion = PHPVersion.PHP5_3;
                break;
            }
        } catch (NumberFormatException e) {
        }
    }

    try {
        OrionPhpPlugin.setProjectPhpVersion(phpVersion);
    } catch (CoreException e) {
        handleException(resp, "Problem with setting PHP version", e);
        return;
    }
    OrionPhpPlugin.debug("PHPVersion: " + phpVersion.toString());

    // Save script into file in the project and wait for build
    try {
        phpFile = project.getFile(FILE_NAME);
        phpFile.create(new ByteArrayInputStream(script.getBytes()), true, null);
        project.refreshLocal(IResource.DEPTH_INFINITE, null);
        project.build(IncrementalProjectBuilder.FULL_BUILD, null);
    } catch (CoreException e) {
        removeFile();
        handleException(resp, "Problem with saving script file", e);
        return;
    }

    OrionPhpPlugin.waitForIndexer();
    //      OrionPhpPlugin.waitForAutoBuild();

    // Generate the proposals array
    JSONArray result = new JSONArray();

    try {
        CompletionProposal[] proposals = getProposals(DLTKCore.createSourceModuleFrom(phpFile), offset);
        //         OrionPhpPlugin.debug("Number of proposals: " + proposals.length);
        // proposalsArray = new String[proposals.length];
        int i = 0;
        for (CompletionProposal proposal : proposals) {
            String[] parameters = null;
            if (i >= 200) {
                OrionPhpPlugin.debug("More than 200 proposals provided, ignoring");
                break;
            } else if (i < 100) {
                // Do not complete parameters for more than 100 first proposals
                parameters = proposal.findParameterNames(null);
            }

            if (parameters == null) {
                result.put(proposal.getCompletion());
            } else {
                Map<String, Object> proposalWithParameters = getProposalInfo(offset, prefix, proposal,
                        parameters);
                result.put(proposalWithParameters);
                //               OrionPhpPlugin.debug("Number of parameters: " + parameters.length);
            }

            ++i;
        }
    } catch (ModelException e) {
        removeFile();
        handleException(resp, "Could not generate completion proposals", e);
        return;
    }

    writeJSONResponse(req, resp, result);

    removeFile();
}