Skip to content

Commit

Permalink
[SHIBUI-812]
Browse files Browse the repository at this point in the history
Added application.yml which contains default filter attributes
as well as a placeholder for new custom attributes.
Added CustomAttributesConfiguration and supporting code to allow for
reading from the application.yml.
Updated ModelRepresentationConversions to support multiple release attributes.
Updated unit tests to attempt to fix the negative refresh delay issue. Again.
Added spring-boot-configuration-processor to backend build to support
@ConfigurationProperties.
  • Loading branch information
Bill Smith committed Sep 18, 2018
1 parent 37e8347 commit 3b6de6b
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 11 deletions.
6 changes: 5 additions & 1 deletion backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ dependencies {
//JSON schema generator
testCompile 'com.kjetland:mbknor-jackson-jsonschema_2.12:1.0.29'
testCompile 'javax.validation:validation-api:2.0.1.Final'

//Configuration Annotation Processor
//This could go in the spring boot section above, but I wasn't sure about the compileOnly vs compile
compileOnly "org.springframework.boot:spring-boot-configuration-processor"
}

def generatedSrcDir = new File(buildDir, 'generated/src/main/java')
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
@@ -1,5 +1,6 @@
package edu.internet2.tier.shibboleth.admin.ui;

import edu.internet2.tier.shibboleth.admin.ui.configuration.CustomAttributesConfiguration;
import edu.internet2.tier.shibboleth.admin.ui.repository.MetadataResolverRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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 @@ -41,6 +42,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 @@ -168,4 +170,9 @@ public DirectoryService directoryService() {
public LuceneUtility luceneUtility(DirectoryService directoryService) {
return new LuceneUtility(directoryService);
}

@Bean
public CustomAttributesConfiguration customAttributesConfiguration() {
return new CustomAttributesConfiguration();
}
}
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.HashMap;
import java.util.List;

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

private List<HashMap<String, String>> attributes = new ArrayList<>();

public List<HashMap<String, String>> getAttributes() {
return attributes;
}

public void setAttributes(List<HashMap<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 @@ -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: eduPersonPrincipalName (EPPN)
- name: uid
displayName: uid
- name: mail
displayName: mail
- name: surname
displayName: surname
- name: givenName
displayName: givenName
- name: eduPersonAffiliation
displayName: eduPersonAffiliation
- name: eduPersonScopedAffiliation
displayName: eduPersonScopedAffiliation
- name: eduPersonPrimaryAffiliation
displayName: eduPersonPrimaryAffiliation
- name: eduPersonEntitlement
displayName: eduPersonEntitlement
- name: eduPersonAssurance
displayName: eduPersonAssurance
- name: eduPersonUniqueId
displayName: eduPersonUniqueId
- name: employeeNumber
displayName: employeeNumber
# Custom attributes
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ class TestObjectGenerator {
it.metadataURL = 'https://idp.unicon.net/idp/shibboleth'

it.reloadableMetadataResolverAttributes = new ReloadableMetadataResolverAttributes().with {
it.minRefreshDelay = 'PT0M'
it.maxRefreshDelay = 'P1D'
it
}
it
Expand Down
4 changes: 3 additions & 1 deletion backend/src/test/resources/conf/278.2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
<MetadataProvider id="HTTPMetadata"
xsi:type="FileBackedHTTPMetadataProvider"
backingFile="unicon.xml"
metadataURL="https://idp.unicon.net/idp/shibboleth">
metadataURL="https://idp.unicon.net/idp/shibboleth"
minRefreshDelay='PT0M'
maxRefreshDelay='P1D'>
<MetadataFilter xsi:type="SignatureValidation" requireSignedRoot="true"
certificateFile="%{idp.home}/credentials/inc-md-cert.pem" />
</MetadataProvider>
Expand Down
4 changes: 3 additions & 1 deletion backend/src/test/resources/conf/278.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
<MetadataProvider id="HTTPMetadata"
xsi:type="FileBackedHTTPMetadataProvider"
backingFile="unicon.xml"
metadataURL="https://idp.unicon.net/idp/shibboleth">
metadataURL="https://idp.unicon.net/idp/shibboleth"
minRefreshDelay='PT0M'
maxRefreshDelay='P1D'>
<MetadataFilter xsi:type="SignatureValidation" requireSignedRoot="true"
certificateFile="%{idp.home}/credentials/inc-md-cert.pem" />
</MetadataProvider>
Expand Down
4 changes: 3 additions & 1 deletion backend/src/test/resources/conf/532.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<MetadataProvider id="HTTPMetadata"
xsi:type="FileBackedHTTPMetadataProvider"
backingFile="unicon.xml"
metadataURL="https://idp.unicon.net/idp/shibboleth" />
metadataURL="https://idp.unicon.net/idp/shibboleth"
minRefreshDelay='PT0M'
maxRefreshDelay='P1D' />
</MetadataProvider>

0 comments on commit 3b6de6b

Please sign in to comment.