Skip to content

Commit 67613cd

Browse files
authored
Merge pull request #1 from gbailey/master
Creation
2 parents b87fd26 + 7b506d8 commit 67613cd

File tree

16 files changed

+2097
-0
lines changed

16 files changed

+2097
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea/
2+
build
3+
target/
4+
*.iml

README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,89 @@
22

33
The AWS Secrets Manager Java caching client enables in-process caching of secrets for Java applications.
44

5+
## Getting Started
6+
7+
### Required Prerequisites
8+
To use this client you must have:
9+
10+
* **A Java 8 development environment**
11+
12+
If you do not have one, go to [Java SE Downloads](https://www.oracle.com/technetwork/java/javase/downloads/index.html) on the Oracle website, then download and install the Java SE Development Kit (JDK). Java 8 or higher is recommended.
13+
14+
An Amazon Web Services (AWS) account to access secrets stored in AWS Secrets Manager and use AWS SDK for Java.
15+
16+
* **To create an AWS account**, go to [Sign In or Create an AWS Account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) and then choose **I am a new user.** Follow the instructions to create an AWS account.
17+
18+
* **To create a secret in AWS Secrets Manager**, go to [Creating Secrets](https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_create-basic-secret.html) and follow the instructions on that page.
19+
20+
* **To download and install the AWS SDK for Java**, go to [Installing the AWS SDK for Java](https://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/java-dg-install-sdk.html) in the AWS SDK for Java documentation and then follow the instructions on that page.
21+
22+
### Download
23+
24+
You can get the latest release from Maven:
25+
26+
```xml
27+
<dependency>
28+
<groupId>com.amazonaws.secretsmanager</groupId>
29+
<artifactId>aws-secretsmanager-caching-java</artifactId>
30+
<version>1.0.0</version>
31+
</dependency>
32+
```
33+
34+
Don't forget to enable the download of snapshot jars from Maven:
35+
36+
```xml
37+
<profiles>
38+
<profile>
39+
<id>allow-snapshots</id>
40+
<activation><activeByDefault>true</activeByDefault></activation>
41+
<repositories>
42+
<repository>
43+
<id>snapshots-repo</id>
44+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
45+
<releases><enabled>false</enabled></releases>
46+
<snapshots><enabled>true</enabled></snapshots>
47+
</repository>
48+
</repositories>
49+
</profile>
50+
</profiles>
51+
```
52+
53+
### Get Started
54+
55+
The following code sample demonstrates how to get started:
56+
57+
1. Instantiate the caching client.
58+
2. Request secret.
59+
60+
```java
61+
// This example shows how an AWS Lambda function can be written
62+
// to retrieve a cached secret from AWS Secrets Manager caching
63+
// client.
64+
package com.amazonaws.secretsmanager.caching.examples;
65+
66+
import com.amazonaws.services.lambda.runtime.Context;
67+
import com.amazonaws.services.lambda.runtime.RequestHandler;
68+
import com.amazonaws.services.lambda.runtime.LambdaLogger;
69+
70+
import com.amazonaws.secretsmanager.caching.SecretCache;
71+
72+
/**
73+
* SampleClass.
74+
*/
75+
public class SampleClass implements RequestHandler<String, String> {
76+
77+
private final SecretCache cache = new SecretCache();
78+
79+
@Override
80+
public String handleRequest(String secretId, Context context) {
81+
final String secret = cache.getSecretString(secretId);
82+
// Use secret to connect to secured resource.
83+
return "Success!";
84+
}
85+
}
86+
```
87+
588
## License
689

790
This library is licensed under the Apache 2.0 License.

config/checkstyle/checkstyle.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
4+
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
5+
6+
<module name="Checker">
7+
<module name="FileTabCharacter"/>
8+
<module name="TreeWalker">
9+
<module name="UnusedImports"/>
10+
<module name="NeedBraces"/>
11+
<module name="EqualsHashCode"/>
12+
<module name="EmptyStatement"/>
13+
<module name="EqualsAvoidNull"/>
14+
<module name="HideUtilityClassConstructor"/>
15+
<module name="InterfaceIsType"/>
16+
<module name="MissingSwitchDefault"/>
17+
<module name="MultipleVariableDeclarations"/>
18+
<module name="OneStatementPerLine"/>
19+
<module name="NoClone"/>
20+
<module name="NoFinalizer"/>
21+
<module name="RedundantImport"/>
22+
<module name="DefaultComesLast"/>
23+
<module name="SuppressWarningsHolder" />
24+
</module>
25+
26+
<module name="SuppressWarningsFilter" />
27+
</module>

pom.xml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.amazonaws.secretsmanager</groupId>
6+
<artifactId>aws-secretsmanager-caching-java</artifactId>
7+
<version>1.0.0</version>
8+
<packaging>jar</packaging>
9+
10+
11+
<name>aws-secretsmanager-caching-java</name>
12+
<description>AWS Secrets Manager caching client for Java</description>
13+
<url>https://github.com/aws/aws-secretsmanager-caching-java</url>
14+
15+
<licenses>
16+
<license>
17+
<name>Apache License, Version 2.0</name>
18+
<url>https://aws.amazon.com/apache2.0</url>
19+
<distribution>repo</distribution>
20+
</license>
21+
</licenses>
22+
23+
<developers>
24+
<developer>
25+
<id>amazonwebservices</id>
26+
<organization>Amazon Web Services</organization>
27+
<organizationUrl>https://aws.amazon.com</organizationUrl>
28+
<roles>
29+
<role>developer</role>
30+
</roles>
31+
</developer>
32+
</developers>
33+
34+
<scm>
35+
<url>https://github.com/aws/aws-secretsmanager-caching-java.git</url>
36+
</scm>
37+
38+
<properties>
39+
<maven.compiler.source>1.8</maven.compiler.source>
40+
<maven.compiler.target>1.8</maven.compiler.target>
41+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
42+
<checkstyle.plugin.version>3.0.0</checkstyle.plugin.version>
43+
<findbugs.plugin.version>3.0.4</findbugs.plugin.version>
44+
</properties>
45+
46+
<dependencies>
47+
<dependency>
48+
<groupId>com.amazonaws</groupId>
49+
<artifactId>aws-java-sdk-secretsmanager</artifactId>
50+
<version>1.11.409</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.testng</groupId>
54+
<artifactId>testng</artifactId>
55+
<version>6.3.1</version>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.mockito</groupId>
60+
<artifactId>mockito-all</artifactId>
61+
<version>1.10.19</version>
62+
<scope>test</scope>
63+
</dependency>
64+
</dependencies>
65+
<build>
66+
<plugins>
67+
<plugin>
68+
<groupId>org.apache.maven.plugins</groupId>
69+
<artifactId>maven-compiler-plugin</artifactId>
70+
<version>3.8.0</version>
71+
<configuration>
72+
<source>1.8</source>
73+
<target>1.8</target>
74+
<compilerArgument>-Xlint:all</compilerArgument>
75+
<showWarnings>true</showWarnings>
76+
<showDeprecation>true</showDeprecation>
77+
</configuration>
78+
</plugin>
79+
<plugin>
80+
<groupId>org.apache.maven.plugins</groupId>
81+
<artifactId>maven-source-plugin</artifactId>
82+
<version>3.0.1</version>
83+
<executions>
84+
<execution>
85+
<id>attach-sources</id>
86+
<goals>
87+
<goal>jar</goal>
88+
</goals>
89+
</execution>
90+
</executions>
91+
</plugin>
92+
<plugin>
93+
<groupId>org.apache.maven.plugins</groupId>
94+
<artifactId>maven-javadoc-plugin</artifactId>
95+
<version>3.0.1</version>
96+
<executions>
97+
<execution>
98+
<id>attach-javadocs</id>
99+
<goals>
100+
<goal>jar</goal>
101+
</goals>
102+
</execution>
103+
</executions>
104+
</plugin>
105+
<plugin>
106+
<artifactId>maven-checkstyle-plugin</artifactId>
107+
<version>${checkstyle.plugin.version}</version>
108+
<configuration>
109+
<configLocation>${basedir}/config/checkstyle/checkstyle.xml</configLocation>
110+
<encoding>${project.build.sourceEncoding}</encoding>
111+
<consoleOutput>true</consoleOutput>
112+
<failsOnError>true</failsOnError>
113+
<linkXRef>false</linkXRef>
114+
<includeTestSourceDirectory>true</includeTestSourceDirectory>
115+
</configuration>
116+
<executions>
117+
<execution>
118+
<id>validate</id>
119+
<phase>validate</phase>
120+
<goals>
121+
<goal>check</goal>
122+
</goals>
123+
</execution>
124+
</executions>
125+
</plugin>
126+
<plugin>
127+
<groupId>org.codehaus.mojo</groupId>
128+
<artifactId>findbugs-maven-plugin</artifactId>
129+
<version>${findbugs.plugin.version}</version>
130+
<configuration>
131+
<effort>Max</effort>
132+
<threshold>Low</threshold>
133+
<xmlOutput>true</xmlOutput>
134+
</configuration>
135+
<executions>
136+
<execution>
137+
<id>analyze-compile</id>
138+
<phase>compile</phase>
139+
<goals>
140+
<goal>check</goal>
141+
</goals>
142+
</execution>
143+
</executions>
144+
</plugin>
145+
</plugins>
146+
</build>
147+
148+
</project>

0 commit comments

Comments
 (0)