diff --git a/.fernignore b/.fernignore index b48f3efae..232270085 100644 --- a/.fernignore +++ b/.fernignore @@ -26,7 +26,6 @@ src/main/java/com/auth0/json/mgmt/ src/main/java/com/auth0/json/ObjectMapperProvider.java # Client options from auth0-real -src/main/java/com/auth0/client/HttpOptions.java src/main/java/com/auth0/client/ProxyOptions.java src/main/java/com/auth0/client/LoggingOptions.java diff --git a/EXAMPLES.md b/EXAMPLES.md deleted file mode 100644 index e599e0108..000000000 --- a/EXAMPLES.md +++ /dev/null @@ -1,208 +0,0 @@ -# Examples using auth0-java - -- [Error handling](#error-handling) -- [HTTP Client configuration](#http-client-configuration) -- [Verifying an ID token](#verifying-an-id-token) -- [Organizations](#organizations) -- [Client credential management](#client-credential-management) -- [Asynchronous operations](#asynchronous-operations) - -## Error handling - -The API Clients throw an `Auth0Exception` when an unexpected error happens on a request execution, for example a connection or timeout error. - -An `APIException` will be thrown if the network request succeeded, but another error occurred. - -```java -Request request = api.users().list(new UserFilter().withSearchEngine("v1")); -try { - UsersPage usersPage = request.execute().getBody(); -} catch(APIException apiException) { - apiException.getStatusCode(); // 400 - apiException.getError(); // "operation_not_supported" - apiException.getDescription(); // "You are not allowed to use search_engine=v1." -} -``` - -## HTTP Client configuration - -By default, both the Authentication and Management API clients use the OkHttp networking library to make HTTP requests. -The client can be configured by building a `DefaultHttpClient` and providing it to the API clients. -If using both the Management and Authentication API clients, it is recommended to create one `Auth0HttpClient` to be used by both API clients to minimize resource usage. - -```java -Auth0HttpClient client = DefaultHttpClient.newBuilder() - // configure as needed - .build(); - -AuthAPI auth = AuthAPI.newBuilder("DOMAIN", "CLIENT-ID", "CLIENT-SECRET") - .withHttpClient(client) - .build(); - -``` - -```java - -ManagementAPI mgmt = ManagementAPI.newBuilder("DOMAIN", "API-TOKEN") - .withHttpClient(client) - .build(); - -// OR - -TokenProvider tokenProvider = SimpleTokenProvider.create("API-TOKEN"); - -ManagementAPI mgmt = ManagementAPI.newBuilder("DOMAIN", tokenProvider) - .withHttpClient(client) - .build(); - -``` - -If the `DefaultHttpClient` does not support your required networking client configuration, you may choose to implement -your own client by implementing the `Auth0HttpClient` interface and providing it to the API clients. This is an advanced -use case and should be used only when necessary. - -## Verifying an ID token - -This library also provides the ability to validate an OIDC-compliant ID Token, according to the [OIDC Specification](https://openid.net/specs/openid-connect-core-1_0-final.html#IDTokenValidation). - -### Verifying an ID Token signed with the RS256 signing algorithm - -To verify an ID Token that is signed using the RS256 signing algorithm, you will need to provide an implementation of -`PublicKeyProvider` that will return the public key used to verify the token's signature. The example below demonstrates how to use the `JwkProvider` from the [jwks-rsa-java](https://github.com/auth0/jwks-rsa-java) library: - -```java -JwkProvider provider = new JwkProviderBuilder("https://your-domain.auth0.com").build(); -SignatureVerifier signatureVerifier = SignatureVerifier.forRS256(new PublicKeyProvider() { - @Override - public RSAPublicKey getPublicKeyById(String keyId) throws PublicKeyProviderException { - try { - return (RSAPublicKey) provider.get(keyId).getPublicKey(); - } catch (JwkException jwke) { - throw new PublicKeyProviderException("Error obtaining public key", jwke); - } - } -} - -IdTokenVerifier idTokenVerifier = IdTokenVerifier.init("https://your-domain.auth0.com/","your-client-id", signatureVerifier).build(); - -try { - idTokenVerifier.verify("token", "expected-nonce"); -} catch(IdTokenValidationException idtve) { - // Handle invalid token exception -} -``` - -### Verifying an ID Token signed with the HS256 signing algorithm - -To verify an ID Token that is signed using the HS256 signing algorithm: - -```java -SignatureVerifier signatureVerifier = SignatureVerifier.forHS256("your-client-secret"); -IdTokenVerifier idTokenVerifier = IdTokenVerifier.init("https://your-domain.auth0.com/","your-client-id", signatureVerifier).build(); - -try { - idTokenVerifier.verify("token", "expected-nonce"); -} catch(IdTokenValidationException idtve) { - // Handle invalid token exception -} -``` - -## Organizations - -[Organizations](https://auth0.com/docs/organizations) is a set of features that provide better support for developers who build and maintain SaaS and Business-to-Business (B2B) applications. - -Note that Organizations is currently only available to customers on our Enterprise and Startup subscription plans. - -### Log in to an organization - -Log in to an organization by using `withOrganization()` when building the Authorization URL: - -```java -AuthAPI auth = AuthAPI.newBuilder("{YOUR_DOMAIN}", "{YOUR_CLIENT_ID}", "{YOUR_CLIENT_SECRET}").build(); -String url = auth.authorizeUrl("https://me.auth0.com/callback") - .withOrganization("{YOUR_ORGANIZATION_ID") - .build(); -``` - -**Important!** When logging into an organization, it is important to ensure the `org_id` claim of the ID Token matches the expected organization value. The `IdTokenVerifier` can be configured with an expected `org_id` claim value, as the example below demonstrates. -For more information, please read [Work with Tokens and Organizations](https://auth0.com/docs/organizations/using-tokens) on Auth0 Docs. -```java -IdTokenVerifier.init("{ISSUER}", "{AUDIENCE}", signatureVerifier) - .withOrganization("{ORG_ID}") - .build() - .verify(jwt); -``` - -### Accept user invitations - -Accept a user invitation by using `withInvitation()` when building the Authorization URL: - -``` -AuthAPI auth = AuthAPI.newBuilder("{YOUR_DOMAIN}", "{YOUR_CLIENT_ID}", "{YOUR_CLIENT_SECRET}").build(); -String url = auth.authorizeUrl("https://me.auth0.com/callback") - .withOrganization("{YOUR_ORGANIZATION_ID") - .withInvitation("{YOUR_INVITATION_ID}") - .build(); -``` - -## Client credential management - -The SDK provides comprehensive support for managing client credentials used for machine-to-machine authentication and API access. - -### List client credentials - -```java -ManagementAPI mgmt = ManagementAPI.newBuilder("{YOUR_DOMAIN}", "{YOUR_API_TOKEN}").build(); -Request> request = mgmt.clients().listCredentials("{CLIENT_ID}"); -List credentials = request.execute().getBody(); -``` - -### Get a specific client credential - -```java -Request request = mgmt.clients().getCredential("{CLIENT_ID}", "{CREDENTIAL_ID}"); -Credential credential = request.execute().getBody(); -``` - -### Create a new client credential - -```java -Credential newCredential = new Credential("public_key", "{PEM_CONTENT}"); -newCredential.setName("My API Credential"); -Request request = mgmt.clients().createCredential("{CLIENT_ID}", newCredential); -Credential createdCredential = request.execute().getBody(); -``` - -### Update an existing client credential - -```java -Credential updates = new Credential(); -updates.setExpiresAt(""); -// Note: expires_at can also be updated by setting a Date object -Request request = mgmt.clients().updateCredential("{CLIENT_ID}", "{CREDENTIAL_ID}", updates); -Credential updatedCredential = request.execute().getBody(); -``` - -### Delete a client credential - -```java -Request request = mgmt.clients().deleteCredential("{CLIENT_ID}", "{CREDENTIAL_ID}"); -request.execute(); -``` - -**Required Scopes**: -- `read:client_credentials` - for listing and getting credentials -- `create:client_credentials` - for creating new credentials -- `update:client_credentials` - for updating existing credentials -- `delete:client_credentials` - for deleting credentials - -For more information, see the [Auth0 Management API documentation](https://auth0.com/docs/api/management/v2/clients). - -## Asynchronous operations - -Requests can be executed asynchronously, using the `executeAsync()` method, which returns a `CompletableFuture`. - -```java -CompletableFuture> userFuture = mgmt.users().getUser("auth0|123", new UserFilter()).executeAsync(); -User user = userFuture.get().getBody(); -``` diff --git a/src/main/java/com/auth0/client/HttpOptions.java b/src/main/java/com/auth0/client/HttpOptions.java deleted file mode 100644 index cf2cb481f..000000000 --- a/src/main/java/com/auth0/client/HttpOptions.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.auth0.client; - -/** - * Used to configure additional configuration options when customizing the API client instance. - * @deprecated use the {@link com.auth0.net.client.DefaultHttpClient} to configure HTTP client behavior - */ -@Deprecated -public class HttpOptions { - - private ProxyOptions proxyOptions; - private int connectTimeout = 10; - private int readTimeout = 10; - private int mgmtApiMaxRetries = 3; - private int maxRequests = 64; - private int maxRequestsPerHost = 5; - private LoggingOptions loggingOptions; - - /** - * Getter for the Proxy configuration options - * - * @return the Proxy configuration options if set, null otherwise. - */ - public ProxyOptions getProxyOptions() { - return proxyOptions; - } - - /** - * Setter for the Proxy configuration options - * - * @param proxyOptions the Proxy configuration options - */ - public void setProxyOptions(ProxyOptions proxyOptions) { - this.proxyOptions = proxyOptions; - } - - /** - * @return the connect timeout, in seconds - */ - public int getConnectTimeout() { - return connectTimeout; - } - - /** - * Sets the value of the connect timeout, in seconds. Defaults to ten seconds. A value of zero results in no connect timeout. - * Negative numbers will be treated as zero. - * @param connectTimeout the value of the connect timeout to use. - */ - public void setConnectTimeout(int connectTimeout) { - if (connectTimeout < 0) { - connectTimeout = 0; - } - this.connectTimeout = connectTimeout; - } - - /** - * @return the read timeout, in seconds - */ - public int getReadTimeout() { - return readTimeout; - } - - /** - * Sets the value of the read timeout, in seconds. Defaults to ten seconds. A value of zero results in no read timeout. - * Negative numbers will be treated as zero. - * - * @param readTimeout the value of the read timeout to use. - */ - public void setReadTimeout(int readTimeout) { - if (readTimeout < 0) { - readTimeout = 0; - } - this.readTimeout = readTimeout; - } - - /** - * Set the HTTP logging configuration options. If not set, no logs will be captured. - * @param loggingOptions the Logging configuration options - */ - public void setLoggingOptions(LoggingOptions loggingOptions) { - this.loggingOptions = loggingOptions; - } - - /** - * @return the Logging configurration options if set, null otherwise. - */ - public LoggingOptions getLoggingOptions() { - return this.loggingOptions; - } - - /** - * @return the configured number of maximum retries to attempt when a rate-limit error is encountered by the Management API client. - */ - public int getManagementAPIMaxRetries() { - return mgmtApiMaxRetries; - } - - /** - * Sets the maximum number of consecutive retries for Management API requests that fail due to rate-limits being reached. - * By default, rate-limited requests will be retries a maximum of three times. To disable retries on rate-limit - * errors, set this value to zero. - * - *

- * Note: Rate-limiting retries is only applicable to the Management API client. - *

- * - * @param maxRetries the maximum number of consecutive retries to attempt upon a rate-limit error. Defaults to three. - * Must be a number between zero (do not retry) and ten. - */ - public void setManagementAPIMaxRetries(int maxRetries) { - if (maxRetries < 0 || maxRetries > 10) { - throw new IllegalArgumentException("Retries must be between zero and ten."); - } - this.mgmtApiMaxRetries = maxRetries; - } - - /** - * Sets the maximum number of requests for each host to execute concurrently. - * - * @param maxRequestsPerHost the maximum number of requests for each host to execute concurrently. Must be equal to or greater than one. - */ - public void setMaxRequestsPerHost(int maxRequestsPerHost) { - if (maxRequestsPerHost < 1) { - throw new IllegalArgumentException("maxRequestsPerHost must be one or greater."); - } - this.maxRequestsPerHost = maxRequestsPerHost; - } - - /** - * @return the maximum number of requests for each host to execute concurrently. - */ - public int getMaxRequestsPerHost() { - return this.maxRequestsPerHost; - } - - /** - * Sets the maximum number of requests to execute concurrently. - * - * @param maxRequests the number of requests to execute concurrently. Must be equal to or greater than one. - */ - public void setMaxRequests(int maxRequests) { - if (maxRequests < 1) { - throw new IllegalArgumentException("maxRequests must be one or greater."); - } - this.maxRequests = maxRequests; - } - - /** - * @return the number of requests to execute concurrently - */ - public int getMaxRequests() { - return this.maxRequests; - } -} diff --git a/src/main/java/com/auth0/client/auth/AuthAPI.java b/src/main/java/com/auth0/client/auth/AuthAPI.java index c09e32464..7072aed26 100644 --- a/src/main/java/com/auth0/client/auth/AuthAPI.java +++ b/src/main/java/com/auth0/client/auth/AuthAPI.java @@ -15,7 +15,6 @@ import java.util.Map; import java.util.Objects; import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; import org.jetbrains.annotations.TestOnly; /** @@ -73,40 +72,6 @@ public class AuthAPI { private final ClientAssertionSigner clientAssertionSigner; private final HttpUrl baseUrl; - /** - * Create a new instance with the given tenant's domain, application's client id and client secret. - * These values can be obtained at {@code https://manage.auth0.com/#/applications/{YOUR_CLIENT_ID}/settings}. - * In addition, accepts an {@link com.auth0.client.HttpOptions} that will be used to configure the networking client. - * - * @deprecated Use the {@link Builder} to configure and create instances. - * - * @param domain tenant's domain. - * @param clientId the application's client id. - * @param clientSecret the application's client secret. - * @param options configuration options for this client instance. - * @see #AuthAPI(String, String, String) - */ - @Deprecated - @SuppressWarnings("deprecation") - public AuthAPI(String domain, String clientId, String clientSecret, com.auth0.client.HttpOptions options) { - this(domain, clientId, clientSecret, null, buildNetworkingClient(options)); - } - - /** - * Create a new instance with the given tenant's domain, application's client id and client secret. - * These values can be obtained at {@code https://manage.auth0.com/#/applications/{YOUR_CLIENT_ID}/}settings. - * - * @deprecated Use the {@link Builder} to configure and create instances. - * - * @param domain tenant's domain. - * @param clientId the application's client id. - * @param clientSecret the application's client secret. - */ - @Deprecated - public AuthAPI(String domain, String clientId, String clientSecret) { - this(domain, clientId, clientSecret, new com.auth0.client.HttpOptions()); - } - /** * Initialize a new {@link Builder} to configure and create an instance. Use this to construct an instance * with a client secret when using a confidential client (Regular Web Application). @@ -163,27 +128,6 @@ private AuthAPI( this.client = httpClient; } - /** - * Given a set of options, it creates a new instance of the {@link OkHttpClient} - * configuring them according to their availability. - * - * @param options the options to set to the client. - * @return a new networking client instance configured as requested. - */ - @SuppressWarnings("deprecation") - private static Auth0HttpClient buildNetworkingClient(com.auth0.client.HttpOptions options) { - Asserts.assertNotNull(options, "Http options"); - return DefaultHttpClient.newBuilder() - .withLogging(options.getLoggingOptions()) - .withMaxRetries(options.getManagementAPIMaxRetries()) - .withMaxRequests(options.getMaxRequests()) - .withMaxRequestsPerHost(options.getMaxRequestsPerHost()) - .withProxy(options.getProxyOptions()) - .withConnectTimeout(options.getConnectTimeout()) - .withReadTimeout(options.getReadTimeout()) - .build(); - } - @TestOnly Auth0HttpClient getHttpClient() { return this.client; @@ -600,37 +544,6 @@ public SignUpRequest signUp(String email, String username, char[] password, Stri return request; } - /** - * Creates a sign up request with the given credentials and database connection. - * "Requires Username" option must be turned on in the Connection's configuration first. - * i.e.: - *
-     * {@code
-     * try {
-     *      Map fields = new HashMap();
-     *      fields.put("age", "25);
-     *      fields.put("city", "Buenos Aires");
-     *      authAPI.signUp("me@auth0.com", "myself", "topsecret", "db-connection")
-     *          .setCustomFields(fields)
-     *          .execute();
-     * } catch (Auth0Exception e) {
-     *      //Something happened
-     * }
-     * }
-     * 
- * - * @param email the desired user's email. - * @param username the desired user's username. - * @param password the desired user's password. - * @param connection the database connection where the user is going to be created. - * @return a Request to configure and execute. - * @deprecated Use {@linkplain #signUp(String, String, char[], String)} instead. - */ - @Deprecated - public SignUpRequest signUp(String email, String username, String password, String connection) { - return this.signUp(email, username, password != null ? password.toCharArray() : null, connection); - } - /** * Creates a sign up request with the given credentials and database connection. * "Requires Username" option must be turned on in the Connection's configuration first. @@ -665,35 +578,6 @@ public SignUpRequest signUp(String email, String username, char[] password, Stri return request; } - /** - * Creates a sign up request with the given credentials and database connection. - * i.e.: - *
-     * {@code
-     * try {
-     *      Map fields = new HashMap();
-     *      fields.put("age", "25);
-     *      fields.put("city", "Buenos Aires");
-     *      authAPI.signUp("me@auth0.com", "topsecret", "db-connection")
-     *          .setCustomFields(fields)
-     *          .execute();
-     * } catch (Auth0Exception e) {
-     *      //Something happened
-     * }
-     * }
-     * 
- * - * @param email the desired user's email. - * @param password the desired user's password. - * @param connection the database connection where the user is going to be created. - * @return a Request to configure and execute. - * @deprecated Use {@linkplain #signUp(String, char[], String)} instead. - */ - @Deprecated - public SignUpRequest signUp(String email, String password, String connection) { - return this.signUp(email, password != null ? password.toCharArray() : null, connection); - } - /** * Creates a sign up request with the given credentials and database connection. *
@@ -735,31 +619,6 @@ public SignUpRequest signUp(String email, char[] password, String connection) {
         return request;
     }
 
-    /**
-     * Creates a log in request using the 'Password' grant and the given credentials.
-     * i.e.:
-     * 
-     * {@code
-     * try {
-     *      TokenHolder result = authAPI.login("me@auth0.com", "topsecret")
-     *          .setScope("openid email nickname")
-     *          .execute();
-     * } catch (Auth0Exception e) {
-     *      //Something happened
-     * }
-     * }
-     * 
- * - * @param emailOrUsername the identity of the user. - * @param password the password of the user. - * @return a Request to configure and execute. - * @deprecated Use {@linkplain #login(String, char[])} instead. - */ - @Deprecated - public TokenRequest login(String emailOrUsername, String password) { - return this.login(emailOrUsername, password != null ? password.toCharArray() : null); - } - /** * Creates a log in request using the 'Password' grant and the given credentials. * @@ -798,33 +657,6 @@ public TokenRequest login(String emailOrUsername, char[] password) { return request; } - /** - * Creates a log in request using the 'Password Realm' grant and the given credentials. - * Default used realm and audience are defined in the "API Authorization Settings" in the account's advanced settings in the Auth0 Dashboard. - *
-     * {@code
-     * try {
-     *      TokenHolder result = authAPI.login("me@auth0.com", "topsecret", "my-realm")
-     *          .setAudience("https://myapi.me.auth0.com/users")
-     *          .execute()
-     *          .getBody();
-     * } catch (Auth0Exception e) {
-     *      //Something happened
-     * }
-     * }
-     * 
- * - * @param emailOrUsername the identity of the user. - * @param password the password of the user. - * @param realm the realm to use. - * @return a Request to configure and execute. - * @deprecated Use {@linkplain #login(String, char[], String)} instead. - */ - @Deprecated - public TokenRequest login(String emailOrUsername, String password, String realm) { - return this.login(emailOrUsername, password != null ? password.toCharArray() : null, realm); - } - /** * Creates a log in request using the 'Password Realm' grant and the given credentials. * Default used realm and audience are defined in the "API Authorization Settings" in the account's advanced settings in the Auth0 Dashboard. @@ -1406,46 +1238,6 @@ private BaseRequest createBaseOobRequest(String mfaToken, Li return request; } - /** - * Associates or adds a new OOB authenticator for multi-factor authentication (MFA). - * Confidential clients (Regular Web Apps) must have a client secret configured on this {@code AuthAPI} instance. - *
-     * {@code
-     * try {
-     *      CreatedOobResponse result = authAPI.addOobAuthenticator("the-mfa-token", Collections.singletonList("sms"), "phone-number")
-     *          .execute()
-     *          .getBody();
-     * } catch (Auth0Exception e) {
-     *      //Something happened
-     * }
-     * }
-     * 
- * - * @param mfaToken The token received from mfa_required error. Must not be null. - * @param oobChannels The type of OOB channels supported by the client. Must not be null. - * @param phoneNumber The phone number for "sms" or "voice" channels. May be null if not using "sms" or "voice". - * @return a Request to execute. - * @see Add an Authenticator API documentation - * @deprecated Use {@linkplain #addOobAuthenticator(String, List, String, String)} instead. - */ - @Deprecated - public Request addOobAuthenticator( - String mfaToken, List oobChannels, String phoneNumber) { - Asserts.assertNotNull(mfaToken, "mfa token"); - Asserts.assertNotNull(oobChannels, "OOB channels"); - if (oobChannels.contains("sms") || oobChannels.contains("voice")) { - Asserts.assertNotNull(phoneNumber, "phone number"); - } - - BaseRequest request = createBaseOobRequest(mfaToken, oobChannels); - - if (phoneNumber != null) { - request.addParameter("phone_number", phoneNumber); - } - - return request; - } - /** * Associates or adds a new OOB authenticator for multi-factor authentication (MFA). * Confidential clients (Regular Web Apps) must have a client secret configured on this {@code AuthAPI} instance. diff --git a/src/main/java/com/auth0/json/mgmt/selfserviceprofiles/GoogleWorkspaceProvisioningConfig.java b/src/main/java/com/auth0/json/mgmt/selfserviceprofiles/GoogleWorkspaceProvisioningConfig.java deleted file mode 100644 index a20726c78..000000000 --- a/src/main/java/com/auth0/json/mgmt/selfserviceprofiles/GoogleWorkspaceProvisioningConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.auth0.json.mgmt.selfserviceprofiles; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonIgnoreProperties(ignoreUnknown = true) -public class GoogleWorkspaceProvisioningConfig { - @JsonProperty("sync_users") - private boolean syncUsers; - - @JsonProperty("sync_users") - public boolean isSyncUsers() { - return syncUsers; - } - - @JsonProperty("sync_users") - public void setSyncUsers(boolean syncUsers) { - this.syncUsers = syncUsers; - } -} diff --git a/src/main/java/com/auth0/json/mgmt/selfserviceprofiles/ProvisioningConfig.java b/src/main/java/com/auth0/json/mgmt/selfserviceprofiles/ProvisioningConfig.java deleted file mode 100644 index 8b1378917..000000000 --- a/src/main/java/com/auth0/json/mgmt/selfserviceprofiles/ProvisioningConfig.java +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/java/com/auth0/net/EmptyBodyVoidRequest.java b/src/main/java/com/auth0/net/EmptyBodyVoidRequest.java deleted file mode 100644 index af6881824..000000000 --- a/src/main/java/com/auth0/net/EmptyBodyVoidRequest.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.auth0.net; - -import com.auth0.client.mgmt.TokenProvider; -import com.auth0.exception.Auth0Exception; -import com.auth0.net.client.Auth0HttpClient; -import com.auth0.net.client.Auth0HttpResponse; -import com.auth0.net.client.HttpMethod; -import com.auth0.net.client.HttpRequestBody; -import com.fasterxml.jackson.core.type.TypeReference; - -/** - * Request class that does not accept parameters to be sent as part of its body and request doesn't return any value on its success. - * The content type of this request is "application/json". - * - * @param The type expected to be received as part of the response. - * @see BaseRequest - */ -public class EmptyBodyVoidRequest extends BaseRequest { - public EmptyBodyVoidRequest( - Auth0HttpClient client, - TokenProvider tokenProvider, - String url, - HttpMethod method, - TypeReference tType) { - super(client, tokenProvider, url, method, tType); - } - - @Override - @SuppressWarnings("deprecation") - protected HttpRequestBody createRequestBody() { - return HttpRequestBody.create("application/json", new byte[0]); - } - - @Override - public EmptyBodyVoidRequest addParameter(String name, Object value) { - // do nothing - return this; - } - - @Override - protected T parseResponseBody(Auth0HttpResponse response) throws Auth0Exception { - if (!response.isSuccessful()) { - throw super.createResponseException(response); - } - return null; - } -} diff --git a/src/main/java/com/auth0/net/MultipartRequest.java b/src/main/java/com/auth0/net/MultipartRequest.java index 9e6a4da91..5e0e1085d 100644 --- a/src/main/java/com/auth0/net/MultipartRequest.java +++ b/src/main/java/com/auth0/net/MultipartRequest.java @@ -7,7 +7,6 @@ import com.auth0.net.client.*; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.File; import java.io.IOException; import java.util.HashMap; @@ -82,26 +81,6 @@ public MultipartRequest addHeader(String name, String value) { return this; } - /** - * Adds a file part to the form of this request - * - * @param name the name of the part - * @param file the file contents to send in this part - * @param mediaType the file contents media type - * @return this same request instance - */ - @SuppressWarnings("deprecation") - public MultipartRequest addPart(String name, File file, String mediaType) { - assertNotNull(name, "name"); - assertNotNull(name, "file"); - if (!file.exists()) { - throw new IllegalArgumentException("Failed to add part because the file specified cannot be found."); - } - bodyBuilder.withFilePart(new Auth0MultipartRequestBody.FilePart(name, file, mediaType)); - partsCount++; - return this; - } - /** * Adds a key-value part to the form of this request *