Skip to content

Commit 8c1cbe3

Browse files
committed
Improve Guardian section
1 parent 850961d commit 8c1cbe3

13 files changed

Lines changed: 190 additions & 78 deletions

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

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public class GuardianEntity extends BaseManagementEntity {
2323

2424
/**
2525
* Create a new Guardian Enrollment Ticket. A token with scope create:guardian_enrollment_tickets is needed.
26-
* See https://auth0.com/docs/api/management/v2#!/Guardian/post_ticket
2726
*
2827
* @param enrollmentTicket the enrollment ticket data to set.
2928
* @return a Request to execute.
29+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/post_ticket">Management API2 docs</a>
3030
*/
3131
public Request<EnrollmentTicket> createEnrollmentTicket(EnrollmentTicket enrollmentTicket) {
3232
Asserts.assertNotNull(enrollmentTicket, "enrollment ticket");
@@ -46,10 +46,10 @@ public Request<EnrollmentTicket> createEnrollmentTicket(EnrollmentTicket enrollm
4646

4747
/**
4848
* Delete an existing Guardian Enrollment. A token with scope delete:guardian_enrollments is needed.
49-
* See https://auth0.com/docs/api/management/v2#!/Guardian/delete_enrollments_by_id
5049
*
5150
* @param enrollmentId the id of the enrollment to retrieve.
5251
* @return a Request to execute.
52+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/delete_enrollments_by_id">Management API2 docs</a>
5353
*/
5454
public Request deleteEnrollment(String enrollmentId) {
5555
Asserts.assertNotNull(enrollmentId, "enrollment id");
@@ -66,10 +66,11 @@ public Request deleteEnrollment(String enrollmentId) {
6666
}
6767

6868
/**
69-
* Request the Guardian enrollment and verification Templates. A token with scope read:guardian_factors is needed.
70-
* See https://auth0.com/docs/api/management/v2#!/Guardian/get_templates
69+
* Request the Guardian SMS enrollment and verification templates.
70+
* A token with scope read:guardian_factors is needed.
7171
*
7272
* @return a Request to execute.
73+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/get_templates">Management API2 docs</a>
7374
*/
7475
public Request<GuardianTemplates> getTemplates() {
7576
String url = baseUrl
@@ -84,11 +85,12 @@ public Request<GuardianTemplates> getTemplates() {
8485
}
8586

8687
/**
87-
* Updates the existing Guardian enrollment and verification Templates. A token with scope update:guardian_factors is needed.
88-
* See https://auth0.com/docs/api/management/v2#!/Guardian/put_templates
88+
* Updates the existing Guardian SMS enrollment and verification templates.
89+
* A token with scope update:guardian_factors is needed.
8990
*
9091
* @param guardianTemplates the templates data to set.
9192
* @return a Request to execute.
93+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/put_templates">Management API2 docs</a>
9294
*/
9395
public Request<GuardianTemplates> updateTemplates(GuardianTemplates guardianTemplates) {
9496
Asserts.assertNotNull(guardianTemplates, "guardian templates");
@@ -107,9 +109,9 @@ public Request<GuardianTemplates> updateTemplates(GuardianTemplates guardianTemp
107109

108110
/**
109111
* Request all the Guardian Factors. A token with scope read:guardian_factors is needed.
110-
* See https://auth0.com/docs/api/management/v2#!/Guardian/get_factors
111112
*
112113
* @return a Request to execute.
114+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/get_factors">Management API2 docs</a>
113115
*/
114116
public Request<List<Factor>> listFactors() {
115117
String url = baseUrl
@@ -125,11 +127,11 @@ public Request<List<Factor>> listFactors() {
125127

126128
/**
127129
* Update an existing Guardian Factor. A token with scope update:guardian_factors is needed.
128-
* See https://auth0.com/docs/api/management/v2#!/Guardian/put_factors_by_name
129130
*
130131
* @param name the name of the Factor to update.
131132
* @param enabled whether to enable or disable the Factor.
132133
* @return a Request to execute.
134+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/put_factors_by_name">Management API2 docs</a>
133135
*/
134136
public Request<Factor> updateFactor(String name, Boolean enabled) {
135137
Asserts.assertNotNull(name, "name");
@@ -149,10 +151,10 @@ public Request<Factor> updateFactor(String name, Boolean enabled) {
149151
}
150152

151153
/**
152-
* Request the Guardian's Twilio Factor Provider. A token with scope read:guardian_factors is needed.
153-
* See https://auth0.com/docs/api/management/v2#!/Guardian/get_twilio
154+
* Request Guardian's Twilio SMS Factor Provider settings. A token with scope read:guardian_factors is needed.
154155
*
155156
* @return a Request to execute.
157+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/get_twilio">Management API2 docs</a>
156158
*/
157159
public Request<TwilioFactorProvider> getTwilioFactorProvider() {
158160

@@ -168,11 +170,11 @@ public Request<TwilioFactorProvider> getTwilioFactorProvider() {
168170
}
169171

170172
/**
171-
* Update the existing Guardian's Twilio Factor Provider. A token with scope update:guardian_factors is needed.
172-
* See https://auth0.com/docs/api/management/v2#!/Guardian/put_twilio
173+
* Update Guardian's Twilio SMS Factor Provider. A token with scope update:guardian_factors is needed.
173174
*
174175
* @param provider the provider data to set.
175176
* @return a Request to execute.
177+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/put_twilio">Management API2 docs</a>
176178
*/
177179
public Request<TwilioFactorProvider> updateTwilioFactorProvider(TwilioFactorProvider provider) {
178180
Asserts.assertNotNull(provider, "provider");
@@ -190,10 +192,21 @@ public Request<TwilioFactorProvider> updateTwilioFactorProvider(TwilioFactorProv
190192
}
191193

192194
/**
193-
* Request the Guardian's Sns Factor Provider. A token with scope read:guardian_factors is needed.
194-
* See https://auth0.com/docs/api/management/v2#!/Guardian/get_sns
195+
* Reset Guardian's Twilio SMS Factor Provider to the defaults.
196+
* A token with scope update:guardian_factors is needed.
195197
*
196198
* @return a Request to execute.
199+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/put_twilio">Management API2 docs</a>
200+
*/
201+
public Request<TwilioFactorProvider> resetTwilioFactorProvider() {
202+
return updateTwilioFactorProvider(new TwilioFactorProvider(null, null, null, null));
203+
}
204+
205+
/**
206+
* Request Guardian's SNS push-notification Factor Provider. A token with scope read:guardian_factors is needed.
207+
*
208+
* @return a Request to execute.
209+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/get_sns">Management API2 docs</a>
197210
*/
198211
public Request<SNSFactorProvider> getSNSFactorProvider() {
199212

@@ -209,11 +222,11 @@ public Request<SNSFactorProvider> getSNSFactorProvider() {
209222
}
210223

211224
/**
212-
* Update the existing Guardian's Sns Factor Provider. A token with scope update:guardian_factors is needed.
213-
* See https://auth0.com/docs/api/management/v2#!/Guardian/put_sns
225+
* Update Guardian's SNS push-notification Factor Provider. A token with scope update:guardian_factors is needed.
214226
*
215227
* @param provider the provider data to set.
216228
* @return a Request to execute.
229+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/put_sns">Management API2 docs</a>
217230
*/
218231
public Request<SNSFactorProvider> updateSNSFactorProvider(SNSFactorProvider provider) {
219232
Asserts.assertNotNull(provider, "provider");
@@ -229,4 +242,15 @@ public Request<SNSFactorProvider> updateSNSFactorProvider(SNSFactorProvider prov
229242
request.setBody(provider);
230243
return request;
231244
}
245+
246+
/**
247+
* Reset Guardian's SNS push-notification Factor Provider to the defaults.
248+
* A token with scope update:guardian_factors is needed.
249+
*
250+
* @return a Request to execute.
251+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Guardian/put_sns">Management API2 docs</a>
252+
*/
253+
public Request<SNSFactorProvider> resetSNSFactorProvider() {
254+
return updateSNSFactorProvider(new SNSFactorProvider(null, null, null, null, null));
255+
}
232256
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ public Request deleteMultifactorProvider(String userId, String provider) {
228228
}
229229

230230
/**
231-
* Rotates a User's Recovery Code. A token with scope update:users is needed.
232-
* See https://auth0.com/docs/api/management/v2#!/Users/post_recovery_code_regeneration
231+
* Rotates a User's Guardian recovery code. A token with scope update:users is needed.
233232
*
234233
* @param userId the user id
235234
* @return a Request to execute.
235+
* @see <a href="https://auth0.com/docs/api/management/v2#!/Users/post_recovery_code_regeneration">Management API2 docs</a>
236236
*/
237237
public Request<RecoveryCode> rotateRecoveryCode(String userId) {
238238
Asserts.assertNotNull(userId, "user id");

src/main/java/com/auth0/json/mgmt/guardian/Enrollment.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public String getType() {
6767
}
6868

6969
/**
70-
* Getter for the enrollment name. This is usually the phone number.
70+
* Getter for the enrollment name. This is usually the phone name. Only for 'guardian' enrollments.
7171
*
7272
* @return the name.
7373
*/
@@ -77,7 +77,7 @@ public String getName() {
7777
}
7878

7979
/**
80-
* Getter for the device identifier. This is usually the phone identifier.
80+
* Getter for the device identifier. This is usually a unique phone identifier. Only for 'guardian' enrollments.
8181
*
8282
* @return the identifier.
8383
*/
@@ -87,7 +87,7 @@ public String getIdentifier() {
8787
}
8888

8989
/**
90-
* Getter for the phone number.
90+
* Getter for the phone number. Only for 'sms' enrollments.
9191
*
9292
* @return the phone number.
9393
*/

src/main/java/com/auth0/json/mgmt/guardian/EnrollmentTicket.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,37 @@ public class EnrollmentTicket {
2525
private String ticketUrl;
2626

2727
/**
28-
* Creates a new instance of the Enrollment Ticket for a given User. You can then specify the email and sendMail
28+
* Creates a new instance of the Enrollment Ticket for a given User.
2929
*
3030
* @param userId the user id
3131
*/
3232
public EnrollmentTicket(String userId) {
33+
this(userId, null, null);
34+
}
35+
36+
/**
37+
* Creates a new instance of the Enrollment Ticket for a given User, specifying if you want the ticket to also be
38+
* sent to the user by email.
39+
*
40+
* @param userId the user id
41+
* @param sendEmail whether the ticket should also be sent to the user by email
42+
*/
43+
public EnrollmentTicket(String userId, Boolean sendEmail) {
44+
this(userId, sendEmail, null);
45+
}
46+
47+
/**
48+
* Creates a new instance of the Enrollment Ticket for a given User, specifying if you want the ticket to also be
49+
* sent to the specified email address.
50+
*
51+
* @param userId the user id
52+
* @param sendEmail whether the ticket should also be sent to the user by email
53+
* @param email the email where the ticket will be sent.
54+
*/
55+
public EnrollmentTicket(String userId, Boolean sendEmail, String email) {
3356
this.userId = userId;
57+
this.sendEmail = sendEmail;
58+
this.email = email;
3459
}
3560

3661
@JsonCreator
@@ -43,6 +68,7 @@ public EnrollmentTicket(String userId) {
4368
* Getter for the id of the User this ticket was made for.
4469
*
4570
* @return the user id.
71+
* @deprecated
4672
*/
4773
@JsonProperty("user_id")
4874
public String getUserId() {
@@ -53,6 +79,7 @@ public String getUserId() {
5379
* Setter for the id of the user this ticket is meant to.
5480
*
5581
* @param userId the user id to set.
82+
* @deprecated use the constructor instead
5683
*/
5784
@JsonProperty("user_id")
5885
public void setUserId(String userId) {
@@ -63,6 +90,7 @@ public void setUserId(String userId) {
6390
* Whether to send and email for enrollment or not.
6491
*
6592
* @return true is this ticket will send an email upon enrollment, false otherwise.
93+
* @deprecated
6694
*/
6795
@JsonProperty("send_mail")
6896
public Boolean willSendEmail() {
@@ -73,6 +101,7 @@ public Boolean willSendEmail() {
73101
* Sets whether to send and email for enrollment or not.
74102
*
75103
* @param sendEmail whether this ticket will send an email upon enrollment or not.
104+
* @deprecated use the constructor instead
76105
*/
77106
@JsonProperty("send_mail")
78107
public void setSendEmail(Boolean sendEmail) {
@@ -83,6 +112,7 @@ public void setSendEmail(Boolean sendEmail) {
83112
* Getter for the email to which the ticket will be sent.
84113
*
85114
* @return the email.
115+
* @deprecated
86116
*/
87117
@JsonProperty("email")
88118
public String getEmail() {
@@ -93,6 +123,7 @@ public String getEmail() {
93123
* Setter for the email to which the ticket will be sent.
94124
*
95125
* @param email the email to sent the ticket to.
126+
* @deprecated use the constructor instead
96127
*/
97128
@JsonProperty("email")
98129
public void setEmail(String email) {

src/main/java/com/auth0/json/mgmt/guardian/Factor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public Boolean isTrialExpired() {
5656
}
5757

5858
/**
59-
* Getter fot the name of this factor.
59+
* Getter for the name of this factor.
6060
*
6161
* @return the factor name.
6262
*/

src/main/java/com/auth0/json/mgmt/guardian/GuardianTemplates.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.fasterxml.jackson.annotation.JsonProperty;
77

88
/**
9-
* Class that represents an Auth0 Guardian Templates object. Related to the {@link com.auth0.client.mgmt.GuardianEntity} entity.
9+
* Class that represents an Auth0 Guardian SMS Templates object. Related to the {@link com.auth0.client.mgmt.GuardianEntity} entity.
1010
*/
1111
@SuppressWarnings({"unused", "WeakerAccess"})
1212
@JsonIgnoreProperties(ignoreUnknown = true)
@@ -25,7 +25,7 @@ public GuardianTemplates(@JsonProperty("enrollment_message") String enrollmentMe
2525
}
2626

2727
/**
28-
* Getter for the message to send when the user is invited to enroll with a phone number.
28+
* Getter for the message to send when the user enrolls with SMS.
2929
*
3030
* @return the message to send upon enrollment.
3131
*/
@@ -35,7 +35,7 @@ public String getEnrollmentMessage() {
3535
}
3636

3737
/**
38-
* Setter for the message to send when the user is invited to enroll with a phone number.
38+
* Setter for the message to send when the user enrolls with SMS.
3939
*
4040
* @param enrollmentMessage the message to send upon enrollment.
4141
*/
@@ -45,7 +45,7 @@ public void setEnrollmentMessage(String enrollmentMessage) {
4545
}
4646

4747
/**
48-
* Getter for the message to send when the user is prompted to verify their account.
48+
* Getter for the message to send when the user is prompted to verify their account via SMS.
4949
*
5050
* @return the message to send upon verification.
5151
*/
@@ -55,7 +55,7 @@ public String getVerificationMessage() {
5555
}
5656

5757
/**
58-
* Setter for the message to send when the user is prompted to verify their account.
58+
* Setter for the message to send when the user is prompted to verify their account via SMS.
5959
*
6060
* @param verificationMessage the message to send upon verification.
6161
*/

0 commit comments

Comments
 (0)