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.transdroid.search.BitHdtv.BitHdtvAdapter.java

private HttpClient prepareRequest(Context context) throws Exception {

    String username = SettingsHelper.getSiteUser(context, TorrentSite.BitHdtv);
    String password = SettingsHelper.getSitePass(context, TorrentSite.BitHdtv);
    if (username == null || password == null) {
        throw new InvalidParameterException(
                "No username or password was provided, while this is required for this private site.");
    }//ww  w  .j a v a  2s  .  c om

    // First log in
    HttpClient httpclient = HttpHelper.buildDefaultSearchHttpClient(false);
    HttpPost loginPost = new HttpPost(LOGINURL);
    loginPost.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair(LOGIN_USER, username),
            new BasicNameValuePair(LOGIN_PASS, password))));
    HttpResponse loginResult = httpclient.execute(loginPost);
    if (loginResult.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
        // Failed to sign in
        throw new LoginException("Login failure for BitHdTv with user " + username);
    }
    String loginHtml = HttpHelper.convertStreamToString(loginResult.getEntity().getContent());
    final String LOGIN_ERROR = "Login failed!";
    if (loginHtml == null || loginHtml.contains(LOGIN_ERROR)) {
        // Failed to sign in
        throw new LoginException("Login failure for BitHdTv with user " + username);
    }

    return httpclient;

}

From source file:org.transdroid.search.IpTorrents.IpTorrentsAdapter.java

private DefaultHttpClient prepareRequest(Context context) throws Exception {

    String username = null;//SettingsHelper.getSiteUser(context, TorrentSite.IpTorrents);
    String password = null;//SettingsHelper.getSitePass(context, TorrentSite.IpTorrents);
    if (username == null || password == null) {
        throw new InvalidParameterException(
                "No username or password was provided, while this is required for this private site.");
    }//w  w  w . j  a va2 s.  c  o m

    // Setup request using GET
    HttpParams httpparams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpparams, CONNECTION_TIMEOUT);
    HttpConnectionParams.setSoTimeout(httpparams, CONNECTION_TIMEOUT);
    DefaultHttpClient httpclient = new DefaultHttpClient(httpparams);

    // First log in
    HttpPost loginPost = new HttpPost(LOGINURL);
    loginPost.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair[] {
            new BasicNameValuePair(LOGIN_USER, username), new BasicNameValuePair(LOGIN_PASS, password) })));
    HttpResponse loginResult = httpclient.execute(loginPost);
    if (loginResult.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
        // Failed to sign in
        throw new LoginException("Login failure for IPTorrents with user " + username);
    }

    return httpclient;

}

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

/**
 * Set the "permlink" of this instance.//from  w w w.  j a v a2  s.co  m
 * 
 * @param link
 *            The "permlink" in its String representation. The link can
 *            either be empty or needs to have a length between 0 and 256
 *            characters. If provided, only "a-z", "0-9" and "-" are allowed
 *            characters.
 * @throws InvalidParameterException
 *             If the link does not fulfill the requirements describes
 *             above.
 */
public void setLink(String link) {
    if (link == null) {
        this.link = "";
    } else {
        if (!link.isEmpty()) {
            if (link.length() < 0 || link.length() > 256) {
                throw new InvalidParameterException(
                        "A permlink needs to have a minimum length of 0 and a maximum length of 256.");
            } else if (!link.matches("^[a-z0-9\\-]{0,256}")) {
                throw new InvalidParameterException(
                        "The provided permlink contains invalid characters. Only 'a-z', '0-9' and '-' are allowed. "
                                + "If copied from steemit.com, the permlink is only the part of the URL after the last '/'.");
            }
        }

        this.link = link;
    }
}

From source file:org.transdroid.core.gui.navigation.SetLabelDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (onLabelPickedListener == null)
        throw new InvalidParameterException(
                "Please first set the callback listener using setOnLabelPickedListener before opening the dialog.");
    if (currentLabels == null)
        throw new InvalidParameterException(
                "Please first set the list of currently known labels before opening the dialog, even if the list is empty.");
    final View setlabelFrame = getActivity().getLayoutInflater().inflate(R.layout.dialog_setlabel, null, false);
    final ListView labelsList = (ListView) setlabelFrame.findViewById(R.id.labels_list);
    final EditText newlabelEdit = (EditText) setlabelFrame.findViewById(R.id.newlabel_edit);
    if (currentLabels.size() == 0) {
        // Hide the list (and its label) if there are no labels yet
        setlabelFrame.findViewById(R.id.pick_label).setVisibility(View.GONE);
        setlabelFrame.findViewById(R.id.line1).setVisibility(View.GONE);
        setlabelFrame.findViewById(R.id.line2).setVisibility(View.GONE);
        labelsList.setVisibility(View.GONE);
    } else {/*from www.  j ava2 s . c  om*/
        labelsList.setAdapter(new FilterListItemAdapter(getActivity(), currentLabels));
        labelsList.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                onLabelPickedListener.onLabelPicked(((Label) labelsList.getItemAtPosition(position)).getName());
                dismiss();
            }
        });
    }
    return new AlertDialog.Builder(getActivity()).setView(setlabelFrame)
            .setPositiveButton(R.string.status_update, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // User should have provided a new label
                    if (newlabelEdit.getText().toString().equals("")) {
                        Crouton.showText(getActivity(), R.string.error_notalabel,
                                NavigationHelper.CROUTON_ERROR_STYLE);
                    }
                    onLabelPickedListener.onLabelPicked(newlabelEdit.getText().toString());
                }
            }).setNeutralButton(R.string.status_label_remove, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    onLabelPickedListener.onLabelPicked(null);
                }
            }).setNegativeButton(android.R.string.cancel, null).show();
}

From source file:org.transdroid.search.BroadcasTheNet.BroadcasTheNetAdapter.java

private DefaultHttpClient prepareRequest(Context context) throws Exception {

    String username = SettingsHelper.getSiteUser(context, TorrentSite.BroadcasTheNet);
    String password = SettingsHelper.getSitePass(context, TorrentSite.BroadcasTheNet);
    if (username == null || password == null) {
        throw new InvalidParameterException(
                "No username or password was provided, while this is required for this private site.");
    }/*  www .j a v  a  2  s  .  co  m*/

    // Setup request using GET
    HttpParams httpparams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpparams, CONNECTION_TIMEOUT);
    HttpConnectionParams.setSoTimeout(httpparams, CONNECTION_TIMEOUT);
    DefaultHttpClient httpclient = new DefaultHttpClient(httpparams);

    // First log in
    HttpPost loginPost = new HttpPost(LOGINURL);
    loginPost.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair[] {
            new BasicNameValuePair(LOGIN_USER, username), new BasicNameValuePair(LOGIN_PASS, password) })));
    HttpResponse loginResult = httpclient.execute(loginPost);
    if (loginResult.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
        // Failed to sign in
        throw new LoginException("Login failure for BroadcasTheNet with user " + username);
    }

    return httpclient;

}

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

/**
 * Define the beneficiary for this comment.
 * // w  ww. ja  va  2  s.  co  m
 * @param account
 *            The beneficiary account.
 * @throws InvalidParameterException
 *             If the <code>account</code> is null.
 */
public void setAccount(AccountName account) {
    if (account == null) {
        throw new InvalidParameterException("The account cannot be null.");
    }

    this.account = account;
}

From source file:org.sejda.model.pdf.label.PdfPageLabel.java

/**
 * Creates a label with given label and given style for the given logical page number.
 * /*from w  w w.  j  av  a  2 s . c o m*/
 * @param label
 * @param numberingStyle
 * @param logicalPageNumber
 * @return the newly created instance
 * @throws InvalidParameterException
 *             if the input logical page number is not positive. if the input label or numbering style are null.
 */
public static PdfPageLabel newInstanceWithLabel(String label, PdfLabelNumberingStyle numberingStyle,
        int logicalPageNumber) {
    if (logicalPageNumber < 1) {
        throw new InvalidParameterException("Input page number must be positive.");
    }
    if (label == null) {
        throw new InvalidParameterException("Input label cannot be null.");
    }
    if (numberingStyle == null) {
        throw new InvalidParameterException("Input numbering style cannot be null.");
    }
    return new PdfPageLabel(label, numberingStyle, logicalPageNumber);
}

From source file:ua.at.tsvetkov.data_processor.ProcessingCentre.java

/**
 * @param request// ww  w.j  ava 2 s  .c  om
 * @param clazz
 */
public ProcessingCentre(Request request, Class<T> clazz) {
    if (request == null || clazz == null) {
        throw new InvalidParameterException(INVALID_PARAMETER);
    }
    this.request = request;
    this.clazz = clazz;
    this.callback = null;

    if (Looper.myLooper() != null)
        handler = new Handler();
    else
        handler = null;
    thread = Thread.currentThread();
}

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

public void setColumnCount(int columnCount) {
    if (columnCount < 0)
        throw new InvalidParameterException("Invalid columnCount " + columnCount);

    m_columnCount = columnCount;/*from w w  w .  ja  v  a2s.c  o m*/
}