List of usage examples for java.security InvalidParameterException InvalidParameterException
public InvalidParameterException(String msg)
From source file:org.sakuli.datamodel.helper.TestSuiteHelper.java
/** * Replace an string like:// ww w. java 2 s . co m * <ul> * <li>replaceEmptyLines("bla\n\nbla", "123") = "bla\n123\nbla"</li> * <li>replaceEmptyLines("bla\r\n\r\nbla", "123") = "bla\r\n123\r\nbla"</li> * </ul> * * @param source source String * @param replaceString replace String without double new line * @return modify String without empty lines */ protected static String replaceEmptyLines(String source, String replaceString) { if (source != null) { for (String newlineChars : Arrays.asList("\n", "\r\n")) { String doubleNewLine = newlineChars + newlineChars; if (replaceString.contains(doubleNewLine) || StringUtils.isEmpty(replaceString)) { throw new InvalidParameterException( "The assigned replace pattern contains the not allowed chars '" + doubleNewLine + "'!"); } while (source.contains(doubleNewLine)) { source = source.replace(doubleNewLine, newlineChars + replaceString + newlineChars); } } } return source; }
From source file:net.nelz.simplesm.aop.CacheBase.java
protected Object validateReturnValueAsKeyObject(final Object returnValue, final Method methodToCache) throws Exception { if (returnValue == null) { throw new InvalidParameterException(String.format( "The result of the method [%s] is null, which will not give an appropriate cache key.", methodToCache.toString())); }/*from w w w .j av a 2 s. c o m*/ return returnValue; }
From source file:backtype.storm.security.auth.ThriftClient.java
public void getMaster(Map conf, String host, Integer port) { if (StringUtils.isBlank(host) == false) { this.host = host; if (port == null) { port = type.getPort(conf);/*from ww w. j a v a 2 s . c o m*/ } this.port = port; this.hostPort = host + ":" + port; } else { try { hostPort = ThriftClient.getMasterByZk(conf); } catch (Exception e) { // TODO Auto-generated catch block throw new RuntimeException("Failed to get master from ZK.", e); } String[] host_port = hostPort.split(":"); if (host_port.length != 2) { throw new InvalidParameterException("Host format error: " + hostPort); } this.host = host_port[0]; this.port = Integer.parseInt(host_port[1]); } // create a socket with server if (this.host == null) { throw new IllegalArgumentException("host is not set"); } if (this.port == null || this.port <= 0) { throw new IllegalArgumentException("invalid port: " + port); } }
From source file:org.transdroid.search.ScambioEtico.ScambioEtico.java
private DefaultHttpClient prepareRequest(Context context) throws Exception { String username = SettingsHelper.getSiteUser(context, TorrentSite.ScambioEtico); String password = SettingsHelper.getSitePass(context, TorrentSite.ScambioEtico); if (username == null || password == null) { throw new InvalidParameterException( "No username or password was provided, while " + "this is required for Scambio Etico."); }/*from w w w .j ava2s .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 Log.d("ScambioEtico", "Starting Authentication"); 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); String loginHtml = HttpHelper.convertStreamToString(loginResult.getEntity().getContent()); if (loginHtml.indexOf(WRONG_LOGIN) >= 0) { throw new LoginException("Login failure for Scambio Etico wrong username " + username); } else if (loginHtml.indexOf(WRONG_PASSWORD) >= 0) { throw new LoginException("Login failure for Scambio Etico: bad password for user " + username); } Log.d("ScambioEtico", "Authentication successful"); return httpclient; }
From source file:de.uzk.hki.da.format.ConverterService.java
/** * Executes a conversion routine. Therefore creates an instance of the java class mentioned in the ConversionInstruction ci. * Checks whether the resulting file exists and is not a null byte file. * @throws IOException /*from w w w.j a va2 s . co m*/ * * @throws RuntimeException if resulting file doesn't exit or is null byte file. */ private List<Event> executeConversionInstruction(ConversionInstruction ci, Object object) throws IOException { if (ci.getConversion_routine() == null) throw new InvalidParameterException("ConversionRoutine not set in ConversionInstruction"); final ConversionStrategy strategy; try { strategy = getStrategy(ci.getConversion_routine().getType()); } catch (Exception e) { throw new RuntimeException( "Critical Error: Could not create strategy of type: " + ci.getConversion_routine().getType() + ". Please inform the DA-Admin to view the settings for the conversionRoutine " + ci.getConversion_routine().getName(), e); } logger.info("Preparing conversion of: " + ci.getSource_file() + "\"->\"" + ci.getTarget_folder() + "\" " + "(CI with id \"" + ci.getId() + "\" will be executed with " + ci.getConversion_routine().getName() + " which is of type " + strategy.getClass().toString() + ")."); ci.getSource_file().setPackage(object.getLatestPackage()); strategy.setCLIConnector(new SimplifiedCommandLineConnector()); strategy.setObject(object); strategy.setParam(ci.getConversion_routine().getParams()); List<Event> results; // TODO remove try catch. evaluate in convertbatch and not in convertfile try { results = strategy.convertFile(ci); } catch (FileNotFoundException e) { throw new RuntimeException("Resulting file of conversion strategy does not exist", e); } return results; }
From source file:org.flite.cach3.aop.ReadThroughAssignCacheAdvice.java
static AnnotationInfo getAnnotationInfo(final ReadThroughAssignCache annotation, final String targetMethodName, final int jitterDefault) { final AnnotationInfo result = new AnnotationInfo(); if (annotation == null) { throw new InvalidParameterException( String.format("No annotation of type [%s] found.", ReadThroughAssignCache.class.getName())); }// w w w.j ava 2s .com final String namespace = annotation.namespace(); if (AnnotationConstants.DEFAULT_STRING.equals(namespace) || namespace == null || namespace.length() < 1) { throw new InvalidParameterException( String.format("Namespace for annotation [%s] must be defined on [%s]", ReadThroughAssignCache.class.getName(), targetMethodName)); } result.add(new AType.Namespace(namespace)); final String assignKey = annotation.assignedKey(); if (AnnotationConstants.DEFAULT_STRING.equals(assignKey) || assignKey == null || assignKey.length() < 1) { throw new InvalidParameterException( String.format("AssignedKey for annotation [%s] must be defined on [%s]", ReadThroughAssignCache.class.getName(), targetMethodName)); } result.add(new AType.AssignKey(assignKey)); final int expiration = annotation.expiration(); if (expiration < 0) { throw new InvalidParameterException( String.format("Expiration for annotation [%s] must be 0 or greater on [%s]", ReadThroughAssignCache.class.getName(), targetMethodName)); } result.add(new AType.Expiration(expiration)); final int jitter = annotation.jitter(); if (jitter < -1 || jitter > 99) { throw new InvalidParameterException( String.format("Jitter for annotation [%s] must be -1 <= jitter <= 99 on [%s]", ReadThroughAssignCache.class.getName(), targetMethodName)); } result.add(new AType.Jitter(jitter == -1 ? jitterDefault : jitter)); return result; }
From source file:org.cesecore.authorization.user.AccessUserAspectData.java
@Override public void setMatchWith(Integer matchWith) { if (matchWith == null) { throw new InvalidParameterException("Invalid to set matchWith == null"); }/* w w w . ja v a 2 s.c o m*/ this.matchWith = matchWith; }
From source file:eu.bittrade.libs.steemj.base.models.BeneficiaryRouteType.java
@Override public void validate(ValidationType validationType) { if (!validationType.equals(ValidationType.SKIP_VALIDATION) && this.getWeight() > 10000) { throw new InvalidParameterException("Cannot allocate more than 100% of rewards to one account."); }/*from w w w .j a v a 2 s. c o m*/ }
From source file:com.aitorvs.android.fingerlock.FingerLockApi23.java
@Override public void register(@NonNull Context context, @NonNull final String keyName, @NonNull FingerLockResultCallback callback) { // double check //noinspection ConstantConditions if (context == null || callback == null || keyName == null) { throw new InvalidParameterException("Invalid or null input parameters"); } else if (mCallback != null) { // already registered, force clean unregister forceUnregister();/*from www . j ava 2 s . co m*/ } if (BuildConfig.DEBUG) Log.d(TAG, "Registering " + keyName); mContext = context; mCallback = callback; mKey = new Key(keyName); mFingerprintManager = getFingerprintManager(); if (!isFingerprintAuthSupported()) { callback.onFingerLockError(FingerLock.FINGERPRINT_NOT_SUPPORTED, new Exception("Fingerprint authentication not supported in this device")); } else if (!isFingerprintRegistered()) { callback.onFingerLockError(FingerLock.FINGERPRINT_REGISTRATION_NEEDED, new Exception("No fingerprints registered in this device")); } else { // all systems Go! callback.onFingerLockReady(); } }
From source file:org.flite.cach3.aop.L2InvalidateSingleCacheAdvice.java
static AnnotationInfo getAnnotationInfo(final L2InvalidateSingleCache annotation, final String targetMethodName) { final AnnotationInfo result = new AnnotationInfo(); if (annotation == null) { throw new InvalidParameterException( String.format("No annotation of type [%s] found.", L2InvalidateSingleCache.class.getName())); }// w w w. j av a2 s .com final String namespace = annotation.namespace(); if (AnnotationConstants.DEFAULT_STRING.equals(namespace) || namespace == null || namespace.length() < 1) { throw new InvalidParameterException( String.format("Namespace for annotation [%s] must be defined on [%s]", L2InvalidateSingleCache.class.getName(), targetMethodName)); } result.add(new AType.Namespace(namespace)); final String keyPrefix = annotation.keyPrefix(); if (!AnnotationConstants.DEFAULT_STRING.equals(keyPrefix)) { if (StringUtils.isBlank(keyPrefix)) { throw new InvalidParameterException(String.format( "KeyPrefix for annotation [%s] must not be defined as an empty string on [%s]", L2InvalidateSingleCache.class.getName(), targetMethodName)); } result.add(new AType.KeyPrefix(keyPrefix)); } final Integer keyIndex = annotation.keyIndex(); if (keyIndex != AnnotationConstants.DEFAULT_KEY_INDEX && keyIndex < -1) { throw new InvalidParameterException( String.format("KeyIndex for annotation [%s] must be -1 or greater on [%s]", L2InvalidateSingleCache.class.getName(), targetMethodName)); } final boolean keyIndexDefined = keyIndex >= -1; final String keyTemplate = annotation.keyTemplate(); if (StringUtils.isBlank(keyTemplate)) { throw new InvalidParameterException( String.format("KeyTemplate for annotation [%s] must not be defined as an empty string on [%s]", L2InvalidateSingleCache.class.getName(), targetMethodName)); } final boolean keyTemplateDefined = !AnnotationConstants.DEFAULT_STRING.equals(keyTemplate); if (keyIndexDefined == keyTemplateDefined) { throw new InvalidParameterException(String.format( "Exactly one of [keyIndex,keyTemplate] must be defined for annotation [%s] on [%s]", L2InvalidateSingleCache.class.getName(), targetMethodName)); } if (keyIndexDefined) { result.add(new AType.KeyIndex(keyIndex)); } if (keyTemplateDefined) { result.add(new AType.KeyTemplate(keyTemplate)); } return result; }