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

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


            logger.error("executeUploadPart failed due to " + e.getMessage(), e)
            response.setStatus(500);
            return;
        }

        S3PutObjectInlineRequest engineRequest = new S3PutObjectInlineRequest();
        engineRequest.setBucketName(bucket);
        engineRequest.setKey(key);
        engineRequest.setContentLength(contentLength);
        DataHandler dataHandler = new DataHandler(new ServletRequestDataSource(request));
        engineRequest.setData(dataHandler);

        S3PutObjectInlineResponse engineResponse = ServiceProvider.getInstance().getS3Engine().saveUploadPart( engineRequest, uploadId, partNumber );
        if (null != engineResponse.getETag()) response.setHeader("ETag", "\"" + engineResponse.getETag() + "\"");
        response.setStatus(engineResponse.getResultCode());
    }
View Full Code Here


     *
     * @param request
     * @param response
     */
    private void processDimeRequest(HttpServletRequest request, HttpServletResponse response) {
        S3PutObjectRequest  putRequest  = null;
        S3PutObjectResponse putResponse = null;
        int                 bytesRead   = 0;

        S3Engine engine = new S3Engine();

        try {  
            logRequest(request);

            MultiPartDimeInputStream ds = new MultiPartDimeInputStream( request.getInputStream());

            // -> the first stream MUST be the SOAP party
            if (ds.nextInputStream())
            {
                //logger.debug( "DIME msg [" + ds.getStreamType() + "," + ds.getStreamTypeFormat() + "," + ds.getStreamId() + "]" );
                byte[] buffer = new byte[8192];
                bytesRead = ds.read( buffer, 0, 8192 );
                //logger.debug( "DIME SOAP Bytes read: " + bytesRead );
                ByteArrayInputStream bis = new ByteArrayInputStream( buffer, 0, bytesRead );
                putRequest = toEnginePutObjectRequest( bis );
            }

            // -> we only need to support a DIME message with two bodyparts
            if (null != putRequest && ds.nextInputStream())
            {
                InputStream is = ds.getInputStream();
                putRequest.setData( is );
            }

            // -> need to do SOAP level auth here, on failure return the SOAP fault
            StringBuffer xml = new StringBuffer();
            String AWSAccessKey = putRequest.getAccessKey();
            UserInfo info = ServiceProvider.getInstance().getUserInfo(AWSAccessKey);
            try
            {   S3SoapAuth.verifySignature( putRequest.getSignature(), "PutObject", putRequest.getRawTimestamp(), AWSAccessKey, info.getSecretKey());    

            } catch( AxisFault e ) {
                String reason = e.toString();
                int start = reason.indexOf( ".AxisFault:" );
                if (-1 != start) reason = reason.substring( start+11 );
View Full Code Here

        NodeList        children = null;
        String          temp     = null;
        String          element  = null;
        int             count    = 0;

        S3PutObjectRequest request = new S3PutObjectRequest();

        // [A] Pull out the simple nodes first
        NodeList part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Bucket" );
        if (null != part)
        {
            if (null != (contents = part.item( 0 )))
                request.setBucketName( contents.getFirstChild().getNodeValue());
       
        part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Key" );
        if (null != part)
        {
            if (null != (contents = part.item( 0 )))
                request.setKey( contents.getFirstChild().getNodeValue());
        }   
        part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "ContentLength" );
        if (null != part)
        {
            if (null != (contents = part.item( 0 )))
            {
                String length = contents.getFirstChild().getNodeValue();
                if (null != length) request.setContentLength( Long.decode( length ));
            }
        }   
        part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "AWSAccessKeyId" );
        if (null != part)
        {
            if (null != (contents = part.item( 0 )))
                request.setAccessKey( contents.getFirstChild().getNodeValue());
        }   
        part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Signature" );
        if (null != part)
        {
            if (null != (contents = part.item( 0 )))
                request.setSignature( contents.getFirstChild().getNodeValue());
        }   
        part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Timestamp" );
        if (null != part)
        {
            if (null != (contents = part.item( 0 )))
                request.setRawTimestamp( contents.getFirstChild().getNodeValue());
       
        part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "StorageClass" );
        if (null != part)
        {
            if (null != (contents = part.item( 0 )))
                request.setStorageClass( contents.getFirstChild().getNodeValue());
        }   
        part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Credential" );
        if (null != part)
        {
            if (null != (contents = part.item( 0 )))
                request.setCredential( contents.getFirstChild().getNodeValue());
        }


        // [B] Get a list of all 'Metadata' elements
        part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Metadata" );
        if (null != part)
        {
            count = part.getLength();
            S3MetaDataEntry[] metaEntry = new S3MetaDataEntry[ count ];

            for( int i=0; i < count; i++ )
            {
                parent = part.item(i);
                metaEntry[i] = new S3MetaDataEntry();

                // -> get a list of all the children elements of the 'Metadata' parent element
                if (null != (children = parent.getChildNodes()))
                {
                    int numChildren = children.getLength();
                    for( int j=0; j < numChildren; j++ )
                    {
                        contents = children.item( j );
                        element = contents.getNodeName().trim();
                        if ( element.endsWith( "Name" ))
                        {
                            temp = contents.getFirstChild().getNodeValue();
                            if (null != temp) metaEntry[i].setName( temp );
                        }
                        else if (element.endsWith( "Value" ))
                        {
                            temp = contents.getFirstChild().getNodeValue();
                            if (null != temp) metaEntry[i].setValue( temp );
                        }
                    }
                }
            }
            request.setMetaEntries( metaEntry );
        }

        // [C] Get a list of all Grant elements in an AccessControlList
        part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Grant" );
        if (null != part)
        {
            S3AccessControlList engineAcl = new S3AccessControlList();

            count = part.getLength();
            for( int i=0; i < count; i++ )
            {
                parent = part.item(i);
                S3Grant engineGrant = new S3Grant();

                // -> get a list of all the children elements of the 'Grant' parent element
                if (null != (children = parent.getChildNodes()))
                {
                    int numChildren = children.getLength();
                    for( int j=0; j < numChildren; j++ )
                    {
                        contents = children.item( j );
                        element  = contents.getNodeName().trim();
                        if ( element.endsWith( "Grantee" ))
                        {
                            NamedNodeMap attbs = contents.getAttributes();
                            if (null != attbs)
                            {
                                Node type = attbs.getNamedItemNS( "http://www.w3.org/2001/XMLSchema-instance", "type" );
                                if ( null != type )
                                    temp = type.getFirstChild().getNodeValue().trim();
                                else temp = null;

                                if ( null != temp && temp.equalsIgnoreCase( "CanonicalUser" ))
                                {
                                    engineGrant.setGrantee(SAcl.GRANTEE_USER);
                                    engineGrant.setCanonicalUserID( getChildNodeValue( contents, "ID" ));
                                }
                                else throw new UnsupportedOperationException( "Missing http://www.w3.org/2001/XMLSchema-instance:type value" );
                            }
                        }
                        else if (element.endsWith( "Permission" ))
                        {
                            temp = contents.getFirstChild().getNodeValue().trim();
                            if (temp.equalsIgnoreCase("READ"        )) engineGrant.setPermission(SAcl.PERMISSION_READ);
                            else if (temp.equalsIgnoreCase("WRITE"       )) engineGrant.setPermission(SAcl.PERMISSION_WRITE);
                            else if (temp.equalsIgnoreCase("READ_ACP"    )) engineGrant.setPermission(SAcl.PERMISSION_READ_ACL);
                            else if (temp.equalsIgnoreCase("WRITE_ACP"   )) engineGrant.setPermission(SAcl.PERMISSION_WRITE_ACL);
                            else if (temp.equalsIgnoreCase("FULL_CONTROL")) engineGrant.setPermission(SAcl.PERMISSION_FULL);
                            else throw new UnsupportedOperationException( "Unsupported permission: " + temp );
                        }
                    }
                    engineAcl.addGrant( engineGrant );
                }
            }
            request.setAcl( engineAcl );
        }
        return request;
    }
View Full Code Here

    response.flushBuffer();
  }
 
  public void executePutBucketAcl(HttpServletRequest request, HttpServletResponse response) throws IOException
  {
    S3PutObjectRequest putRequest = null;
   
    // -> reuse the Access Control List parsing code that was added to support DIME
    String bucketName = (String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY);
    try {
        putRequest = S3RestServlet.toEnginePutObjectRequest( request.getInputStream());
    }
    catch( Exception e ) {
      throw new IOException( e.toString());
    }
   
    // -> reuse the SOAP code to save the passed in ACLs
    S3SetBucketAccessControlPolicyRequest engineRequest = new S3SetBucketAccessControlPolicyRequest();
    engineRequest.setBucketName( bucketName );
    engineRequest.setAcl( putRequest.getAcl());
   
      S3Response engineResponse = ServiceProvider.getInstance().getS3Engine().handleRequest(engineRequest)
      response.setStatus( engineResponse.getResultCode());
  }
View Full Code Here

    }
  }
 
  private void executePutObjectAcl(HttpServletRequest request, HttpServletResponse response) throws IOException
  {
    S3PutObjectRequest putRequest = null;
   
    // -> reuse the Access Control List parsing code that was added to support DIME
    String bucketName = (String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY);
    String key        = (String)request.getAttribute(S3Constants.OBJECT_ATTR_KEY);
    try {
        putRequest = S3RestServlet.toEnginePutObjectRequest( request.getInputStream());
    }
    catch( Exception e ) {
      throw new IOException( e.toString());
    }
     
    // -> reuse the SOAP code to save the passed in ACLs
    S3SetObjectAccessControlPolicyRequest engineRequest = new S3SetObjectAccessControlPolicyRequest();
    engineRequest.setBucketName( bucketName );
    engineRequest.setKey( key );
    engineRequest.setAcl( putRequest.getAcl());

    // -> 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=" ));
View Full Code Here

     *
     * @param request
     * @param response
     */
    private void processDimeRequest(HttpServletRequest request, HttpServletResponse response) {
      S3PutObjectRequest  putRequest  = null;
      S3PutObjectResponse putResponse = null;
      int                 bytesRead   = 0;
     
        S3Engine engine = new S3Engine();
     
        try {  
          logRequest(request);
         
            MultiPartDimeInputStream ds = new MultiPartDimeInputStream( request.getInputStream());
         
            // -> the first stream MUST be the SOAP party
            if (ds.nextInputStream())
            {
                //logger.debug( "DIME msg [" + ds.getStreamType() + "," + ds.getStreamTypeFormat() + "," + ds.getStreamId() + "]" );
                byte[] buffer = new byte[8192];
                bytesRead = ds.read( buffer, 0, 8192 );
                //logger.debug( "DIME SOAP Bytes read: " + bytesRead );
                ByteArrayInputStream bis = new ByteArrayInputStream( buffer, 0, bytesRead );
                putRequest = toEnginePutObjectRequest( bis );
            }
           
            // -> we only need to support a DIME message with two bodyparts
            if (null != putRequest && ds.nextInputStream())
            {
              InputStream is = ds.getInputStream();
              putRequest.setData( is );
            }

            // -> need to do SOAP level auth here, on failure return the SOAP fault
            StringBuffer xml = new StringBuffer();
            String AWSAccessKey = putRequest.getAccessKey();
        UserInfo info = ServiceProvider.getInstance().getUserInfo(AWSAccessKey);
        try
        {   S3SoapAuth.verifySignature( putRequest.getSignature(), "PutObject", putRequest.getRawTimestamp(), AWSAccessKey, info.getSecretKey());    
       
        } catch( AxisFault e ) {
          String reason = e.toString();
          int start = reason.indexOf( ".AxisFault:" );
          if (-1 != start) reason = reason.substring( start+11 );
View Full Code Here

    NodeList        children = null;
    String          temp     = null;
    String          element  = null;
    int             count    = 0;

    S3PutObjectRequest request = new S3PutObjectRequest();

    // [A] Pull out the simple nodes first
    NodeList part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Bucket" );
    if (null != part)
    {
        if (null != (contents = part.item( 0 )))
          request.setBucketName( contents.getFirstChild().getNodeValue());
   
    part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Key" );
    if (null != part)
    {
        if (null != (contents = part.item( 0 )))
          request.setKey( contents.getFirstChild().getNodeValue());
    }   
    part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "ContentLength" );
    if (null != part)
    {
        if (null != (contents = part.item( 0 )))
        {
          String length = contents.getFirstChild().getNodeValue();
          if (null != length) request.setContentLength( Long.decode( length ));
        }
    }   
    part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "AWSAccessKeyId" );
    if (null != part)
    {
        if (null != (contents = part.item( 0 )))
          request.setAccessKey( contents.getFirstChild().getNodeValue());
    }   
    part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Signature" );
    if (null != part)
    {
        if (null != (contents = part.item( 0 )))
          request.setSignature( contents.getFirstChild().getNodeValue());
    }   
    part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Timestamp" );
    if (null != part)
    {
        if (null != (contents = part.item( 0 )))
          request.setRawTimestamp( contents.getFirstChild().getNodeValue());
   
    part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "StorageClass" );
    if (null != part)
    {
        if (null != (contents = part.item( 0 )))
          request.setStorageClass( contents.getFirstChild().getNodeValue());
    }   
    part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Credential" );
    if (null != part)
    {
        if (null != (contents = part.item( 0 )))
          request.setCredential( contents.getFirstChild().getNodeValue());
    }
   
   
    // [B] Get a list of all 'Metadata' elements
    part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Metadata" );
    if (null != part)
    {
      count = part.getLength();
      S3MetaDataEntry[] metaEntry = new S3MetaDataEntry[ count ];
     
      for( int i=0; i < count; i++ )
      {
         parent = part.item(i);
         metaEntry[i] = new S3MetaDataEntry();

         // -> get a list of all the children elements of the 'Metadata' parent element
         if (null != (children = parent.getChildNodes()))
         {
           int numChildren = children.getLength();
           for( int j=0; j < numChildren; j++ )
           {
              contents = children.item( j );
              element = contents.getNodeName().trim();
              if ( element.endsWith( "Name" ))
              {
                 temp = contents.getFirstChild().getNodeValue();
                 if (null != temp) metaEntry[i].setName( temp );
              }
              else if (element.endsWith( "Value" ))
              {
                 temp = contents.getFirstChild().getNodeValue();
                 if (null != temp) metaEntry[i].setValue( temp );
              }
           }
         }
      }
      request.setMetaEntries( metaEntry );
    }

    // [C] Get a list of all Grant elements in an AccessControlList
    part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Grant" );
    if (null != part)
    {
      S3AccessControlList engineAcl = new S3AccessControlList();

      count = part.getLength();
            for( int i=0; i < count; i++ )
            {
         parent = part.item(i);
         S3Grant engineGrant = new S3Grant();

         // -> get a list of all the children elements of the 'Grant' parent element
         if (null != (children = parent.getChildNodes()))
         {
           int numChildren = children.getLength();
           for( int j=0; j < numChildren; j++ )
           {
            contents = children.item( j );
            element  = contents.getNodeName().trim();
            if ( element.endsWith( "Grantee" ))
            {
                         NamedNodeMap attbs = contents.getAttributes();
                         if (null != attbs)
                         {
                           Node type = attbs.getNamedItemNS( "http://www.w3.org/2001/XMLSchema-instance", "type" );
                           if ( null != type )
                              temp = type.getFirstChild().getNodeValue().trim();
                           else temp = null;
                          
                 if ( null != temp && temp.equalsIgnoreCase( "CanonicalUser" ))
                 {
                      engineGrant.setGrantee(SAcl.GRANTEE_USER);
                    engineGrant.setCanonicalUserID( getChildNodeValue( contents, "ID" ));
                 }
                 else throw new UnsupportedOperationException( "Missing http://www.w3.org/2001/XMLSchema-instance:type value" );
                         }
            }
            else if (element.endsWith( "Permission" ))
            {
                 temp = contents.getFirstChild().getNodeValue().trim();
                    if (temp.equalsIgnoreCase("READ"        )) engineGrant.setPermission(SAcl.PERMISSION_READ);
               else if (temp.equalsIgnoreCase("WRITE"       )) engineGrant.setPermission(SAcl.PERMISSION_WRITE);
               else if (temp.equalsIgnoreCase("READ_ACP"    )) engineGrant.setPermission(SAcl.PERMISSION_READ_ACL);
               else if (temp.equalsIgnoreCase("WRITE_ACP"   )) engineGrant.setPermission(SAcl.PERMISSION_WRITE_ACL);
               else if (temp.equalsIgnoreCase("FULL_CONTROL")) engineGrant.setPermission(SAcl.PERMISSION_FULL);
               else throw new UnsupportedOperationException( "Unsupported permission: " + temp );
            }
           }
           engineAcl.addGrant( engineGrant );
         }
            }
        request.setAcl( engineAcl );
    }
    return request;
  }
View Full Code Here

     *
     * @param request
     * @param response
     */
    private void processDimeRequest(HttpServletRequest request, HttpServletResponse response) {
        S3PutObjectRequest putRequest = null;
        S3PutObjectResponse putResponse = null;
        int bytesRead = 0;

        S3Engine engine = new S3Engine();

        try {
            logRequest(request);

            MultiPartDimeInputStream ds = new MultiPartDimeInputStream(request.getInputStream());

            // -> the first stream MUST be the SOAP party
            if (ds.nextInputStream()) {
                //logger.debug( "DIME msg [" + ds.getStreamType() + "," + ds.getStreamTypeFormat() + "," + ds.getStreamId() + "]" );
                byte[] buffer = new byte[8192];
                bytesRead = ds.read(buffer, 0, 8192);
                //logger.debug( "DIME SOAP Bytes read: " + bytesRead );
                ByteArrayInputStream bis = new ByteArrayInputStream(buffer, 0, bytesRead);
                putRequest = toEnginePutObjectRequest(bis);
            }

            // -> we only need to support a DIME message with two bodyparts
            if (null != putRequest && ds.nextInputStream()) {
                InputStream is = ds.getInputStream();
                putRequest.setData(is);
            }

            // -> need to do SOAP level auth here, on failure return the SOAP fault
            StringBuffer xml = new StringBuffer();
            String AWSAccessKey = putRequest.getAccessKey();
            UserInfo info = ServiceProvider.getInstance().getUserInfo(AWSAccessKey);
            try {
                S3SoapAuth.verifySignature(putRequest.getSignature(), "PutObject", putRequest.getRawTimestamp(), AWSAccessKey, info.getSecretKey());

            } catch (AxisFault e) {
                String reason = e.toString();
                int start = reason.indexOf(".AxisFault:");
                if (-1 != start)
View Full Code Here

        NodeList children = null;
        String temp = null;
        String element = null;
        int count = 0;

        S3PutObjectRequest request = new S3PutObjectRequest();

        // [A] Pull out the simple nodes first
        NodeList part = getElement(doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Bucket");
        if (null != part) {
            if (null != (contents = part.item(0)))
                request.setBucketName(contents.getFirstChild().getNodeValue());
        }
        part = getElement(doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Key");
        if (null != part) {
            if (null != (contents = part.item(0)))
                request.setKey(contents.getFirstChild().getNodeValue());
        }
        part = getElement(doc, "http://s3.amazonaws.com/doc/2006-03-01/", "ContentLength");
        if (null != part) {
            if (null != (contents = part.item(0))) {
                String length = contents.getFirstChild().getNodeValue();
                if (null != length)
                    request.setContentLength(Long.decode(length));
            }
        }
        part = getElement(doc, "http://s3.amazonaws.com/doc/2006-03-01/", "AWSAccessKeyId");
        if (null != part) {
            if (null != (contents = part.item(0)))
                request.setAccessKey(contents.getFirstChild().getNodeValue());
        }
        part = getElement(doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Signature");
        if (null != part) {
            if (null != (contents = part.item(0)))
                request.setSignature(contents.getFirstChild().getNodeValue());
        }
        part = getElement(doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Timestamp");
        if (null != part) {
            if (null != (contents = part.item(0)))
                request.setRawTimestamp(contents.getFirstChild().getNodeValue());
        }
        part = getElement(doc, "http://s3.amazonaws.com/doc/2006-03-01/", "StorageClass");
        if (null != part) {
            if (null != (contents = part.item(0)))
                request.setStorageClass(contents.getFirstChild().getNodeValue());
        }
        part = getElement(doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Credential");
        if (null != part) {
            if (null != (contents = part.item(0)))
                request.setCredential(contents.getFirstChild().getNodeValue());
        }

        // [B] Get a list of all 'Metadata' elements
        part = getElement(doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Metadata");
        if (null != part) {
            count = part.getLength();
            S3MetaDataEntry[] metaEntry = new S3MetaDataEntry[count];

            for (int i = 0; i < count; i++) {
                parent = part.item(i);
                metaEntry[i] = new S3MetaDataEntry();

                // -> get a list of all the children elements of the 'Metadata' parent element
                if (null != (children = parent.getChildNodes())) {
                    int numChildren = children.getLength();
                    for (int j = 0; j < numChildren; j++) {
                        contents = children.item(j);
                        element = contents.getNodeName().trim();
                        if (element.endsWith("Name")) {
                            temp = contents.getFirstChild().getNodeValue();
                            if (null != temp)
                                metaEntry[i].setName(temp);
                        } else if (element.endsWith("Value")) {
                            temp = contents.getFirstChild().getNodeValue();
                            if (null != temp)
                                metaEntry[i].setValue(temp);
                        }
                    }
                }
            }
            request.setMetaEntries(metaEntry);
        }

        // [C] Get a list of all Grant elements in an AccessControlList
        part = getElement(doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Grant");
        if (null != part) {
            S3AccessControlList engineAcl = new S3AccessControlList();

            count = part.getLength();
            for (int i = 0; i < count; i++) {
                parent = part.item(i);
                S3Grant engineGrant = new S3Grant();

                // -> get a list of all the children elements of the 'Grant' parent element
                if (null != (children = parent.getChildNodes())) {
                    int numChildren = children.getLength();
                    for (int j = 0; j < numChildren; j++) {
                        contents = children.item(j);
                        element = contents.getNodeName().trim();
                        if (element.endsWith("Grantee")) {
                            NamedNodeMap attbs = contents.getAttributes();
                            if (null != attbs) {
                                Node type = attbs.getNamedItemNS("http://www.w3.org/2001/XMLSchema-instance", "type");
                                if (null != type)
                                    temp = type.getFirstChild().getNodeValue().trim();
                                else
                                    temp = null;

                                if (null != temp && temp.equalsIgnoreCase("CanonicalUser")) {
                                    engineGrant.setGrantee(SAcl.GRANTEE_USER);
                                    engineGrant.setCanonicalUserID(getChildNodeValue(contents, "ID"));
                                } else
                                    throw new UnsupportedOperationException("Missing http://www.w3.org/2001/XMLSchema-instance:type value");
                            }
                        } else if (element.endsWith("Permission")) {
                            temp = contents.getFirstChild().getNodeValue().trim();
                            if (temp.equalsIgnoreCase("READ"))
                                engineGrant.setPermission(SAcl.PERMISSION_READ);
                            else if (temp.equalsIgnoreCase("WRITE"))
                                engineGrant.setPermission(SAcl.PERMISSION_WRITE);
                            else if (temp.equalsIgnoreCase("READ_ACP"))
                                engineGrant.setPermission(SAcl.PERMISSION_READ_ACL);
                            else if (temp.equalsIgnoreCase("WRITE_ACP"))
                                engineGrant.setPermission(SAcl.PERMISSION_WRITE_ACL);
                            else if (temp.equalsIgnoreCase("FULL_CONTROL"))
                                engineGrant.setPermission(SAcl.PERMISSION_FULL);
                            else
                                throw new UnsupportedOperationException("Unsupported permission: " + temp);
                        }
                    }
                    engineAcl.addGrant(engineGrant);
                }
            }
            request.setAcl(engineAcl);
        }
        return request;
    }
View Full Code Here

     *
     * @param request
     * @param response
     */
    private void processDimeRequest(HttpServletRequest request, HttpServletResponse response) {
      S3PutObjectRequest  putRequest  = null;
      S3PutObjectResponse putResponse = null;
      int                 bytesRead   = 0;
     
        S3Engine engine = new S3Engine();
     
        try {  
          logRequest(request);
         
            MultiPartDimeInputStream ds = new MultiPartDimeInputStream( request.getInputStream());
         
            // -> the first stream MUST be the SOAP party
            if (ds.nextInputStream())
            {
                //logger.debug( "DIME msg [" + ds.getStreamType() + "," + ds.getStreamTypeFormat() + "," + ds.getStreamId() + "]" );
                byte[] buffer = new byte[8192];
                bytesRead = ds.read( buffer, 0, 8192 );
                //logger.debug( "DIME SOAP Bytes read: " + bytesRead );
                ByteArrayInputStream bis = new ByteArrayInputStream( buffer, 0, bytesRead );
                putRequest = toEnginePutObjectRequest( bis );
            }
           
            // -> we only need to support a DIME message with two bodyparts
            if (null != putRequest && ds.nextInputStream())
            {
              InputStream is = ds.getInputStream();
              putRequest.setData( is );
            }

            // -> need to do SOAP level auth here, on failure return the SOAP fault
            StringBuffer xml = new StringBuffer();
            String AWSAccessKey = putRequest.getAccessKey();
        UserInfo info = ServiceProvider.getInstance().getUserInfo(AWSAccessKey);
        try
        {   S3SoapAuth.verifySignature( putRequest.getSignature(), "PutObject", putRequest.getRawTimestamp(), AWSAccessKey, info.getSecretKey());    
       
        } catch( AxisFault e ) {
          String reason = e.toString();
          int start = reason.indexOf( ".AxisFault:" );
          if (-1 != start) reason = reason.substring( start+11 );
View Full Code Here

TOP

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

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.