List of usage examples for java.security InvalidParameterException InvalidParameterException
public InvalidParameterException(String msg)
From source file:org.springmodules.validation.util.condition.range.NumberAwareComparableComparator.java
/** * Compares the two given objects. Expects both of them to be * {@link Comparable} instances.//from w w w. j a v a 2 s. c o m * * @see ComparableComparator#compare(Object, Object) */ public int compare(Object o1, Object o2) { if (Number.class.isInstance(o1) && Number.class.isInstance(o2)) { return compareNumbers((Number) o1, (Number) o2); } throw new InvalidParameterException("Object must be of type number"); }
From source file:org.deegree.tools.rendering.viewer.File3dImporter.java
public static List<WorldRenderableObject> open(Frame parent, String fileName) { if (fileName == null || "".equals(fileName.trim())) { throw new InvalidParameterException("the file name may not be null or empty"); }// w w w.j a va 2s.c o m fileName = fileName.trim(); CityGMLImporter openFile2; XMLInputFactory fac = XMLInputFactory.newInstance(); InputStream in = null; try { XMLStreamReader reader = fac.createXMLStreamReader(in = new FileInputStream(fileName)); reader.next(); String ns = "http://www.opengis.net/citygml/1.0"; openFile2 = new CityGMLImporter(null, null, null, reader.getNamespaceURI().equals(ns)); } catch (Throwable t) { openFile2 = new CityGMLImporter(null, null, null, false); } finally { IOUtils.closeQuietly(in); } final CityGMLImporter openFile = openFile2; final JDialog dialog = new JDialog(parent, "Loading", true); dialog.getContentPane().setLayout(new BorderLayout()); dialog.getContentPane().add( new JLabel("<HTML>Loading file:<br>" + fileName + "<br>Please wait!</HTML>", SwingConstants.CENTER), BorderLayout.NORTH); final JProgressBar progressBar = new JProgressBar(); progressBar.setStringPainted(true); progressBar.setIndeterminate(false); dialog.getContentPane().add(progressBar, BorderLayout.CENTER); dialog.pack(); dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); dialog.setResizable(false); dialog.setLocationRelativeTo(parent); final Thread openThread = new Thread() { /** * Opens the file in a separate thread. */ @Override public void run() { // openFile.openFile( progressBar ); if (dialog.isDisplayable()) { dialog.setVisible(false); dialog.dispose(); } } }; openThread.start(); dialog.setVisible(true); List<WorldRenderableObject> result = null; try { result = openFile.importFromFile(fileName, 6, 2); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } gm = openFile.getQmList(); // // if ( result != null ) { // openGLEventListener.addDataObjectToScene( result ); // File f = new File( fileName ); // setTitle( WIN_TITLE + f.getName() ); // } else { // showExceptionDialog( "The file: " + fileName // + " could not be read,\nSee error log for detailed information." ); // } return result; }
From source file:com.jhash.oimadmin.Utils.java
public static DiagnosticCollector<JavaFileObject> compileJava(String className, String code, String outputFileLocation) { logger.trace("Entering compileJava({},{},{})", new Object[] { className, code, outputFileLocation }); File outputFileDirectory = new File(outputFileLocation); logger.trace("Validating if the output location {} exists and is a directory", outputFileLocation); if (outputFileDirectory.exists()) { if (outputFileDirectory.isDirectory()) { try { logger.trace("Deleting the directory and its content"); FileUtils.deleteDirectory(outputFileDirectory); } catch (IOException exception) { throw new OIMAdminException( "Failed to delete directory " + outputFileLocation + " and its content", exception); }//from ww w . j ava 2 s . co m } else { throw new InvalidParameterException( "The location " + outputFileLocation + " was expected to be a directory but it is a file."); } } logger.trace("Creating destination directory for compiled class file"); outputFileDirectory.mkdirs(); JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); if (compiler == null) { throw new NullPointerException( "Failed to locate a java compiler. Please ensure that application is being run using JDK (Java Development Kit) and NOT JRE (Java Runtime Environment) "); } StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); Iterable<File> files = Arrays.asList(new File(outputFileLocation)); boolean success = false; DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>(); try { JavaFileObject javaFileObject = new InMemoryJavaFileObject(className, code); fileManager.setLocation(StandardLocation.CLASS_OUTPUT, files); JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, Arrays.asList("-source", "1.6", "-target", "1.6"), null, Arrays.asList(javaFileObject)); success = task.call(); fileManager.close(); } catch (Exception exception) { throw new OIMAdminException("Failed to compile " + className, exception); } if (!success) { logger.trace("Exiting compileJava(): Return Value {}", diagnostics); return diagnostics; } else { logger.trace("Exiting compileJava(): Return Value null"); return null; } }
From source file:eu.bittrade.libs.steemj.plugins.apis.tags.models.TagName.java
/** * @param tag/*ww w . j a va 2 s .c o m*/ * the tag to set * @throws InvalidParameterException * If the provided <code>tag</code> has more than 32 characters. */ public void setTag(String tag) { if (tag.length() <= MAX_TAG_LENGTH) { throw new InvalidParameterException( "The provided tag is too long - Only " + MAX_TAG_LENGTH + " characters are allowed."); } this.tag = tag; }
From source file:com.smash.revolance.ui.comparator.element.ElementComparator.java
@Override public Collection<ElementDifferency> compare(ElementBean reference, ElementBean element) throws InvalidParameterException { List<ElementDifferency> differencies = new ArrayList<ElementDifferency>(); if (reference == null) { throw new InvalidParameterException("Null reference element passed in."); }/* w w w . j a v a 2 s. c o m*/ if (!valueEquals(reference, element)) { differencies.add(ElementDifferency.VALUE); } if (!lookEquals(reference, element)) { differencies.add(ElementDifferency.LOOK); } if (!posEquals(reference, element)) { differencies.add(ElementDifferency.POS); } if (!targetEquals(reference, element)) { differencies.add(ElementDifferency.TARGET); } if (!implEquals(reference, element)) { differencies.add(ElementDifferency.IMPL); } return differencies; }
From source file:com.mobdb.android.MobDB.java
/** * Send request for file byte array/*from w w w.j av a 2s . c o m*/ * @param appKey Application key * @param sql_query SQL string array * @param bargraph Analytics tag name * @param listener MobDBResponseListener class object * @throws InvalidParameterException */ public synchronized void executeFileRequest(String appKey, String[] sql_query, String bargraph, boolean secure, MobDBResponseListener listener) throws InvalidParameterException { try { JSONObject req = new JSONObject(); if (appKey == null) { throw new InvalidParameterException("Application key required"); } req.put(SDKConstants.KEY, appKey); if (bargraph != null) { req.put(SDKConstants.BAR_GRAPH, bargraph); } JSONObject sql = new JSONObject(); JSONArray quary = new JSONArray(); if (sql_query == null) { throw new InvalidParameterException("SQL query required"); } for (int i = 0; i < sql_query.length; i++) { if (!sql_query[0].startsWith("GET file=")) { throw new InvalidParameterException("Invalid file request format"); } quary.put(sql_query[i]); } sql.put(SDKConstants.QUERY, quary); req.put(SDKConstants.SQL, sql); MobDBRequest request = new MobDBRequest(secure, listener); request.setParams(req.toString()); requestQueue.add(request); executeRequest(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.xdi.oxauth.model.crypto.signature.RSAKeyFactory.java
public RSAKeyFactory(SignatureAlgorithm signatureAlgorithm, String dnName) throws InvalidParameterException, NoSuchProviderException, NoSuchAlgorithmException, SignatureException, InvalidKeyException, CertificateEncodingException { if (signatureAlgorithm == null) { throw new InvalidParameterException("The signature algorithm cannot be null"); }/*from w w w .j ava2s . c o m*/ KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA", "BC"); keyGen.initialize(2048, new SecureRandom()); KeyPair keyPair = keyGen.generateKeyPair(); JCERSAPrivateCrtKey jcersaPrivateCrtKey = (JCERSAPrivateCrtKey) keyPair.getPrivate(); JCERSAPublicKey jcersaPublicKey = (JCERSAPublicKey) keyPair.getPublic(); rsaPrivateKey = new RSAPrivateKey(jcersaPrivateCrtKey.getModulus(), jcersaPrivateCrtKey.getPrivateExponent()); rsaPublicKey = new RSAPublicKey(jcersaPublicKey.getModulus(), jcersaPublicKey.getPublicExponent()); if (StringUtils.isNotBlank(dnName)) { // Create certificate GregorianCalendar startDate = new GregorianCalendar(); // time from which certificate is valid GregorianCalendar expiryDate = new GregorianCalendar(); // time after which certificate is not valid expiryDate.add(Calendar.YEAR, 1); BigInteger serialNumber = new BigInteger(1024, new Random()); // serial number for certificate X509V1CertificateGenerator certGen = new X509V1CertificateGenerator(); X500Principal principal = new X500Principal(dnName); certGen.setSerialNumber(serialNumber); certGen.setIssuerDN(principal); certGen.setNotBefore(startDate.getTime()); certGen.setNotAfter(expiryDate.getTime()); certGen.setSubjectDN(principal); // note: same as issuer certGen.setPublicKey(keyPair.getPublic()); certGen.setSignatureAlgorithm(signatureAlgorithm.getAlgorithm()); X509Certificate x509Certificate = certGen.generate(jcersaPrivateCrtKey, "BC"); certificate = new Certificate(signatureAlgorithm, x509Certificate); } }
From source file:net.padlocksoftware.padlock.license.LicenseSigner.java
/** * Create a new LicenseSigner object. This instance can sign any number of licenses using a single * PrivateKey./*from ww w . j av a2 s . com*/ * * @param privateKey The DSA (Padlock 2.x) Private Key to sign the License objects with. * @param padlockLicense The instance of the Padlock License, purchased from Padlock Software LLC. * @return A new LicenseSigner instance. * @since 2.0.2 */ public static LicenseSigner createLicenseSigner(DSAPrivateKey privateKey) { if (privateKey == null) { throw new InvalidParameterException("privateKey cannot be null"); } return new LicenseSigner(privateKey); }
From source file:edu.upc.dama.sparksee.RemoteGraph.java
private RemoteGraph(final Configuration configuration) throws IOException { URL logback = this.getClass().getClassLoader().getResource("logback.groovy"); if (logback == null) { java.lang.System.out.println("logback.groovy NOT found"); } else {// w ww . j a v a2s . co m java.lang.System.out.println("logback.groovy found!"); } final String fileName = configuration.getString(DB_PARAMETER); final String configFile = configuration.getString(CONFIG_DIRECTORY, null); dabaseFile = fileName; dbFile = new File(fileName).getCanonicalFile(); if (!dbFile.getParentFile().exists() && !dbFile.getParentFile().mkdirs()) { throw new InvalidParameterException( String.format("Unable to create directory %s.", dbFile.getParent())); } try { if (configFile != null) { Properties prop = new Properties(); InputStream input = null; input = new FileInputStream(configFile); prop.load(input); licenseCode = prop.getProperty("sparksee.license"); if (input != null) { input.close(); } com.sparsity.sparksee.gdb.SparkseeProperties.load(configFile); } sparksee = new com.sparsity.sparksee.gdb.Sparksee(new com.sparsity.sparksee.gdb.SparkseeConfig()); if (!dbFile.exists()) { db = sparksee.create(dbFile.getPath(), dbFile.getName()); } else { db = sparksee.open(dbFile.getPath(), false); } transaction = new RemoteTransaction(db); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:com.joey.software.plottingToolkit.PlotingToolkit.java
public static XYSeriesCollection getCollection(float[] xData, float[] yData, String name) { if (xData.length != yData.length) { throw new InvalidParameterException("X and Y must be same length"); }//from w w w . j av a 2s . c o m XYSeries series = new XYSeries(name); for (int i = 0; i < xData.length; i++) { series.add(xData[i], yData[i]); } XYSeriesCollection result = new XYSeriesCollection(series); return result; }