Advertisement
tpeierls

com.example.server.AwsCredentialsModule

Jan 23rd, 2012
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.06 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement