SHARE
TWEET

com.example.server.AwsCredentialsModule

tpeierls Jan 23rd, 2012 232 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * This code is placed in the public domain by its author, Tim Peierls.
  3.  */
  4. package com.example.server;
  5. import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
  6.  
  7. /**
  8.  * A module that binds AWS credentials whether passed as "com.example.server.xxx"
  9.  * system properties or Elastic Beanstalk system properties. Client code inject
  10.  * these values using @Named, e.g.,
  11.  * <pre>
  12.  * @Inject AwsDependent(@Named(AWS_ACCESS_KEY_ID) String accessKeyId,
  13.  *                      @Named(AWS_SECRET_KEY) String secretKey) { ... }
  14.  * </pre>
  15.  */
  16. public class AwsCredentialsModule extends ConfigurationModule {
  17.  
  18.     public static final String AWS_ACCESS_KEY_ID        = "aws.access.key.id";
  19.     public static final String AWS_SECRET_KEY           = "aws.secret.key";
  20.  
  21.     @Override protected void bindConfigurations() {
  22.         bindProperty(AWS_ACCESS_KEY_ID)
  23.             .toValue("${com.example.server.accesskeyid|}${AWS_ACCESS_KEY_ID|}");
  24.         bindProperty(AWS_SECRET_KEY)
  25.             .toValue("${com.example.server.secretaccesskey|}${AWS_SECRET_KEY|}");
  26.     }
  27. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 60% OFF on Pastebin PRO accounts!
Top