Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
### Added
- N/A

## 1.2.42 - 2018-07-12
### Added
- Support for tagging Load Balancers in the Load Balancing service
- Support for export options in the File Storage service
- Support for retrieving compartment name and user name as part of events in the Audit service

## 1.2.41 - 2018-06-28
### Added
- Support for service gateway management in the Networking service
Expand Down
4 changes: 2 additions & 2 deletions bmc-audit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -18,7 +18,7 @@
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-common</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
</dependency>
</dependencies>

Expand Down
40 changes: 38 additions & 2 deletions bmc-audit/src/main/java/com/oracle/bmc/audit/model/AuditEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ public Builder compartmentId(String compartmentId) {
return this;
}

@com.fasterxml.jackson.annotation.JsonProperty("compartmentName")
private String compartmentName;

public Builder compartmentName(String compartmentName) {
this.compartmentName = compartmentName;
this.__explicitlySet__.add("compartmentName");
return this;
}

@com.fasterxml.jackson.annotation.JsonProperty("eventId")
private String eventId;

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

@com.fasterxml.jackson.annotation.JsonProperty("userName")
private String userName;

public Builder userName(String userName) {
this.userName = userName;
this.__explicitlySet__.add("userName");
return this;
}

@com.fasterxml.jackson.annotation.JsonIgnore
private final java.util.Set<String> __explicitlySet__ = new java.util.HashSet<String>();

Expand All @@ -212,6 +230,7 @@ public AuditEvent build() {
new AuditEvent(
tenantId,
compartmentId,
compartmentName,
eventId,
eventName,
eventSource,
Expand All @@ -229,7 +248,8 @@ public AuditEvent build() {
responseHeaders,
responseStatus,
responseTime,
responsePayload);
responsePayload,
userName);
__instance__.__explicitlySet__.addAll(__explicitlySet__);
return __instance__;
}
Expand All @@ -239,6 +259,7 @@ public Builder copy(AuditEvent o) {
Builder copiedBuilder =
tenantId(o.getTenantId())
.compartmentId(o.getCompartmentId())
.compartmentName(o.getCompartmentName())
.eventId(o.getEventId())
.eventName(o.getEventName())
.eventSource(o.getEventSource())
Expand All @@ -256,7 +277,8 @@ public Builder copy(AuditEvent o) {
.responseHeaders(o.getResponseHeaders())
.responseStatus(o.getResponseStatus())
.responseTime(o.getResponseTime())
.responsePayload(o.getResponsePayload());
.responsePayload(o.getResponsePayload())
.userName(o.getUserName());

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

/**
* The name of the compartment. This value is the friendly name associated with compartmentId.
* This value can change, but the service logs the value that appeared at the time of the audit event.
*
**/
@com.fasterxml.jackson.annotation.JsonProperty("compartmentName")
String compartmentName;

/**
* The GUID of the event.
**/
Expand Down Expand Up @@ -392,6 +422,12 @@ public static Builder builder() {
@com.fasterxml.jackson.annotation.JsonProperty("responsePayload")
java.util.Map<String, Object> responsePayload;

/**
* The name of the user or service. This value is the friendly name associated with principalId.
**/
@com.fasterxml.jackson.annotation.JsonProperty("userName")
String userName;

@com.fasterxml.jackson.annotation.JsonIgnore
private final java.util.Set<String> __explicitlySet__ = new java.util.HashSet<String>();
}
24 changes: 12 additions & 12 deletions bmc-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>oci-java-sdk-bom</artifactId>
Expand All @@ -19,68 +19,68 @@
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-common</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<optional>false</optional>
</dependency>
<!-- Service modules, alpha sorted -->
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-audit</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-containerengine</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-core</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-database</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-dns</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-email</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-filestorage</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-identity</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-loadbalancer</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<optional>false</optional>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-objectstorage</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<optional>false</optional>
<type>pom</type>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion bmc-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk</artifactId>
<version>1.2.41</version>
<version>1.2.42</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -304,17 +305,14 @@ private SecurityTokenAdapter getSecurityTokenFromServer() {
}

// really simple retry until the SDK supports internal retries
private Response makeCall(Builder ib, X509FederationRequest federationRequest) {
@VisibleForTesting
Response makeCall(Builder ib, X509FederationRequest federationRequest) {
BmcException lastException = null;
// Keeping one instance of the WrappedInvocationBuilder in order to preserve the request ID on retries.
final WrappedInvocationBuilder wrappedIb = new WrappedInvocationBuilder(ib);
for (int retry = 0; retry < 5; retry++) {
try {
// we don't have a wrapper object for the request, just give a new object
Response response =
federationHttpClient.post(
new WrappedInvocationBuilder(ib),
federationRequest,
new BmcRequest());
return response;
return federationHttpClient.post(wrappedIb, federationRequest, new BmcRequest());
} catch (BmcException e) {
// retry in all cases right now
lastException = e;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
*/
package com.oracle.bmc.http.signing;

public class RequestSignerException extends RuntimeException {
public RequestSignerException(final String msg) {
super(msg);
}

public RequestSignerException(final String msg, final Throwable cause) {
super(msg, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import com.google.common.annotations.VisibleForTesting;
import com.oracle.bmc.http.signing.RequestSignerException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -180,14 +182,14 @@ private Version validateVersion(String version, Algorithm algorithm) {
final Optional<SignedRequestVersion> oVersion = SignedRequestVersion.getVersion(version);
if (!oVersion.isPresent()) {
LOG.debug("Invalid version number '{}'", version);
throw new RuntimeException("Invalid version number");
throw new RequestSignerException("Invalid version number");
}
final Version srVersion = oVersion.get();

final Optional<Version.Error> errorOpt = srVersion.validateAlgorithm(algorithm);
if (errorOpt.isPresent()) {
LOG.debug("Signature version rule validation failed '{}'", errorOpt.get());
throw new RuntimeException("Version validation fails " + errorOpt.get());
throw new RequestSignerException("Version validation fails " + errorOpt.get());
}
return srVersion;
}
Expand All @@ -201,23 +203,41 @@ private RSAPrivateKey getPrivateKey(String keyId) {
// having caller dealing with exception
if (!keyOptional.isPresent()) {
LOG.debug("Could not find private key associated with keyId '{}'", keyId);
throw new RuntimeException("Could not find private key");
throw new RequestSignerException("Could not find private key");
}
return keyOptional.get();
}

private Map<String, String> ignoreCaseHeaders(final Map<String, List<String>> originalHeaders) {
@VisibleForTesting
static Map<String, String> ignoreCaseHeaders(Map<String, List<String>> originalHeaders) {
Map<String, String> transformedMap = new HashMap<>();
for (Entry<String, List<String>> entry : originalHeaders.entrySet()) {
if (entry.getValue().size() != 1) {
throw new RuntimeException(
"Expecting exactly one value for header " + entry.getKey());
final String headerKey = entry.getKey();
final RequestSignerException exception =
new RequestSignerException(
"Expecting exactly one value for header " + headerKey);
LOG.error(
"More than one value for header [{}] found. All headers: {}",
headerKey,
transformHeadersToJsonString(originalHeaders),
exception);
throw exception;
}
transformedMap.put(entry.getKey().toLowerCase(Locale.ROOT), entry.getValue().get(0));
}
return transformedMap;
}

private static String transformHeadersToJsonString(Map<String, List<String>> headers) {
try {
return RestClientFactory.getObjectMapper().writeValueAsString(headers);
} catch (JsonProcessingException ex) {
LOG.debug("Unable to serialize headers to JSON string", ex);
return "UNABLE TO SERIALIZE";
}
}

private static String extractPath(URI uri) {
String path = uri.getRawPath();
String query = uri.getRawQuery();
Expand Down Expand Up @@ -251,7 +271,7 @@ private Map<String, String> calculateMissingHeaders(
if (!(isPut || isPost || isPatch)) {
// Asking to sign a body on GET/DELETE/HEAD is not allowed
if (body != null) {
throw new RuntimeException("MUST NOT send body on non-POST/PUT request");
throw new RequestSignerException("MUST NOT send body on non-POST/PUT request");
} else {
// nothing left to do
return missingHeaders;
Expand Down
Loading