Package javax.crypto

Examples of javax.crypto.KeyGenerator


        }
        return secretKey;
    }
   
    private Key generateDataEncryptionKey() throws Exception {     
        KeyGenerator keyGenerator = null;
        if (xmlCipherAlgorithm.equalsIgnoreCase(XMLCipher.TRIPLEDES)) {
            keyGenerator = KeyGenerator.getInstance("DESede");
        } else {
            keyGenerator = KeyGenerator.getInstance("AES");
       
            if (xmlCipherAlgorithm.equalsIgnoreCase(XMLCipher.AES_128)
                || xmlCipherAlgorithm.equalsIgnoreCase(XMLCipher.AES_128_GCM)
                || xmlCipherAlgorithm.equalsIgnoreCase(XMLCipher.SEED_128)
                || xmlCipherAlgorithm.equalsIgnoreCase(XMLCipher.CAMELLIA_128)) {
                keyGenerator.init(128);
            } else if (xmlCipherAlgorithm.equalsIgnoreCase(XMLCipher.AES_192)
                || xmlCipherAlgorithm.equalsIgnoreCase(XMLCipher.AES_192_GCM)
                || xmlCipherAlgorithm.equalsIgnoreCase(XMLCipher.CAMELLIA_192)) {
                keyGenerator.init(192);
            } else if (xmlCipherAlgorithm.equalsIgnoreCase(XMLCipher.AES_256)
                || xmlCipherAlgorithm.equalsIgnoreCase(XMLCipher.AES_256_GCM)
                || xmlCipherAlgorithm.equalsIgnoreCase(XMLCipher.CAMELLIA_256)) {
                keyGenerator.init(256);
            }
        }
        return keyGenerator.generateKey();
    }
View Full Code Here


    }
   
    @Test
    public void testAES128() throws Exception {
        // Set up the Key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        keygen.init(128);
        SecretKey key = keygen.generateKey();
       
        final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
        xmlEncDataFormat.setPassPhrase(key.getEncoded());
        xmlEncDataFormat.setSecureTagContents(true);
        xmlEncDataFormat.setSecureTag("//cheesesites/italy/cheese");
View Full Code Here

    }
   
    @Test
    public void testAES128GCM() throws Exception {
        // Set up the Key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        keygen.init(128);
        SecretKey key = keygen.generateKey();
       
        final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
        xmlEncDataFormat.setPassPhrase(key.getEncoded());
        xmlEncDataFormat.setSecureTagContents(true);
        xmlEncDataFormat.setSecureTag("//cheesesites/italy/cheese");
View Full Code Here

        if (!TestHelper.UNRESTRICTED_POLICIES_INSTALLED) {
            return;
        }
       
        // Set up the Key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        keygen.init(192);
        SecretKey key = keygen.generateKey();
       
        final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
        xmlEncDataFormat.setPassPhrase(key.getEncoded());
        xmlEncDataFormat.setSecureTagContents(true);
        xmlEncDataFormat.setSecureTag("//cheesesites/italy/cheese");
View Full Code Here

        if (!TestHelper.UNRESTRICTED_POLICIES_INSTALLED) {
            return;
        }
       
        // Set up the Key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        keygen.init(192);
        SecretKey key = keygen.generateKey();
       
        final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
        xmlEncDataFormat.setPassPhrase(key.getEncoded());
        xmlEncDataFormat.setSecureTagContents(true);
        xmlEncDataFormat.setSecureTag("//cheesesites/italy/cheese");
View Full Code Here

        if (!TestHelper.UNRESTRICTED_POLICIES_INSTALLED) {
            return;
        }
       
        // Set up the Key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        keygen.init(256);
        SecretKey key = keygen.generateKey();
       
        final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
        xmlEncDataFormat.setPassPhrase(key.getEncoded());
        xmlEncDataFormat.setSecureTagContents(true);
        xmlEncDataFormat.setSecureTag("//cheesesites/italy/cheese");
View Full Code Here

        if (!TestHelper.UNRESTRICTED_POLICIES_INSTALLED) {
            return;
        }
       
        // Set up the Key
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        keygen.init(256);
        SecretKey key = keygen.generateKey();
       
        final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
        xmlEncDataFormat.setPassPhrase(key.getEncoded());
        xmlEncDataFormat.setSecureTagContents(true);
        xmlEncDataFormat.setSecureTag("//cheesesites/italy/cheese");
View Full Code Here

    }

    @Test
    public void testTRIPLEDES() throws Exception {
        // Set up the Key
        KeyGenerator keygen = KeyGenerator.getInstance("DESede");
        keygen.init(192);
        SecretKey key = keygen.generateKey();
       
        final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
        xmlEncDataFormat.setPassPhrase(key.getEncoded());
        xmlEncDataFormat.setSecureTagContents(true);
        xmlEncDataFormat.setSecureTag("//cheesesites/italy/cheese");
View Full Code Here

    }
   
    @Test
    public void testSEED128() throws Exception {
        // Set up the Key
        KeyGenerator keygen = KeyGenerator.getInstance("SEED");
        keygen.init(128);
        SecretKey key = keygen.generateKey();
       
        final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
        xmlEncDataFormat.setPassPhrase(key.getEncoded());
        xmlEncDataFormat.setSecureTagContents(true);
        xmlEncDataFormat.setSecureTag("//cheesesites/italy/cheese");
View Full Code Here

    }
   
    @Test
    public void testCAMELLIA128() throws Exception {
        // Set up the Key
        KeyGenerator keygen = KeyGenerator.getInstance("CAMELLIA");
        keygen.init(128);
        SecretKey key = keygen.generateKey();
       
        final XMLSecurityDataFormat xmlEncDataFormat = new XMLSecurityDataFormat();
        xmlEncDataFormat.setPassPhrase(key.getEncoded());
        xmlEncDataFormat.setSecureTagContents(true);
        xmlEncDataFormat.setSecureTag("//cheesesites/italy/cheese");
View Full Code Here

TOP

Related Classes of javax.crypto.KeyGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.