Skip to content

Commit d2c9b2f

Browse files
committed
Feat: Add Support for Self-Service-Provisioning
1 parent dc3dda5 commit d2c9b2f

26 files changed

+2174
-9
lines changed

src/main/java/com/auth0/client/mgmt/ManagementAPI.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,14 @@ public NetworkAclsEntity networkAcls() {
415415
return new NetworkAclsEntity(client, baseUrl, tokenProvider);
416416
}
417417

418+
/**
419+
* Getter for the User Attribute Profiles Entity
420+
* @return the User Attribute Profiles Entity
421+
*/
422+
public UserAttributeProfilesEntity userAttributeProfiles() {
423+
return new UserAttributeProfilesEntity(client, baseUrl, tokenProvider);
424+
}
425+
418426
/**
419427
* Builder for {@link ManagementAPI} API client instances.
420428
*/
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
package com.auth0.client.mgmt;
2+
3+
import com.auth0.client.mgmt.filter.UserAttributeProfilesFilter;
4+
import com.auth0.json.mgmt.userAttributeProfiles.*;
5+
import com.auth0.net.BaseRequest;
6+
import com.auth0.net.Request;
7+
import com.auth0.net.VoidRequest;
8+
import com.auth0.net.client.Auth0HttpClient;
9+
import com.auth0.net.client.HttpMethod;
10+
import com.auth0.utils.Asserts;
11+
import com.fasterxml.jackson.core.type.TypeReference;
12+
import okhttp3.HttpUrl;
13+
14+
public class UserAttributeProfilesEntity extends BaseManagementEntity {
15+
16+
private final static String ORGS_PATH = "api/v2/user-attribute-profiles";
17+
18+
UserAttributeProfilesEntity(Auth0HttpClient client, HttpUrl baseUrl, TokenProvider tokenProvider) {
19+
super(client, baseUrl, tokenProvider);
20+
}
21+
22+
/**
23+
* Get a user attribute profile by its ID. A token with {@code read:user_attribute_profiles} scope is required.
24+
* @param id the ID of the user attribute profile to retrieve.
25+
* @return a Request to execute.
26+
*/
27+
public Request<UserAttributeProfile> get(String id) {
28+
Asserts.assertNotNull(id, "id");
29+
30+
String url = baseUrl.newBuilder()
31+
.addPathSegments(ORGS_PATH)
32+
.addPathSegment(id)
33+
.build().toString();
34+
35+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<UserAttributeProfile>() {
36+
});
37+
}
38+
39+
/**
40+
* Get all user attribute profiles. A token with {@code read:user_attribute_profiles} scope is required.
41+
*
42+
* @param filter an optional pagination filter
43+
* @return a Request to execute
44+
*
45+
*/
46+
public Request<ListUserAttributeProfile> getAll(UserAttributeProfilesFilter filter) {
47+
HttpUrl.Builder builder = baseUrl.newBuilder()
48+
.addPathSegments(ORGS_PATH);
49+
50+
applyFilter(filter, builder);
51+
52+
String url = builder.build().toString();
53+
54+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<ListUserAttributeProfile>() {
55+
});
56+
}
57+
58+
private void applyFilter(UserAttributeProfilesFilter filter, HttpUrl.Builder builder) {
59+
if (filter != null) {
60+
filter.getAsMap().forEach((k, v) -> builder.addQueryParameter(k, String.valueOf(v)));
61+
}
62+
}
63+
64+
65+
/**
66+
* Update a user attribute profile. A token with {@code update:user_attribute_profiles} scope is required.
67+
*
68+
* @param userAttributeProfile the user attribute profile to update.
69+
* @return a Request to execute.
70+
*/
71+
public Request<UserAttributeProfile> update(String id, UserAttributeProfile userAttributeProfile) {
72+
Asserts.assertNotNull(id, "id");
73+
Asserts.assertNotNull(userAttributeProfile, "userAttributeProfile");
74+
75+
String url = baseUrl.newBuilder()
76+
.addPathSegments(ORGS_PATH)
77+
.addPathSegment(id)
78+
.build().toString();
79+
80+
BaseRequest<UserAttributeProfile> request = new BaseRequest<>(client, tokenProvider, url, HttpMethod.PATCH, new TypeReference<UserAttributeProfile>() {
81+
});
82+
83+
request.setBody(userAttributeProfile);
84+
return request;
85+
}
86+
87+
/**
88+
* Create a new user attribute profile. A token with {@code create:user_attribute_profiles} scope is required.
89+
* @param userAttributeProfile the user attribute profile to create.
90+
* @return a Request to execute.
91+
*/
92+
public Request<UserAttributeProfile> create(UserAttributeProfile userAttributeProfile) {
93+
Asserts.assertNotNull(userAttributeProfile.getName(), "name");
94+
Asserts.assertNotNull(userAttributeProfile.getUserAttributes(), "userAttributes");
95+
96+
String url = baseUrl.newBuilder()
97+
.addPathSegments(ORGS_PATH)
98+
.build().toString();
99+
100+
BaseRequest<UserAttributeProfile> request = new BaseRequest<>(client, tokenProvider, url, HttpMethod.POST, new TypeReference<UserAttributeProfile>() {
101+
});
102+
103+
request.setBody(userAttributeProfile);
104+
return request;
105+
}
106+
107+
/**
108+
* Delete a user attribute profile by its ID. A token with {@code delete:user_attribute_profiles} scope is required.
109+
* @param id the ID of the user attribute profile to delete.
110+
* @return a Request to execute.
111+
*/
112+
public Request<Void> delete(String id) {
113+
Asserts.assertNotNull(id, "id");
114+
115+
HttpUrl.Builder builder = baseUrl
116+
.newBuilder()
117+
.addPathSegments(ORGS_PATH)
118+
.addPathSegment(id);
119+
120+
String url = builder.build().toString();
121+
return new VoidRequest(client, tokenProvider, url, HttpMethod.DELETE);
122+
}
123+
124+
/**
125+
* Get a user attribute profile template by its ID. A token with {@code read:user_attribute_profiles} scope is required.
126+
* @param id the ID of the user attribute profile template to retrieve.
127+
* @return a Request to execute.
128+
*/
129+
public Request<UserAttributeProfileTemplateResponse> getTemplate(String id) {
130+
Asserts.assertNotNull(id, "id");
131+
132+
String url = baseUrl.newBuilder()
133+
.addPathSegments(ORGS_PATH)
134+
.addPathSegment("templates")
135+
.addPathSegment(id)
136+
.build().toString();
137+
138+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<UserAttributeProfileTemplateResponse>() {
139+
});
140+
}
141+
142+
/**
143+
* Get all user attribute profile templates. A token with {@code read:user_attribute_profiles} scope is required.
144+
*
145+
* @return a Request to execute
146+
*/
147+
public Request<ListUserAttributeProfileTemplate> getAllTemplates() {
148+
String url = baseUrl.newBuilder()
149+
.addPathSegments(ORGS_PATH)
150+
.addPathSegment("templates")
151+
.build().toString();
152+
153+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<ListUserAttributeProfileTemplate>() {
154+
});
155+
}
156+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.auth0.client.mgmt.filter;
2+
3+
public class UserAttributeProfilesFilter extends BaseFilter {
4+
5+
/**
6+
* Filter by checkpoint pagination support
7+
*
8+
* @param from the starting index identifier
9+
* @param take the number of items to retrieve
10+
* @return this filter instance
11+
*/
12+
public UserAttributeProfilesFilter withCheckpointPagination(String from, int take) {
13+
parameters.put("from", from);
14+
parameters.put("take", take);
15+
return this;
16+
}
17+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.auth0.json.mgmt.selfserviceprofiles;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
import java.util.List;
8+
9+
@JsonInclude(JsonInclude.Include.NON_NULL)
10+
@JsonIgnoreProperties(ignoreUnknown = true)
11+
public class ProvisioningConfig {
12+
@JsonProperty("scopes")
13+
private List<String> scopes;
14+
@JsonProperty("token_lifetime")
15+
private int tokenLifetime;
16+
17+
18+
/**
19+
* Getter for the scopes.
20+
* @return the scopes.
21+
*/
22+
@JsonProperty("scopes")
23+
public List<String> getScopes() {
24+
return scopes;
25+
}
26+
27+
/**
28+
* Setter for the scopes.
29+
* @param scopes the scopes to set.
30+
*/
31+
@JsonProperty("scopes")
32+
public void setScopes(List<String> scopes) {
33+
this.scopes = scopes;
34+
}
35+
36+
/**
37+
* Getter for the token lifetime.
38+
* @return the token lifetime.
39+
*/
40+
@JsonProperty("token_lifetime")
41+
public int getTokenLifetime() {
42+
return tokenLifetime;
43+
}
44+
45+
/**
46+
* Setter for the token lifetime.
47+
* @param tokenLifetime the token lifetime to set.
48+
*/
49+
@JsonProperty("token_lifetime")
50+
public void setTokenLifetime(int tokenLifetime) {
51+
this.tokenLifetime = tokenLifetime;
52+
}
53+
}

src/main/java/com/auth0/json/mgmt/selfserviceprofiles/SelfServiceProfile.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class SelfServiceProfile {
2020
private Branding branding;
2121
@JsonProperty("allowed_strategies")
2222
private List<String> allowedStrategies;
23+
@JsonProperty("user_attribute_profile_id")
24+
private String userAttributeProfileId;
2325

2426
/**
2527
* Getter for the name of the self-service profile.
@@ -100,4 +102,20 @@ public List<String> getAllowedStrategies() {
100102
public void setAllowedStrategies(List<String> allowedStrategies) {
101103
this.allowedStrategies = allowedStrategies;
102104
}
105+
106+
/**
107+
* Getter for user attribute profile ID.
108+
* @return the user attribute profile ID.
109+
*/
110+
public String getUserAttributeProfileId() {
111+
return userAttributeProfileId;
112+
}
113+
114+
/**
115+
* Setter for user attribute profile ID.
116+
* @param userAttributeProfileId the user attribute profile ID to set.
117+
*/
118+
public void setUserAttributeProfileId(String userAttributeProfileId) {
119+
this.userAttributeProfileId = userAttributeProfileId;
120+
}
103121
}

src/main/java/com/auth0/json/mgmt/selfserviceprofiles/SsoAccessTicketRequest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class SsoAccessTicketRequest {
2222
private int ttlSec;
2323
@JsonProperty("domain_aliases_config")
2424
private DomainAliasesConfig domainAliasesConfig;
25+
@JsonProperty("provisioning_config")
26+
private ProvisioningConfig provisioningConfig;
2527

2628
/**
2729
* Creates a new instance.
@@ -118,4 +120,20 @@ public DomainAliasesConfig getDomainAliasesConfig() {
118120
public void setDomainAliasesConfig(DomainAliasesConfig domainAliasesConfig) {
119121
this.domainAliasesConfig = domainAliasesConfig;
120122
}
123+
124+
/**
125+
* Getter for the provisioning configuration.
126+
* @return the provisioning configuration.
127+
*/
128+
public ProvisioningConfig getProvisioningConfig() {
129+
return provisioningConfig;
130+
}
131+
132+
/**
133+
* Setter for the provisioning configuration.
134+
* @param provisioningConfig the provisioning configuration to set.
135+
*/
136+
public void setProvisioningConfig(ProvisioningConfig provisioningConfig) {
137+
this.provisioningConfig = provisioningConfig;
138+
}
121139
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.auth0.json.mgmt.userAttributeProfiles;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
import java.util.List;
8+
9+
@JsonIgnoreProperties(ignoreUnknown = true)
10+
@JsonInclude(JsonInclude.Include.NON_NULL)
11+
public class ListUserAttributeProfile {
12+
@JsonProperty("user_attribute_profiles")
13+
private List<UserAttributeProfile> userAttributeProfiles;
14+
15+
/**
16+
* Gets the user attribute profiles.
17+
* @return the user attribute profiles
18+
*/
19+
@JsonProperty("user_attribute_profiles")
20+
public List<UserAttributeProfile> getUserAttributeProfiles() {
21+
return userAttributeProfiles;
22+
}
23+
24+
/**
25+
* Sets the user attribute profiles.
26+
* @param userAttributeProfiles the user attribute profiles
27+
*/
28+
@JsonProperty("user_attribute_profiles")
29+
public void setUserAttributeProfiles(List<UserAttributeProfile> userAttributeProfiles) {
30+
this.userAttributeProfiles = userAttributeProfiles;
31+
}
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.auth0.json.mgmt.userAttributeProfiles;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
import java.util.List;
8+
9+
@JsonIgnoreProperties(ignoreUnknown = true)
10+
@JsonInclude(JsonInclude.Include.NON_NULL)
11+
public class ListUserAttributeProfileTemplate {
12+
@JsonProperty("user_attribute_profile_templates")
13+
private List<UserAttributeProfileTemplateResponse> userAttributeProfileTemplateResponses;
14+
15+
/**
16+
* Gets the user attribute profile templates
17+
* @return the user attribute profile templates
18+
*/
19+
@JsonProperty("user_attribute_profile_templates")
20+
public List<UserAttributeProfileTemplateResponse> getUserAttributeProfileTemplates() {
21+
return userAttributeProfileTemplateResponses;
22+
}
23+
24+
/**
25+
* Sets the user attribute profile templates
26+
* @param userAttributeProfileTemplateResponses the user attribute profile templates
27+
*/
28+
@JsonProperty("user_attribute_profile_templates")
29+
public void setUserAttributeProfileTemplates(List<UserAttributeProfileTemplateResponse> userAttributeProfileTemplateResponses) {
30+
this.userAttributeProfileTemplateResponses = userAttributeProfileTemplateResponses;
31+
}
32+
}

0 commit comments

Comments
 (0)