當前位置: 首頁>>代碼示例>>Java>>正文


Java InvalidParameterSpecException類代碼示例

本文整理匯總了Java中java.security.spec.InvalidParameterSpecException的典型用法代碼示例。如果您正苦於以下問題:Java InvalidParameterSpecException類的具體用法?Java InvalidParameterSpecException怎麽用?Java InvalidParameterSpecException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InvalidParameterSpecException類屬於java.security.spec包,在下文中一共展示了InvalidParameterSpecException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
public static void main(final String[] argv) throws IOException, InvalidKeySpecException, NoSuchPaddingException, 
        InvalidKeyException, InvalidParameterSpecException, IllegalBlockSizeException, BadPaddingException,
        InvalidAlgorithmParameterException, ClassNotFoundException, GeneralSecurityException {
    
    if(argv.length >= 2) {
        ip = argv[0];
        port = Integer.parseInt(argv[1]);
    } else {
        Logger.getLogger(Main.class.getName()).log(Level.INFO, "Default ip and port were applied.");
        ip = Parameters.RELAY_IP;
        port = Parameters.RELAY_PORT_WALLET_LISTENER;
    }
    
    // Init connection with relay
    try {
        RelayConnection.getInstance();
    } catch(IOException ex) {
        Logger.getLogger(Main.class.getName()).severe(ex.getMessage());
        return;
    }
    
    new ClientApplication();

}
 
開發者ID:StanIsAdmin,項目名稱:CrashCoin,代碼行數:25,代碼來源:Main.java

示例2: engineInit

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
@Override
protected void engineInit(int opmode, Key key,
        AlgorithmParameters params, SecureRandom random)
    throws InvalidKeyException, InvalidAlgorithmParameterException {

    AlgorithmParameterSpec spec;

    try {

        spec = params.getParameterSpec(IvParameterSpec.class);

        if (debug.DEBUG)
            log("initialized with key and AlgorithmParameters");

    } catch (InvalidParameterSpecException ipe) {
        throw new InvalidAlgorithmParameterException(ipe);
    }

    wolfCryptCipherInit(opmode, key, spec, random);
}
 
開發者ID:wolfSSL,項目名稱:wolfcrypt-jni,代碼行數:21,代碼來源:WolfCryptCipher.java

示例3: engineInit

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
protected void engineInit(AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException {

    if (!(paramSpec instanceof RC2ParameterSpec)) {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
    RC2ParameterSpec rps = (RC2ParameterSpec) paramSpec;

    // check effective key size (a value of 0 means it is unspecified)
    effectiveKeySize = rps.getEffectiveKeyBits();
    if (effectiveKeySize != 0) {
        if (effectiveKeySize < 1 || effectiveKeySize > 1024) {
            throw new InvalidParameterSpecException("RC2 effective key " +
                "size must be between 1 and 1024 bits");
        }
        if (effectiveKeySize < 256) {
            version = EKB_TABLE[effectiveKeySize];
        } else {
            version = effectiveKeySize;
        }
    }
    this.iv = rps.getIV();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:RC2Parameters.java

示例4: localEngineGetParameterSpec

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
protected AlgorithmParameterSpec localEngineGetParameterSpec(
    Class paramSpec)
    throws InvalidParameterSpecException
{
    if (paramSpec == RC2ParameterSpec.class)
    {
        if (parameterVersion != -1)
        {
            if (parameterVersion < 256)
            {
                return new RC2ParameterSpec(ekb[parameterVersion], iv);
            }
            else
            {
                return new RC2ParameterSpec(parameterVersion, iv);
            }
        }
    }

    if (paramSpec == IvParameterSpec.class)
    {
        return new IvParameterSpec(iv);
    }

    throw new InvalidParameterSpecException("unknown parameter spec passed to RC2 parameters object.");
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:27,代碼來源:RC2.java

示例5: getParams

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
/**
 * Returns the DSA parameters associated with this key, or null if the
 * parameters could not be parsed.
 */
public DSAParams getParams() {
    try {
        if (algid instanceof DSAParams) {
            return (DSAParams)algid;
        } else {
            DSAParameterSpec paramSpec;
            AlgorithmParameters algParams = algid.getParameters();
            if (algParams == null) {
                return null;
            }
            paramSpec = algParams.getParameterSpec(DSAParameterSpec.class);
            return (DSAParams)paramSpec;
        }
    } catch (InvalidParameterSpecException e) {
        return null;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:22,代碼來源:DSAPrivateKey.java

示例6: engineGetParameterSpec

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
protected <T extends AlgorithmParameterSpec>
    T engineGetParameterSpec(Class<T> paramSpec)
    throws InvalidParameterSpecException
{
        try {
            Class<?> dsaParamSpec = Class.forName
                ("java.security.spec.DSAParameterSpec");
            if (dsaParamSpec.isAssignableFrom(paramSpec)) {
                return paramSpec.cast(
                        new DSAParameterSpec(this.p, this.q, this.g));
            } else {
                throw new InvalidParameterSpecException
                    ("Inappropriate parameter Specification");
            }
        } catch (ClassNotFoundException e) {
            throw new InvalidParameterSpecException
                ("Unsupported parameter specification: " + e.getMessage());
        }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:DSAParameters.java

示例7: engineInit

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
protected void engineInit(
    AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof ElGamalParameterSpec) && !(paramSpec instanceof DHParameterSpec))
    {
        throw new InvalidParameterSpecException("DHParameterSpec required to initialise a ElGamal algorithm parameters object");
    }

    if (paramSpec instanceof ElGamalParameterSpec)
    {
        this.currentSpec = (ElGamalParameterSpec)paramSpec;
    }
    else
    {
        DHParameterSpec s = (DHParameterSpec)paramSpec;

        this.currentSpec = new ElGamalParameterSpec(s.getP(), s.getG());
    }
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:21,代碼來源:AlgorithmParametersSpi.java

示例8: engineGetParameters

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
protected AlgorithmParameters engineGetParameters() {
    if (spec != null && spec instanceof OAEPParameterSpec) {
        try {
            AlgorithmParameters params =
                AlgorithmParameters.getInstance("OAEP",
                    SunJCE.getInstance());
            params.init(spec);
            return params;
        } catch (NoSuchAlgorithmException nsae) {
            // should never happen
            throw new RuntimeException("Cannot find OAEP " +
                " AlgorithmParameters implementation in SunJCE provider");
        } catch (InvalidParameterSpecException ipse) {
            // should never happen
            throw new RuntimeException("OAEPParameterSpec not supported");
        }
    } else {
        return null;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:RSACipher.java

示例9: engineInit

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
protected void engineInit(int opmode, Key key,
        AlgorithmParameters params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    if (params == null) {
        init(opmode, key, random, null);
    } else {
        try {
            OAEPParameterSpec spec =
                    params.getParameterSpec(OAEPParameterSpec.class);
            init(opmode, key, random, spec);
        } catch (InvalidParameterSpecException ipse) {
            InvalidAlgorithmParameterException iape =
                new InvalidAlgorithmParameterException("Wrong parameter");
            iape.initCause(ipse);
            throw iape;
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:RSACipher.java

示例10: checkCryptoPerm

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
private void checkCryptoPerm(CipherSpi checkSpi, Key key,
        AlgorithmParameters params)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    if (cryptoPerm == CryptoAllPermission.INSTANCE) {
        return;
    }
    // Convert the specified parameters into specs and then delegate.
    AlgorithmParameterSpec pSpec;
    try {
        pSpec = getAlgorithmParameterSpec(params);
    } catch (InvalidParameterSpecException ipse) {
        throw new InvalidAlgorithmParameterException
            ("Failed to retrieve algorithm parameter specification");
    }
    checkCryptoPerm(checkSpi, key, pSpec);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:Cipher.java

示例11: writeWalletFile

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
/**
 * Methods used to write the current ClientWallent into a generated file.
 * @param userPassword
 * @param accountName
 * @param keyPair
 * @throws InvalidKeyException
 * @throws InvalidParameterSpecException
 * @throws IllegalBlockSizeException
 * @throws BadPaddingException
 * @throws FileNotFoundException
 * @throws IOException 
 */
public static void writeWalletFile(final char[] userPassword, final String accountName, final KeyPair keyPair) 
        throws InvalidKeyException,
        InvalidParameterSpecException, IllegalBlockSizeException, BadPaddingException, FileNotFoundException,
        IOException {
    
    // Write wallet information in the wallet file
    final WalletInformation walletInformation = Cryptography.walletInformationFromKeyPair(userPassword, keyPair);

    // Creates wallet folder if not exists
    final File walletFolder = new File(Parameters.WALLETS_PATH);
    if (!walletFolder.exists()) {
        walletFolder.mkdir();
    }

    // Creates new wallet file
    final File f = new File(Parameters.WALLETS_PATH + accountName + ".wallet");
    final ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));
    oos.writeObject(walletInformation);
    oos.flush();
    oos.close();

    System.out.println("The creation of your wallet completed successfully");
    System.out.println("Please sign in and start crashing coins");
}
 
開發者ID:StanIsAdmin,項目名稱:CrashCoin,代碼行數:37,代碼來源:WalletClient.java

示例12: actionMenuNotRegistered

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
private void actionMenuNotRegistered(final int choice) throws ClassNotFoundException, IOException, FileNotFoundException,
        InvalidKeyException, InvalidAlgorithmParameterException,
        InvalidKeySpecException, IllegalBlockSizeException, BadPaddingException, InvalidParameterSpecException {
    switch (choice) {
        case 1:
            signIn();
            break;

        case 2:
            signUp();
            break;
            
        case 3: // close with condition in while
            break;

        default:
            System.out.println("Unknow choice " + choice + "\n");
            break;

    }
}
 
開發者ID:StanIsAdmin,項目名稱:CrashCoin,代碼行數:22,代碼來源:ClientApplication.java

示例13: engineInit

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
@Override
protected void engineInit(int opmode, Key key, AlgorithmParameters params,
		SecureRandom random) throws InvalidKeyException,
		InvalidAlgorithmParameterException {
	
	try {
		engineInit(opmode, key, params.getParameterSpec(AlgorithmParameterSpec.class), random);
	} catch (InvalidParameterSpecException e) {
		throw new InvalidAlgorithmParameterException(e);
	}

}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:13,代碼來源:NativeAESCipherSpi.java

示例14: engineGetParameterSpec

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
protected <T extends AlgorithmParameterSpec>
        T engineGetParameterSpec(Class<T> paramSpec)
    throws InvalidParameterSpecException {

    if (GCMParameterSpec.class.isAssignableFrom(paramSpec)) {
        return paramSpec.cast(new GCMParameterSpec(tLen * 8, iv));
    } else {
        throw new InvalidParameterSpecException
            ("Inappropriate parameter specification");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:12,代碼來源:GCMParameters.java

示例15: engineInit

import java.security.spec.InvalidParameterSpecException; //導入依賴的package包/類
protected void engineInit(
    AlgorithmParameterSpec paramSpec)
    throws InvalidParameterSpecException
{
    if (!(paramSpec instanceof PBEParameterSpec))
    {
        throw new InvalidParameterSpecException("PBEParameterSpec required to initialise a PKCS12 PBE parameters algorithm parameters object");
    }

    PBEParameterSpec pbeSpec = (PBEParameterSpec)paramSpec;

    this.params = new PKCS12PBEParams(pbeSpec.getSalt(),
        pbeSpec.getIterationCount());
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:15,代碼來源:PBEPKCS12.java


注:本文中的java.security.spec.InvalidParameterSpecException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。