Skip to content

Commit f8395a9

Browse files
authored
Merge pull request #71 from oracle/release_2018-07-12
Releasing version 1.2.42
2 parents 1c38885 + fe05b52 commit f8395a9

File tree

53 files changed

+2260
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2260
-105
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
1313
### Added
1414
- N/A
1515

16+
## 1.2.42 - 2018-07-12
17+
### Added
18+
- Support for tagging Load Balancers in the Load Balancing service
19+
- Support for export options in the File Storage service
20+
- Support for retrieving compartment name and user name as part of events in the Audit service
21+
1622
## 1.2.41 - 2018-06-28
1723
### Added
1824
- Support for service gateway management in the Networking service

bmc-audit/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.oracle.oci.sdk</groupId>
77
<artifactId>oci-java-sdk</artifactId>
8-
<version>1.2.41</version>
8+
<version>1.2.42</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

@@ -18,7 +18,7 @@
1818
<dependency>
1919
<groupId>com.oracle.oci.sdk</groupId>
2020
<artifactId>oci-java-sdk-common</artifactId>
21-
<version>1.2.41</version>
21+
<version>1.2.42</version>
2222
</dependency>
2323
</dependencies>
2424

bmc-audit/src/main/java/com/oracle/bmc/audit/model/AuditEvent.java

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ public Builder compartmentId(String compartmentId) {
3939
return this;
4040
}
4141

42+
@com.fasterxml.jackson.annotation.JsonProperty("compartmentName")
43+
private String compartmentName;
44+
45+
public Builder compartmentName(String compartmentName) {
46+
this.compartmentName = compartmentName;
47+
this.__explicitlySet__.add("compartmentName");
48+
return this;
49+
}
50+
4251
@com.fasterxml.jackson.annotation.JsonProperty("eventId")
4352
private String eventId;
4453

@@ -204,6 +213,15 @@ public Builder responsePayload(java.util.Map<String, Object> responsePayload) {
204213
return this;
205214
}
206215

216+
@com.fasterxml.jackson.annotation.JsonProperty("userName")
217+
private String userName;
218+
219+
public Builder userName(String userName) {
220+
this.userName = userName;
221+
this.__explicitlySet__.add("userName");
222+
return this;
223+
}
224+
207225
@com.fasterxml.jackson.annotation.JsonIgnore
208226
private final java.util.Set<String> __explicitlySet__ = new java.util.HashSet<String>();
209227

@@ -212,6 +230,7 @@ public AuditEvent build() {
212230
new AuditEvent(
213231
tenantId,
214232
compartmentId,
233+
compartmentName,
215234
eventId,
216235
eventName,
217236
eventSource,
@@ -229,7 +248,8 @@ public AuditEvent build() {
229248
responseHeaders,
230249
responseStatus,
231250
responseTime,
232-
responsePayload);
251+
responsePayload,
252+
userName);
233253
__instance__.__explicitlySet__.addAll(__explicitlySet__);
234254
return __instance__;
235255
}
@@ -239,6 +259,7 @@ public Builder copy(AuditEvent o) {
239259
Builder copiedBuilder =
240260
tenantId(o.getTenantId())
241261
.compartmentId(o.getCompartmentId())
262+
.compartmentName(o.getCompartmentName())
242263
.eventId(o.getEventId())
243264
.eventName(o.getEventName())
244265
.eventSource(o.getEventSource())
@@ -256,7 +277,8 @@ public Builder copy(AuditEvent o) {
256277
.responseHeaders(o.getResponseHeaders())
257278
.responseStatus(o.getResponseStatus())
258279
.responseTime(o.getResponseTime())
259-
.responsePayload(o.getResponsePayload());
280+
.responsePayload(o.getResponsePayload())
281+
.userName(o.getUserName());
260282

261283
copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__);
262284
return copiedBuilder;
@@ -282,6 +304,14 @@ public static Builder builder() {
282304
@com.fasterxml.jackson.annotation.JsonProperty("compartmentId")
283305
String compartmentId;
284306

307+
/**
308+
* The name of the compartment. This value is the friendly name associated with compartmentId.
309+
* This value can change, but the service logs the value that appeared at the time of the audit event.
310+
*
311+
**/
312+
@com.fasterxml.jackson.annotation.JsonProperty("compartmentName")
313+
String compartmentName;
314+
285315
/**
286316
* The GUID of the event.
287317
**/
@@ -392,6 +422,12 @@ public static Builder builder() {
392422
@com.fasterxml.jackson.annotation.JsonProperty("responsePayload")
393423
java.util.Map<String, Object> responsePayload;
394424

425+
/**
426+
* The name of the user or service. This value is the friendly name associated with principalId.
427+
**/
428+
@com.fasterxml.jackson.annotation.JsonProperty("userName")
429+
String userName;
430+
395431
@com.fasterxml.jackson.annotation.JsonIgnore
396432
private final java.util.Set<String> __explicitlySet__ = new java.util.HashSet<String>();
397433
}

bmc-bom/pom.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.oracle.oci.sdk</groupId>
77
<artifactId>oci-java-sdk</artifactId>
8-
<version>1.2.41</version>
8+
<version>1.2.42</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<artifactId>oci-java-sdk-bom</artifactId>
@@ -19,68 +19,68 @@
1919
<dependency>
2020
<groupId>com.oracle.oci.sdk</groupId>
2121
<artifactId>oci-java-sdk-common</artifactId>
22-
<version>1.2.41</version>
22+
<version>1.2.42</version>
2323
<optional>false</optional>
2424
</dependency>
2525
<!-- Service modules, alpha sorted -->
2626
<dependency>
2727
<groupId>com.oracle.oci.sdk</groupId>
2828
<artifactId>oci-java-sdk-audit</artifactId>
29-
<version>1.2.41</version>
29+
<version>1.2.42</version>
3030
<optional>false</optional>
3131
</dependency>
3232
<dependency>
3333
<groupId>com.oracle.oci.sdk</groupId>
3434
<artifactId>oci-java-sdk-containerengine</artifactId>
35-
<version>1.2.41</version>
35+
<version>1.2.42</version>
3636
<optional>false</optional>
3737
</dependency>
3838
<dependency>
3939
<groupId>com.oracle.oci.sdk</groupId>
4040
<artifactId>oci-java-sdk-core</artifactId>
41-
<version>1.2.41</version>
41+
<version>1.2.42</version>
4242
<optional>false</optional>
4343
</dependency>
4444
<dependency>
4545
<groupId>com.oracle.oci.sdk</groupId>
4646
<artifactId>oci-java-sdk-database</artifactId>
47-
<version>1.2.41</version>
47+
<version>1.2.42</version>
4848
<optional>false</optional>
4949
</dependency>
5050
<dependency>
5151
<groupId>com.oracle.oci.sdk</groupId>
5252
<artifactId>oci-java-sdk-dns</artifactId>
53-
<version>1.2.41</version>
53+
<version>1.2.42</version>
5454
<optional>false</optional>
5555
</dependency>
5656
<dependency>
5757
<groupId>com.oracle.oci.sdk</groupId>
5858
<artifactId>oci-java-sdk-email</artifactId>
59-
<version>1.2.41</version>
59+
<version>1.2.42</version>
6060
<optional>false</optional>
6161
</dependency>
6262
<dependency>
6363
<groupId>com.oracle.oci.sdk</groupId>
6464
<artifactId>oci-java-sdk-filestorage</artifactId>
65-
<version>1.2.41</version>
65+
<version>1.2.42</version>
6666
<optional>false</optional>
6767
</dependency>
6868
<dependency>
6969
<groupId>com.oracle.oci.sdk</groupId>
7070
<artifactId>oci-java-sdk-identity</artifactId>
71-
<version>1.2.41</version>
71+
<version>1.2.42</version>
7272
<optional>false</optional>
7373
</dependency>
7474
<dependency>
7575
<groupId>com.oracle.oci.sdk</groupId>
7676
<artifactId>oci-java-sdk-loadbalancer</artifactId>
77-
<version>1.2.41</version>
77+
<version>1.2.42</version>
7878
<optional>false</optional>
7979
</dependency>
8080
<dependency>
8181
<groupId>com.oracle.oci.sdk</groupId>
8282
<artifactId>oci-java-sdk-objectstorage</artifactId>
83-
<version>1.2.41</version>
83+
<version>1.2.42</version>
8484
<optional>false</optional>
8585
<type>pom</type>
8686
</dependency>

bmc-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.oracle.oci.sdk</groupId>
77
<artifactId>oci-java-sdk</artifactId>
8-
<version>1.2.41</version>
8+
<version>1.2.42</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

bmc-common/src/main/java/com/oracle/bmc/auth/internal/X509FederationClient.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.fasterxml.jackson.annotation.JsonInclude;
77
import com.fasterxml.jackson.annotation.JsonProperty;
8+
import com.google.common.annotations.VisibleForTesting;
89
import com.google.common.base.Function;
910
import com.google.common.base.Optional;
1011
import com.google.common.base.Preconditions;
@@ -304,17 +305,14 @@ private SecurityTokenAdapter getSecurityTokenFromServer() {
304305
}
305306

306307
// really simple retry until the SDK supports internal retries
307-
private Response makeCall(Builder ib, X509FederationRequest federationRequest) {
308+
@VisibleForTesting
309+
Response makeCall(Builder ib, X509FederationRequest federationRequest) {
308310
BmcException lastException = null;
311+
// Keeping one instance of the WrappedInvocationBuilder in order to preserve the request ID on retries.
312+
final WrappedInvocationBuilder wrappedIb = new WrappedInvocationBuilder(ib);
309313
for (int retry = 0; retry < 5; retry++) {
310314
try {
311-
// we don't have a wrapper object for the request, just give a new object
312-
Response response =
313-
federationHttpClient.post(
314-
new WrappedInvocationBuilder(ib),
315-
federationRequest,
316-
new BmcRequest());
317-
return response;
315+
return federationHttpClient.post(wrappedIb, federationRequest, new BmcRequest());
318316
} catch (BmcException e) {
319317
// retry in all cases right now
320318
lastException = e;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
3+
*/
4+
package com.oracle.bmc.http.signing;
5+
6+
public class RequestSignerException extends RuntimeException {
7+
public RequestSignerException(final String msg) {
8+
super(msg);
9+
}
10+
11+
public RequestSignerException(final String msg, final Throwable cause) {
12+
super(msg, cause);
13+
}
14+
}

bmc-common/src/main/java/com/oracle/bmc/http/signing/internal/RequestSignerImpl.java

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import javax.annotation.Nullable;
2222
import javax.annotation.concurrent.Immutable;
2323

24+
import com.google.common.annotations.VisibleForTesting;
25+
import com.oracle.bmc.http.signing.RequestSignerException;
2426
import org.apache.commons.codec.binary.Base64;
2527
import org.apache.commons.lang3.StringUtils;
2628

@@ -180,14 +182,14 @@ private Version validateVersion(String version, Algorithm algorithm) {
180182
final Optional<SignedRequestVersion> oVersion = SignedRequestVersion.getVersion(version);
181183
if (!oVersion.isPresent()) {
182184
LOG.debug("Invalid version number '{}'", version);
183-
throw new RuntimeException("Invalid version number");
185+
throw new RequestSignerException("Invalid version number");
184186
}
185187
final Version srVersion = oVersion.get();
186188

187189
final Optional<Version.Error> errorOpt = srVersion.validateAlgorithm(algorithm);
188190
if (errorOpt.isPresent()) {
189191
LOG.debug("Signature version rule validation failed '{}'", errorOpt.get());
190-
throw new RuntimeException("Version validation fails " + errorOpt.get());
192+
throw new RequestSignerException("Version validation fails " + errorOpt.get());
191193
}
192194
return srVersion;
193195
}
@@ -201,23 +203,41 @@ private RSAPrivateKey getPrivateKey(String keyId) {
201203
// having caller dealing with exception
202204
if (!keyOptional.isPresent()) {
203205
LOG.debug("Could not find private key associated with keyId '{}'", keyId);
204-
throw new RuntimeException("Could not find private key");
206+
throw new RequestSignerException("Could not find private key");
205207
}
206208
return keyOptional.get();
207209
}
208210

209-
private Map<String, String> ignoreCaseHeaders(final Map<String, List<String>> originalHeaders) {
211+
@VisibleForTesting
212+
static Map<String, String> ignoreCaseHeaders(Map<String, List<String>> originalHeaders) {
210213
Map<String, String> transformedMap = new HashMap<>();
211214
for (Entry<String, List<String>> entry : originalHeaders.entrySet()) {
212215
if (entry.getValue().size() != 1) {
213-
throw new RuntimeException(
214-
"Expecting exactly one value for header " + entry.getKey());
216+
final String headerKey = entry.getKey();
217+
final RequestSignerException exception =
218+
new RequestSignerException(
219+
"Expecting exactly one value for header " + headerKey);
220+
LOG.error(
221+
"More than one value for header [{}] found. All headers: {}",
222+
headerKey,
223+
transformHeadersToJsonString(originalHeaders),
224+
exception);
225+
throw exception;
215226
}
216227
transformedMap.put(entry.getKey().toLowerCase(Locale.ROOT), entry.getValue().get(0));
217228
}
218229
return transformedMap;
219230
}
220231

232+
private static String transformHeadersToJsonString(Map<String, List<String>> headers) {
233+
try {
234+
return RestClientFactory.getObjectMapper().writeValueAsString(headers);
235+
} catch (JsonProcessingException ex) {
236+
LOG.debug("Unable to serialize headers to JSON string", ex);
237+
return "UNABLE TO SERIALIZE";
238+
}
239+
}
240+
221241
private static String extractPath(URI uri) {
222242
String path = uri.getRawPath();
223243
String query = uri.getRawQuery();
@@ -251,7 +271,7 @@ private Map<String, String> calculateMissingHeaders(
251271
if (!(isPut || isPost || isPatch)) {
252272
// Asking to sign a body on GET/DELETE/HEAD is not allowed
253273
if (body != null) {
254-
throw new RuntimeException("MUST NOT send body on non-POST/PUT request");
274+
throw new RequestSignerException("MUST NOT send body on non-POST/PUT request");
255275
} else {
256276
// nothing left to do
257277
return missingHeaders;

0 commit comments

Comments
 (0)