Skip to content

Commit

Permalink
Merge branch 'SHIBUI-905' into SHIBUI-906
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Smith committed Oct 9, 2018
2 parents c8643d8 + 145f18d commit 8b0a1ed
Show file tree
Hide file tree
Showing 54 changed files with 2,265 additions and 424 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package edu.internet2.tier.shibboleth.admin.ui.controller

import com.fasterxml.jackson.databind.ObjectMapper
import edu.internet2.tier.shibboleth.admin.ui.configuration.CustomAttributesConfiguration
import groovy.json.JsonOutput
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.core.io.ResourceLoader
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

import javax.annotation.PostConstruct

import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR

/**
* Controller implementing REST resource responsible for exposing structure definition for metadata sources user
* interface in terms of JSON schema.
*
* @author Dmitriy Kopylenko
*/
@RestController('/api/ui/MetadataSources')
@ConfigurationProperties('shibui')
class MetadataSourcesUiDefinitionController {

//Configured via @ConfigurationProperties with 'shibui.metadata-sources-ui-schema-location' property and default
//value set here if that property is not explicitly set in application.properties
String metadataSourcesUiSchemaLocation = 'classpath:metadata-sources-ui-schema.json'

URL jsonSchemaUrl

@Autowired
ResourceLoader resourceLoader

@Autowired
ObjectMapper jacksonObjectMapper

@Autowired
CustomAttributesConfiguration customAttributesConfiguration

@GetMapping
ResponseEntity<?> getUiDefinitionJsonSchema() {
try {
def parsedJson = jacksonObjectMapper.readValue(this.jsonSchemaUrl, Map)
def widget = parsedJson["properties"]["attributeRelease"]["widget"]
def data = []
customAttributesConfiguration.getAttributes().each {
def attribute = [:]
attribute["key"] = it["name"]
attribute["label"] = it["displayName"]
data << attribute
}
widget["data"] = data
return ResponseEntity.ok(parsedJson)
}
catch (Exception e) {
return ResponseEntity.status(INTERNAL_SERVER_ERROR)
.body([jsonParseError : e.getMessage(),
sourceUiSchemaDefinitionFile: this.jsonSchemaUrl])
}
}

@PostConstruct
def init() {
jsonSchemaUrl = this.resourceLoader.getResource(this.metadataSourcesUiSchemaLocation).getURL()
}
}
3 changes: 3 additions & 0 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ spring.profiles.active=default

#shibui.default-password=

shibui.metadata-sources-ui-schema-location=classpath:metadata-sources-ui-schema.json

#Actuator endpoints (info)
# Un-comment to get full git details exposed like author, abbreviated SHA-1, commit message
#management.info.git.mode=full

2 changes: 1 addition & 1 deletion backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ tooltip.enable-provider-upon-saving=Enable Metadata Provider upon saving?
tooltip.max-validity-interval=Defines the window within which the metadata is valid.
tooltip.require-signed-root=If true, this fails to load metadata with no signature on the root XML element.
tooltip.certificate-file=A key used to verify the signature. Conflicts with trustEngineRef and both of the child elements.
tooltip.retained-roles=Retained Roles
tooltip.retained-roles=Controls whether to keep entity descriptors that contain no roles
tooltip.remove-roleless-entity-descriptors=Controls whether to keep entity descriptors that contain no roles.
tooltip.remove-empty-entities-descriptors=Controls whether to keep entities descriptors that contain no entity descriptors.

Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ tooltip.enable-provider-upon-saving=Enable Metadata Provider upon saving?
tooltip.max-validity-interval=Defines the window within which the metadata is valid.
tooltip.require-signed-root=If true, this fails to load metadata with no signature on the root XML element.
tooltip.certificate-file=A key used to verify the signature. Conflicts with trustEngineRef and both of the child elements.
tooltip.retained-roles=Retained Roles
tooltip.retained-roles=Controls whether to keep entity descriptors that contain no roles
tooltip.remove-roleless-entity-descriptors=Controls whether to keep entity descriptors that contain no roles.
tooltip.remove-empty-entities-descriptors=Controls whether to keep entities descriptors that contain no entity descriptors.

Expand Down
Loading

0 comments on commit 8b0a1ed

Please sign in to comment.