|
4 | 4 |
|
5 | 5 | package sample; |
6 | 6 |
|
| 7 | +import com.auth0.client.auth.AuthAPI; |
| 8 | +import com.auth0.client.mgmt.ManagementApi; |
| 9 | +import com.auth0.client.mgmt.ManagementApiBuilder; |
| 10 | +import com.auth0.client.mgmt.actions.types.CreateActionModuleRequestContent; |
| 11 | +import com.auth0.client.mgmt.connections.types.ListDirectoryProvisioningsRequestParameters; |
| 12 | +import com.auth0.client.mgmt.connections.types.ReplaceSynchronizedGroupsRequestContent; |
| 13 | +import com.auth0.client.mgmt.core.*; |
| 14 | +import com.auth0.client.mgmt.organizations.types.CreateOrganizationDiscoveryDomainRequestContent; |
| 15 | +import com.auth0.client.mgmt.organizations.types.UpdateOrganizationDiscoveryDomainRequestContent; |
| 16 | +import com.auth0.client.mgmt.selfserviceprofiles.types.CreateSelfServiceProfileSsoTicketRequestContent; |
| 17 | +import com.auth0.client.mgmt.tenants.types.UpdateTenantSettingsRequestContent; |
| 18 | +import com.auth0.client.mgmt.types.*; |
| 19 | +import com.auth0.json.auth.TokenHolder; |
| 20 | +import com.auth0.net.TokenRequest; |
| 21 | + |
| 22 | +import java.io.IOException; |
| 23 | +import java.util.*; |
| 24 | +import java.util.concurrent.TimeUnit; |
| 25 | + |
| 26 | +import static com.auth0.client.mgmt.types.ClientAppTypeEnum.REGULAR_WEB; |
| 27 | + |
7 | 28 | public final class App { |
8 | 29 |
|
| 30 | + private static String domain = "dev-tanya.us.auth0.com"; |
| 31 | + private static String clientId = "PY6HuuGyYjDktVGOrf47DIaXwUy8uVYP"; |
| 32 | + private static String clientSecret = "D8gp_WGbAQXE7kT7QdcP7xM2SOkvfa8LC5fRGh5ryXUTOr74fPWrGxjpdeY_2gkA"; |
| 33 | + private static String audience = "https://dev-tanya.us.auth0.com/api/v2/"; |
| 34 | + |
| 35 | + public static void main(String[] args) throws IOException { |
| 36 | + |
| 37 | + // import com.auth0.client.mgmt.AsyncManagementApi |
| 38 | + |
| 39 | + AuthAPI auth = AuthAPI.newBuilder(domain, clientId, clientSecret).build(); |
| 40 | + |
| 41 | + TokenRequest tokenRequest = auth.requestToken(audience); |
| 42 | + TokenHolder holder = tokenRequest.execute().getBody(); |
| 43 | + String accessToken = holder.getAccessToken(); |
| 44 | + System.out.println("Access Token: " + accessToken); |
| 45 | + |
| 46 | + try { |
| 47 | +// |
| 48 | +// OkHttpClient customClient = new OkHttpClient.Builder() |
| 49 | +// .connectTimeout(30, TimeUnit.SECONDS) |
| 50 | +// .build(); |
| 51 | + |
| 52 | + |
| 53 | + ManagementApi client = ManagementApi |
| 54 | + .builder() |
| 55 | + .url(audience) |
| 56 | + .token(accessToken) |
| 57 | + // .httpClient(customClient) // no unnecessary default client created |
| 58 | + .build(); |
| 59 | + |
| 60 | + CreateSelfServiceProfileSsoTicketResponseContent responseContent = client.selfServiceProfiles().ssoTicket().create("ssp_mziGb8PGF6zeoytyXB2M2A", |
| 61 | + CreateSelfServiceProfileSsoTicketRequestContent.builder() |
| 62 | + //.connectionConfig() |
| 63 | + .connectionId("con_YRBTBFZNNRiBJGKX") |
| 64 | + .enabledFeatures(SelfServiceProfileSsoTicketEnabledFeatures.builder().sso(true).build()) |
| 65 | + .domainAliasesConfig(SelfServiceProfileSsoTicketDomainAliasesConfig.builder() |
| 66 | + .domainVerification(SelfServiceProfileSsoTicketDomainVerificationEnum.OPTIONAL).pendingDomains(Arrays.asList("example.com", "company.org")).build()) |
| 67 | + .build()); |
| 68 | + |
| 69 | + System.out.println("Create SSO Ticket: " + responseContent.toString()); |
| 70 | + |
| 71 | + |
| 72 | +// SyncPagingIterable<SynchronizedGroupPayload> synchronizedGroupPayloads = client.connections().directoryProvisioning().listSynchronizedGroups("<CONNECTION_ID>"); |
| 73 | +// |
| 74 | +// client.connections().directoryProvisioning().set("<CONNECTION_ID>", ReplaceSynchronizedGroupsRequestContent.builder().groups("...").build()); |
| 75 | + |
| 76 | + |
| 77 | +// GetSupplementalSignalsResponseContent get = client.supplementalSignals().get(); |
| 78 | +// System.out.println("Get Supplemental Signals: " + get.toString()); |
| 79 | + |
| 80 | +// UpdateSupplementalSignalsRequestContent updateRequest = UpdateSupplementalSignalsRequestContent |
| 81 | +// .builder() |
| 82 | +// .akamaiEnabled(true) |
| 83 | +// .build(); |
| 84 | +// PatchSupplementalSignalsResponseContent update = client.supplementalSignals().patch(updateRequest); |
| 85 | +// System.out.println("Update Supplemental Signals: " + update.toString()); |
| 86 | + |
| 87 | + |
| 88 | + List<PostConnectionsKeysResponseContentItem> list = client.connections().keys().create("con_ymgDLr1eilH0khg4"); |
| 89 | + for(PostConnectionsKeysResponseContentItem item : list) { |
| 90 | + System.out.println("Connection Key: " + item.toString()); |
| 91 | + } |
| 92 | + |
| 93 | + |
| 94 | + } |
| 95 | + catch (Exception ex) { |
| 96 | + System.out.println("Exception: " + ex.getMessage() + " " + ex.toString()); |
| 97 | + } |
| 98 | + } |
| 99 | + |
9 | 100 | } |
10 | 101 |
|
0 commit comments