Class SecuredData

  • All Implemented Interfaces:
    java.io.Serializable

    public class SecuredData
    extends java.lang.Object
    implements java.io.Serializable
    Secured data container
    After encryption you can safely move this object in the insecure networks
    Author:
    Ruslan Nazirov
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      SecuredData​(byte[] data)
      Init SecuredData from bytes array
      SecuredData​(java.io.File file)
      Init SecuredData from file
    • Constructor Detail

      • SecuredData

        public SecuredData​(byte[] data)
        Init SecuredData from bytes array
        Parameters:
        data - Data to encrypt
      • SecuredData

        public SecuredData​(java.io.File file)
                    throws java.lang.Exception
        Init SecuredData from file
        Parameters:
        file - File to read data from
        Throws:
        java.lang.Exception - Error during SecuredData creation
    • Method Detail

      • encrypt

        public void encrypt​(java.security.PublicKey aeaPublicKey,
                            java.security.PrivateKey dsaPrivateKey,
                            byte[] macSecretKey,
                            SymmetricEncryptionAlgorithm SEA,
                            AsymmetricEncryptionAlgorithm AEA,
                            DigitalSignatureAlgorithm DSA,
                            MessageAuthenticationCodeAlgorithm MAC)
                     throws java.lang.Exception
        Encrypt object
        Parameters:
        aeaPublicKey - Public key for asymmetric encryption algorithm
        dsaPrivateKey - Private key for digital signature algorithm
        macSecretKey - Secret key for message authentication code algorithm
        SEA - Symmetric encryption algorithm
        AEA - Asymmetric encryption algorithm
        DSA - Digital signature algorithm
        MAC - Message authentication code algorithm
        Throws:
        java.lang.Exception - Encryption error
      • decrypt

        public void decrypt​(java.security.PrivateKey aeaPrivateKey,
                            java.security.PublicKey dsaPublicKey,
                            byte[] macSecretKey)
                     throws java.lang.Exception
        Дешифрование объекта
        Parameters:
        aeaPrivateKey - Private key for asymmetric encryption algorithm
        dsaPublicKey - Public key for digital signature algorithm
        macSecretKey - Secret key for message authentication code algorithm
        Throws:
        java.lang.Exception - Decryption error
      • getData

        public byte[] getData()
        Get data in the current state (encrypted or not, depends on what operations were executed with SecuredData)
        Returns:
        data Data in the current state