Skip to content

Commit b3306fe

Browse files
authored
Merge pull request #3 from GovTechSG/development
Minor version bump for December 2017
2 parents 447c39d + 1fe4e3b commit b3306fe

File tree

12 files changed

+310
-259
lines changed

12 files changed

+310
-259
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@
44
### V1.0-SNAPSHOT
55
+ Initial release with HMAC256 and RSA256 signing utility
66
### V1.0.1-SNAPSHOT
7-
+ Enhancement for Issue #1 - ApiList sorting is not based on key first then value
7+
+ Enhancement for Issue #1 - ApiList sorting is not based on key first then value
8+
### V1.1.0-SNAPSHOT
9+
+ Minor refactoring
10+
+ Update interface name so as be intuitive
11+
+ Update corresponding test cases
12+
+ Include Issue/PR templates
13+
+ Include Contribution template

CONTRIBUTION.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Contributing:
2+
We welcome your involvement, be it fixing bugs or implementing new features that you find relevant to this library.
3+
4+
To contribute, you may follow the steps below:
5+
1. Fork the repo
6+
2. Create a new branch from `development` to work on your contribution
7+
3. Create a pull request back when you are done
8+
9+
Please refer to the ISSUES and PULL REQUEST templates when raising them.
10+
11+
You can raise an issue within this Github repository to kick-start the discussion first.

ISSUE_TEMPLATE.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Expected Behavior
2+
3+
Please describe the behavior you are expecting
4+
5+
# Current Behavior
6+
7+
What is the current behavior?
8+
9+
# Failure Information (for bugs)
10+
11+
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template and label it as **enhancement**
12+
13+
## Steps to Reproduce
14+
15+
Please provide detailed steps for reproducing the issue.
16+
17+
1. step 1
18+
2. step 2
19+
3. and so on...
20+
21+
## Context
22+
23+
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
24+
25+
26+
## Failure Logs
27+
28+
Please include any relevant log snippets or files here.

PULL_REQUEST_TEMPLATE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Description
2+
3+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
4+
5+
Fixes # (issue number)
6+
7+
## Type of change
8+
9+
Please delete options that are not relevant.
10+
11+
- [ ] Bug fix (non-breaking change which fixes an issue)
12+
- [ ] New feature (non-breaking change which adds functionality)
13+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
14+
- [ ] This change requires a documentation update
15+
16+
# How Has This Been Tested?
17+
18+
Please describe or list the test cases that you ran to verify your changes, and provide instructions so we can reproduce.
19+

README.md

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ mvn package
2626
```
2727

2828
The compiled _jar_ file will be located in the **target** folder
29-
+ java-apex-api-security-1.0-SNAPSHOT.jar
30-
+ java-apex-api-security-1.0-SNAPSHOT-jar-with-dependencies.jar (this includes log4j libraries)
29+
+ java-apex-api-security-<version>-SNAPSHOT.jar
30+
+ java-apex-api-security-<version>-SNAPSHOT-jar-with-dependencies.jar (this includes log4j libraries)
3131

3232
Import this jar file into your java classpath to use the utility class
3333

@@ -113,7 +113,7 @@ dependencies {
113113

114114
#### Development
115115

116-
##### Preparing BaseString :
116+
##### Preparing Signature BaseString :
117117

118118
Method:
119119
* getBaseString
@@ -137,7 +137,7 @@ formList.add("param1", "data1");
137137
String baseString;
138138

139139
try {
140-
baseString = ApiAuthorization.getBaseString(
140+
baseString = ApiSigning.getBaseString(
141141
"<<authPrefix>>",
142142
"HMACSHA256",
143143
"<<appId>>",
@@ -156,10 +156,10 @@ System.out.println(baseString);
156156

157157
```
158158

159-
##### Preparing L1 Security Signature :
159+
##### Preparing HMACSHA256 L1 Security Signature :
160160

161161
Method:
162-
* getL1Signature
162+
* getHMACSignature
163163

164164
Params:
165165
* baseString
@@ -171,7 +171,7 @@ String secret = "<<appSecret>>";
171171
String L1Sig;
172172

173173
try {
174-
L1Sig = ApiAuthorization.getL1Signature(baseString, secret);
174+
L1Sig = ApiSigning.getHMACSignature(baseString, secret);
175175
System.out.println(L1Sig);
176176

177177
} catch (ApiUtilException e) {
@@ -180,10 +180,10 @@ try {
180180

181181
```
182182

183-
##### Preparing L2 Security Signature :
183+
##### Preparing RSA256 L2 Security Signature :
184184

185185
Method:
186-
* getL2Signature
186+
* getRSASignature
187187

188188
Params:
189189
* baseString
@@ -198,22 +198,25 @@ String publicCertFileName = "certificates/ssc.alpha.example.com.cer";
198198

199199
try {
200200

201-
PrivateKey privateKey = ApiAuthorization.getPrivateKeyFromKeyStore(keyStoreFileName, password, alias);
201+
PrivateKey privateKey = ApiSigning.getPrivateKeyFromKeyStore(keyStoreFileName, password, alias);
202202

203-
String signature = ApiAuthorization.getL2Signature(baseString, privateKey);
203+
String signature = ApiSigning.getRSASignature(baseString, privateKey);
204204

205205
System.out.println(expectedSignature);
206206
System.out.println(signature);
207207

208-
PublicKey publicKey = ApiAuthorization.getPublicKeyFromX509Certificate(publicCertFileName);
208+
PublicKey publicKey = ApiSigning.getPublicKeyFromX509Certificate(publicCertFileName);
209209

210210
} catch (ApexUtilLibException e) {
211211
e.printStackTrace();
212212
}
213213

214214
```
215215

216-
##### Preparing Authorization Token :
216+
##### Preparing HTTP Signature Token :
217+
218+
Append this signature token into the Authorization header of the HTTP request
219+
217220
Params:
218221
* realm
219222
* authPrefix - Authorization Header scheme prefix , i.e 'prefix_appId'
@@ -241,23 +244,17 @@ String nonce = null;
241244
String timestamp = null;
242245

243246
try {
244-
String signature = ApiAuthorization.getToken("http://api.test.io/l2", "<<authPrefix>>", "get", url, appId, null, null, password, alias, certFileName, nonce, timestamp);
247+
String signature = ApiSigning.getSignatureToken("http://api.test.io/l2", "<<authPrefix>>", "get", url, appId, null, null, password, alias, certFileName, nonce, timestamp);
245248
} catch (ApiUtilException e) {
246249
e.printStackTrace();
247250
}
248251
```
249-
### Release:
250-
+ Checkout CHANGELOG.md for releases
251-
252-
### Contributing:
253-
We welcome your involvement, be it fixing bugs or implementing new features that you find relevant to this library.
254252

255-
To contribute, you may follow the steps below:
256-
1. Fork the repo
257-
2. Create a new branch from `development` to work on your contribution
258-
3. Create a pull request back when you are done
253+
### Contributing
254+
+ For more information about contributing PRs and issues, see [CONTRIBUTING.md](CONTRIBUTING.md).
259255

260-
Alternatively, you can raise an issue within this Github repository.
256+
### Release
257+
+ See [CHANGELOG.md](CHANGELOG.md).
261258

262259
### Reference:
263260
+ [UTF-8 in Gradle](https://stackoverflow.com/questions/21267234/show-utf-8-text-properly-in-gradle)

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
id 'com.github.kt3k.coveralls' version '2.6.3'
55
}
66

7-
version '1.0.1-SNAPSHOT'
7+
version '1.1.0-SNAPSHOT'
88

99
tasks.withType(JavaCompile) {
1010
options.encoding = "UTF-8"
@@ -29,7 +29,7 @@ jar {
2929
}
3030
}
3131
manifest {
32-
attributes 'Main-Class': 'ApiAuthorization'
32+
attributes 'Main-Class': 'ApiSigning'
3333
}
3434
}
3535

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.api.util</groupId>
44
<artifactId>ApiSecurity</artifactId>
5-
<version>1.0.1-SNAPSHOT</version>
5+
<version>1.1.0-SNAPSHOT</version>
66
<build>
77
<plugins>
88
<plugin>

0 commit comments

Comments
 (0)