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

Add sharedProfileValueResolvingMethod as first class attribute to claim mgt API #766

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 @@ -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);
AnuradhaSK marked this conversation as resolved.
Show resolved Hide resolved
}
}

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
Loading