Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jj committed Sep 25, 2018
2 parents 46da4d6 + 9444d86 commit d77f55b
Show file tree
Hide file tree
Showing 166 changed files with 3,135 additions and 5,343 deletions.
6 changes: 5 additions & 1 deletion backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ dependencies {
// TODO: figure out what this should really be
runtimeOnly 'org.springframework.boot:spring-boot-starter-tomcat'

//Spring Configuration Annotation Processor - makes IntelliJ happy about @ConfigurationProperties
compileOnly "org.springframework.boot:spring-boot-configuration-processor"

// lucene deps
['core', 'analyzers-common', 'queryparser'].each {
compile "org.apache.lucene:lucene-${it}:${project.'lucene.version'}"
Expand All @@ -100,6 +103,7 @@ dependencies {

//Swagger
compile 'io.springfox:springfox-swagger2:2.9.2'
compile 'io.springfox:springfox-swagger-ui:2.9.2'

testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile "org.spockframework:spock-core:1.1-groovy-2.4"
Expand Down Expand Up @@ -217,4 +221,4 @@ docker {
noCache true
files tasks.bootWar.outputs
buildArgs(['JAR_FILE': 'shibui.war'])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
Expand All @@ -42,6 +43,7 @@
import javax.servlet.http.HttpServletRequest;

@Configuration
@EnableConfigurationProperties(CustomAttributesConfiguration.class)
public class CoreShibUiConfiguration {
private static final Logger logger = LoggerFactory.getLogger(CoreShibUiConfiguration.class);

Expand Down Expand Up @@ -170,6 +172,11 @@ public LuceneUtility luceneUtility(DirectoryService directoryService) {
return new LuceneUtility(directoryService);
}

@Bean
public CustomAttributesConfiguration customAttributesConfiguration() {
return new CustomAttributesConfiguration();
}

@Bean
public Module stringTrimModule() {
return new StringTrimModule();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package edu.internet2.tier.shibboleth.admin.ui.configuration;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
* @author Bill Smith (wsmith@unicon.net)
*/
@Configuration
@ConfigurationProperties(prefix="custom")
public class CustomAttributesConfiguration {

private List<? extends Map<String, String>> attributes = new ArrayList<>();

public List<? extends Map<String, String>> getAttributes() {
return attributes;
}

public void setAttributes(List<? extends Map<String, String>> attributes) {
this.attributes = attributes;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package edu.internet2.tier.shibboleth.admin.ui.controller;

import edu.internet2.tier.shibboleth.admin.ui.configuration.CustomAttributesConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
* @author Bill Smith (wsmith@unicon.net)
*/
@Controller
@RequestMapping(value = "/api")
public class ConfigurationController {

@Autowired
CustomAttributesConfiguration customAttributesConfiguration;

@GetMapping(value = "/customAttributes")
public ResponseEntity<?> getCustomAttributes() {
return ResponseEntity.ok(customAttributesConfiguration.getAttributes());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.stream.Collectors;

/**
* @author Bill Smith (wsmith@unicon.net)
Expand All @@ -22,4 +28,33 @@ public class InternationalizationMessagesController {
public ResponseEntity<?> getAll(Locale locale) {
return ResponseEntity.ok(messageSource.getMessagesMap(locale));
}

@GetMapping(value = "/available")
public ResponseEntity<?> getAvailableLocales() {
Set<ResourceBundle> supportedLocaleResourceBundles = getResourceBundles();
Set<Locale> supportedLocales = supportedLocaleResourceBundles
.stream()
.map(ResourceBundle::getLocale)
.collect(Collectors.toSet());
return ResponseEntity.ok(supportedLocales);
}

/**
* Get all available resource bundles in i18n/messages that matches a locale supported by this JRE.
*
* @return a set of resource bundles for supported locales for this system
*/
private Set<ResourceBundle> getResourceBundles() {
Set<ResourceBundle> resourceBundles = new HashSet<>();

for (Locale locale : Locale.getAvailableLocales()) {
try {
resourceBundles.add(ResourceBundle.getBundle("i18n/messages", locale));
} catch (MissingResourceException e) {
// do nothing
}
}

return Collections.unmodifiableSet(resourceBundles);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,11 @@ public static List<String> getAttributeReleaseListFromAttributeList(List<Attribu
.filter(attribute -> attribute.getName().equals(MDDCConstants.RELEASE_ATTRIBUTES))
.collect(Collectors.toList());

if (releaseAttributes.size() != 1) {
// TODO: What do we do if there is more than one?
}
if (releaseAttributes.size() == 0) {
return new ArrayList<>();
} else {
return getStringListOfAttributeValues(releaseAttributes.get(0).getAttributeValues());
List<String> attributeValues = new ArrayList<>();
for (Attribute attribute : releaseAttributes) {
attributeValues.addAll(getStringListOfAttributeValues(attribute.getAttributeValues()));
}
return attributeValues;
}

public static boolean getBooleanValueOfAttribute(Attribute attribute) {
Expand Down
28 changes: 28 additions & 0 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
custom:
attributes:
# Default attributes
- name: eduPersonPrincipalName
displayName: label.attribute-eduPersonPrincipalName
- name: uid
displayName: label.attribute-uid
- name: mail
displayName: label.attribute-mail
- name: surname
displayName: label.attribute-surname
- name: givenName
displayName: label.attribute-givenName
- name: eduPersonAffiliation
displayName: label.attribute-eduPersonAffiliation
- name: eduPersonScopedAffiliation
displayName: label.attribute-eduPersonScopedAffiliation
- name: eduPersonPrimaryAffiliation
displayName: label.attribute-eduPersonPrimaryAffiliation
- name: eduPersonEntitlement
displayName: label.attribute-eduPersonEntitlement
- name: eduPersonAssurance
displayName: label.attribute-eduPersonAssurance
- name: eduPersonUniqueId
displayName: label.attribute-eduPersonUniqueId
- name: employeeNumber
displayName: label.attribute-employeeNumber
# Custom attributes
Loading

0 comments on commit d77f55b

Please sign in to comment.