Search in sources :

Example 16 with InvalidParameterException

use of java.security.InvalidParameterException in project robovm by robovm.

the class SignerTest method test_setKeyPairLjava_security_KeyPair.

/**
     * java.security.Signer#setKeyPair(java.security.KeyPair)
     */
public void test_setKeyPairLjava_security_KeyPair() throws Exception {
    // test: NullPointerException if pair is null
    try {
        new SignerStub("name").setKeyPair(null);
        fail("No expected NullPointerException");
    } catch (NullPointerException e) {
    }
    try {
        KeyPair kp = new KeyPair(null, null);
        SignerStub s = new SignerStub("name");
        s.setKeyPair(kp);
    } catch (InvalidParameterException e) {
    // ok
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) KeyPair(java.security.KeyPair) SignerStub(org.apache.harmony.security.tests.support.SignerStub)

Example 17 with InvalidParameterException

use of java.security.InvalidParameterException in project zaproxy by zaproxy.

the class ExtensionBreak method addHttpBreakpoint.

public void addHttpBreakpoint(String string, String location, String match, boolean inverse, boolean ignoreCase) {
    Location loc;
    Match mtch;
    try {
        loc = Location.valueOf(location);
    } catch (Exception e) {
        throw new InvalidParameterException("location must be one of " + Arrays.toString(Location.values()));
    }
    try {
        mtch = Match.valueOf(match);
    } catch (Exception e) {
        throw new InvalidParameterException("match must be one of " + Arrays.toString(Match.values()));
    }
    this.addBreakpoint(new HttpBreakpointMessage(string, loc, mtch, inverse, ignoreCase));
}
Also used : InvalidParameterException(java.security.InvalidParameterException) HttpBreakpointMessage(org.zaproxy.zap.extension.brk.impl.http.HttpBreakpointMessage) InvalidParameterException(java.security.InvalidParameterException) MalformedURLException(java.net.MalformedURLException) Location(org.zaproxy.zap.extension.brk.impl.http.HttpBreakpointMessage.Location) Match(org.zaproxy.zap.extension.brk.impl.http.HttpBreakpointMessage.Match)

Example 18 with InvalidParameterException

use of java.security.InvalidParameterException in project jforum2 by rafaelsteil.

the class SystemGlobals method buildSystem.

private void buildSystem(String appPath, String mainConfigurationFile) {
    if (mainConfigurationFile == null) {
        throw new InvalidParameterException("defaultConfig could not be null");
    }
    this.defaultConfig = mainConfigurationFile;
    this.defaults = new Properties();
    this.defaults.put(ConfigKeys.APPLICATION_PATH, appPath);
    this.defaults.put(ConfigKeys.DEFAULT_CONFIG, mainConfigurationFile);
    SystemGlobals.loadDefaults();
    this.installation = new Properties();
    this.installationConfig = getVariableValue(ConfigKeys.INSTALLATION_CONFIG);
    for (Iterator iter = additionalDefaultsList.iterator(); iter.hasNext(); ) {
        loadAdditionalDefaults((String) iter.next());
    }
    if (new File(this.installationConfig).exists()) {
        loadAdditionalDefaults(this.installationConfig);
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) Iterator(java.util.Iterator) Properties(java.util.Properties) File(java.io.File)

Example 19 with InvalidParameterException

use of java.security.InvalidParameterException in project robovm by robovm.

the class BaseKeyGenerator method engineInit.

protected void engineInit(int keySize, SecureRandom random) {
    try {
        if (random == null) {
            random = new SecureRandom();
        }
        engine.init(new KeyGenerationParameters(random, keySize));
        uninitialised = false;
    } catch (IllegalArgumentException e) {
        throw new InvalidParameterException(e.getMessage());
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) SecureRandom(java.security.SecureRandom) KeyGenerationParameters(org.bouncycastle.crypto.KeyGenerationParameters)

Example 20 with InvalidParameterException

use of java.security.InvalidParameterException in project robovm by robovm.

the class OpenSSLCipher method engineInitInternal.

private void engineInitInternal(int opmode, Key key, byte[] iv, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException {
    if (opmode == Cipher.ENCRYPT_MODE || opmode == Cipher.WRAP_MODE) {
        encrypting = true;
    } else if (opmode == Cipher.DECRYPT_MODE || opmode == Cipher.UNWRAP_MODE) {
        encrypting = false;
    } else {
        throw new InvalidParameterException("Unsupported opmode " + opmode);
    }
    if (!(key instanceof SecretKey)) {
        throw new InvalidKeyException("Only SecretKey is supported");
    }
    final byte[] encodedKey = key.getEncoded();
    if (encodedKey == null) {
        throw new InvalidKeyException("key.getEncoded() == null");
    }
    checkSupportedKeySize(encodedKey.length);
    final long cipherType = NativeCrypto.EVP_get_cipherbyname(getCipherName(encodedKey.length, mode));
    if (cipherType == 0) {
        throw new InvalidAlgorithmParameterException("Cannot find name for key length = " + (encodedKey.length * 8) + " and mode = " + mode);
    }
    final int ivLength = NativeCrypto.EVP_CIPHER_iv_length(cipherType);
    if (iv == null && ivLength != 0) {
        iv = new byte[ivLength];
        if (encrypting) {
            if (random == null) {
                random = new SecureRandom();
            }
            random.nextBytes(iv);
        }
    } else if (iv != null && iv.length != ivLength) {
        throw new InvalidAlgorithmParameterException("expected IV length of " + ivLength);
    }
    this.iv = iv;
    if (supportsVariableSizeKey()) {
        NativeCrypto.EVP_CipherInit_ex(cipherCtx.getContext(), cipherType, null, null, encrypting);
        NativeCrypto.EVP_CIPHER_CTX_set_key_length(cipherCtx.getContext(), encodedKey.length);
        NativeCrypto.EVP_CipherInit_ex(cipherCtx.getContext(), 0, encodedKey, iv, encrypting);
    } else {
        NativeCrypto.EVP_CipherInit_ex(cipherCtx.getContext(), cipherType, encodedKey, iv, encrypting);
    }
    // OpenSSL only supports PKCS5 Padding.
    NativeCrypto.EVP_CIPHER_CTX_set_padding(cipherCtx.getContext(), padding == Padding.PKCS5PADDING);
    modeBlockSize = NativeCrypto.EVP_CIPHER_CTX_block_size(cipherCtx.getContext());
    calledUpdate = false;
}
Also used : InvalidParameterException(java.security.InvalidParameterException) SecretKey(javax.crypto.SecretKey) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) SecureRandom(java.security.SecureRandom) InvalidKeyException(java.security.InvalidKeyException)

Aggregations

InvalidParameterException (java.security.InvalidParameterException)280 IOException (java.io.IOException)34 ArrayList (java.util.ArrayList)24 ActionEvent (com.cloud.event.ActionEvent)22 SecureRandom (java.security.SecureRandom)19 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)18 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)16 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)16 File (java.io.File)16 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)15 FirewallRule (com.cloud.network.rules.FirewallRule)14 DB (com.cloud.utils.db.DB)14 Map (java.util.Map)14 HashMap (java.util.HashMap)12 MalformedURLException (java.net.MalformedURLException)11 Paint (android.graphics.Paint)9 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)8 CommunicationException (com.globalcollect.gateway.sdk.client.android.sdk.exception.CommunicationException)8 HttpURLConnection (java.net.HttpURLConnection)8 Scanner (java.util.Scanner)8