Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • perun/perun-proxyidp/v1/OpenID-Connect-Java-Spring-Server
1 result
Show changes
Commits on Source (3)
# [18.3.0](https://gitlab.ics.muni.cz/perun/perun-proxyidp/v1/OpenID-Connect-Java-Spring-Server/compare/v18.2.0...v18.3.0) (2024-04-09)
### Features
* 🎸 allow claimModifier to replace old value (configurable) ([c615346](https://gitlab.ics.muni.cz/perun/perun-proxyidp/v1/OpenID-Connect-Java-Spring-Server/commit/c61534601a7ec94325d47b2f07fa3eeaa0ff5bdf))
# [18.2.0](https://gitlab.ics.muni.cz/perun/perun-proxyidp/v1/OpenID-Connect-Java-Spring-Server/compare/v18.1.0...v18.2.0) (2024-04-08)
......
......@@ -21,7 +21,7 @@
<parent>
<groupId>cz.muni.ics</groupId>
<artifactId>perun-oidc-parent</artifactId>
<version>18.2.0</version>
<version>18.3.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
......@@ -22,7 +22,7 @@
<parent>
<groupId>cz.muni.ics</groupId>
<artifactId>perun-oidc-parent</artifactId>
<version>18.2.0</version>
<version>18.3.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
......
package cz.muni.ics.oidc.server.claims;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
/**
......@@ -15,9 +16,13 @@ public abstract class ClaimModifier {
private final String claimName;
private final String modifierName;
@Getter
private final boolean replaceOldValue;
public ClaimModifier(ClaimModifierInitContext ctx) {
this.claimName = ctx.getClaimName();
this.modifierName = ctx.getModifierName();
this.replaceOldValue = ctx.isReplaceOldValue();
log.debug("{} - claim modifier initialized", ctx.getClaimName());
}
......
......@@ -15,12 +15,13 @@ import java.util.Properties;
public class ClaimModifierInitContext extends ClaimInitContext {
private final String modifierName;
private final boolean replaceOldValue;
public ClaimModifierInitContext(String propertyPrefix, Properties properties, String claimName, String modifierName) {
super(propertyPrefix, properties, claimName);
this.modifierName = modifierName;
this.replaceOldValue = Boolean.parseBoolean(getProperty("replaceOldValue", "true"));
log.debug("{}:{} - context: property prefix for modifier configured to '{}'",
claimName, modifierName, propertyPrefix);
}
......
......@@ -303,15 +303,19 @@ public class PerunUserInfoCacheLoader extends CacheLoader<UserInfoCacheKey, User
return TextNode.valueOf(modifier.modify(claimInJson.asText()));
} else if (claimInJson.isArray()) {
ArrayNode arrayNode = (ArrayNode) claimInJson;
ArrayNode newArrayNode = JsonNodeFactory.instance.arrayNode();
for (int i = 0; i < arrayNode.size(); i++) {
JsonNode item = arrayNode.get(i);
if (item.isTextual()) {
String original = item.asText();
String modified = modifier.modify(original);
arrayNode.set(i, TextNode.valueOf(modified));
if (!modifier.isReplaceOldValue()) {
newArrayNode.add(TextNode.valueOf(original));
}
newArrayNode.add(TextNode.valueOf(modified));
}
}
return arrayNode;
return newArrayNode;
} else {
log.warn("Original value is neither string nor array of strings - cannot modify values");
return orig;
......
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cz.muni.ics</groupId>
<artifactId>perun-oidc-parent</artifactId>
<version>18.2.0</version>
<version>18.3.0</version>
<packaging>pom</packaging>
<modules>
......