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;
 
 import java.util.Map;
 
A convenient S3 object wrapper useful for crypto purposes.
 
 class S3ObjectWrapper implements Closeable {
     private final S3Object s3obj;
     private final S3ObjectId id;
     
     S3ObjectWrapper(S3Object s3objS3ObjectId id) {
         if (s3obj == null)
             throw new IllegalArgumentException();
         this. = s3obj;
         this. = id;
     }
 
     public S3ObjectId getS3ObjectId() {
         return ;
     }
 
         return .getObjectMetadata();
     }
 
     void setObjectMetadata(ObjectMetadata metadata) {
         .setObjectMetadata(metadata);
     }
 
         return .getObjectContent();
     }
 
     void setObjectContent(S3ObjectInputStream objectContent) {
         .setObjectContent(objectContent);
     }
     
     void setObjectContent(InputStream objectContent) {
         .setObjectContent(objectContent);
     }
 
     String getBucketName() {
         return .getBucketName();
     }
 
     void setBucketName(String bucketName) {
         .setBucketName(bucketName);
     }
 
     String getKey() {
         return .getKey();
     }
 
     void setKey(String key) {
         .setKey(key);
     }
     
         return .getRedirectLocation();
     }
     
     void setRedirectLocation(String redirectLocation) {
         .setRedirectLocation(redirectLocation);
     }
 
     @Override public String toString() {
         return .toString();
     }

    
Returns true if this S3 object is an instruction file; false otherwise.
 
    final boolean isInstructionFile() {
        ObjectMetadata metadata = .getObjectMetadata();
        Map<StringStringuserMeta = metadata.getUserMetadata();
        return userMeta != null
            && userMeta.containsKey(.);
    }

    
Returns true if this S3 object has the encryption information stored as user meta data; false otherwise.
    final boolean hasEncryptionInfo() {
        ObjectMetadata metadata = .getObjectMetadata();
        Map<StringStringuserMeta = metadata.getUserMetadata();
        return userMeta != null
            && userMeta.containsKey(.)
            && (userMeta.containsKey(.)
                || userMeta.containsKey(.));
    }

    
Converts and return the underlying S3 object as a json string.

Throws:
com.amazonaws.AmazonClientException if failed in JSON conversion.
    String toJsonString() {
        try {
            return from(.getObjectContent());
        } catch (Exception e) {
            throw new AmazonClientException("Error parsing JSON: " + e.getMessage());
        }
    }
    private static String from(InputStream isthrows IOException {
        if (is == null)
            return "";
        StringBuilder sb = new StringBuilder();
        try {
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(is));
            String line;
            while ((line = reader.readLine()) != null) {
                sb.append(line);
            }
        } finally {
            is.close();
        }
        return sb.toString();
    }
    @Override
    public void close() throws IOException {
        .close();
    }
    S3Object getS3Object() { return ; }

    
Returns the original crypto scheme used for encryption, which may differ from the crypto scheme used for decryption during, for example, a range-get operation.

Parameters:
instructionFile the instruction file of the s3 object; or null if there is none.
        if (instructionFile != null) {
            String cekAlgo = instructionFile.get(.);
            return ContentCryptoScheme.fromCEKAlgo(cekAlgo);
        }
        ObjectMetadata meta = .getObjectMetadata();
        Map<StringStringuserMeta = meta.getUserMetadata();
        String cekAlgo = userMeta.get(.);
        return ContentCryptoScheme.fromCEKAlgo(cekAlgo);
    }
New to GrepCode? Check out our FAQ X