Skip to content

Commit

Permalink
Merge pull request #766 from AnuradhaSK/add-SharedProfileValueResolvi…
Browse files Browse the repository at this point in the history
…ngMethod-as-firstclass-attribute

Add sharedProfileValueResolvingMethod as first class attribute to claim mgt API
  • Loading branch information
AnuradhaSK authored Jan 6, 2025
2 parents 732e9e3 + 671313d commit 59238d5
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ public enum UniquenessScopeEnum {
@Valid
private UniquenessScopeEnum uniquenessScope = null;

@Valid
public enum SharedProfileValueResolvingMethodEnum {
FromOrigin, FromSharedProfile, FromFirstFoundInHierarchy,
};

@Valid
private SharedProfileValueResolvingMethodEnum sharedProfileValueResolvingMethod = null;

@Valid
@NotNull(message = "Property attributeMapping cannot be null.")
private List<AttributeMappingDTO> attributeMapping = new ArrayList<AttributeMappingDTO>();

Expand Down Expand Up @@ -181,6 +188,20 @@ public void setUniquenessScope(UniquenessScopeEnum uniquenessScope) {
this.uniquenessScope = uniquenessScope;
}

/**
* Specifies claim value resolving method for shared user profile.
**/
@ApiModelProperty(value = "Specifies claim value resolving method for shared user profile.")
@JsonProperty("sharedProfileValueResolvingMethod")
public SharedProfileValueResolvingMethodEnum getSharedProfileValueResolvingMethod() {
return sharedProfileValueResolvingMethod;
}

public void setSharedProfileValueResolvingMethod(
SharedProfileValueResolvingMethodEnum sharedProfileValueResolvingMethod) {
this.sharedProfileValueResolvingMethod = sharedProfileValueResolvingMethod;
}

/**
* Userstore attribute mappings.
**/
Expand Down Expand Up @@ -220,6 +241,7 @@ public String toString() {
sb.append(" required: ").append(required).append("\n");
sb.append(" supportedByDefault: ").append(supportedByDefault).append("\n");
sb.append(" uniquenessScope: ").append(uniquenessScope).append("\n");
sb.append(" sharedProfileValueResolvingMethod: ").append(sharedProfileValueResolvingMethod).append("\n");
sb.append(" attributeMapping: ").append(attributeMapping).append("\n");
sb.append(" properties: ").append(properties).append("\n");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ public enum UniquenessScopeEnum {
@Valid
private UniquenessScopeEnum uniquenessScope = null;

@Valid
public enum SharedProfileValueResolvingMethodEnum {
FromOrigin, FromSharedProfile, FromFirstFoundInHierarchy,
};
@Valid
private SharedProfileValueResolvingMethodEnum sharedProfileValueResolvingMethod = null;

@Valid
private List<AttributeMappingDTO> attributeMapping = new ArrayList<AttributeMappingDTO>();

@Valid
Expand Down Expand Up @@ -209,6 +215,20 @@ public void setUniquenessScope(UniquenessScopeEnum uniquenessScope) {
this.uniquenessScope = uniquenessScope;
}

/**
* Specifies claim value resolving method for shared user profile.
**/
@ApiModelProperty(value = "Specifies claim value resolving method for shared user profile.")
@JsonProperty("sharedProfileValueResolvingMethod")
public SharedProfileValueResolvingMethodEnum getSharedProfileValueResolvingMethod() {
return sharedProfileValueResolvingMethod;
}

public void setSharedProfileValueResolvingMethod(
SharedProfileValueResolvingMethodEnum sharedProfileValueResolvingMethod) {
this.sharedProfileValueResolvingMethod = sharedProfileValueResolvingMethod;
}

/**
* Userstore attribute mappings.
**/
Expand Down Expand Up @@ -251,6 +271,7 @@ public String toString() {
sb.append(" required: ").append(required).append("\n");
sb.append(" supportedByDefault: ").append(supportedByDefault).append("\n");
sb.append(" uniquenessScope: ").append(uniquenessScope).append("\n");
sb.append(" sharedProfileValueResolvingMethod: ").append(sharedProfileValueResolvingMethod).append("\n");
sb.append(" attributeMapping: ").append(attributeMapping).append("\n");
sb.append(" properties: ").append(properties).append("\n");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,19 @@ private LocalClaimResDTO getLocalClaimResDTO(LocalClaim localClaim) {
}
}

String sharedProfileValueResolvingMethod =
claimProperties.remove(ClaimConstants.SHARED_PROFILE_VALUE_RESOLVING_METHOD);
if (StringUtils.isNotBlank(sharedProfileValueResolvingMethod)) {
try {
localClaimResDTO.setSharedProfileValueResolvingMethod(
LocalClaimResDTO.SharedProfileValueResolvingMethodEnum.valueOf(
sharedProfileValueResolvingMethod));
} catch (IllegalArgumentException e) {
// If the value is not a valid enum value, treat it as null.
localClaimResDTO.setSharedProfileValueResolvingMethod(null);
}
}

List<AttributeMappingDTO> attributeMappingDTOs = new ArrayList<>();
for (AttributeMapping attributeMapping : localClaim.getMappedAttributes()) {
AttributeMappingDTO attributeMappingDTO = new AttributeMappingDTO();
Expand Down Expand Up @@ -1063,6 +1076,11 @@ private LocalClaim createLocalClaim(LocalClaimReqDTO localClaimReqDTO) {
claimProperties.put(PROP_UNIQUENESS_SCOPE, localClaimReqDTO.getUniquenessScope().toString());
}

if (localClaimReqDTO.getSharedProfileValueResolvingMethod() != null) {
claimProperties.put(ClaimConstants.SHARED_PROFILE_VALUE_RESOLVING_METHOD,
String.valueOf(localClaimReqDTO.getSharedProfileValueResolvingMethod()));
}

claimProperties.put(PROP_READ_ONLY, String.valueOf(localClaimReqDTO.getReadOnly()));
claimProperties.put(PROP_REQUIRED, String.valueOf(localClaimReqDTO.getRequired()));
claimProperties.put(PROP_SUPPORTED_BY_DEFAULT, String.valueOf(localClaimReqDTO.getSupportedByDefault()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,14 @@ definitions:
- WITHIN_USERSTORE
- ACROSS_USERSTORES
example: "NONE"
sharedProfileValueResolvingMethod:
type: string
description: Specifies claim value resolving method for shared user profile.
enum:
- FromOrigin
- FromSharedProfile
- FromFirstFoundInHierarchy
example: "FromOrigin"
attributeMapping:
type: array
description: Userstore attribute mappings.
Expand Down Expand Up @@ -812,6 +820,14 @@ definitions:
- WITHIN_USERSTORE
- ACROSS_USERSTORES
example: "NONE"
sharedProfileValueResolvingMethod:
type: string
description: Specifies claim value resolving method for shared user profile.
enum:
- FromOrigin
- FromSharedProfile
- FromFirstFoundInHierarchy
example: "FromOrigin"
attributeMapping:
type: array
description: Userstore attribute mappings.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@
<maven.buildnumber.plugin.version>1.4</maven.buildnumber.plugin.version>
<org.apache.felix.annotations.version>1.2.4</org.apache.felix.annotations.version>
<identity.governance.version>1.11.21</identity.governance.version>
<carbon.identity.framework.version>7.7.66</carbon.identity.framework.version>
<carbon.identity.framework.version>7.7.73</carbon.identity.framework.version>
<maven.findbugsplugin.version>3.0.5</maven.findbugsplugin.version>
<findsecbugs-plugin.version>1.12.0</findsecbugs-plugin.version>
<maven.checkstyleplugin.excludes>**/gen/**/*</maven.checkstyleplugin.excludes>
Expand Down

0 comments on commit 59238d5

Please sign in to comment.