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

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


        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


        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()) {
                // -> data of a body part starts here
                state = 2;
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

          }

           
          // -> authenticated calls
          if (!method.equalsIgnoreCase( "POST" )) {
              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

            }

            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

           
            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

TOP

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

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.