Skip to content

Commit

Permalink
Sort attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Oct 7, 2023
1 parent 9fe4a74 commit 471fa53
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mujina-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.openconext</groupId>
<artifactId>mujina</artifactId>
<version>8.0.6</version>
<version>8.0.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion mujina-idp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.openconext</groupId>
<artifactId>mujina</artifactId>
<version>8.0.6</version>
<version>8.0.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
9 changes: 8 additions & 1 deletion mujina-idp/src/main/java/mujina/idp/UserController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mujina.idp;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -10,9 +11,13 @@
import org.springframework.web.bind.annotation.GetMapping;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.Comparator;
import java.util.List;
import java.util.Map;

import static java.util.Comparator.comparing;

@Controller
public class UserController {

Expand All @@ -25,7 +30,9 @@ public UserController(ObjectMapper objectMapper,

DefaultResourceLoader loader = new DefaultResourceLoader();
this.samlAttributes = objectMapper.readValue(
loader.getResource(samlAttributesConfigFile).getInputStream(), List.class);
loader.getResource(samlAttributesConfigFile).getInputStream(), new TypeReference<>() {
});
this.samlAttributes.sort(comparing(m -> m.get("id")));
}

@GetMapping("/")
Expand Down
3 changes: 2 additions & 1 deletion mujina-idp/src/main/resources/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ <h1>Mujina Identity Provider</h1>
<label for="add-attribute" class="sr-only">Select attributes</label>
<select class="attribute-select" id="add-attribute">
<option value="Add attribute...">Add attribute...</option>
<option th:each="attr : ${samlAttributes}" th:value="${attr.get('name')}"
<option th:each="attr : ${samlAttributes}"
th:value="${attr.get('name')}"
th:text="${attr.get('id')}"
th:attr="data-multiplicity=${attr.get('multiplicity')}"></option>
</select>
Expand Down
2 changes: 1 addition & 1 deletion mujina-sp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.openconext</groupId>
<artifactId>mujina</artifactId>
<version>8.0.6</version>
<version>8.0.7</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.List;
import java.util.Optional;

import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toList;

public class DefaultSAMLUserDetailsService implements SAMLUserDetailsService {
Expand All @@ -28,7 +29,7 @@ public Principal loadUserBySAML(SAMLCredential credential) {
attribute.getName(),
attribute.getAttributeValues().stream().map(SAMLBuilder::getStringValueFromXMLObject)
.filter(Optional::isPresent).map(Optional::get).collect(toList()))).collect(toList());

attributes.sort(comparing(SAMLAttribute::getName));
NameID nameID = credential.getNameID();
return new SAMLPrincipal(nameID.getValue(), nameID.getFormat(), attributes);
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<groupId>org.openconext</groupId>
<artifactId>mujina</artifactId>
<version>8.0.6</version>
<version>8.0.7</version>
<packaging>pom</packaging>

<parent>
Expand Down

0 comments on commit 471fa53

Please sign in to comment.