當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectMetadata.getUserMetadata方法代碼示例

本文整理匯總了Java中com.amazonaws.services.s3.model.ObjectMetadata.getUserMetadata方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectMetadata.getUserMetadata方法的具體用法?Java ObjectMetadata.getUserMetadata怎麽用?Java ObjectMetadata.getUserMetadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.amazonaws.services.s3.model.ObjectMetadata的用法示例。


在下文中一共展示了ObjectMetadata.getUserMetadata方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: populateMetadataWithEncryptionParams

import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
private void populateMetadataWithEncryptionParams(ObjectMetadata source, ObjectMetadata destination) {
    Map<String, String> userMetadataSource = source.getUserMetadata();
    Map<String, String> userMetadataDestination = destination.getUserMetadata();

    String[] headersToCopy = { Headers.CRYPTO_CEK_ALGORITHM,
            Headers.CRYPTO_IV, Headers.CRYPTO_KEY, Headers.CRYPTO_KEY_V2,
            Headers.CRYPTO_KEYWRAP_ALGORITHM, Headers.CRYPTO_TAG_LENGTH,
            Headers.MATERIALS_DESCRIPTION,
            Headers.UNENCRYPTED_CONTENT_LENGTH,
            Headers.UNENCRYPTED_CONTENT_MD5 };

    if (userMetadataSource != null) {
        if(userMetadataDestination == null){
            userMetadataDestination= new HashMap<String,String>();
            destination.setUserMetadata(userMetadataDestination);
        }

        String headerValue;
        for(String header : headersToCopy){
            headerValue = userMetadataSource.get(header);
            if(headerValue != null){
                userMetadataDestination.put(header, headerValue);
            }
        }
    }
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:27,代碼來源:CopyCallable.java

示例2: hasEncryptionInfo

import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
/**
 * Returns true if this S3 object has the encryption information stored
 * as user meta data; false otherwise.
 */
final boolean hasEncryptionInfo() {
    ObjectMetadata metadata = s3obj.getObjectMetadata();
    Map<String, String> userMeta = metadata.getUserMetadata();
    return userMeta != null
        && userMeta.containsKey(Headers.CRYPTO_IV)
        && (userMeta.containsKey(Headers.CRYPTO_KEY_V2)
            || userMeta.containsKey(Headers.CRYPTO_KEY));
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:13,代碼來源:S3ObjectWrapper.java

示例3: fromObjectMetadata0

import com.amazonaws.services.s3.model.ObjectMetadata; //導入方法依賴的package包/類
/**
 * @return a non-null content crypto material.
 */
private static ContentCryptoMaterial fromObjectMetadata0(
        ObjectMetadata metadata,
        EncryptionMaterialsAccessor kekMaterialAccessor,
        Provider securityProvider,
        long[] range,
        ExtraMaterialsDescription extra,
        boolean keyWrapExpected,
        AWSKMS kms) {
    // CEK and IV
    Map<String, String> userMeta = metadata.getUserMetadata();
    String b64key = userMeta.get(Headers.CRYPTO_KEY_V2);
    if (b64key == null) {
        b64key = userMeta.get(Headers.CRYPTO_KEY);
        if (b64key == null)
            throw new SdkClientException(
                    "Content encrypting key not found.");
    }
    byte[] cekWrapped = Base64.decode(b64key);
    byte[] iv = Base64.decode(userMeta.get(Headers.CRYPTO_IV));
    if (cekWrapped == null || iv == null) {
        throw new SdkClientException(
                "Content encrypting key or IV not found.");
    }
    // Material description
    String matdescStr = userMeta.get(Headers.MATERIALS_DESCRIPTION);
    final String keyWrapAlgo = userMeta.get(Headers.CRYPTO_KEYWRAP_ALGORITHM);
    final boolean isKMS = isKMSKeyWrapped(keyWrapAlgo);
    final Map<String, String> core = matdescFromJson(matdescStr);
    final Map<String, String> merged = isKMS || extra == null
            ? core : extra.mergeInto(core);
    final EncryptionMaterials materials;
    if (isKMS) {
        materials = new KMSEncryptionMaterials(
                core.get(KMSEncryptionMaterials.CUSTOMER_MASTER_KEY_ID));
        materials.addDescriptions(core);
    } else {
        materials = kekMaterialAccessor == null
            ? null
            : kekMaterialAccessor.getEncryptionMaterials(merged)
            ;
        if (materials == null) {
            throw new SdkClientException(
                    "Unable to retrieve the client encryption materials");
        }
    }
    // CEK algorithm
    String cekAlgo = userMeta.get(Headers.CRYPTO_CEK_ALGORITHM);
    boolean isRangeGet = range != null;
    // The content crypto scheme may vary depending on whether
    // it is a range get operation
    ContentCryptoScheme contentCryptoScheme =
        ContentCryptoScheme.fromCEKAlgo(cekAlgo, isRangeGet);
    if (isRangeGet) {
        // Adjust the IV as needed
        iv = contentCryptoScheme.adjustIV(iv, range[0]);
    } else {
        // Validate the tag length supported
        int tagLenExpected = contentCryptoScheme.getTagLengthInBits();
        if (tagLenExpected > 0) {
            String s = userMeta.get(Headers.CRYPTO_TAG_LENGTH);
            int tagLenActual = Integer.parseInt(s);
            if (tagLenExpected != tagLenActual) {
                throw new SdkClientException("Unsupported tag length: "
                        + tagLenActual + ", expected: " + tagLenExpected);
            }
        }
    }
    // Unwrap or decrypt the CEK
    if (keyWrapExpected && keyWrapAlgo == null)
        throw newKeyWrapException();
    SecretKey cek = cek(cekWrapped, keyWrapAlgo, materials,
            securityProvider, contentCryptoScheme, kms);
    return new ContentCryptoMaterial(merged, cekWrapped, keyWrapAlgo,
            contentCryptoScheme.createCipherLite(cek, iv,
                    Cipher.DECRYPT_MODE, securityProvider));
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:80,代碼來源:ContentCryptoMaterial.java


注:本文中的com.amazonaws.services.s3.model.ObjectMetadata.getUserMetadata方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。