Search in sources :

Example 1 with DataHeadBucket

use of com.pspace.ifs.ksan.gw.data.DataHeadBucket in project ksan by infinistor.

the class HeadBucket method process.

@Override
public void process() throws GWException {
    logger.info(GWConstants.LOG_HEAD_BUCKET_START);
    String bucket = s3Parameter.getBucketName();
    initBucketInfo(bucket);
    S3Bucket s3Bucket = new S3Bucket();
    s3Bucket.setCors(getBucketInfo().getCors());
    s3Bucket.setAccess(getBucketInfo().getAccess());
    s3Parameter.setBucket(s3Bucket);
    GWUtils.checkCors(s3Parameter);
    if (s3Parameter.isPublicAccess() && GWUtils.isIgnorePublicAcls(s3Parameter)) {
        throw new GWException(GWErrorCode.ACCESS_DENIED, s3Parameter);
    }
    checkGrantBucket(s3Parameter.isPublicAccess(), String.valueOf(s3Parameter.getUser().getUserId()), GWConstants.GRANT_READ);
    DataHeadBucket dataHeadBucket = new DataHeadBucket(s3Parameter);
    dataHeadBucket.extract();
    String expectedBucketOwner = dataHeadBucket.getExpectedBucketOwner();
    if (!Strings.isNullOrEmpty(expectedBucketOwner)) {
        if (!isBucketOwner(expectedBucketOwner)) {
            throw new GWException(GWErrorCode.ACCESS_DENIED, s3Parameter);
        }
    }
    if (isGrant(String.valueOf(s3Parameter.getUser().getUserId()), GWConstants.GRANT_READ)) {
        s3Parameter.getResponse().setStatus(HttpServletResponse.SC_OK);
    } else {
        throw new GWException(GWErrorCode.ACCESS_DENIED, s3Parameter);
    }
}
Also used : S3Bucket(com.pspace.ifs.ksan.gw.identity.S3Bucket) DataHeadBucket(com.pspace.ifs.ksan.gw.data.DataHeadBucket) GWException(com.pspace.ifs.ksan.gw.exception.GWException)

Aggregations

DataHeadBucket (com.pspace.ifs.ksan.gw.data.DataHeadBucket)1 GWException (com.pspace.ifs.ksan.gw.exception.GWException)1 S3Bucket (com.pspace.ifs.ksan.gw.identity.S3Bucket)1