当前位置: 首页>>代码示例>>Java>>正文


Java GeneralSecurityException.getMessage方法代码示例

本文整理汇总了Java中java.security.GeneralSecurityException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java GeneralSecurityException.getMessage方法的具体用法?Java GeneralSecurityException.getMessage怎么用?Java GeneralSecurityException.getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.GeneralSecurityException的用法示例。


在下文中一共展示了GeneralSecurityException.getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: trustAllHttpsCertificates

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
/**
 * Set the default X509 Trust Manager to an instance of a dummy class that trust all certificates,
 * even the self-signed ones.
 * 
 * @param protocol e.g. TLS, TLSv1.2
 */
public static void trustAllHttpsCertificates( String protocol ) {

    // Create a trust manager that does not validate certificate chains
    if (instance.trustManagers == null) {
        synchronized (instance) {
            if (instance.trustManagers == null) { // if several threads had waited for entering the synchronized block
                instance.trustManagers = new TrustManager[]{ new DefaultTrustManager() };
                // Install the all-trusting trust manager:
                try {
                    trustAllSSlContext = SSLContext.getInstance(protocol);
                    trustAllSSlContext.init(null, instance.trustManagers, null);
                } catch (GeneralSecurityException gse) {
                    throw new IllegalStateException(gse.getMessage());
                }
                HttpsURLConnection.setDefaultSSLSocketFactory(trustAllSSlContext.getSocketFactory());
            }
        }
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:26,代码来源:SslUtils.java

示例2: getInitializedDes

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
/**
 * Obtains an initialized DES cipher.
 *
 * @param encryptMode true if encryption is desired, false is decryption
 * is desired.
 * @param key the bytes for the DES key
 * @param ivBytes the initial vector bytes
 */
private final Cipher getInitializedDes(boolean encryptMode, byte[] key,
                                      byte[] ivBytes)
    throws  GSSException  {


    try {
        IvParameterSpec iv = new IvParameterSpec(ivBytes);
        SecretKey jceKey = (SecretKey) (new SecretKeySpec(key, "DES"));

        Cipher desCipher = Cipher.getInstance("DES/CBC/NoPadding");
        desCipher.init(
            (encryptMode ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE),
            jceKey, iv);
        return desCipher;
    } catch (GeneralSecurityException e) {
        GSSException ge = new GSSException(GSSException.FAILURE, -1,
            e.getMessage());
        ge.initCause(e);
        throw ge;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:CipherHelper.java

示例3: __trustAllHttpsCertificates

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
/**
 * Set the default X509 Trust Manager to an instance of a fake class that 
 * trust all certificates, even the self-signed ones. This method uses the 
 * old deprecated API from the com.sun.ssl package.
 *
 * @deprecated see {@link #_trustAllHttpsCertificates()}.
 */
private static void __trustAllHttpsCertificates() {
    com.sun.net.ssl.SSLContext context;
    
    // Create a trust manager that does not validate certificate chains
    if(__trustManagers == null) {
        __trustManagers = new com.sun.net.ssl.TrustManager[] 
            {new _FakeX509TrustManager()};
    } // if
    // Install the all-trusting trust manager
    try {
        context = com.sun.net.ssl.SSLContext.getInstance("SSL");
        context.init(null, __trustManagers, new SecureRandom());
    } catch(GeneralSecurityException gse) {
        throw new IllegalStateException(gse.getMessage());
    } // catch
    com.sun.net.ssl.HttpsURLConnection.
        setDefaultSSLSocketFactory(context.getSocketFactory());
}
 
开发者ID:oci-pronghorn,项目名称:GreenLightning,代码行数:26,代码来源:SSLUtilities.java

示例4: calculateMac

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
public byte[] calculateMac(byte[] pwd, byte[] data)
    throws CRMFException
{
    try
    {
        mac.init(new SecretKeySpec(pwd, mac.getAlgorithm()));

        return mac.doFinal(data);
    }
    catch (GeneralSecurityException e)
    {
        throw new CRMFException("failure in setup: " + e.getMessage(), e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:JcePKMACValuesCalculator.java

示例5: verifyKeyedChecksum

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
/**
 * Verifies keyed checksum.
 * @param data the data.
 * @param size the length of data.
 * @param key the key used to encrypt the checksum.
 * @param checksum
 * @return true if verification is successful.
 */
public boolean verifyKeyedChecksum(byte[] data, int size,
    byte[] key, byte[] checksum, int usage) throws KrbCryptoException {

     try {
        byte[] newCksum = Aes128.calculateChecksum(key, usage,
                                                    data, 0, size);
        return isChecksumEqual(checksum, newCksum);
     } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
     }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:HmacSha1Aes128CksumType.java

示例6: decrypt

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
public byte[] decrypt(byte[] cipher, byte[] key, byte[] ivec, int usage)
    throws KrbApErrException, KrbCryptoException {
    try {
        return Aes128.decrypt(key, usage, ivec, cipher, 0, cipher.length);
    } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:Aes128CtsHmacSha1EType.java

示例7: encrypt

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
public byte[] encrypt(byte[] data, byte[] key, byte[] ivec, int usage)
    throws KrbCryptoException {
    try {
        return Aes256.encrypt(key, usage, ivec, data, 0, data.length);
    } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:Aes256CtsHmacSha1EType.java

示例8: aes128Decrypt

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
private void aes128Decrypt(WrapToken_v2 token, byte[] ciphertext,
    int cStart, int cLen, byte[] plaintext, int pStart, int key_usage)
    throws GSSException {

    byte[] ptext = null;

    try {
        ptext = Aes128.decryptRaw(keybytes, key_usage,
                    ZERO_IV_AES, ciphertext, cStart, cLen);
    } catch (GeneralSecurityException e) {
        GSSException ge = new GSSException(GSSException.FAILURE, -1,
            "Could not use AES128 Cipher - " + e.getMessage());
        ge.initCause(e);
        throw ge;
    }

    /*
    Krb5Token.debug("\naes128Decrypt in: " +
        Krb5Token.getHexBytes(ciphertext, cStart, cLen));
    Krb5Token.debug("\naes128Decrypt plain: " +
        Krb5Token.getHexBytes(ptext));
    Krb5Token.debug("\naes128Decrypt ptext: " +
        Krb5Token.getHexBytes(ptext));
    */

    // Strip out confounder and token header
    int len = ptext.length - WrapToken_v2.CONFOUNDER_SIZE -
                    WrapToken_v2.TOKEN_HEADER_SIZE;
    System.arraycopy(ptext, WrapToken_v2.CONFOUNDER_SIZE,
                            plaintext, pStart, len);

    /*
    Krb5Token.debug("\naes128Decrypt plaintext: " +
        Krb5Token.getHexBytes(plaintext, pStart, len));
    */
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:CipherHelper.java

示例9: unseal

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
/**
 * Unseals the sealed key.
 */
Key unseal(SealedObject so)
    throws NoSuchAlgorithmException, UnrecoverableKeyException
{
    try {
        // create PBE key from password
        PBEKeySpec pbeKeySpec = new PBEKeySpec(this.password);
        SecretKey skey = new PBEKey(pbeKeySpec, "PBEWithMD5AndTripleDES");
        pbeKeySpec.clearPassword();

        SealedObjectForKeyProtector soForKeyProtector = null;
        if (!(so instanceof SealedObjectForKeyProtector)) {
            soForKeyProtector = new SealedObjectForKeyProtector(so);
        } else {
            soForKeyProtector = (SealedObjectForKeyProtector)so;
        }
        AlgorithmParameters params = soForKeyProtector.getParameters();
        if (params == null) {
            throw new UnrecoverableKeyException("Cannot get " +
                                                "algorithm parameters");
        }
        PBEWithMD5AndTripleDESCipher cipherSpi;
        cipherSpi = new PBEWithMD5AndTripleDESCipher();
        Cipher cipher = new CipherForKeyProtector(cipherSpi,
                                                  SunJCE.getInstance(),
                                                  "PBEWithMD5AndTripleDES");
        cipher.init(Cipher.DECRYPT_MODE, skey, params);
        return (Key)soForKeyProtector.getObject(cipher);
    } catch (NoSuchAlgorithmException ex) {
        // Note: this catch needed to be here because of the
        // later catch of GeneralSecurityException
        throw ex;
    } catch (IOException ioe) {
        throw new UnrecoverableKeyException(ioe.getMessage());
    } catch (ClassNotFoundException cnfe) {
        throw new UnrecoverableKeyException(cnfe.getMessage());
    } catch (GeneralSecurityException gse) {
        throw new UnrecoverableKeyException(gse.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:KeyProtector.java

示例10: decrypt

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
public byte[] decrypt(byte[] cipher, byte[] key, byte[] ivec, int usage)
    throws KrbApErrException, KrbCryptoException {
    try {
        return Aes256.decrypt(key, usage, ivec, cipher, 0, cipher.length);
    } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Aes256CtsHmacSha1EType.java

示例11: stringToKey

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
private static byte[] stringToKey(char[] password, String salt,
    byte[] s2kparams, int keyType) throws KrbCryptoException {

    char[] slt = salt.toCharArray();
    char[] pwsalt = new char[password.length + slt.length];
    System.arraycopy(password, 0, pwsalt, 0, password.length);
    System.arraycopy(slt, 0, pwsalt, password.length, slt.length);
    Arrays.fill(slt, '0');

    try {
        switch (keyType) {
            case EncryptedData.ETYPE_DES_CBC_CRC:
            case EncryptedData.ETYPE_DES_CBC_MD5:
                    return Des.string_to_key_bytes(pwsalt);

            case EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD:
                    return Des3.stringToKey(pwsalt);

            case EncryptedData.ETYPE_ARCFOUR_HMAC:
                    return ArcFourHmac.stringToKey(password);

            case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
                    return Aes128.stringToKey(password, salt, s2kparams);

            case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
                    return Aes256.stringToKey(password, salt, s2kparams);

            default:
                    throw new IllegalArgumentException("encryption type " +
                    EType.toString(keyType) + " not supported");
        }

    } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
    } finally {
        Arrays.fill(pwsalt, '0');
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:EncryptionKey.java

示例12: decrypt

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
public byte[] decrypt(byte[] cipher, byte[] key, byte[] ivec, int usage)
    throws KrbApErrException, KrbCryptoException {
    try {
        return Des3.decrypt(key, usage, ivec, cipher, 0, cipher.length);
    } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:Des3CbcHmacSha1KdEType.java

示例13: encrypt

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
public byte[] encrypt(byte[] data, byte[] key, byte[] ivec, int usage)
    throws KrbCryptoException {
    try {
        return ArcFourHmac.encrypt(key, usage, ivec, data, 0, data.length);
    } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:ArcFourHmacEType.java

示例14: calculateKeyedChecksum

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
/**
 * Calculates keyed checksum.
 * @param data the data used to generate the checksum.
 * @param size length of the data.
 * @param key the key used to encrypt the checksum.
 * @return keyed checksum.
 */
public byte[] calculateKeyedChecksum(byte[] data, int size, byte[] key,
    int usage) throws KrbCryptoException {

     try {
        return Aes256.calculateChecksum(key, usage, data, 0, size);
     } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
     }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:HmacSha1Aes256CksumType.java

示例15: decrypt

import java.security.GeneralSecurityException; //导入方法依赖的package包/类
public byte[] decrypt(byte[] cipher, byte[] key, byte[] ivec, int usage)
    throws KrbApErrException, KrbCryptoException {
    try {
        return ArcFourHmac.decrypt(key, usage, ivec, cipher, 0, cipher.length);
    } catch (GeneralSecurityException e) {
        KrbCryptoException ke = new KrbCryptoException(e.getMessage());
        ke.initCause(e);
        throw ke;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ArcFourHmacEType.java


注:本文中的java.security.GeneralSecurityException.getMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。