forked from OpenConext/Mujina
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Externalized SAML attribute and default value configuration
- Loading branch information
1 parent
47912a6
commit eff5ab8
Showing
4 changed files
with
66 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
mujina-idp/src/main/java/mujina/config/StandardAttributes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package mujina.config; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
@Component | ||
@ConfigurationProperties(prefix = "idp") | ||
public class StandardAttributes { | ||
|
||
private Map<String, String> attributes; | ||
|
||
private final Pattern escapedValuePattern = Pattern.compile("\\[(.*)]"); | ||
|
||
public void setAttributes(Map<String, String> attributes) { | ||
Map<String, String> processedAttributes = new HashMap<>(); | ||
|
||
for (Map.Entry<String, String> attribute : attributes.entrySet()) { | ||
Matcher matcher = escapedValuePattern.matcher(attribute.getKey()); | ||
processedAttributes.put(matcher.matches() ? matcher.group(1) : attribute.getKey(), attribute.getValue()); | ||
} | ||
|
||
this.attributes = processedAttributes; | ||
} | ||
|
||
public Map<String, String> getAttributes() { | ||
return attributes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters