com.aliyun.oss.crypto

## 类 CryptoModuleBase

- java.lang.Object
- - com.aliyun.oss.crypto.CryptoModuleBase

- 所有已实现的接口:
    CryptoModule

      public abstract class CryptoModuleBase
      extends Object
      implements CryptoModule

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `protected CryptoScheme` | `contentCryptoScheme`
    `protected CryptoConfiguration` | `cryptoConfig`
    `protected static int` | `DEFAULT_BUFFER_SIZE`
    `protected String` | `encryptionClientUserAgent`
    `protected EncryptionMaterials` | `encryptionMaterials`
    `protected OSSDirect` | `ossDirect`

  - ### 构造器概要

    构造器
    限定符 | 构造器和说明
    --- | ---
    `protected` | `CryptoModuleBase(OSSDirect ossDirect, EncryptionMaterials encryptionMaterials, CryptoConfiguration cryptoConfig)`

  - ### 方法概要

    方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected OSSObject` | `adjustToDesiredRange(OSSObject OSSobject, long[] range)` Adjusts the retrieved OSSObject so that the object contents contain only the range of bytes desired by the user.
    `protected ContentCryptoMaterial` | `buildContentCryptoMaterials()` Build a new content crypto material read-only.
    `protected ContentCryptoMaterial` | `createContentMaterialFromMetadata(ObjectMetadata meta)` Builds a new content crypto material for decrypting the object achieved.
    `protected OSSObject` | `decipherWithMetadata(GetObjectRequest req, long[] desiredRange, long[] cryptoRange, OSSObject retrieved)` Decrypt the encypted object by the metadata achieved.
    `protected SecretKey` | `generateCEK()` Returns a srcret key for encrypting content.
    `protected static Map<String,String>` | `getDescFromJsonString(String jsonString)`
    `OSSObject` | `getObjectSecurely(GetObjectRequest req)` Gets the object in OSS, if it was an encrypted object then decrypt it and return the result, otherwise return the object directly.
    `ObjectMetadata` | `getObjectSecurely(GetObjectRequest getObjectRequest, File file)` Gets the object in OSS and write it in a file, if it was an encrypted object then decrypt it, otherwise wirte the object directly.
    `static boolean` | `hasEncryptionInfo(ObjectMetadata metadata)` Checks there an encryption info in the metadata.
    `InitiateMultipartUploadResult` | `initiateMultipartUploadSecurely(InitiateMultipartUploadRequest req, MultipartUploadCryptoContext context)` Initiates the multipart upload request, and bulid the crypto context.
    `protected long` | `plaintextLength(PutObjectRequest request, ObjectMetadata metadata)` Returns the plaintext length from the request and metadata; or -1 if unknown.
    `PutObjectResult` | `putObjectSecurely(PutObjectRequest req)` Puts the object with data encrypted.
    `protected void` | `safeCloseSource(Closeable is)`
    `protected void` | `setUserAgent(WebServiceRequest req, String userAgent)`
    `protected ObjectMetadata` | `updateMetadataWithContentCryptoMaterial(ObjectMetadata metadata, File file, ContentCryptoMaterial contentCryptoMaterial)` Storages the encrytion materials in the object metadata.
    `protected ObjectMetadata` | `updateMetadataWithUploadContext(ObjectMetadata metadata, MultipartUploadCryptoContext context)` Add the upload part info into metadata.
    `UploadPartResult` | `uploadPartSecurely(UploadPartRequest req, MultipartUploadCryptoContext context)` Uploads the part secured.
    `protected PutObjectRequest` | `wrapPutRequestWithCipher(PutObjectRequest request, ContentCryptoMaterial cekMaterial)` Returns the given `PutObjectRequest` instance but has the content as input stream wrapped with a cipher, and configured with some meta data and user metadata.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 字段详细资料

    - #### DEFAULT_BUFFER_SIZE

          protected static final int DEFAULT_BUFFER_SIZE

      另请参阅:
        常量字段值

    - #### encryptionMaterials

          protected final EncryptionMaterials encryptionMaterials

    - #### contentCryptoScheme

          protected final CryptoScheme contentCryptoScheme

    - #### cryptoConfig

          protected final CryptoConfiguration cryptoConfig

    - #### ossDirect

          protected final OSSDirect ossDirect

    - #### encryptionClientUserAgent

          protected final String encryptionClientUserAgent

  - ### 构造器详细资料

    - #### CryptoModuleBase

          protected CryptoModuleBase(OSSDirect ossDirect,
                          EncryptionMaterials encryptionMaterials,
                          CryptoConfiguration cryptoConfig)

  - ### 方法详细资料

    - #### putObjectSecurely

          public PutObjectResult putObjectSecurely(PutObjectRequest req)

      Puts the object with data encrypted.
      指定者:
        `putObjectSecurely` 在接口中 `CryptoModule`
      参数:
        `req` - The put object request.
      返回:
        the result of the request.

    - #### wrapPutRequestWithCipher

          protected final PutObjectRequest wrapPutRequestWithCipher(PutObjectRequest request,
                                                  ContentCryptoMaterial cekMaterial)

      Returns the given `PutObjectRequest` instance but has the content as input stream wrapped with a cipher, and configured with some meta data and user metadata.

    - #### hasEncryptionInfo

          public static boolean hasEncryptionInfo(ObjectMetadata metadata)

      Checks there an encryption info in the metadata.

    - #### getObjectSecurely

          public OSSObject getObjectSecurely(GetObjectRequest req)

      Gets the object in OSS, if it was an encrypted object then decrypt it and return the result, otherwise return the object directly.
      指定者:
        `getObjectSecurely` 在接口中 `CryptoModule`

    - #### decipherWithMetadata

          protected OSSObject decipherWithMetadata(GetObjectRequest req,
                                       long[] desiredRange,
                                       long[] cryptoRange,
                                       OSSObject retrieved)

      Decrypt the encypted object by the metadata achieved.

    - #### safeCloseSource

          protected void safeCloseSource(Closeable is)

    - #### adjustToDesiredRange

          protected final OSSObject adjustToDesiredRange(OSSObject OSSobject,
                                       long[] range)

      Adjusts the retrieved OSSObject so that the object contents contain only the range of bytes desired by the user. Since encrypted contents can only be retrieved in CIPHER_BLOCK_SIZE (16 bytes) chunks, the OSSObject potentially contains more bytes than desired, so this method adjusts the contents range.

    - #### getObjectSecurely

          public ObjectMetadata getObjectSecurely(GetObjectRequest getObjectRequest,
                                         File file)

      Gets the object in OSS and write it in a file, if it was an encrypted object then decrypt it, otherwise wirte the object directly.
      指定者:
        `getObjectSecurely` 在接口中 `CryptoModule`

    - #### initiateMultipartUploadSecurely

          public InitiateMultipartUploadResult initiateMultipartUploadSecurely(InitiateMultipartUploadRequest req,
                                                                      MultipartUploadCryptoContext context)

      Initiates the multipart upload request, and bulid the crypto context.
      指定者:
        `initiateMultipartUploadSecurely` 在接口中 `CryptoModule`
      参数:
        `context` - The multi part crypto context contains the content crypto materials and upload information, it should created on the outside with part-size and data-size set done, the content crypto materials and other upload information will be filled after initiate request done.

    - #### uploadPartSecurely

          public UploadPartResult uploadPartSecurely(UploadPartRequest req,
                                            MultipartUploadCryptoContext context)

      Uploads the part secured.
      指定者:
        `uploadPartSecurely` 在接口中 `CryptoModule`

    - #### plaintextLength

          protected final long plaintextLength(PutObjectRequest request,
                             ObjectMetadata metadata)

      Returns the plaintext length from the request and metadata; or -1 if unknown.

    - #### buildContentCryptoMaterials

          protected final ContentCryptoMaterial buildContentCryptoMaterials()

      Build a new content crypto material read-only.

    - #### updateMetadataWithUploadContext

          protected final ObjectMetadata updateMetadataWithUploadContext(ObjectMetadata metadata,
                                                       MultipartUploadCryptoContext context)

      Add the upload part info into metadata.

    - #### updateMetadataWithContentCryptoMaterial

          protected final ObjectMetadata updateMetadataWithContentCryptoMaterial(ObjectMetadata metadata,
                                                               File file,
                                                               ContentCryptoMaterial contentCryptoMaterial)

      Storages the encrytion materials in the object metadata.

    - #### createContentMaterialFromMetadata

          protected ContentCryptoMaterial createContentMaterialFromMetadata(ObjectMetadata meta)

      Builds a new content crypto material for decrypting the object achieved.

    - #### getDescFromJsonString

          protected static Map<String,String> getDescFromJsonString(String jsonString)

      返回:
        the corresponding material description from the given json string.

    - #### generateCEK

          protected SecretKey generateCEK()

      Returns a srcret key for encrypting content.
      返回:
        content encrypt key.

    - #### setUserAgent

          protected void setUserAgent(WebServiceRequest req,
                          String userAgent)

Copyright © 2020. All Rights Reserved.