Skip to content

Commit c04b563

Browse files
committed
merged with master
2 parents 492477b + d8601b6 commit c04b563

48 files changed

Lines changed: 1232 additions & 621 deletions

Some content is hidden

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

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### GitHub repo: [code-examples-java](./README.md)
44

5-
This GitHub repo includes code examples for the DocuSign Admin API, Click API, eSignature REST API, Monitor API, and Rooms API. To switch between API code examples, in the application.json file, modify the `DS_API_NAME` setting from `ESIGNATURE` to `ADMIN`, `CLICK`, `MONITOR`, or `ROOMS`, .
5+
This GitHub repo includes code examples for the DocuSign Admin API, Click API, eSignature REST API, Monitor API, and Rooms API. To switch between API code examples, in the application.json file, modify the `DS_API_NAME` setting from `ESIGNATURE` to `ADMIN`, `CLICK`, `MONITOR`, or `ROOMS`.
66

77

88
## Introduction
@@ -72,7 +72,7 @@ For a list of code examples that use the Admin API, select the Java tab under [E
7272

7373
To use [Authorization Code Grant](https://developers.docusign.com/platform/auth/authcode/), you will need an integration key and a secret key. See [Installation steps](#installation-steps) for details.
7474

75-
To use [JWT Grant](https://developers.docusign.com/platform/auth/jwt/), you will need an integration key, an RSA key pair, and the API Username GUID of the impersonated user. See [Installation steps for JWT Grant authentication](#installation-steps-for-jwt-grant-authentication) for details.
75+
To use [JWT Grant](https://developers.docusign.com/platform/auth/jwt/), you will need an integration key, an RSA key pair, and the User ID GUID of the impersonated user. See [Installation steps for JWT Grant authentication](#installation-steps-for-jwt-grant-authentication) for details.
7676

7777
For both authentication flows:
7878

@@ -87,8 +87,10 @@ For a list of code examples that use the Admin API, select the Java tab under [E
8787

8888
where {base_url} is the URL for the web app.
8989

90-
1. [JDK 11](https://jdk.java.net/java-se-ri/11) or later
91-
1. [Maven](https://maven.apache.org/download.cgi)
90+
1. Download [JDK 11](https://jdk.java.net/java-se-ri/11) or later and extract to C:\Program Files\Java
91+
1. Download [Maven](https://maven.apache.org/download.cgi) and extract to C:
92+
* Follow these [instructions](https://maven.apache.org/install.html) to add both Java and Maven to the `PATH` environment variable.
93+
1. [Git Bash command line](https://gitforwindows.org/), macOS Terminal, or Linux shell
9294

9395

9496
### Installation steps
@@ -100,7 +102,7 @@ For a list of code examples that use the Admin API, select the Java tab under [E
100102
`cd <Quickstart folder>` or `cd code-examples-java`
101103
1. Package the code: `mvn package`
102104
1. To configure the launcher for [Authorization Code Grant](https://developers.docusign.com/platform/auth/authcode/) authentication, create a copy of the file src/main/resources/application.example.json and save the copy as src/main/resources/application.json.
103-
1. Add your API Username. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **My Account Information**, copy the **API Username** GUID and save it in application.json as your `DS_TARGET_ACCOUNT_ID`.
105+
1. Add your User ID. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **My Account Information**, copy the **User ID** GUID and save it in application.json as your `DS_TARGET_ACCOUNT_ID`.
104106
1. Add your integration key. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **Apps and Integration Keys**, choose the app to use, then select **Actions > Edit**. Under **General Info**, copy the **Integration Key** GUID and save it in application.json as your `authorization.code.grant.client.client-id`.
105107
1. Generate a secret key, if you don’t already have one. Under **Authentication**, select **+ ADD SECRET KEY**. Copy the secret key and save it in application.json as your `authorization.code.grant.client.client-secret`.
106108
1. Add the launcher’s redirect URI. Under **Additional settings**, select **+ ADD URI**, and set a redirect URI of http://localhost:8080/login&type=acg. Select **SAVE**.
@@ -118,7 +120,7 @@ Also, in order to select JSON Web Token authentication in the launcher, in src/m
118120
1. In your command-line environment, switch to the folder: `cd <Quickstart folder>` or `cd code-examples-java`
119121
1. Package the code: `mvn package`
120122
1. To configure the launcher for [JWT Grant](https://developers.docusign.com/platform/auth/jwt/) authentication, create a copy of the file src/main/resources/application.example.json and save the copy as src/main/resources/application.json.
121-
1. Add your API Username. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **My Account Information**, copy the **API Username** GUID and save it in application.json as your `DS_TARGET_ACCOUNT_ID` and as your `jwt.grant.client.impersonated-user-guid`.
123+
1. Add your User ID. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **My Account Information**, copy the **User ID** GUID and save it in application.json as your `DS_TARGET_ACCOUNT_ID` and as your `jwt.grant.client.impersonated-user-guid`.
122124
1. Add your integration key. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **Apps and Integration Keys**, choose the app to use, then select **Actions > Edit**. Under **General Info**, copy the **Integration Key** GUID and save it in application.json as your `jwt.grant.client.client-id`.
123125
1. Generate an RSA key pair, if you don’t already have one. Under **Authentication**, select **+ GENERATE RSA**. Copy the private key, and save it in a new file named src/main/resources/private.key.
124126
1. Add the launcher’s redirect URI. Under **Additional settings**, select **+ ADD URI**, and set a redirect URI of http://localhost:8080/login&type=jwt. Select **SAVE**.
@@ -140,7 +142,7 @@ IntelliJ IDEA can be used with the launcher. The [IntelliJ IDEA Ultimate edition
140142

141143
1. Extract the Quickstart ZIP file or download or clone the code-examples-java repository.
142144
1. To configure the launcher for [Authorization Code Grant](https://developers.docusign.com/platform/auth/authcode/) authentication, create a copy of the file src/main/resources/application.example.json and save the copy as src/main/resources/application.json.
143-
1. Add your API Username. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **My Account Information**, copy the **API Username** GUID and save it in application.json as your `DS_TARGET_ACCOUNT_ID`.
145+
1. Add your User ID. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **My Account Information**, copy the **User ID** GUID and save it in application.json as your `DS_TARGET_ACCOUNT_ID`.
144146
1. Add your integration key. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **Apps and Integration Keys**, choose the app to use, then select **Actions > Edit**. Under **General Info**, copy the **Integration Key** GUID and save it in application.json as your `authorization.code.grant.client.client-id`.
145147
1. Generate a secret key, if you don’t already have one. Under **Authentication**, select **+ ADD SECRET KEY**. Copy the secret key and save it in application.json as your `authorization.code.grant.client.client-secret`.
146148
1. Add the launcher’s redirect URI. Under **Additional settings**, select **+ ADD URI**, and set a redirect URI of http://localhost:8080/login&type=acg. Select **SAVE**.
@@ -165,7 +167,7 @@ IntelliJ IDEA can be used with the launcher. The [IntelliJ IDEA Ultimate edition
165167

166168
1. Extract the Quickstart ZIP file or download or clone the code-examples-java repository.
167169
1. To configure the launcher for [Authorization Code Grant](https://developers.docusign.com/platform/auth/authcode/) authentication, create a copy of the file src/main/resources/application.example.json and save the copy as src/main/resources/application.json.
168-
1. Add your API Username. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **My Account Information**, copy the **API Username** GUID and save it in application.json as your `DS_TARGET_ACCOUNT_ID`.
170+
1. Add your User ID. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **My Account Information**, copy the **User ID** GUID and save it in application.json as your `DS_TARGET_ACCOUNT_ID`.
169171
1. Add your integration key. On the [Apps and Keys](https://admindemo.docusign.com/authenticate?goTo=apiIntegratorKey) page, under **Apps and Integration Keys**, choose the app to use, then select **Actions > Edit**. Under **General Info**, copy the **Integration Key** GUID and save it in application.json as your `authorization.code.grant.client.client-id`.
170172
1. Generate a secret key, if you don’t already have one. Under **Authentication**, select **+ ADD SECRET KEY**. Copy the secret key and save it in application.json as your `authorization.code.grant.client.client-secret`.
171173
1. Add the launcher’s redirect URI. Under **Additional settings**, select **+ ADD URI**, and set a redirect URI of http://localhost:8080/login&type=acg. Select **SAVE**.

docs/ds-java-auth-final.zip

81.9 KB
Binary file not shown.

pom.xml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
<java.version>11</java.version>
2121
<oauth2.version>2.5.2</oauth2.version>
2222
<commonsio.version>2.11.0</commonsio.version>
23-
<docusign.version>3.15.0-RC1</docusign.version>
24-
<rooms.version>1.1.0-RC1</rooms.version>
23+
<docusign.version>3.17.1</docusign.version>
24+
<rooms.version>1.1.0</rooms.version>
2525
<click.version>1.0.0-BETA</click.version>
2626
<monitor.version>1.0.0-BETA</monitor.version>
27+
<admin.version>1.0.0-BETA</admin.version>
2728
</properties>
2829

2930
<dependencies>
@@ -109,7 +110,7 @@
109110
<dependency>
110111
<groupId>com.docusign</groupId>
111112
<artifactId>docusign-admin-java</artifactId>
112-
<version>1.0.0-BETA</version>
113+
<version>${admin.version}</version>
113114
</dependency>
114115

115116
<dependency>
@@ -137,4 +138,20 @@
137138
</plugins>
138139
</build>
139140

141+
142+
143+
<dependencyManagement>
144+
145+
<dependencies>
146+
147+
148+
<dependency>
149+
<groupId>org.bouncycastle</groupId>
150+
<artifactId>bcprov-jdk15on</artifactId>
151+
<version>1.69</version>
152+
</dependency>
153+
154+
</dependencies>
155+
156+
</dependencyManagement>
140157
</project>

src/main/java/com/docusign/common/WorkArguments.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,6 @@ public class WorkArguments {
6464
private String eSignProfileId;
6565
private UUID eSignProductId;
6666
private UUID dsGroupId;
67+
private String resumeDate;
68+
private String delay;
6769
}

src/main/java/com/docusign/controller/admin/examples/A001AddActiveUser.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package com.docusign.controller.admin.examples;
22

33
import com.docusign.DSConfiguration;
4-
import com.docusign.admin.client.ApiException;
5-
import com.docusign.admin.model.NewUserResponse;
4+
import com.docusign.admin.api.UsersApi;
5+
import com.docusign.admin.model.*;
66
import com.docusign.common.WorkArguments;
7+
import com.docusign.controller.admin.services.AddActiveUserService;
78
import com.docusign.core.model.DoneExample;
89
import com.docusign.core.model.Session;
910
import com.docusign.core.model.User;
@@ -12,15 +13,14 @@
1213
import com.docusign.esign.client.ApiClient;
1314
import com.docusign.esign.model.GroupInformation;
1415
import com.docusign.esign.model.PermissionProfileInformation;
15-
import com.docusign.controller.admin.services.AddActiveUserService;
16-
import com.docusign.controller.admin.services.GetExistingAccountIdService;
1716
import org.springframework.beans.factory.annotation.Autowired;
1817
import org.springframework.stereotype.Controller;
1918
import org.springframework.ui.ModelMap;
2019
import org.springframework.web.bind.annotation.RequestMapping;
2120

2221
import javax.servlet.http.HttpServletResponse;
2322
import javax.ws.rs.core.HttpHeaders;
23+
import java.util.ArrayList;
2424
import java.util.UUID;
2525

2626
/**
@@ -35,23 +35,12 @@ public class A001AddActiveUser extends AbstractAdminController {
3535
private static final String MODEL_LIST_GROUPS = "listGroups";
3636
private final User user;
3737
private final Session session;
38-
private final String accessToken;
39-
private final String basePath;
40-
private final UUID organizationId;
41-
private final UUID accountId;
4238

4339
@Autowired
44-
public A001AddActiveUser(DSConfiguration config, Session session, User user) throws Exception {
40+
public A001AddActiveUser(DSConfiguration config, Session session, User user) {
4541
super(config, "a001", "Create a new active eSignature user");
4642
this.user = user;
4743
this.session = session;
48-
this.accessToken = this.user.getAccessToken();
49-
this.basePath = this.session.getBasePath();
50-
this.organizationId = this.getOrganizationId(accessToken, basePath);
51-
this.accountId = GetExistingAccountIdService.getExistingAccountId(
52-
createUsersApi(accessToken, basePath),
53-
config.getSignerEmail(),
54-
organizationId);
5544
}
5645

5746
@Override
@@ -62,6 +51,8 @@ protected void onInitModel(WorkArguments args, ModelMap model) throws Exception
6251

6352
// Step 3 start
6453
AccountsApi accountsApi = new AccountsApi(apiClient);
54+
UUID orgId = this.getOrganizationId(this.user.getAccessToken(), this.session.getBasePath());
55+
UUID accountId = this.getExistingAccountId(this.user.getAccessToken(), this.session.getBasePath(), orgId);
6556
PermissionProfileInformation permissionsInfo = accountsApi.listPermissions(String.valueOf(accountId));
6657
// Step 3 end
6758

@@ -77,21 +68,31 @@ protected void onInitModel(WorkArguments args, ModelMap model) throws Exception
7768

7869
@Override
7970
protected Object doWork(WorkArguments args, ModelMap model, HttpServletResponse response) throws Exception {
80-
NewUserResponse userResponse = AddActiveUserService.addActiveUser(
71+
String accessToken = this.user.getAccessToken();
72+
String basePath = this.session.getBasePath();
73+
// Create a users api instance
74+
UsersApi usersApi = createUsersApi(accessToken, basePath);
75+
76+
// Collect ids needed for the request
77+
UUID organizationId = this.getOrganizationId(accessToken, basePath);
78+
79+
// Step 5 start
80+
UUID accountId = this.getExistingAccountId(accessToken, basePath, organizationId);
81+
NewUserResponse result = AddActiveUserService.createNewActiveUser(
8182
args.getGroupId(),
8283
args.getProfileId(),
8384
args.getEmail(),
8485
args.getUserName(),
8586
args.getFirstName(),
8687
args.getLastName(),
87-
createUsersApi(accessToken, basePath),
88+
usersApi,
8889
organizationId,
8990
accountId);
9091

9192
// Process results
9293
DoneExample.createDefault(title)
9394
.withMessage("Results from eSignUserManagement:createUser method:")
94-
.withJsonObject(userResponse)
95+
.withJsonObject(result)
9596
.addToModel(model);
9697
return DONE_EXAMPLE_PAGE;
9798
}

0 commit comments

Comments
 (0)