Commit 9d3886ee authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading
+53 −0
Changes for PAWS_examples/java/ExampleAuthorizer.java: 53 added lines, 0 removed lines.
Original line number Diff line number Diff line
package org.jets3t.servlets.gatekeeper.impl;

import org.jets3t.servlets.gatekeeper.Authorizer;
import org.jets3t.service.utils.gatekeeper.GatekeeperMessage;
import org.jets3t.service.utils.gatekeeper.SignatureRequest;
import org.jets3t.servlets.gatekeeper.ClientInformation;

/**
 * Authorizer implementation to disallow DELETE requests from 
 * users not in the 'gatekeeper-admin' role. 
 */
public class ExampleAuthorizer extends Authorizer {

  /**
   * Default constructor - no configuration parameters are required. 
   */
  public ExampleAuthorizer(javax.servlet.ServletConfig servletConfig) 
      throws javax.servlet.ServletException 
  {
    super(servletConfig);
  }

  /**
   * Control which users can perform DELETE requests.
   */
  public boolean allowSignatureRequest(GatekeeperMessage requestMessage,
    ClientInformation clientInformation, SignatureRequest signatureRequest)
  {
    // Apply custom rules if this is a DELETE request.
    if (SignatureRequest.SIGNATURE_TYPE_DELETE.equals(
        signatureRequest.getSignatureType()))
    {            
      // Return true if the user is a member of the "gatekeeper-admin"
      // access role, false otherwise.
      return clientInformation.getHttpServletRequest()
          .isUserInRole("gatekeeper-admin");
    } else {
      // Requests for operations other than DELETE are always allowed.
      return true;            
    }
  }

  /**
   * Allow any user to obtain a listing of a bucket's contents.
   */
  public boolean allowBucketListingRequest(
    GatekeeperMessage requestMessage, ClientInformation clientInformation)
  {
    return true;
  }
  
}
+56 −0
Changes for PAWS_examples/java/MultiCommandPoolManager.java: 56 added lines, 0 removed lines.
Original line number Diff line number Diff line
import com.directthought.lifeguard.PoolManager;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class MultiCommandPoolManager extends PoolManager {
  private static Log logger = LogFactory
    .getLog(MultiCommandPoolManager.class);

  protected String moduleName = "";
  protected String notifyEmail = "";
  protected String logQueueName = "";
  protected String outputQueueName = "";
  protected String statusQueueName = "";

  public void setLogQueueName(String value) {
    logQueueName = value;
  }

  public void setOutputQueueName(String value) {
    outputQueueName = value;
  }

  public void setStatusQueueName(String value) {
    statusQueueName = value;
  }

  public void setModuleName(String value) {
    moduleName = value;
  }

  public void setNotifyEmail(String value) {
    notifyEmail = value;
  }

  protected String getUserData() {
    String userData =
      // User Data parameters available in standard Lifeguard configuration
      "ami=" + config.getServiceAMI() +
      "|input_queue_name=" + config.getServiceWorkQueue() +
      "|class_name=" + config.getServiceName() +
      "|aws_access_key_id=" + awsAccessId +
      "|aws_secret_access_key=" + awsSecretKey +

      // Parameters requiring additional configuration options
      "|module_name=" + moduleName +
      "|log_queue_name=" + logQueueName +
      "|output_queue_name=" + outputQueueName +
      "|status_queue_name=" + statusQueueName +
      "|notify_email=" + notifyEmail;

    logger.debug("User Data: " + userData);
    return userData;
  }

}
+1050 −0

File added.

Preview size limit exceeded, changes collapsed.

+781 −0

File added.

Preview size limit exceeded, changes collapsed.

+951 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading