类java.security.InvalidParameterException源码实例Demo

下面列出了怎么用java.security.InvalidParameterException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openjdk-jdk9   文件: SunProvider.java
@Override
public Object newInstance(Object ctrParamObj)
    throws NoSuchAlgorithmException {
    String type = getType();
    if (ctrParamObj != null) {
        throw new InvalidParameterException
            ("constructorParameter not used with " + type +
             " engines");
    }
    String algo = getAlgorithm();
    try {
        if (type.equals("GssApiMechanism")) {
            if (algo.equals("1.2.840.113554.1.2.2")) {
                return new Krb5MechFactory();
            } else if (algo.equals("1.3.6.1.5.5.2")) {
                return new SpNegoMechFactory();
            }
        }
    } catch (Exception ex) {
        throw new NoSuchAlgorithmException
            ("Error constructing " + type + " for " +
            algo + " using SunJGSS", ex);
    }
    throw new ProviderException("No impl for " + algo +
        " " + type);
}
 
源代码2 项目: jdk8u-jdk   文件: DSAParameterGenerator.java
/**
     * Initializes this parameter generator for a certain strength
     * and source of randomness.
     *
     * @param strength the strength (size of prime) in bits
     * @param random the source of randomness
     */
    protected void engineInit(int strength, SecureRandom random) {
        if ((strength >= 512) && (strength <= 1024) && (strength % 64 == 0)) {
            this.valueN = 160;
        } else if (strength == 2048) {
            this.valueN = 224;
//      } else if (strength == 3072) {
//          this.valueN = 256;
        } else {
            throw new InvalidParameterException
                ("Prime size should be 512 - 1024, or 2048");
        }
        this.valueL = strength;
        this.seedLen = valueN;
        this.random = random;
    }
 
源代码3 项目: RipplePower   文件: KeyPairGeneratorSpi.java
public void initialize(
    int             strength,
    SecureRandom    random)
{
    this.strength = strength;
    this.random = random;

    ECGenParameterSpec ecParams = (ECGenParameterSpec)ecParameters.get(Integers.valueOf(strength));
    if (ecParams == null)
    {
        throw new InvalidParameterException("unknown key size.");
    }

    try
    {
        initialize(ecParams, random);
    }
    catch (InvalidAlgorithmParameterException e)
    {
        throw new InvalidParameterException("key size not configurable.");
    }
}
 
源代码4 项目: keystore-explorer   文件: EccUtil.java
/**
 * Determines the name of the domain parameters that were used for generating the key.
 *
 * @param key An EC key
 * @return The name of the domain parameters that were used for the EC key,
 *         or an empty string if curve is unknown.
 */
public static String getNamedCurve(Key key) {

	if (!(key instanceof ECKey)) {
		throw new InvalidParameterException("Not a EC private key.");
	}

	ECKey ecKey = (ECKey) key;
	ECParameterSpec params = ecKey.getParams();
	if (!(params instanceof ECNamedCurveSpec)) {
		return "";
	}

	ECNamedCurveSpec ecPrivateKeySpec = (ECNamedCurveSpec) params;
	String namedCurve = ecPrivateKeySpec.getName();
	return namedCurve;
}
 
源代码5 项目: RipplePower   文件: ECCKeyGenParameterSpec.java
/**
 * Constructor.
 *
 * @param m degree of the finite field GF(2^m)
 * @param t error correction capability of the code
 * @throws InvalidParameterException if <tt>m &lt; 1</tt> or <tt>m &gt; 32</tt> or
 * <tt>t &lt; 0</tt> or <tt>t &gt; n</tt>.
 */
public ECCKeyGenParameterSpec(int m, int t)
    throws InvalidParameterException
{
    if (m < 1)
    {
        throw new InvalidParameterException("m must be positive");
    }
    if (m > 32)
    {
        throw new InvalidParameterException("m is too large");
    }
    this.m = m;
    n = 1 << m;
    if (t < 0)
    {
        throw new InvalidParameterException("t must be positive");
    }
    if (t > n)
    {
        throw new InvalidParameterException("t must be less than n = 2^m");
    }
    this.t = t;
    fieldPoly = PolynomialRingGF2.getIrreduciblePolynomial(m);
}
 
@Override
protected void build(final AnnotationData data, final Annotation annotation, final Class<? extends Annotation> expectedAnnotationClass,
        final Method targetMethod) {
    if (isReturnDataUpdateContent(targetMethod)) {
        data.setReturnDataIndex(true);
        return;
    }

    final Integer foundIndex = getIndexOfAnnotatedParam(targetMethod, ParameterDataUpdateContent.class);
    if (foundIndex == null) {
        throw new InvalidParameterException(String.format(
                "No ReturnDataUpdateContent or ParameterDataUpdateContent annotation found on method [%s]", targetMethod.getName()));
    }

    data.setDataIndex(foundIndex);
}
 
源代码7 项目: chart-fx   文件: GridPosition.java
public static HexagonMap.Direction getDirectionFromNumber(final int i) {
    switch (i) {
    case 0:
        return HexagonMap.Direction.NORTHWEST;
    case 1:
        return HexagonMap.Direction.NORTHEAST;
    case 2:
        return HexagonMap.Direction.EAST;
    case 3:
        return HexagonMap.Direction.SOUTHEAST;
    case 4:
        return HexagonMap.Direction.SOUTHWEST;
    case 5:
        return HexagonMap.Direction.WEST;
    default:
    }
    throw new InvalidParameterException("unknown direction: " + i);
}
 
源代码8 项目: lams   文件: EventNotificationService.java
/**
    * See {@link IEventNotificationService#unsubscribe(String, String, Long, Long)
    */
   protected void unsubscribe(Event event, Integer userId) throws InvalidParameterException {
if (userId == null) {
    throw new InvalidParameterException("User ID can not be null.");
}
Iterator<Subscription> subscriptionIterator = event.getSubscriptions().iterator();
while (subscriptionIterator.hasNext()) {
    Subscription subscription = subscriptionIterator.next();
    if (subscription.getUserId().equals(userId)) {
	subscriptionIterator.remove();
    }
}
if (event.getSubscriptions().isEmpty()) {
    eventDAO.delete(event);
} else {
    eventDAO.insertOrUpdate(event);
}
   }
 
源代码9 项目: UltimateAndroid   文件: PullRefreshLayout.java
public void setRefreshStyle(int type){
    setRefreshing(false);
    switch (type){
        case STYLE_CIRCLES:
            mRefreshDrawable = new CirclesDrawable(getContext(), this);
            break;
        case STYLE_WATER_DROP:
            mRefreshDrawable = new WaterDropDrawable(getContext(), this);
            break;
        case STYLE_RING:
            mRefreshDrawable = new RingDrawable(getContext(), this);
            break;
        default:
            throw new InvalidParameterException("Type does not exist");
    }
    mRefreshDrawable.setColorSchemeColors(mColorSchemeColors);
    mRefreshView.setImageDrawable(mRefreshDrawable);
}
 
源代码10 项目: subtitle   文件: SubtitleRegion.java
public void setX(float x) {
    if (x < 0.0f || x > 100.0f) {
        throw new InvalidParameterException("X value must be defined in percentage between 0 and 100");
    }

    this.x = x;
}
 
源代码11 项目: chart-fx   文件: Function1D.java
/**
 * @param xmin min. x range
 * @param xmax max x range
 * @param nsamples number of sample points
 * @return DataSet representation of the function
 */
default DataSet getDataSetEstimate(final double xmin, final double xmax, final int nsamples) {
    if (xmin > xmax || nsamples <= 0) {
        throw new InvalidParameterException("AbstractFunciton1D::getDataSetEstimate(" + xmin + "," + xmax + ","
                + nsamples + ") - " + "invalid range");
    }
    final double[] xValues = new double[nsamples];
    final double step = (xmax - xmin) / nsamples;
    for (int i = 0; i < nsamples; i++) {
        xValues[i] = xmin + i * step;
    }
    return getDataSetEstimate(xValues);
}
 
源代码12 项目: DDMQ   文件: ZkServiceImpl.java
@Override
public boolean createOrUpdateCProxy(CProxyConfig config) throws Exception {
    if (!config.validate()) {
        LOGGER.error("invalid cproxy config, config={}", config);
        throw new InvalidParameterException("invalid cproxy config");
    }
    setZkData(getProxyPath(CARRERA_CPROXY, config.getInstance()), config);
    return true;
}
 
public KafkaClientPropertiesBuilder withSaslJassConfig(String clientId, String clientSecretName, String oauthTokenEndpointUri) {
    if (clientId.isEmpty() || clientSecretName.isEmpty() || oauthTokenEndpointUri.isEmpty()) {
        throw new InvalidParameterException("You do not specify client-id, client-secret name or oauth-token-endpoint-uri inside kafka client!");
    }

    this.properties.setProperty(SaslConfigs.SASL_JAAS_CONFIG,
        "org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule " +
            "required " +
            "oauth.client.id=\"" + clientId + "\" " +
            "oauth.client.secret=\"" + clientSecretName + "\" " +
            "oauth.token.endpoint.uri=\"" + oauthTokenEndpointUri + "\";");

    return this;
}
 
源代码14 项目: IoTgo_Android_App   文件: CertificateValidator.java
/**
 * validates a specific certificate inside of the keystore being passed in
 * 
 * @param keyStore
 * @param cert
 * @throws CertificateException
 */
public void validate(KeyStore keyStore, Certificate cert) throws CertificateException
{
    Certificate[] certChain = null;
    
    if (cert != null && cert instanceof X509Certificate)
    {
        ((X509Certificate)cert).checkValidity();
        
        String certAlias = null;
        try
        {
            if (keyStore == null)
            {
                throw new InvalidParameterException("Keystore cannot be null");
            }

            certAlias = keyStore.getCertificateAlias((X509Certificate)cert);
            if (certAlias == null)
            {
                certAlias = "JETTY" + String.format("%016X",__aliasCount.incrementAndGet());
                keyStore.setCertificateEntry(certAlias, cert);
            }
            
            certChain = keyStore.getCertificateChain(certAlias);
            if (certChain == null || certChain.length == 0)
            {
                throw new IllegalStateException("Unable to retrieve certificate chain");
            }
        }
        catch (KeyStoreException kse)
        {
            LOG.debug(kse);
            throw new CertificateException("Unable to validate certificate" +
                    (certAlias == null ? "":" for alias [" +certAlias + "]") + ": " + kse.getMessage(), kse);
        }
        
        validate(certChain);
    } 
}
 
源代码15 项目: brooklyn-library   文件: KafkaSupport.java
/**
     * Retrieve the next message on the given topic from the {@link KafkaCluster}.
     */
    public String getMessage(String topic) {
        ZooKeeperNode zookeeper = cluster.getZooKeeper();
        Optional<Entity> anyBrokerNodeInCluster = Iterables.tryFind(cluster.getCluster().getChildren(), Predicates.and(
                Predicates.instanceOf(KafkaBroker.class),
                EntityPredicates.attributeEqualTo(KafkaBroker.SERVICE_UP, true)));
        if (anyBrokerNodeInCluster.isPresent()) {
            KafkaBroker broker = (KafkaBroker)anyBrokerNodeInCluster.get();

            Properties props = new Properties();

            props.put("bootstrap.servers", format("%s:%d", broker.getAttribute(KafkaBroker.HOSTNAME), broker.getKafkaPort()));
            props.put("zookeeper.connect", format(zookeeper.getHostname(), zookeeper.getZookeeperPort()));
            props.put("group.id", "brooklyn");
            props.put("partition.assignment.strategy", "RoundRobin");
            props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
            props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");

            KafkaConsumer consumer = new KafkaConsumer(props);

            consumer.subscribe(topic);
            // FIXME unimplemented KafkaConsumer.poll
//            Object consumerRecords = consumer.poll(Duration.seconds(3).toMilliseconds()).get(topic);
            return "TEST_MESSAGE";
        } else {
            throw new InvalidParameterException("No kafka broker node found");
        }
    }
 
源代码16 项目: ServiceCutter   文件: SolverConfiguration.java
public void setAlgorithmParams(final Map<String, Double> mclParams) {
	if (mclParams != null) {
		this.algorithmParams = mclParams;
	} else {
		throw new InvalidParameterException("mclParams should not be null!");
	}
}
 
源代码17 项目: jdk8u60   文件: AESKeyGenerator.java
/**
 * Initializes this key generator for a certain keysize, using the given
 * source of randomness.
 *
 * @param keysize the keysize. This is an algorithm-specific
 * metric specified in number of bits.
 * @param random the source of randomness for this key generator
 */
protected void engineInit(int keysize, SecureRandom random) {
    if (((keysize % 8) != 0) ||
        (!AESCrypt.isKeySizeValid(keysize/8))) {
        throw new InvalidParameterException
            ("Wrong keysize: must be equal to 128, 192 or 256");
    }
    this.keySize = keysize/8;
    this.engineInit(random);
}
 
@Override
public void validate(List<ValidationType> validationsToSkip) {
    if ((!validationsToSkip.contains(ValidationType.SKIP_ASSET_VALIDATION)
            && !validationsToSkip.contains(ValidationType.SKIP_VALIDATION))
            && (!SteemJConfig.getInstance().getVestsSymbol().equals(this.getVestingShares().getSymbol()))) {
        throw new InvalidParameterException("The vesting shares needs to be provided in VESTS.");
    }
}
 
源代码19 项目: cloudbreak   文件: ClusterTemplateTestAssertion.java
private static InstanceGroupV1Request getInstanceGroup(List<InstanceGroupV1Request> instanceGroups) {
    return instanceGroups
            .stream()
            .filter(ig -> HostGroupType.MASTER.getName().equals(ig.getName()))
            .findFirst()
            .orElseThrow(() -> new InvalidParameterException("Unable to find valid instancegroup by type"));
}
 
public void setStrategy(AssertionFactory.Strategy strategy) {

    if (strategy == null) {
      throw new InvalidParameterException("'strategy' cannot be null.");
    }
    
    if (strategyReference.getAndSet(strategy) != strategy) {
      currentFactory = createFactory(strategy, exceptionMapperReference.get());
    }
  }
 
源代码21 项目: ripple-lib-java   文件: ECCKeyGenParameterSpec.java
/**
 * Constructor.
 *
 * @param m    degree of the finite field GF(2^m)
 * @param t    error correction capability of the code
 * @param poly the field polynomial
 * @throws InvalidParameterException if <tt>m &lt; 1</tt> or <tt>m &gt; 32</tt> or
 * <tt>t &lt; 0</tt> or <tt>t &gt; n</tt> or
 * <tt>poly</tt> is not an irreducible field polynomial.
 */
public ECCKeyGenParameterSpec(int m, int t, int poly)
    throws InvalidParameterException
{
    this.m = m;
    if (m < 1)
    {
        throw new InvalidParameterException("m must be positive");
    }
    if (m > 32)
    {
        throw new InvalidParameterException(" m is too large");
    }
    this.n = 1 << m;
    this.t = t;
    if (t < 0)
    {
        throw new InvalidParameterException("t must be positive");
    }
    if (t > n)
    {
        throw new InvalidParameterException("t must be less than n = 2^m");
    }
    if ((PolynomialRingGF2.degree(poly) == m)
        && (PolynomialRingGF2.isIrreducible(poly)))
    {
        this.fieldPoly = poly;
    }
    else
    {
        throw new InvalidParameterException(
            "polynomial is not a field polynomial for GF(2^m)");
    }
}
 
源代码22 项目: marvinproject   文件: MarvinErrorHandler.java
private static String getErrorMessage(TYPE type){
	switch(type){
		case BAD_FILE: 					return "Bad file format!";							
		case ERROR_FILE_OPEN:			return "Error while opening the file:";
		case ERROR_FILE_SAVE:			return "Error while saving the image!";
		case ERROR_FILE_CHOOSE:			return "Error while choosing the file!";
		case ERROR_FILE_NOT_FOUND: 		return "Error! File not found:"; 
		case NO_IMAGE_LOADED:			return "No image loaded!";			
		case IMAGE_RELOAD:				return "Error while reloading the image!";
		case ERROR_PLUGIN_NOT_FOUND:	return "Error: plug-in not found!";
		default: throw new InvalidParameterException("Unknown error type");
	}
}
 
源代码23 项目: TelegramBots   文件: DefaultBotSession.java
@Override
public void setToken(String token) {
    if (this.token != null) {
        throw new InvalidParameterException("Token has already been set");
    }
    this.token = token;
}
 
源代码24 项目: lams   文件: DeliveryMethodMail.java
@Override
   protected String send(Integer fromUserId, Integer toUserId, String subject, String message, boolean isHtmlFormat,
    String attachmentFilename) throws InvalidParameterException {
try {
    User toUser = (User) DeliveryMethodMail.userManagementService.findById(User.class, toUserId);
    if (toUser == null) {
	return "Target user with ID " + toUserId + " was not found.";
    }
    String toEmail = toUser.getEmail();
    if (!DeliveryMethodMail.emailValidator.isValid(toEmail)) {
	return "Target user's e-mail address is invalid.";
    }

    if (fromUserId == null) {
	Emailer.sendFromSupportEmail(subject, toEmail, message, isHtmlFormat, attachmentFilename);
    } else {
	User fromUser = (User) DeliveryMethodMail.userManagementService.findById(User.class, fromUserId);
	if (fromUser == null) {
	    return "Source user with ID " + fromUserId + " was not found.";
	}
	String fromEmail = fromUser.getEmail();
	if (!DeliveryMethodMail.emailValidator.isValid(fromEmail)) {
	    return "Source user's e-mail address is invalid.";
	}

	Emailer.send(subject, toEmail, "", fromEmail, "", message, isHtmlFormat, attachmentFilename);
    }
    return null;
} catch (Exception e) {
    String error = e.toString();
    logError(error);
    return error;
}
   }
 
@Test
public void testConstructor() {
    try {
        new PostToProfileCommand("");
    } catch (InvalidParameterException ipe) {
        fail("empty String as a parameter should be accepted.");
    }
}
 
源代码26 项目: sejda   文件: PdfPageTransition.java
/**
 * Creates a new {@link PdfPageTransition} instance.
 * 
 * @param style
 * @param transitionDuration
 * @param displayDuration
 * @return the newly created instance.
 * @throws InvalidParameterException
 *             if the input transition or display duration is not positive. if the input style is null.
 */
public static PdfPageTransition newInstance(PdfPageTransitionStyle style, int transitionDuration,
        int displayDuration) {

    if (transitionDuration < 1) {
        throw new InvalidParameterException("Input transition duration must be positive.");
    }
    if (displayDuration < 1) {
        throw new InvalidParameterException("Input display duration must be positive.");
    }
    if (style == null) {
        throw new InvalidParameterException("Input style cannot be null.");
    }
    return new PdfPageTransition(style, transitionDuration, displayDuration);
}
 
源代码27 项目: fusionauth-jwt   文件: PEMEncoder.java
/**
 * Encode the provided key in a PEM format and return a string.
 * <p>
 * Both values may no be null.
 *
 * @param key the key, this parameter may be of type <code>PrivateKey</code> <code>PublicKey</code>
 * @return a PEM encoded key
 */
public String encode(Key key) {
  if (key instanceof PrivateKey) {
    return encode((PrivateKey) key, null);
  } else if (key instanceof PublicKey) {
    return encode(null, (PublicKey) key);
  }

  throw new PEMEncoderException(new InvalidParameterException("Unexpected key type. Expecting instance of [PrivateKey | PublicKey], found [" + key.getClass().getCanonicalName() + "]"));
}
 
源代码28 项目: jdk8u_jdk   文件: AESKeyGenerator.java
/**
 * Initializes this key generator for a certain keysize, using the given
 * source of randomness.
 *
 * @param keysize the keysize. This is an algorithm-specific
 * metric specified in number of bits.
 * @param random the source of randomness for this key generator
 */
protected void engineInit(int keysize, SecureRandom random) {
    if (((keysize % 8) != 0) ||
        (!AESCrypt.isKeySizeValid(keysize/8))) {
        throw new InvalidParameterException
            ("Wrong keysize: must be equal to 128, 192 or 256");
    }
    this.keySize = keysize/8;
    this.engineInit(random);
}
 
源代码29 项目: openjdk-jdk8u   文件: AESKeyGenerator.java
/**
 * Initializes this key generator for a certain keysize, using the given
 * source of randomness.
 *
 * @param keysize the keysize. This is an algorithm-specific
 * metric specified in number of bits.
 * @param random the source of randomness for this key generator
 */
protected void engineInit(int keysize, SecureRandom random) {
    if (((keysize % 8) != 0) ||
        (!AESCrypt.isKeySizeValid(keysize/8))) {
        throw new InvalidParameterException
            ("Wrong keysize: must be equal to 128, 192 or 256");
    }
    this.keySize = keysize/8;
    this.engineInit(random);
}
 
源代码30 项目: components   文件: DefaultSQLCreateTableAction.java
public DefaultSQLCreateTableAction(final String[] fullTableName, final Schema schema, boolean createIfNotExists, boolean drop,
    boolean dropIfExists) {
    if (fullTableName == null || fullTableName.length < 1) {
        throw new InvalidParameterException("Table name can't be null or empty");
    }

    this.fullTableName = fullTableName;
    this.schema = schema;
    this.createIfNotExists = createIfNotExists;

    this.drop = drop || dropIfExists;
    this.dropIfExists = dropIfExists;
}
 
 类所在包
 类方法
 同包方法