Package com.cloud.bridge.service.core.s3

Examples of com.cloud.bridge.service.core.s3.S3AccessControlPolicy


    engineRequest.setAccessKey(UserContext.current().getAccessKey());
    engineRequest.setRequestTimestamp( cal );
    engineRequest.setSignature( "" );
    engineRequest.setBucketName((String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY));

    S3AccessControlPolicy engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest(engineRequest);
   
    // -> serialize using the apache's Axiom classes
    GetBucketAccessControlPolicyResponse onePolicy = S3SoapServiceImpl.toGetBucketAccessControlPolicyResponse( engineResponse );
 
    OutputStream os = response.getOutputStream();
View Full Code Here


    engineRequest.setAccessKey(UserContext.current().getAccessKey());
    engineRequest.setRequestTimestamp( cal );
    engineRequest.setSignature( "" );   // TODO - Consider providing signature in a future release which allows additional user description
    engineRequest.setBucketName((String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY));

    S3AccessControlPolicy engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest(engineRequest);
   
    // To allow the bucket acl policy result to be serialized via Axiom classes
    GetBucketAccessControlPolicyResponse onePolicy = S3SerializableServiceImplementation.toGetBucketAccessControlPolicyResponse( engineResponse );

    OutputStream outputStream = response.getOutputStream();
View Full Code Here

   
    // -> is this a request for a specific version of the object?  look for "versionId=" in the query string
    String queryString = request.getQueryString();
    if (null != queryString) engineRequest.setVersion( returnParameter( queryString, "versionId=" ));

    S3AccessControlPolicy engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest(engineRequest);
      int resultCode = engineResponse.getResultCode();
      if (200 != resultCode) {
          response.setStatus( resultCode );
          return;
      }
      String version = engineResponse.getVersion();
      if (null != version) response.addHeader( "x-amz-version-id", version );
     
 
    // To allow the get object acl policy result to be serialized via Axiom classes
    GetObjectAccessControlPolicyResponse onePolicy = S3SerializableServiceImplementation.toGetObjectAccessControlPolicyResponse( engineResponse )
View Full Code Here

        engineRequest.setAccessKey(UserContext.current().getAccessKey());
        engineRequest.setRequestTimestamp( cal );
        engineRequest.setSignature( "" );   // TODO - Consider providing signature in a future release which allows additional user description
        engineRequest.setBucketName((String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY));

        S3AccessControlPolicy engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest(engineRequest);

        // To allow the bucket acl policy result to be serialized via Axiom classes
        GetBucketAccessControlPolicyResponse onePolicy = S3SerializableServiceImplementation.toGetBucketAccessControlPolicyResponse( engineResponse );

        OutputStream outputStream = response.getOutputStream();
View Full Code Here

        int countMeta = 0;
        int state = 0;

        // [A] First parse all the parts out of the POST request and message body
        // -> bucket name is still encoded in a Host header
        S3AuthParams params = new S3AuthParams();
        List<S3MetaDataEntry> metaSet = new ArrayList<S3MetaDataEntry>()
        S3PutObjectInlineRequest engineRequest = new S3PutObjectInlineRequest();
        engineRequest.setBucketName( bucket );

        // -> the last body part contains the content that is used to write the S3 object, all
        //    other body parts are header values
        while( null != (oneLine = br.readLine()))
        {
            if ( oneLine.startsWith( lastBoundary ))
            {
                // -> this is the data of the object to put
                if (0 < temp.length())
                {
                    value = temp.toString();
                    temp.setLength( 0 );

                    engineRequest.setContentLength( value.length())
                    engineRequest.setDataAsString( value );
                }
                break;
            }
            else if ( oneLine.startsWith( boundary ))
            {
                // -> this is the header data
                if (0 < temp.length())
                {
                    value = temp.toString().trim();
                    temp.setLength( 0 );            
                    //System.out.println( "param: " + name + " = " + value );

                    if (name.equalsIgnoreCase( "key" )) {
                        engineRequest.setKey( value );
                    }
                    else if (name.equalsIgnoreCase( "x-amz-acl" )) {
                        engineRequest.setCannedAccess( value );
                    }
                    else if (isMetaTag) {
                        S3MetaDataEntry oneMeta = new S3MetaDataEntry();
                        oneMeta.setName( metaName );
                        oneMeta.setValue( value );
                        metaSet.add( oneMeta );
                        countMeta++;
                        metaName = null;
                    }

                    // -> build up the headers so we can do authentication on this POST
                    HeaderParam oneHeader = new HeaderParam();
                    oneHeader.setName( name );
                    oneHeader.setValue( value );
                    params.addHeader( oneHeader );
                }
                state = 1;
            }
            else if (1 == state && 0 == oneLine.length())
            {
View Full Code Here


            txn.start();
            // -> authenticated calls
            if ( !((method.equalsIgnoreCase( "POST" ) && !(request.getQueryString().equalsIgnoreCase("delete"))) ) ){
                S3AuthParams params = extractRequestHeaders( request );
                authenticateRequest( request, params );
            }

            ServletAction action = routeRequest(request);
            if ( action != null ) {
View Full Code Here

    /**
     * We are using the S3AuthParams class to hide where the header values are coming
     * from so that the authenticateRequest call can be made from several places.
     */
    public static S3AuthParams extractRequestHeaders( HttpServletRequest request ) {
        S3AuthParams params = new S3AuthParams();

        Enumeration headers = request.getHeaderNames();
        if (null != headers)
        {
            while( headers.hasMoreElements())
            {
                HeaderParam oneHeader = new HeaderParam();
                String headerName = (String)headers.nextElement();
                oneHeader.setName( headerName );
                oneHeader.setValue( request.getHeader( headerName ));
                params.addHeader( oneHeader );
            }
        }
        return params;
    }
View Full Code Here

        request.setAttribute(S3Constants.PLAIN_POST_SIGNATURE, signatureString);

        // -> authenticated calls
        try {
            // S3AuthParams params = extractRequestHeaders( request );
            S3AuthParams params = new S3AuthParams();
            HeaderParam headerParam1 = new HeaderParam("accessKey", accessKeyString);
            params.addHeader(headerParam1);
            HeaderParam headerParam2 = new HeaderParam("secretKey", signatureString);
            params.addHeader(headerParam2);
            authenticateRequest( request, params );
        }
        catch (Exception e)
        { logger.warn("Authentication details insufficient"); }
View Full Code Here

     *         even if it is set at null.
     */
    public OrderedPair<S3BucketPolicy,Integer> getBucketPolicy(String bucketName) {

        if (policyMap.containsKey( bucketName )) {
            S3BucketPolicy policy = policyMap.get( bucketName );
            return new OrderedPair<S3BucketPolicy,Integer>( policy, 0 );
        }
        else return new OrderedPair<S3BucketPolicy,Integer>( null, -1 );           // For case (1) where the map has no entry for bucketName
    }
View Full Code Here

        Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
        // [B] Place the policy into the database over writting an existing policy
        try {
            // -> first make sure that the policy is valid by parsing it
            PolicyParser parser = new PolicyParser();
            S3BucketPolicy sbp = parser.parse( policy, bucketName );
            bPolicyDao.deletePolicy(bucketName);

            if (null != policy && !policy.isEmpty()) {
                BucketPolicyVO bpolicy = new BucketPolicyVO(bucketName, client, policy);
                bpolicy = bPolicyDao.persist(bpolicy);
View Full Code Here

TOP

Related Classes of com.cloud.bridge.service.core.s3.S3AccessControlPolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.