Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the organization user invitation APIs #488

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ public class GuestsApi {
@Path("/invitation/accept")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApiOperation(value = "Accepts an invitation from a user in the parent organization", notes = "After user clicks on the link provided, the application should invoke this API. In order to invoke this API a user should be logged in to the application. Then this API can be initiated with the access token issued for that user. This logged in user should be the same user which the invitation was initiated to. <b>Scope required:</b> <br/> - none ", response = Void.class, tags={ "Parent Organization User Invitation", })
@ApiOperation(value = "Accepts an invitation from a user in the parent organization", notes = "After user clicks on the link provided, the redirected application should invoke this API. This API is a public API and this should be invoked with the confirmation code which is appended to the notification. <b>Scope required:</b> <br/> - none ", response = Void.class, tags={ "Parent Organization User Invitation", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful Response", response = Void.class),
@ApiResponse(code = 400, message = "Bad Request", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Error.class),
@ApiResponse(code = 403, message = "Forbidden", response = Error.class),
@ApiResponse(code = 500, message = "Internal Server Error", response = Error.class)
})
public Response invitationAcceptPost(@ApiParam(value = "Details that need to confirm an invitation" ,required=true) @Valid AcceptanceRequestBody acceptanceRequestBody) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class InvitationRequestBody {
private String userDomain;
private List<RoleAssignmentRequestBody> roleAssignments = null;

private String userRedirectUrl;

/**
* Username of the user who will be invited to the organization. This can be an email or an alphanumeric username.
Expand Down Expand Up @@ -108,26 +107,7 @@ public InvitationRequestBody addRoleAssignmentsItem(RoleAssignmentRequestBody ro
return this;
}

/**
* URL to which the user should be redirected for authenticate and a place where accepting API can be invoked. This should be able to invoke switch grant and get the token from the organization where the user is existing.
**/
public InvitationRequestBody userRedirectUrl(String userRedirectUrl) {

this.userRedirectUrl = userRedirectUrl;
return this;
}

@ApiModelProperty(example = "https://localhost:8080/travel-manager/invitations/accept", value = "URL to which the user should be redirected for authenticate and a place where accepting API can be invoked. This should be able to invoke switch grant and get the token from the organization where the user is existing.")
@JsonProperty("userRedirectUrl")
@Valid
public String getUserRedirectUrl() {
return userRedirectUrl;
}
public void setUserRedirectUrl(String userRedirectUrl) {
this.userRedirectUrl = userRedirectUrl;
}



@Override
public boolean equals(java.lang.Object o) {
Expand All @@ -141,13 +121,12 @@ public boolean equals(java.lang.Object o) {
InvitationRequestBody invitationRequestBody = (InvitationRequestBody) o;
return Objects.equals(this.username, invitationRequestBody.username) &&
Objects.equals(this.userDomain, invitationRequestBody.userDomain) &&
Objects.equals(this.roleAssignments, invitationRequestBody.roleAssignments) &&
Objects.equals(this.userRedirectUrl, invitationRequestBody.userRedirectUrl);
Objects.equals(this.roleAssignments, invitationRequestBody.roleAssignments);
}

@Override
public int hashCode() {
return Objects.hash(username, userDomain, roleAssignments, userRedirectUrl);
return Objects.hash(username, userDomain, roleAssignments);
}

@Override
Expand All @@ -159,7 +138,6 @@ public String toString() {
sb.append(" username: ").append(toIndentedString(username)).append("\n");
sb.append(" userDomain: ").append(toIndentedString(userDomain)).append("\n");
sb.append(" roleAssignments: ").append(toIndentedString(roleAssignments)).append("\n");
sb.append(" userRedirectUrl: ").append(toIndentedString(userRedirectUrl)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@
public class InvitationResponse {

private String id;
private String confirmationCode;
private String username;
private String email;
private List<RoleAssignmentResponse> roleAssignments = null;

private String status;
private String expiredAt;
private String userRedirectUrl;

/**
**/
Expand All @@ -65,26 +63,6 @@ public void setId(String id) {
this.id = id;
}

/**
**/
public InvitationResponse confirmationCode(String confirmationCode) {

this.confirmationCode = confirmationCode;
return this;
}

@ApiModelProperty(example = "2663329b-c8c5-4c71-9500-9ea8c4e77d94", required = true, value = "")
@JsonProperty("confirmationCode")
@Valid
@NotNull(message = "Property confirmationCode cannot be null.")

public String getConfirmationCode() {
return confirmationCode;
}
public void setConfirmationCode(String confirmationCode) {
this.confirmationCode = confirmationCode;
}

/**
**/
public InvitationResponse username(String username) {
Expand Down Expand Up @@ -189,26 +167,6 @@ public void setExpiredAt(String expiredAt) {
this.expiredAt = expiredAt;
}

/**
**/
public InvitationResponse userRedirectUrl(String userRedirectUrl) {

this.userRedirectUrl = userRedirectUrl;
return this;
}

@ApiModelProperty(example = "https://localhost:8080/travel-manager/login", required = true, value = "")
@JsonProperty("userRedirectUrl")
@Valid
@NotNull(message = "Property userRedirectUrl cannot be null.")

public String getUserRedirectUrl() {
return userRedirectUrl;
}
public void setUserRedirectUrl(String userRedirectUrl) {
this.userRedirectUrl = userRedirectUrl;
}



@Override
Expand All @@ -222,18 +180,16 @@ public boolean equals(java.lang.Object o) {
}
InvitationResponse invitationResponse = (InvitationResponse) o;
return Objects.equals(this.id, invitationResponse.id) &&
Objects.equals(this.confirmationCode, invitationResponse.confirmationCode) &&
Objects.equals(this.username, invitationResponse.username) &&
Objects.equals(this.email, invitationResponse.email) &&
Objects.equals(this.roleAssignments, invitationResponse.roleAssignments) &&
Objects.equals(this.status, invitationResponse.status) &&
Objects.equals(this.expiredAt, invitationResponse.expiredAt) &&
Objects.equals(this.userRedirectUrl, invitationResponse.userRedirectUrl);
Objects.equals(this.expiredAt, invitationResponse.expiredAt);
}

@Override
public int hashCode() {
return Objects.hash(id, confirmationCode, username, email, roleAssignments, status, expiredAt, userRedirectUrl);
return Objects.hash(id, username, email, roleAssignments, status, expiredAt);
}

@Override
Expand All @@ -243,13 +199,11 @@ public String toString() {
sb.append("class InvitationResponse {\n");

sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" confirmationCode: ").append(toIndentedString(confirmationCode)).append("\n");
sb.append(" username: ").append(toIndentedString(username)).append("\n");
sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append(" roleAssignments: ").append(toIndentedString(roleAssignments)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append(" expiredAt: ").append(toIndentedString(expiredAt)).append("\n");
sb.append(" userRedirectUrl: ").append(toIndentedString(userRedirectUrl)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,10 @@

public class InvitationSuccessResponse {

private String confirmationCode;
private String username;
private String email;
private List<RoleAssignmentResponse> roleAssignments = new ArrayList<>();

private String userRedirectUrl;

/**
* Confirmation code of the invitation which needs to be passed back from the confirmation API to accept the invitation.
**/
public InvitationSuccessResponse confirmationCode(String confirmationCode) {

this.confirmationCode = confirmationCode;
return this;
}

@ApiModelProperty(example = "2663329b-c8c5-4c71-9500-9ea8c4e77d94", required = true, value = "Confirmation code of the invitation which needs to be passed back from the confirmation API to accept the invitation.")
@JsonProperty("confirmationCode")
@Valid
@NotNull(message = "Property confirmationCode cannot be null.")

public String getConfirmationCode() {
return confirmationCode;
}
public void setConfirmationCode(String confirmationCode) {
this.confirmationCode = confirmationCode;
}

/**
* Username of the user who will be invited to the organization. This can be an email or an alphanumeric username.
Expand Down Expand Up @@ -131,28 +108,7 @@ public InvitationSuccessResponse addRoleAssignmentsItem(RoleAssignmentResponse r
return this;
}

/**
* URL to which the user should be redirected for authenticate before accepting API is invoked.
**/
public InvitationSuccessResponse userRedirectUrl(String userRedirectUrl) {

this.userRedirectUrl = userRedirectUrl;
return this;
}

@ApiModelProperty(example = "https://localhost:8080/travel-manager/login", required = true, value = "URL to which the user should be redirected for authenticate before accepting API is invoked.")
@JsonProperty("userRedirectUrl")
@Valid
@NotNull(message = "Property userRedirectUrl cannot be null.")

public String getUserRedirectUrl() {
return userRedirectUrl;
}
public void setUserRedirectUrl(String userRedirectUrl) {
this.userRedirectUrl = userRedirectUrl;
}



@Override
public boolean equals(java.lang.Object o) {
Expand All @@ -164,16 +120,14 @@ public boolean equals(java.lang.Object o) {
return false;
}
InvitationSuccessResponse invitationSuccessResponse = (InvitationSuccessResponse) o;
return Objects.equals(this.confirmationCode, invitationSuccessResponse.confirmationCode) &&
Objects.equals(this.username, invitationSuccessResponse.username) &&
return Objects.equals(this.username, invitationSuccessResponse.username) &&
Objects.equals(this.email, invitationSuccessResponse.email) &&
Objects.equals(this.roleAssignments, invitationSuccessResponse.roleAssignments) &&
Objects.equals(this.userRedirectUrl, invitationSuccessResponse.userRedirectUrl);
Objects.equals(this.roleAssignments, invitationSuccessResponse.roleAssignments);
}

@Override
public int hashCode() {
return Objects.hash(confirmationCode, username, email, roleAssignments, userRedirectUrl);
return Objects.hash(username, email, roleAssignments);
}

@Override
Expand All @@ -182,11 +136,9 @@ public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class InvitationSuccessResponse {\n");

sb.append(" confirmationCode: ").append(toIndentedString(confirmationCode)).append("\n");
sb.append(" username: ").append(toIndentedString(username)).append("\n");
sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append(" roleAssignments: ").append(toIndentedString(roleAssignments)).append("\n");
sb.append(" userRedirectUrl: ").append(toIndentedString(userRedirectUrl)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public InvitationSuccessResponse createInvitation(InvitationRequestBody invitati
Invitation invitation = new Invitation();
invitation.setUsername(invitationRequestBody.getUsername());
invitation.setUserDomain(invitationRequestBody.getUserDomain());
invitation.setUserRedirectUrl(invitationRequestBody.getUserRedirectUrl());
if (invitationRequestBody.getRoleAssignments() != null) {
List<RoleAssignments> roleAssignments = new ArrayList<>();
for (RoleAssignmentRequestBody roleAssignmentRequestBody : invitationRequestBody.getRoleAssignments()) {
Expand Down Expand Up @@ -249,10 +248,8 @@ private String includeData(UserInvitationMgtConstants.ErrorMessage error, String
private InvitationSuccessResponse createInvitationSuccessResponse(Invitation invitation) {

InvitationSuccessResponse invitationSuccessResponse = new InvitationSuccessResponse();
invitationSuccessResponse.setConfirmationCode(invitation.getConfirmationCode());
invitationSuccessResponse.setUsername(invitation.getUsername());
invitationSuccessResponse.setEmail(invitation.getEmail());
invitationSuccessResponse.setUserRedirectUrl(invitation.getUserRedirectUrl());
if (invitation.getRoleAssignments().length > 0) {
List<RoleAssignmentResponse> roleAssignmentResponses = buildRoleAssignmentResponse(invitation);
invitationSuccessResponse.setRoleAssignments(roleAssignmentResponses);
Expand All @@ -266,12 +263,10 @@ private InvitationsListResponse buildInvitationsListResponse(List<Invitation> in
for (Invitation invitationRecord : invitationList) {
InvitationResponse invitationResponse = new InvitationResponse();
invitationResponse.setId(invitationRecord.getInvitationId());
invitationResponse.setConfirmationCode(invitationRecord.getConfirmationCode());
invitationResponse.setUsername(invitationRecord.getUsername());
invitationResponse.setEmail(invitationRecord.getEmail());
invitationResponse.setStatus(invitationRecord.getStatus());
invitationResponse.setExpiredAt(invitationRecord.getExpiredAt().toString());
invitationResponse.setUserRedirectUrl(invitationRecord.getUserRedirectUrl());
if (invitationRecord.getRoleAssignments().length > 0) {
List<RoleAssignmentResponse> roleAssignments = buildRoleAssignmentResponse(invitationRecord);
invitationResponse.setRoleAssignments(roleAssignments);
Expand Down
Loading
Loading