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.revolutiontt.RevolutionTTAdapter.java

private HttpClient prepareRequest(Context context) throws Exception {

    String username = SettingsHelper.getSiteUser(context, TorrentSite.RevolutionTT);
    String password = SettingsHelper.getSitePass(context, TorrentSite.RevolutionTT);
    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  v  a 2s.c  om*/

    // Setup http client
    HttpClient httpclient = HttpHelper.buildDefaultSearchHttpClient(false);

    httpclient.execute(new HttpGet("https://revolutiontt.me/login.php"));

    // First log in
    HttpPost loginPost = new HttpPost(LOGINURL);
    loginPost.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair[] {
            new BasicNameValuePair("username", username), new BasicNameValuePair("password", password) })));
    HttpResponse loginResult = httpclient.execute(loginPost);
    String loginHtml = HttpHelper.convertStreamToString(loginResult.getEntity().getContent());
    final String LOGIN_ERROR = "Login failed!";
    if (loginResult.getStatusLine().getStatusCode() != HttpStatus.SC_OK
            || loginHtml.indexOf(LOGIN_ERROR) >= 0) {
        // Failed to sign in
        throw new LoginException("Login failure for RevolutionTT with user " + username);
    }

    return httpclient;

}

From source file:org.onexus.resource.manager.internal.providers.ZipProjectProvider.java

@Override
protected void importProject() {

    try {//w ww .j  av  a2  s  .  co  m

        byte[] buffer = new byte[1024];
        URL url = new URL(getProjectUrl());
        ZipInputStream zis = new ZipInputStream(url.openStream());
        ZipEntry ze = zis.getNextEntry();

        File projectFolder = getProjectFolder();
        if (!projectFolder.exists()) {
            projectFolder.mkdir();
        } else {
            FileUtils.cleanDirectory(projectFolder);
        }

        while (ze != null) {

            String fileName = ze.getName();
            File newFile = new File(projectFolder, fileName);
            if (ze.isDirectory()) {
                newFile.mkdir();
            } else {
                FileOutputStream fos = new FileOutputStream(newFile);
                int len;
                while ((len = zis.read(buffer)) > 0) {
                    fos.write(buffer, 0, len);
                }
                fos.close();
            }

            ze = zis.getNextEntry();

        }
        zis.close();

    } catch (Exception e) {

        LOGGER.error("Importing project '" + getProjectUrl() + "'", e);
        throw new InvalidParameterException("Invalid Onexus URL project");
    }

    //To change body of implemented methods use File | Settings | File Templates.
}

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

/**
 * Returns only the id & object pairs that are actually in the cache.
 * @param ids//from   w w w  . j a  v a 2s. c  o  m
 * @param duration
 * @return
 */
public Map<String, Object> getBulk(Collection<String> ids, Duration duration) {
    if (duration == null || Duration.UNDEFINED == duration) {
        throw new InvalidParameterException("UNDEFINED is not an allowed value");
    }
    //        warnOfDuplication(ids, duration);

    final Map<String, Object> partial = caches.get(duration).getAllPresent(ids);
    if (partial.size() == 0) {
        return partial;
    }

    final Map<String, Object> results = new HashMap<String, Object>(partial.size());
    for (Map.Entry<String, Object> entry : partial.entrySet()) {
        final Object value = entry.getValue() instanceof PertinentNegativeNull ? null : entry.getValue();
        results.put(entry.getKey(), value);
    }
    return results;
}

From source file:org.transdroid.search.TorrentDay.TorrentDayAdapter.java

private DefaultHttpClient prepareRequest(Context context) throws Exception {

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

    // Setup http client
    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("username", username), new BasicNameValuePair("password", password) })));
    HttpResponse loginResult = httpclient.execute(loginPost);
    if (loginResult.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
        // Failed to sign in
        throw new LoginException("Login failure for TorrentDay with user " + username);
    }

    return httpclient;

}

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

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

    m_rowCount = rowCount;/* w  w w  .java 2s.c  om*/
}

From source file:org.easyxml.xml.Attribute.java

/**
 * Constructor of a new Attribute of a XmlElemwent. Notice that for
 * simplicity, there is no checking of if there is already an attribute with
 * the same name existed within the element.
 * /*from   www .  ja  va  2s.c o m*/
 * @param element
 *            - Element containing the attribute.
 * @param name
 *            - Name of the new attribute.
 * @param value
 *            - Value of the new attribute.
 */
public Attribute(Element element, String name, String value) {
    if (StringUtils.isBlank(name)) {
        throw new InvalidParameterException("Name of an attribute cannot be null or blank!");
    }
    if (value == null) {
        throw new InvalidParameterException("Value of an attribute cannot be null!");
    }
    if (!StringUtils.containsNone(name, Element.EntityReferenceKeys)) {
        throw new InvalidParameterException(String.format(
                "\"{s}\" cannot contain any of the 5 chars: \'<\', \'>\', \'&\', \'\'\', \'\"\'", name));
    }
    this.name = name;
    setValue(value);
}

From source file:org.onexus.resource.manager.internal.providers.GitProjectProvider.java

@Override
protected void importProject() {

    try {/*from   w  w w.  j av a2 s .c  om*/

        File projectFolder = getProjectFolder();

        boolean cloneDone = true;

        if (!projectFolder.exists()) {
            projectFolder.mkdir();
            cloneDone = false;
        }

        FileRepositoryBuilder builder = new FileRepositoryBuilder();
        Repository repository = builder.setWorkTree(projectFolder).readEnvironment().build();
        Git git = new Git(repository);

        if (cloneDone) {
            PullCommand pull = git.pull();
            pull.call();

        } else {
            CloneCommand clone = git.cloneRepository();
            clone.setBare(false);
            clone.setCloneAllBranches(true);
            clone.setDirectory(projectFolder).setURI(getProjectUrl().toString());
            clone.call();

            //TODO Checkout branch
        }

    } catch (Exception e) {
        LOGGER.error("Importing project '" + getProjectUrl() + "'", e);
        throw new InvalidParameterException("Error importing project. " + e.getMessage());
    }
}

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

/**
 * Like {@link #Version(byte, byte, short)}, but this constructor allows to
 * provide the version in its String representation (e.g. 0.19.2).
 * //from www  . j  av  a 2 s .  c  om
 * @param versionAsString
 *            The version to set.
 */
@JsonCreator
public Version(String versionAsString) {
    if (!versionAsString.contains(".") && !versionAsString.contains("_")) {
        throw new InvalidParameterException(
                "The given version does not contain the expected delemitter '.' or '_'.");
    }

    String[] versionParts;

    if (versionAsString.contains(".")) {
        versionParts = versionAsString.split("\\.");
    } else {
        versionParts = versionAsString.split("_");
    }

    if (versionParts.length != 3) {
        throw new InvalidParameterException(
                "The String representation of a version does not contain all 3 required parts (major, hardfork and release number).");
    }

    int major = Integer.parseInt(versionParts[0]);
    int hardfork = Integer.parseInt(versionParts[1]);
    int revision = Integer.parseInt(versionParts[2]);

    if (major > 0xFF) {
        throw new InvalidParameterException("The Major version is out of range.");
    } else if (hardfork > 0xFF) {
        throw new InvalidParameterException("The Hardfork version is out of range.");
    } else if (revision > 0xFFFF) {
        throw new InvalidParameterException("The Revision version is out of range.");
    }

    this.versionNumber = 0 | (major << 24) | (hardfork << 16) | revision;
}

From source file:eu.eidas.node.connector.ColleagueResponseServlet.java

private boolean validateParameterAndIsNormalSAMLResponse(String sAMLResponse) {
    // Validating the only HTTP parameter: sAMLResponse.

    LOG.trace("Validating Parameter SAMLResponse");

    if (!NormalParameterValidator.paramName(EidasParameterKeys.SAML_RESPONSE).paramValue(sAMLResponse)
            .isValid()) {/*w  w w  .  j a  va2 s. c om*/
        LOG.info("ERROR : SAMLResponse parameter is invalid or missing");
        throw new InvalidParameterException("SAMLResponse parameter is invalid or missing");
    }
    return true;
}

From source file:org.transdroid.search.AsiaTorrents.AsiaTorrentsAdapter.java

private DefaultHttpClient prepareRequest(Context context) throws Exception {

    String username = SettingsHelper.getSiteUser(context, TorrentSite.AsiaTorrents);
    String password = SettingsHelper.getSitePass(context, TorrentSite.AsiaTorrents);
    if (username == null || password == null) {
        throw new InvalidParameterException(
                "No username or password was provided, while this is required for this private site.");
    }/* w  ww  .  j av  a  2s  . 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 AsiaTorrents with user " + username);
    }

    return httpclient;

}