Skip to content

Commit

Permalink
Introduce additional attribute json properties option
Browse files Browse the repository at this point in the history
  • Loading branch information
PasinduYeshan committed Jan 19, 2025
1 parent 1bba3ae commit 1943323
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.wso2.charon3.core.attributes;

import org.json.JSONObject;
import org.wso2.charon3.core.schema.SCIMDefinitions;

import java.util.HashMap;
Expand Down Expand Up @@ -48,6 +49,7 @@ public abstract class AbstractAttribute implements Attribute {
protected SCIMDefinitions.Uniqueness uniqueness;
//A container to hold custom attribute properties.
protected Map<String, String> additionalAttributeProperties = new HashMap<>();
protected Map<String, JSONObject> additionalAttributeJSONProperties = new HashMap<>();

public String getURI() {
return uri; }
Expand Down Expand Up @@ -145,4 +147,19 @@ public String removeAttributeProperty(String propertyName) {

return additionalAttributeProperties.remove(propertyName);
}

public Map<String, JSONObject> getAttributeJSONProperties() {

return additionalAttributeJSONProperties;
}

public void addAttributeJsonProperty(String propertyName, JSONObject jsonObject) {

this.additionalAttributeJSONProperties.put(propertyName, jsonObject);
}

public JSONObject getAttributeJsonProperty(String propertyName) {

return additionalAttributeJSONProperties.remove(propertyName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.wso2.charon3.core.attributes;

import org.json.JSONObject;
import org.wso2.charon3.core.exceptions.CharonException;
import org.wso2.charon3.core.schema.SCIMDefinitions;

Expand Down Expand Up @@ -62,4 +63,9 @@ public default Map<String, String> getAttributeProperties() {

throw new UnsupportedOperationException();
}

public default Map<String, JSONObject> getAttributeJSONProperties() {

throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ public JSONObject encodeBasicAttributeSchema(Attribute attribute) throws JSONExc
attributeSchema.put(entry.getKey(), entry.getValue());
}

Map<String, JSONObject> customJSONProperties = attribute.getAttributeJSONProperties();
for (Map.Entry<String, JSONObject> entry: customJSONProperties.entrySet()) {
attributeSchema.put(entry.getKey(), entry.getValue());
}

return attributeSchema;
}

Expand Down

0 comments on commit 1943323

Please sign in to comment.