Search in sources :

Example 16 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class RolesEntity method removePermissions.

/**
 * Un-associate permissions from a role.
 * A token with update:roles is needed.
 * See https://auth0.com/docs/api/management/v2#!/Roles/delete_role_permission_assignment
 *
 * @param roleId the role id
 * @param permissions a list of permission objects to un-associate from the role
 * @return a Request to execute
 */
public Request<Void> removePermissions(String roleId, List<Permission> permissions) {
    Asserts.assertNotNull(roleId, "role id");
    Asserts.assertNotEmpty(permissions, "permissions");
    Map<String, List<Permission>> body = new HashMap<>();
    body.put("permissions", permissions);
    final String url = baseUrl.newBuilder().addEncodedPathSegments("api/v2/roles").addEncodedPathSegments(roleId).addEncodedPathSegments("permissions").build().toString();
    VoidRequest request = new VoidRequest(this.client, url, "DELETE");
    request.setBody(body);
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest) HashMap(java.util.HashMap) List(java.util.List)

Example 17 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class BlacklistsEntity method blacklistToken.

/**
 * Add a Token to the Blacklist. A token with scope blacklist:tokens is needed.
 * See https://auth0.com/docs/api/management/v2#!/Blacklists/post_tokens.
 *
 * @param token the token to blacklist.
 * @return a Request to execute.
 */
public Request<Void> blacklistToken(Token token) {
    Asserts.assertNotNull(token, "token");
    String url = baseUrl.newBuilder().addPathSegments("api/v2/blacklists/tokens").build().toString();
    VoidRequest request = new VoidRequest(client, url, "POST");
    request.addHeader("Authorization", "Bearer " + apiToken);
    request.setBody(token);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 18 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class ClientGrantsEntity method delete.

/**
 * Delete an existing Client Grant. A token with scope delete:client_grants is needed.
 * See https://auth0.com/docs/api/management/v2#!/Client_Grants/delete_client_grants_by_id
 *
 * @param clientGrantId the client grant id.
 * @return a Request to execute.
 */
public Request<Void> delete(String clientGrantId) {
    Asserts.assertNotNull(clientGrantId, "client grant id");
    String url = baseUrl.newBuilder().addPathSegments("api/v2/client-grants").addPathSegment(clientGrantId).build().toString();
    VoidRequest request = new VoidRequest(client, url, "DELETE");
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 19 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class ConnectionsEntity method deleteUser.

/**
 * Delete an existing User from the given Database Connection. A token with scope delete:users is needed.
 * See https://auth0.com/docs/api/management/v2#!/Connections/delete_users_by_email
 *
 * @param connectionId the connection id where the user is stored.
 * @param email        the email of the user to delete.
 * @return a Request to execute.
 */
public Request<Void> deleteUser(String connectionId, String email) {
    Asserts.assertNotNull(connectionId, "connection id");
    Asserts.assertNotNull(email, "email");
    String url = baseUrl.newBuilder().addPathSegments("api/v2/connections").addPathSegment(connectionId).addPathSegment("users").addQueryParameter("email", email).build().toString();
    VoidRequest request = new VoidRequest(this.client, url, "DELETE");
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Example 20 with Request

use of com.auth0.net.Request in project auth0-java by auth0.

the class EmailProviderEntity method delete.

/**
 * Delete the existing Email Provider. A token with scope delete:email_provider is needed.
 * See https://auth0.com/docs/api/management/v2#!/Emails/delete_provider
 *
 * @return a Request to execute.
 */
public Request<Void> delete() {
    String url = baseUrl.newBuilder().addPathSegments("api/v2/emails/provider").build().toString();
    VoidRequest request = new VoidRequest(client, url, "DELETE");
    request.addHeader("Authorization", "Bearer " + apiToken);
    return request;
}
Also used : VoidRequest(com.auth0.net.VoidRequest)

Aggregations

Test (org.junit.Test)193 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)185 DecodedJWT (com.auth0.jwt.interfaces.DecodedJWT)77 IOException (java.io.IOException)76 List (java.util.List)63 Algorithm (com.auth0.jwt.algorithms.Algorithm)35 VoidRequest (com.auth0.net.VoidRequest)33 Auth0Exception (com.auth0.exception.Auth0Exception)30 APIException (com.auth0.exception.APIException)27 RateLimitException (com.auth0.exception.RateLimitException)25 HashMap (java.util.HashMap)24 PageFilter (com.auth0.client.mgmt.filter.PageFilter)23 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)23 ServletException (javax.servlet.ServletException)23 TokenHolder (com.auth0.json.auth.TokenHolder)22 JWTVerifier (com.auth0.jwt.JWTVerifier)22 ArrayList (java.util.ArrayList)22 Test (org.junit.jupiter.api.Test)22 JWTVerificationException (com.auth0.jwt.exceptions.JWTVerificationException)20 Date (java.util.Date)20