Skip to content

Commit 96e413f

Browse files
authored
Merge pull request #4 from docusign/1.1.0-v2-1.0.8
Version 1.1.0 release
2 parents 8310700 + aea85d0 commit 96e413f

5 files changed

Lines changed: 56 additions & 108 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# DocuSign Rooms Java Client Changelog
22
See [DocuSign Support Center](https://support.docusign.com/en/releasenotes/) for Product Release Notes.
33

4+
## [v1.1.0] - Rooms API v2-1.0.8 - 2021-03-25
5+
### Changed
6+
- Added support for version v2-1.0.8 of the DocuSign Rooms API.
7+
- Updated the SDK release version.
8+
49
## [v1.0.0] - Rooms API v2-1.0.7 - 2020-10-19
510
### Changed
611
- First GA version of Rooms API.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Note: DocuSign uses **Eclipse** with **Maven** for testing purposes.
3535
<dependency>
3636
<groupId>com.docusign</groupId>
3737
<artifactId>docusign-rooms-java</artifactId>
38-
<version>1.1.0-RC1</version>
38+
<version>1.1.0</version>
3939
</dependency>
4040
```
4141

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'idea'
22
apply plugin: 'eclipse'
33

44
group = 'com.docusign'
5-
version = '1.1.0-RC1'
5+
version = '1.1.0'
66

77
buildscript {
88
repositories {

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<artifactId>docusign-rooms-java</artifactId>
55
<packaging>jar</packaging>
66
<name>docusign-rooms-java</name>
7-
<version>1.1.0-RC1</version>
7+
<version>1.1.0</version>
88
<description>The official DocuSign Rooms Java client provides libraries for Java application integration with DocuSign Rooms for real estate and mortgage workflows. It is recommended that you use this version of the library for new development.</description>
99
<url>https://developers.docusign.com</url>
1010

src/main/java/com/docusign/rooms/client/ApiClient.java

Lines changed: 48 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
import org.glassfish.jersey.client.spi.ConnectorProvider;
2121
import org.glassfish.jersey.jackson.JacksonFeature;
2222
import org.glassfish.jersey.logging.LoggingFeature;
23-
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
24-
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
25-
import org.glassfish.jersey.media.multipart.MultiPart;
26-
import org.glassfish.jersey.media.multipart.MultiPartFeature;
23+
import org.glassfish.jersey.media.multipart.*;
2724

2825
import javax.net.ssl.*;
2926
import javax.ws.rs.client.*;
@@ -41,11 +38,7 @@
4138
import java.nio.file.Files;
4239
import java.nio.file.StandardCopyOption;
4340
import org.glassfish.jersey.logging.LoggingFeature;
44-
45-
import java.security.KeyManagementException;
46-
import java.security.NoSuchAlgorithmException;
4741
import java.security.SecureRandom;
48-
import java.security.Security;
4942
import java.security.cert.CertificateException;
5043
import java.security.cert.X509Certificate;
5144
import java.text.DateFormat;
@@ -91,7 +84,7 @@ public ApiClient() {
9184
this.dateFormat = new RFC3339DateFormat();
9285

9386
// Set default User-Agent.
94-
setUserAgent("Swagger-Codegen/1.1.0-RC1/java");
87+
setUserAgent("Swagger-Codegen/1.1.0/java");
9588

9689
// Setup authentications (key: authentication name, value: authentication).
9790
authentications = new HashMap<String, Authentication>();
@@ -738,28 +731,11 @@ public void registerAccessTokenListener(AccessTokenListener accessTokenListener)
738731
* @return the OAuth JWT grant uri as a String
739732
*/
740733
public String getJWTUri(String clientId, String redirectURI, String oAuthBasePath) {
741-
return getJWTUri(clientId, redirectURI, oAuthBasePath, null);
742-
}
743-
744-
/**
745-
* Helper method to build the OAuth JWT grant uri (used once to get a user consent for impersonation)
746-
* @param clientId OAuth2 client ID
747-
* @param redirectURI OAuth2 redirect uri
748-
* @param scopes the list of requested scopes. Values include {@link OAuth#Scope_SIGNATURE}, {@link OAuth#Scope_EXTENDED}, {@link OAuth#Scope_IMPERSONATION}. You can also pass any advanced scope.
749-
* @return the OAuth JWT grant uri as a String
750-
*/
751-
public String getJWTUri(String clientId, String redirectURI, String oAuthBasePath, java.util.List<String> scopes) {
752-
String formattedScopes = (scopes == null || scopes.size() < 1) ? "signature%20impersonation" : scopes.get(0);
753-
StringBuilder sb = new StringBuilder(formattedScopes);
754-
for (int i = 1; i < scopes.size(); i++) {
755-
sb.append(" " + scopes.get(i));
756-
}
757-
758734
return UriBuilder.fromUri(oAuthBasePath)
759735
.scheme("https")
760736
.path("/oauth/auth")
761737
.queryParam("response_type", "code")
762-
.queryParam("scope", sb.toString())
738+
.queryParam("scope", "signature%20impersonation")
763739
.queryParam("client_id", clientId)
764740
.queryParam("redirect_uri", redirectURI)
765741
.build().toString();
@@ -847,7 +823,7 @@ public String getJWTUri(String clientId, String redirectURI, String oAuthBasePat
847823
* @throws ApiException if there is an error while exchanging the JWT with an access token
848824
* @throws IOException if there is an issue with either the public or private file
849825
*/
850-
public OAuth.OAuthToken requestJWTUserToken(String clientId, String userId, java.util.List<String> scopes, byte[] rsaPrivateKey, long expiresIn) throws IllegalArgumentException, ApiException, IOException {
826+
public OAuth.OAuthToken requestJWTUserToken(String clientId, String userId, java.util.List<String>scopes, byte[] rsaPrivateKey, long expiresIn) throws IllegalArgumentException, ApiException, IOException {
851827
String formattedScopes = (scopes == null || scopes.size() < 1) ? "" : scopes.get(0);
852828
StringBuilder sb = new StringBuilder(formattedScopes);
853829
for (int i = 1; i < scopes.size(); i++) {
@@ -1197,7 +1173,13 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
11971173
if (contentType.startsWith("multipart/form-data")) {
11981174
MultiPart multiPart = new MultiPart();
11991175
for (Entry<String, Object> param: formParams.entrySet()) {
1200-
if (param.getValue() instanceof File) {
1176+
if (param.getValue() instanceof byte[]) {
1177+
byte[] bytes = (byte[]) param.getValue();
1178+
FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey())
1179+
.fileName(param.getKey()).size(bytes.length).build();
1180+
1181+
multiPart.bodyPart(new FormDataBodyPart(contentDisp, bytes, MediaType.APPLICATION_OCTET_STREAM_TYPE));
1182+
} else if (param.getValue() instanceof File) {
12011183
File file = (File) param.getValue();
12021184
FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey())
12031185
.fileName(file.getName()).size(file.length()).build();
@@ -1347,9 +1329,7 @@ public <T> T invokeAPI(String path, String method, List<Pair> queryParams, List<
13471329
}
13481330
}
13491331

1350-
Invocation.Builder invocationBuilder = target.request().accept(accept)
1351-
.header("Cache-Control", "no-store")
1352-
.header("Pragma", "no-cache");
1332+
Invocation.Builder invocationBuilder = target.request().accept(accept);
13531333

13541334
for (Entry<String, String> entry : headerParams.entrySet()) {
13551335
String value = entry.getValue();
@@ -1368,7 +1348,32 @@ public <T> T invokeAPI(String path, String method, List<Pair> queryParams, List<
13681348
}
13691349
}
13701350

1371-
Entity<?> entity = serialize(body, formParams, contentType);
1351+
Entity<?> entity = (body == null && formParams.isEmpty()) ? Entity.json("{}") : serialize(body, formParams, contentType);
1352+
1353+
// Generate and add Content-Disposition header as per RFC 6266
1354+
if (contentType.startsWith("multipart/form-data")) {
1355+
for (Entry<String, Object> param : formParams.entrySet()) {
1356+
if (param.getValue() instanceof byte[]) {
1357+
MultiPart mp = ((MultiPart) entity.getEntity());
1358+
List<BodyPart> bodyParts = mp.getBodyParts();
1359+
if (!bodyParts.isEmpty()) {
1360+
BodyPart bodyPart = bodyParts.get(0);
1361+
if (bodyPart.getContentDisposition() != null) {
1362+
String contentDispositionValue = bodyPart.getContentDisposition().toString();
1363+
invocationBuilder = invocationBuilder.header("Content-Disposition", contentDispositionValue);
1364+
entity = Entity.entity(param.getValue(), "application/octet-stream");
1365+
}
1366+
}
1367+
}
1368+
}
1369+
}
1370+
1371+
// Add DocuSign Tracking Header
1372+
invocationBuilder = invocationBuilder.header("X-DocuSign-SDK", "Java");
1373+
1374+
if (body == null && formParams.isEmpty()) {
1375+
invocationBuilder = invocationBuilder.header("Content-Length", "0");
1376+
}
13721377

13731378
Response response = null;
13741379
String message = "error";
@@ -1382,7 +1387,7 @@ public <T> T invokeAPI(String path, String method, List<Pair> queryParams, List<
13821387
} else if ("PUT".equals(method)) {
13831388
response = invocationBuilder.put(entity);
13841389
} else if ("DELETE".equals(method)) {
1385-
response = invocationBuilder.delete();
1390+
response = invocationBuilder.method("DELETE", entity);
13861391
} else if ("PATCH".equals(method)) {
13871392
response = invocationBuilder.method("PATCH", entity);
13881393
} else if ("HEAD".equals(method)) {
@@ -1534,14 +1539,17 @@ protected Client buildHttpClient(boolean debugging) {
15341539
clientConfig.register(MultiPartFeature.class);
15351540
clientConfig.register(json);
15361541
clientConfig.register(JacksonFeature.class);
1537-
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
15381542
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
1539-
Security.setProperty("ssl.SocketFactory.provider", CustomSSLSocketFactory.class.getCanonicalName());
1543+
// turn off compliance validation to be able to send payloads with DELETE calls
1544+
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
15401545
if (debugging) {
15411546
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
15421547
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
15431548
// Set logger to ALL
15441549
java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL);
1550+
} else {
1551+
// suppress warnings for payloads with DELETE calls:
1552+
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
15451553
}
15461554
performAdditionalClientConfiguration(clientConfig);
15471555

@@ -1560,11 +1568,7 @@ protected Client buildHttpClient(boolean debugging) {
15601568
} catch (final Exception ex) {
15611569
System.err.println("failed to initialize SSL context");
15621570
}
1563-
try {
1564-
HttpsURLConnection.setDefaultSSLSocketFactory(new CustomSSLSocketFactory());
1565-
} catch (Exception ex) {
1566-
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
1567-
}
1571+
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
15681572
}
15691573

15701574
clientConfig.connectorProvider(new ConnectorProvider() {
@@ -1611,12 +1615,8 @@ public HttpURLConnection getConnection(java.net.URL url) throws IOException {
16111615
}
16121616

16131617
if (isNonProxyHost(url.getHost(), System.getProperty("http.nonProxyHosts"))) {
1614-
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
1615-
try {
1616-
connection.setSSLSocketFactory(new CustomSSLSocketFactory());
1617-
} catch (Exception ex) {
1618-
connection.setSSLSocketFactory(sslContext.getSocketFactory());
1619-
}
1618+
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(Proxy.NO_PROXY);
1619+
connection.setSSLSocketFactory(sslContext.getSocketFactory());
16201620
return connection;
16211621
}
16221622

@@ -1673,13 +1673,8 @@ protected PasswordAuthentication getPasswordAuthentication() {
16731673

16741674
HostnameVerifier allHostsValid = new InsecureHostnameVerifier();
16751675
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(p);
1676-
try {
1677-
connection.setSSLSocketFactory(new CustomSSLSocketFactory());
1678-
} catch (Exception ex) {
1679-
connection.setSSLSocketFactory(sslContext.getSocketFactory());
1680-
}
1676+
connection.setSSLSocketFactory(sslContext.getSocketFactory());
16811677
connection.setHostnameVerifier(allHostsValid);
1682-
connection.setUseCaches(false);
16831678
return connection;
16841679
}
16851680
});
@@ -1689,7 +1684,6 @@ protected PasswordAuthentication getPasswordAuthentication() {
16891684

16901685
return ClientBuilder.newBuilder().
16911686
sslContext(sslContext).
1692-
hostnameVerifier(new InsecureHostnameVerifier()).
16931687
withConfig(clientConfig).build();
16941688
}
16951689

@@ -1730,57 +1724,6 @@ public boolean isServerTrusted(X509Certificate[] arg0) {
17301724
}
17311725

17321726
}
1733-
1734-
private class CustomSSLSocketFactory extends SSLSocketFactory {
1735-
private CustomSSLSocketFactory() throws NoSuchAlgorithmException, KeyManagementException {
1736-
sslContext.init(null, new TrustManager[] { new SecureTrustManager() }, new SecureRandom());
1737-
}
1738-
1739-
@Override
1740-
public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
1741-
throws IOException {
1742-
socket.setKeepAlive(true);
1743-
socket.setSoTimeout(0);
1744-
socket.connect(new InetSocketAddress(host, port), 0);
1745-
return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
1746-
}
1747-
1748-
@Override
1749-
public String[] getDefaultCipherSuites() {
1750-
return sslContext.getSocketFactory().getDefaultCipherSuites();
1751-
}
1752-
1753-
@Override
1754-
public String[] getSupportedCipherSuites() {
1755-
return sslContext.getSocketFactory().getSupportedCipherSuites();
1756-
}
1757-
1758-
@Override
1759-
public Socket createSocket(String host, int port)
1760-
throws IOException {
1761-
return this.createSocket(new Socket(), host, port, true);
1762-
}
1763-
1764-
@Override
1765-
public Socket createSocket(InetAddress address, int port)
1766-
throws IOException {
1767-
return this.createSocket(new Socket(), address.getHostAddress(), port, true);
1768-
}
1769-
1770-
1771-
@Override
1772-
public Socket createSocket(String host, int port, InetAddress localHost, int localPort)
1773-
throws IOException {
1774-
return this.createSocket(new Socket(), host, port, true);
1775-
}
1776-
1777-
1778-
@Override
1779-
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
1780-
throws IOException {
1781-
return this.createSocket(new Socket(), address.getHostAddress(), port, true);
1782-
}
1783-
}
17841727

17851728
protected Map<String, List<String>> buildResponseHeaders(Response response) {
17861729
Map<String, List<String>> responseHeaders = new HashMap<String, List<String>>();

0 commit comments

Comments
 (0)