Skip to content

Commit

Permalink
Merge pull request #504 from AnuradhaSK/role-association
Browse files Browse the repository at this point in the history
Add capability to associate v2 roles with applications
  • Loading branch information
AnuradhaSK authored Oct 24, 2023
2 parents 250d4c1 + 657b832 commit 7852132
Show file tree
Hide file tree
Showing 11 changed files with 523 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.identity.api.server.application.management.v1.AdvancedApplicationConfiguration;
import org.wso2.carbon.identity.api.server.application.management.v1.AssociatedRolesConfig;
import org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationSequence;
import org.wso2.carbon.identity.api.server.application.management.v1.ClaimConfiguration;
import org.wso2.carbon.identity.api.server.application.management.v1.InboundProtocols;
Expand All @@ -45,6 +46,7 @@ public class ApplicationModel {
private String templateId;
private Boolean isManagementApp = false;
private Boolean isB2BSelfServiceApp = false;
private AssociatedRolesConfig associatedRoles;
private ClaimConfiguration claimConfiguration;
private InboundProtocols inboundProtocolConfiguration;
private AuthenticationSequence authenticationSequence;
Expand Down Expand Up @@ -196,6 +198,27 @@ public Boolean getIsB2BSelfServiceApp() {

return isB2BSelfServiceApp;
}
public void setIsB2BSelfServiceApp(Boolean isB2BSelfServiceApp) {
this.isB2BSelfServiceApp = isB2BSelfServiceApp;
}

/**
**/
public ApplicationModel associatedRoles(AssociatedRolesConfig associatedRoles) {

this.associatedRoles = associatedRoles;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("associatedRoles")
@Valid
public AssociatedRolesConfig getAssociatedRoles() {
return associatedRoles;
}
public void setAssociatedRoles(AssociatedRolesConfig associatedRoles) {
this.associatedRoles = associatedRoles;
}

/**
**/
Expand Down Expand Up @@ -307,6 +330,7 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.templateId, applicationModel.templateId) &&
Objects.equals(this.isManagementApp, applicationModel.isManagementApp) &&
Objects.equals(this.isB2BSelfServiceApp, applicationModel.isB2BSelfServiceApp) &&
Objects.equals(this.associatedRoles, applicationModel.associatedRoles) &&
Objects.equals(this.claimConfiguration, applicationModel.claimConfiguration) &&
Objects.equals(this.inboundProtocolConfiguration, applicationModel.inboundProtocolConfiguration) &&
Objects.equals(this.authenticationSequence, applicationModel.authenticationSequence) &&
Expand All @@ -316,7 +340,7 @@ public boolean equals(java.lang.Object o) {

@Override
public int hashCode() {
return Objects.hash(id, name, description, imageUrl, accessUrl, templateId, isManagementApp, isB2BSelfServiceApp, claimConfiguration, inboundProtocolConfiguration, authenticationSequence, advancedConfigurations, provisioningConfigurations);
return Objects.hash(id, name, description, imageUrl, accessUrl, templateId, isManagementApp, isB2BSelfServiceApp, associatedRoles, claimConfiguration, inboundProtocolConfiguration, authenticationSequence, advancedConfigurations, provisioningConfigurations);
}

@Override
Expand All @@ -333,6 +357,7 @@ public String toString() {
sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n");
sb.append(" isManagementApp: ").append(toIndentedString(isManagementApp)).append("\n");
sb.append(" isB2BSelfServiceApp: ").append(toIndentedString(isB2BSelfServiceApp)).append("\n");
sb.append(" associatedRoles: ").append(toIndentedString(associatedRoles)).append("\n");
sb.append(" claimConfiguration: ").append(toIndentedString(claimConfiguration)).append("\n");
sb.append(" inboundProtocolConfiguration: ").append(toIndentedString(inboundProtocolConfiguration)).append("\n");
sb.append(" authenticationSequence: ").append(toIndentedString(authenticationSequence)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.identity.api.server.application.management.v1.AdvancedApplicationConfiguration;
import org.wso2.carbon.identity.api.server.application.management.v1.AssociatedRolesConfig;
import org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationSequence;
import org.wso2.carbon.identity.api.server.application.management.v1.ClaimConfiguration;
import org.wso2.carbon.identity.api.server.application.management.v1.ProvisioningConfiguration;
Expand All @@ -41,6 +42,7 @@ public class ApplicationPatchModel {
private String imageUrl;
private String accessUrl;
private String templateId;
private AssociatedRolesConfig associatedRoles;
private ClaimConfiguration claimConfiguration;
private AuthenticationSequence authenticationSequence;
private AdvancedApplicationConfiguration advancedConfigurations;
Expand Down Expand Up @@ -136,6 +138,24 @@ public void setTemplateId(String templateId) {
this.templateId = templateId;
}

/**
**/
public ApplicationPatchModel associatedRoles(AssociatedRolesConfig associatedRoles) {

this.associatedRoles = associatedRoles;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("associatedRoles")
@Valid
public AssociatedRolesConfig getAssociatedRoles() {
return associatedRoles;
}
public void setAssociatedRoles(AssociatedRolesConfig associatedRoles) {
this.associatedRoles = associatedRoles;
}

/**
**/
public ApplicationPatchModel claimConfiguration(ClaimConfiguration claimConfiguration) {
Expand Down Expand Up @@ -225,6 +245,7 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.imageUrl, applicationPatchModel.imageUrl) &&
Objects.equals(this.accessUrl, applicationPatchModel.accessUrl) &&
Objects.equals(this.templateId, applicationPatchModel.templateId) &&
Objects.equals(this.associatedRoles, applicationPatchModel.associatedRoles) &&
Objects.equals(this.claimConfiguration, applicationPatchModel.claimConfiguration) &&
Objects.equals(this.authenticationSequence, applicationPatchModel.authenticationSequence) &&
Objects.equals(this.advancedConfigurations, applicationPatchModel.advancedConfigurations) &&
Expand All @@ -233,7 +254,7 @@ public boolean equals(java.lang.Object o) {

@Override
public int hashCode() {
return Objects.hash(name, description, imageUrl, accessUrl, templateId, claimConfiguration, authenticationSequence, advancedConfigurations, provisioningConfigurations);
return Objects.hash(name, description, imageUrl, accessUrl, templateId, associatedRoles, claimConfiguration, authenticationSequence, advancedConfigurations, provisioningConfigurations);
}

@Override
Expand All @@ -247,6 +268,7 @@ public String toString() {
sb.append(" imageUrl: ").append(toIndentedString(imageUrl)).append("\n");
sb.append(" accessUrl: ").append(toIndentedString(accessUrl)).append("\n");
sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n");
sb.append(" associatedRoles: ").append(toIndentedString(associatedRoles)).append("\n");
sb.append(" claimConfiguration: ").append(toIndentedString(claimConfiguration)).append("\n");
sb.append(" authenticationSequence: ").append(toIndentedString(authenticationSequence)).append("\n");
sb.append(" advancedConfigurations: ").append(toIndentedString(advancedConfigurations)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.List;
import org.wso2.carbon.identity.api.server.application.management.v1.AdvancedApplicationConfiguration;
import org.wso2.carbon.identity.api.server.application.management.v1.AssociatedRolesConfig;
import org.wso2.carbon.identity.api.server.application.management.v1.AuthenticationSequence;
import org.wso2.carbon.identity.api.server.application.management.v1.ClaimConfiguration;
import org.wso2.carbon.identity.api.server.application.management.v1.InboundProtocolListItem;
Expand All @@ -49,6 +50,7 @@ public class ApplicationResponseModel {
private String templateId;
private Boolean isManagementApp;
private Boolean isB2BSelfServiceApp;
private AssociatedRolesConfig associatedRoles;
private ClaimConfiguration claimConfiguration;
private List<InboundProtocolListItem> inboundProtocols = null;

Expand Down Expand Up @@ -271,6 +273,27 @@ public Boolean getIsB2BSelfServiceApp() {

return isB2BSelfServiceApp;
}
public void setIsB2BSelfServiceApp(Boolean isB2BSelfServiceApp) {
this.isB2BSelfServiceApp = isB2BSelfServiceApp;
}

/**
**/
public ApplicationResponseModel associatedRoles(AssociatedRolesConfig associatedRoles) {

this.associatedRoles = associatedRoles;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("associatedRoles")
@Valid
public AssociatedRolesConfig getAssociatedRoles() {
return associatedRoles;
}
public void setAssociatedRoles(AssociatedRolesConfig associatedRoles) {
this.associatedRoles = associatedRoles;
}

/**
**/
Expand Down Expand Up @@ -410,6 +433,7 @@ public boolean equals(java.lang.Object o) {
Objects.equals(this.templateId, applicationResponseModel.templateId) &&
Objects.equals(this.isManagementApp, applicationResponseModel.isManagementApp) &&
Objects.equals(this.isB2BSelfServiceApp, applicationResponseModel.isB2BSelfServiceApp) &&
Objects.equals(this.associatedRoles, applicationResponseModel.associatedRoles) &&
Objects.equals(this.claimConfiguration, applicationResponseModel.claimConfiguration) &&
Objects.equals(this.inboundProtocols, applicationResponseModel.inboundProtocols) &&
Objects.equals(this.authenticationSequence, applicationResponseModel.authenticationSequence) &&
Expand All @@ -420,7 +444,7 @@ public boolean equals(java.lang.Object o) {

@Override
public int hashCode() {
return Objects.hash(id, name, description, imageUrl, accessUrl, clientId, issuer, templateId, isManagementApp, isB2BSelfServiceApp, claimConfiguration, inboundProtocols, authenticationSequence, advancedConfigurations, provisioningConfigurations, access);
return Objects.hash(id, name, description, imageUrl, accessUrl, clientId, issuer, templateId, isManagementApp, isB2BSelfServiceApp, associatedRoles, claimConfiguration, inboundProtocols, authenticationSequence, advancedConfigurations, provisioningConfigurations, access);
}

@Override
Expand All @@ -439,6 +463,7 @@ public String toString() {
sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n");
sb.append(" isManagementApp: ").append(toIndentedString(isManagementApp)).append("\n");
sb.append(" isB2BSelfServiceApp: ").append(toIndentedString(isB2BSelfServiceApp)).append("\n");
sb.append(" associatedRoles: ").append(toIndentedString(associatedRoles)).append("\n");
sb.append(" claimConfiguration: ").append(toIndentedString(claimConfiguration)).append("\n");
sb.append(" inboundProtocols: ").append(toIndentedString(inboundProtocols)).append("\n");
sb.append(" authenticationSequence: ").append(toIndentedString(authenticationSequence)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.api.server.application.management.v1;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import org.wso2.carbon.identity.api.server.application.management.v1.Role;
import javax.validation.constraints.*;


import io.swagger.annotations.*;
import java.util.Objects;
import javax.validation.Valid;
import javax.xml.bind.annotation.*;

public class AssociatedRolesConfig {


@XmlType(name="AllowedAudienceEnum")
@XmlEnum(String.class)
public enum AllowedAudienceEnum {

@XmlEnumValue("ORGANIZATION") ORGANIZATION(String.valueOf("ORGANIZATION")), @XmlEnumValue("APPLICATION") APPLICATION(String.valueOf("APPLICATION"));


private String value;

AllowedAudienceEnum(String v) {
value = v;
}

public String value() {
return value;
}

@Override
public String toString() {
return String.valueOf(value);
}

public static AllowedAudienceEnum fromValue(String value) {
for (AllowedAudienceEnum b : AllowedAudienceEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
}

private AllowedAudienceEnum allowedAudience = AllowedAudienceEnum.ORGANIZATION;
private List<Role> roles = null;


/**
**/
public AssociatedRolesConfig allowedAudience(AllowedAudienceEnum allowedAudience) {

this.allowedAudience = allowedAudience;
return this;
}

@ApiModelProperty(example = "ORGANIZATION", required = true, value = "")
@JsonProperty("allowedAudience")
@Valid
@NotNull(message = "Property allowedAudience cannot be null.")

public AllowedAudienceEnum getAllowedAudience() {
return allowedAudience;
}
public void setAllowedAudience(AllowedAudienceEnum allowedAudience) {
this.allowedAudience = allowedAudience;
}

/**
**/
public AssociatedRolesConfig roles(List<Role> roles) {

this.roles = roles;
return this;
}

@ApiModelProperty(value = "")
@JsonProperty("roles")
@Valid
public List<Role> getRoles() {
return roles;
}
public void setRoles(List<Role> roles) {
this.roles = roles;
}

public AssociatedRolesConfig addRolesItem(Role rolesItem) {
if (this.roles == null) {
this.roles = new ArrayList<>();
}
this.roles.add(rolesItem);
return this;
}



@Override
public boolean equals(java.lang.Object o) {

if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AssociatedRolesConfig associatedRolesConfig = (AssociatedRolesConfig) o;
return Objects.equals(this.allowedAudience, associatedRolesConfig.allowedAudience) &&
Objects.equals(this.roles, associatedRolesConfig.roles);
}

@Override
public int hashCode() {
return Objects.hash(allowedAudience, roles);
}

@Override
public String toString() {

StringBuilder sb = new StringBuilder();
sb.append("class AssociatedRolesConfig {\n");

sb.append(" allowedAudience: ").append(toIndentedString(allowedAudience)).append("\n");
sb.append(" roles: ").append(toIndentedString(roles)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {

if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n");
}
}

Loading

0 comments on commit 7852132

Please sign in to comment.