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.francetelecom.admindm.changedustate.callviaacs.CallChangeDUStateUninstallCapabilityOnEdgeAcs.java

/**
 * @param args/* w  w  w.  j  a v  a  2s . c  om*/
 */
public static void main(final String[] args) {
    HttpClient client = new HttpClient();
    // client.getHostConfiguration().setProxy("", );

    String host = null;
    String port = null;
    String address = "http://" + host + ":" + port + "/edge/api/";

    String acsUsername = null;
    String acsPassword = null;

    if (host == null || port == null || acsUsername == null || acsPassword == null) {
        throw new InvalidParameterException("Fill host: " + host + ", port: " + port + ", acsUsername: "
                + acsUsername + ", and acsPassword: " + acsPassword + ".");
    }

    String realm = "NBBS_API_Realm";

    AuthScope authscope = new AuthScope(host, Integer.parseInt(port), realm);

    // client.getState().setCredentials(realm, host,
    // new UsernamePasswordCredentials(acsUsername, acsPassword));

    client.getState().setCredentials(authscope, new UsernamePasswordCredentials(acsUsername, acsPassword));

    PostMethod post = null;

    // -----
    // ----- Execution de la capability : changeDUStateUninstall
    // -----

    post = new PostMethod(address + "capability/execute");

    post.addParameter(new NameValuePair("deviceId", "10003"));
    post.addParameter(new NameValuePair("timeoutMs", "60000"));
    post.addParameter(new NameValuePair("capability", "\"changeDUStateUninstall\""));

    // UUID: string
    // Version: string
    // ExecutionEnvRef: String

    JSONObject object = new JSONObject();
    object.put("UUID", "45");
    object.put("Version", "2.2.0");
    object.put("ExecutionEnvRef", "ExecutionEnvRef_value");
    post.addParameter(new NameValuePair("input", object.toString()));

    post.setDoAuthentication(true);

    // post.addParameter(new NameValuePair("deviceId", "60001"));

    // -----
    // ----- Partie commune : Execution du post
    // -----

    try {
        int status = client.executeMethod(post);
        System.out.println("status: " + status);
        String resp = post.getResponseBodyAsString();
        System.out.println("resp: " + resp);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        // release any connection resources used by the method
        post.releaseConnection();
    }
}

From source file:com.francetelecom.admindm.changedustate.callviaacs.CallChangeDUStateUpdateCapabilityOnEdgeAcs.java

/**
 * @param args//from  w w w .  ja va  2 s .c o  m
 */
public static void main(final String[] args) {
    HttpClient client = new HttpClient();
    // client.getHostConfiguration().setProxy("", );

    String host = null;
    String port = null;
    String address = "http://" + host + ":" + port + "/edge/api/";

    String acsUsername = null;
    String acsPassword = null;

    if (host == null || port == null || acsUsername == null || acsPassword == null) {
        throw new InvalidParameterException("Fill host: " + host + ", port: " + port + ", acsUsername: "
                + acsUsername + ", and acsPassword: " + acsPassword + ".");
    }

    String realm = "NBBS_API_Realm";

    AuthScope authscope = new AuthScope(host, Integer.parseInt(port), realm);

    // client.getState().setCredentials(realm, host,
    // new UsernamePasswordCredentials(acsUsername, acsPassword));

    client.getState().setCredentials(authscope, new UsernamePasswordCredentials(acsUsername, acsPassword));

    PostMethod post = null;

    // -----
    // ----- Execution de la capability : changeDUStateUpdate
    // -----

    post = new PostMethod(address + "capability/execute");

    post.addParameter(new NameValuePair("deviceId", "10003"));
    post.addParameter(new NameValuePair("timeoutMs", "60000"));
    post.addParameter(new NameValuePair("capability", "\"changeDUStateUpdate\""));

    // UUID: string
    // Version: string
    // URL: string
    // Username: string
    // Password: string

    JSONObject object = new JSONObject();
    object.put("UUID", "45");
    object.put("Version", "1.0.0");
    object.put("URL", "http://127.0.0.1:8085/a/org.apache.felix.http.jetty-2.2.0.jar");
    object.put("Username", "Username_value");
    object.put("Password", "Password_value");
    post.addParameter(new NameValuePair("input", object.toString()));

    post.setDoAuthentication(true);

    // post.addParameter(new NameValuePair("deviceId", "60001"));

    // -----
    // ----- Partie commune : Execution du post
    // -----

    try {
        int status = client.executeMethod(post);
        System.out.println("status: " + status);
        String resp = post.getResponseBodyAsString();
        System.out.println("resp: " + resp);
    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        // release any connection resources used by the method
        post.releaseConnection();
    }
}

From source file:com.francetelecom.admindm.changedustate.callviaacs.CallChangeDUStateInstallCapabilityOnEdgeAcs.java

/**
 * @param args// ww w .  j a  va  2s.  com
 */
public static void main(final String[] args) {
    HttpClient client = new HttpClient();
    // client.getHostConfiguration().setProxy("", );

    String host = null;
    String port = null;
    String address = "http://" + host + ":" + port + "/edge/api/";

    String acsUsername = null;
    String acsPassword = null;

    if (host == null || port == null || acsUsername == null || acsPassword == null) {
        throw new InvalidParameterException("Fill host: " + host + ", port: " + port + ", acsUsername: "
                + acsUsername + ", and acsPassword: " + acsPassword + ".");
    }

    String realm = "NBBS_API_Realm";

    AuthScope authscope = new AuthScope(host, Integer.parseInt(port), realm);

    // client.getState().setCredentials(realm, host,
    // new UsernamePasswordCredentials(acsUsername, acsPassword));

    client.getState().setCredentials(authscope, new UsernamePasswordCredentials(acsUsername, acsPassword));

    PostMethod post = null;

    // -----
    // ----- Execution de la capability : changeDUStateInstall
    // -----

    post = new PostMethod(address + "capability/execute");

    post.addParameter(new NameValuePair("deviceId", "10003"));
    post.addParameter(new NameValuePair("timeoutMs", "60000"));
    post.addParameter(new NameValuePair("capability", "\"changeDUStateInstall\""));

    // URL: string
    // UUID: string
    // Username: string
    // Password: string
    // ExecutionEnvRef: string

    JSONObject object = new JSONObject();
    object.put("URL", "http://127.0.0.1:8085/a/org.apache.felix.http.jetty-1.0.0.jar");
    // object.put("UUID", "UUID_value");
    object.put("Username", "Username_value");
    object.put("Password", "Password_value");
    object.put("ExecutionEnvRef", "ExecutionEnvRef_value");
    post.addParameter(new NameValuePair("input", object.toString()));

    post.setDoAuthentication(true);

    // post.addParameter(new NameValuePair("deviceId", "60001"));

    // -----
    // ----- Partie commune : Execution du post
    // -----

    try {
        int status = client.executeMethod(post);
        System.out.println("status: " + status);
        String resp = post.getResponseBodyAsString();
        System.out.println("resp: " + resp);

        // 10 avr. 2013 10:09:23
        // org.apache.commons.httpclient.auth.AuthChallengeProcessor
        // selectAuthScheme
        // INFO: basic authentication scheme selected
        // status: 200
        // resp: "executed: changeDUStateInstall: {Password=Password_value,
        // Username=Username_value, ExecutionEnvRef=ExecutionEnvRef_value,
        // URL=http:\/\/archive.apache.org\/dist\/felix\/org.apache.felix.http.jetty-1.0.0.jar},
        // resp: com.netopia.nbbs.tr69.msg.ChangeDUStateResponse@2db81edf"

    } catch (HttpException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        // release any connection resources used by the method
        post.releaseConnection();
    }
}

From source file:Main.java

private static double averageMult(double[] mass1, double[] mass2) throws InvalidParameterException {
    if (mass1.length != mass2.length)
        throw new InvalidParameterException("mass1.length != mass2.length");
    if (0 == mass1.length)
        return 0;
    double sum = 0;

    for (int i = 0; i < mass1.length; i++)
        sum += mass1[i] * mass2[i];//from  ww  w. java2  s .  c o  m
    return sum / mass1.length;
}

From source file:Main.java

/**
 * Performs some basic check-ups on a given bitmap picture.
 *
 * @param pictureBitmap The bitmap that must be checked
 *///w ww  .jav  a  2  s. co m
public static void checkBitmap(Bitmap pictureBitmap) {

    if (pictureBitmap == null) {
        throw new NullPointerException("Picture bitmap cannot be null");
    }

    if (pictureBitmap.getWidth() == 0 || pictureBitmap.getHeight() == 0) {
        throw new InvalidParameterException("Picture must have a valid size");
    }
}

From source file:nl.utwente.mirex.TrecRun.java

/**
 * Runs the MapReduce job "trec run"//from  w  ww. ja v  a2  s. com
 * @param args 0: path to parsed document collection (use AnchorExtract); 1: (non-existing) path that will contain run results; 2: TREC query file
 * @usage. see README.html 
 */
public static void main(String[] args) throws Exception {

    if (args.length != 3 && args.length != 4) {
        System.out.printf("Usage: %s [inputFormat] inputFiles outputFile topicFile \n",
                TrecRun.class.getSimpleName());
        System.out.println("          inputFormat: either WARC or KEYVAL; default WARC");
        System.out.println("          inputFiles: the WARC files");
        System.out.println("          outputFiles: output directory");
        System.out.println("          topicFile: topic descriptions (one query per line)");
        System.exit(1);
    }
    int argc = 0;
    String inputFormat = "WARC";
    if (args.length > 3) {
        inputFormat = args[argc++].toUpperCase();
    }
    String inputFiles = args[argc++];
    String outputFile = args[argc++];
    String topicFile = args[argc++];

    // Set job configuration
    Job job = new Job();
    job.setJobName("MirexTrecRun");
    job.setJarByClass(TrecRun.class);

    // Set intermediate output (override defaults)
    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(Text.class);

    // Set output (override defaults)
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Text.class);

    // Set map-reduce classes
    job.setMapperClass(Map.class);
    job.setCombinerClass(Reduce.class);
    job.setReducerClass(Reduce.class);

    // Set input-output format
    if (inputFormat.equals("KEYVAL")) {
        job.setInputFormatClass(KeyValueTextInputFormat.class);
    } else if (inputFormat.equals("WARC")) {
        job.setInputFormatClass(WarcTextConverterInputFormat.class);
    } else {
        throw new InvalidParameterException("inputFormat must be either WARC or KEYVAL");
    }
    job.setOutputFormatClass(TextOutputFormat.class);

    // Set input-output paths
    FileInputFormat.setInputPaths(job, new Path(inputFiles));
    FileOutputFormat.setOutputPath(job, new Path(outputFile));

    // Set job specific distributed cache file (query file)
    DistributedCache.addCacheFile(new Path(topicFile).toUri(), job.getConfiguration());

    // Run the job
    job.waitForCompletion(true);
}

From source file:com.decay.logger.Logger.java

public static BasicLog tag(@NonNull String tag) {
    if (isEmpty(tag)) {
        throw new InvalidParameterException("Tag should not be null or empty");
    }/*from   w w  w. j  ava 2s .  com*/

    BasicLog log = logs.get(tag);
    if (log == null) {
        log = new BasicLog(tag);
        logs.put(tag, log);
    }
    return log;
}

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

public static Boolean setCacheDisabled(final Cach3State state, final boolean disabled) {
    if (state == null) {
        throw new InvalidParameterException("Cach3State must be defined.");
    }/*from  w  ww . j a va2  s.c o m*/
    state.setCacheDisabled(disabled);
    return disabled;
}

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

public static Integer setJitterDefault(final Cach3State state, final int jitterDefault) {
    if (state == null) {
        throw new InvalidParameterException("Cach3State must be defined.");
    }//from   w w w.  ja  va 2s.c om
    state.setJitterDefault(jitterDefault);
    return jitterDefault;
}

From source file:org.texai.util.FileSystemUtils.java

/** Deletes the supplied {@link File} - for directories,
 * recursively delete any nested directories or files as well.
 *
 * @param root the root <code>File</code> to delete
 * @return <code>true</code> if the <code>File</code> was deleted,
 * otherwise <code>false</code>
 */// ww w. ja v a  2 s .  c o  m
public static boolean deleteRecursively(final File root) {
    //Preconditions
    if (root == null) {
        throw new InvalidParameterException("root must not be null");
    }

    if (root.exists()) {
        if (root.isDirectory()) {
            final File[] children = root.listFiles();
            if (children != null) {
                for (final File child : children) {
                    deleteRecursively(child);
                }
            }
        }
        return root.delete();
    }
    return false;
}