Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2013-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License").
  * You may not use this file except in compliance with the License.
  * A copy of the License is located at
  *
  *  http://aws.amazon.com/apache2.0
  *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.amazonaws.services.s3.internal.crypto;

Deprecated:
this class is no longer used and will be removed in the future

Factory for creating Ciphers based on the crypto key and configuration specified in the constructor. Each invocation of createCipher() will produce a new, identical Cipher object. Each returned Cipher will encrypt data with <bold>exactly</bold> the same output as any other Cipher returned by this instance of CipherFactory.

public class CipherFactory {
    private final SecretKey symmetricKey;
    private final int cipherMode;
    private byte[] initVectorBytes;
    private final Provider cryptoProvider;

    
Creates a new CipherFactory that will produce ciphers using the specified key, mode, IV and provider.

Parameters:
symmetricKey The symmetric key used in the ciphers created by this factory.
cipherMode The mode indicating whether the created ciphers are for encrypting or decrypting.
initVectorBytes The optional crypto IV used to initialize the ciphers.
cryptoProvider The optional Java crypto provider implementation, if an alternate crypto provider is to be used.
    public CipherFactory(SecretKey symmetricKeyint cipherModebyte[] initVectorBytesProvider cryptoProvider) {
        this. = symmetricKey;
        this. = cipherMode;
        this. = initVectorBytes;
        this. = cryptoProvider;
    }

    
Creates a new Cipher instance based on the crypto parameters specified in the constructor. Each Cipher instance is identical to any other Cipher produced by this CipherFactory.

Returns:
A new Cipher instance, identical to each Cipher produced by this factory instance.
    public Cipher createCipher() {
        Cipher cipher = EncryptionUtils.createSymmetricCipher();
        // If we weren't given an IV to use, make sure we store the one the first Cipher
        // used so we can use it for all future Ciphers created by this instance.
        if ( == null = cipher.getIV();
        return cipher;
    }
    public Provider getCryptoProvider() {
        return ;
    }
    public int getCipherMode() {
        return ;
    }
    public byte[] getIV() {
        return  == null ? null : .clone();
    }
New to GrepCode? Check out our FAQ X