Skip to content

Commit cec49b2

Browse files
authored
Sdk 6843 self service provisioning java support (#765)
1 parent dc3dda5 commit cec49b2

25 files changed

+2074
-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: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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+
if (filter != null) {
51+
filter.getAsMap().forEach((k, v) -> builder.addQueryParameter(k, String.valueOf(v)));
52+
}
53+
54+
String url = builder.build().toString();
55+
56+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<ListUserAttributeProfile>() {
57+
});
58+
}
59+
60+
/**
61+
* Update a user attribute profile. A token with {@code update:user_attribute_profiles} scope is required.
62+
*
63+
* @param userAttributeProfile the user attribute profile to update.
64+
* @return a Request to execute.
65+
*/
66+
public Request<UserAttributeProfile> update(String id, UserAttributeProfile userAttributeProfile) {
67+
Asserts.assertNotNull(id, "id");
68+
Asserts.assertNotNull(userAttributeProfile, "userAttributeProfile");
69+
70+
String url = baseUrl.newBuilder()
71+
.addPathSegments(ORGS_PATH)
72+
.addPathSegment(id)
73+
.build().toString();
74+
75+
BaseRequest<UserAttributeProfile> request = new BaseRequest<>(client, tokenProvider, url, HttpMethod.PATCH, new TypeReference<UserAttributeProfile>() {
76+
});
77+
78+
request.setBody(userAttributeProfile);
79+
return request;
80+
}
81+
82+
/**
83+
* Create a new user attribute profile. A token with {@code create:user_attribute_profiles} scope is required.
84+
* @param userAttributeProfile the user attribute profile to create.
85+
* @return a Request to execute.
86+
*/
87+
public Request<UserAttributeProfile> create(UserAttributeProfile userAttributeProfile) {
88+
Asserts.assertNotNull(userAttributeProfile.getName(), "name");
89+
Asserts.assertNotNull(userAttributeProfile.getUserAttributes(), "userAttributes");
90+
91+
String url = baseUrl.newBuilder()
92+
.addPathSegments(ORGS_PATH)
93+
.build().toString();
94+
95+
BaseRequest<UserAttributeProfile> request = new BaseRequest<>(client, tokenProvider, url, HttpMethod.POST, new TypeReference<UserAttributeProfile>() {
96+
});
97+
98+
request.setBody(userAttributeProfile);
99+
return request;
100+
}
101+
102+
/**
103+
* Delete a user attribute profile by its ID. A token with {@code delete:user_attribute_profiles} scope is required.
104+
* @param id the ID of the user attribute profile to delete.
105+
* @return a Request to execute.
106+
*/
107+
public Request<Void> delete(String id) {
108+
Asserts.assertNotNull(id, "id");
109+
110+
HttpUrl.Builder builder = baseUrl
111+
.newBuilder()
112+
.addPathSegments(ORGS_PATH)
113+
.addPathSegment(id);
114+
115+
String url = builder.build().toString();
116+
return new VoidRequest(client, tokenProvider, url, HttpMethod.DELETE);
117+
}
118+
119+
/**
120+
* Get a user attribute profile template by its ID. A token with {@code read:user_attribute_profiles} scope is required.
121+
* @param id the ID of the user attribute profile template to retrieve.
122+
* @return a Request to execute.
123+
*/
124+
public Request<UserAttributeProfileTemplate> getTemplate(String id) {
125+
Asserts.assertNotNull(id, "id");
126+
127+
String url = baseUrl.newBuilder()
128+
.addPathSegments(ORGS_PATH)
129+
.addPathSegment("templates")
130+
.addPathSegment(id)
131+
.build().toString();
132+
133+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<UserAttributeProfileTemplate>() {
134+
});
135+
}
136+
137+
/**
138+
* Get all user attribute profile templates. A token with {@code read:user_attribute_profiles} scope is required.
139+
*
140+
* @return a Request to execute
141+
*/
142+
public Request<ListUserAttributeProfileTemplate> getAllTemplates() {
143+
String url = baseUrl.newBuilder()
144+
.addPathSegments(ORGS_PATH)
145+
.addPathSegment("templates")
146+
.build().toString();
147+
148+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<ListUserAttributeProfileTemplate>() {
149+
});
150+
}
151+
}
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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
@JsonProperty("next")
16+
private String next;
17+
18+
/**
19+
* Gets the user attribute profiles.
20+
* @return the user attribute profiles
21+
*/
22+
@JsonProperty("user_attribute_profiles")
23+
public List<UserAttributeProfile> getUserAttributeProfiles() {
24+
return userAttributeProfiles;
25+
}
26+
27+
/**
28+
* Sets the user attribute profiles.
29+
* @param userAttributeProfiles the user attribute profiles
30+
*/
31+
@JsonProperty("user_attribute_profiles")
32+
public void setUserAttributeProfiles(List<UserAttributeProfile> userAttributeProfiles) {
33+
this.userAttributeProfiles = userAttributeProfiles;
34+
}
35+
36+
@JsonProperty("next")
37+
public String getNext() {
38+
return next;
39+
}
40+
41+
@JsonProperty("next")
42+
public void setNext(String next) {
43+
this.next = next;
44+
}
45+
}
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<UserAttributeProfileTemplate> 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<UserAttributeProfileTemplate> 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<UserAttributeProfileTemplate> userAttributeProfileTemplateResponses) {
30+
this.userAttributeProfileTemplateResponses = userAttributeProfileTemplateResponses;
31+
}
32+
}

0 commit comments

Comments
 (0)