-
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.
Merge branch 'SHIBUI-906' of bitbucket.org:unicon/shib-idp-ui into SH…
…IBUI-906
- Loading branch information
Showing
22 changed files
with
230 additions
and
94 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
.../tier/shibboleth/admin/ui/controller/EntityAttributesFiltersUiDefinitionController.groovy
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,61 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.controller | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation | ||
import edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocationRegistry | ||
import edu.internet2.tier.shibboleth.admin.ui.service.JsonSchemaBuilderService | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
import javax.annotation.PostConstruct | ||
|
||
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.entityAttributesFiltersSchema | ||
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 | ||
* @author Bill Smith (wsmith@unicon.net) | ||
*/ | ||
@RestController | ||
@RequestMapping('/api/ui/EntityAttributesFilters') | ||
class EntityAttributesFiltersUiDefinitionController { | ||
|
||
@Autowired | ||
JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry | ||
|
||
JsonSchemaResourceLocation jsonSchemaLocation | ||
|
||
@Autowired | ||
ObjectMapper jacksonObjectMapper | ||
|
||
@Autowired | ||
JsonSchemaBuilderService jsonSchemaBuilderService | ||
|
||
@GetMapping | ||
ResponseEntity<?> getUiDefinitionJsonSchema() { | ||
try { | ||
def parsedJson = jacksonObjectMapper.readValue(this.jsonSchemaLocation.url, Map) | ||
jsonSchemaBuilderService.addReleaseAttributesToJson(parsedJson['properties']['attributeRelease']['widget']) | ||
jsonSchemaBuilderService.addRelyingPartyOverridesToJson(parsedJson['properties']['relyingPartyOverrides']) | ||
jsonSchemaBuilderService.addRelyingPartyOverridesCollectionDefinitionsToJson(parsedJson["definitions"]) | ||
return ResponseEntity.ok(parsedJson) | ||
} | ||
catch (Exception e) { | ||
e.printStackTrace() | ||
return ResponseEntity.status(INTERNAL_SERVER_ERROR) | ||
.body([jsonParseError : e.getMessage(), | ||
sourceUiSchemaDefinitionFile: this.jsonSchemaLocation.url]) | ||
} | ||
} | ||
|
||
@PostConstruct | ||
void init() { | ||
this.jsonSchemaLocation = entityAttributesFiltersSchema(this.jsonSchemaResourceLocationRegistry); | ||
} | ||
} |
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
61 changes: 61 additions & 0 deletions
61
...ain/groovy/edu/internet2/tier/shibboleth/admin/ui/service/JsonSchemaBuilderService.groovy
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,61 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.service | ||
|
||
import edu.internet2.tier.shibboleth.admin.ui.configuration.CustomPropertiesConfiguration | ||
import org.springframework.beans.factory.annotation.Autowired | ||
|
||
/** | ||
* @author Bill Smith (wsmith@unicon.net) | ||
*/ | ||
class JsonSchemaBuilderService { | ||
|
||
@Autowired | ||
CustomPropertiesConfiguration customPropertiesConfiguration | ||
|
||
void addReleaseAttributesToJson(Object json) { | ||
json['data'] = customPropertiesConfiguration.getAttributes().collect { | ||
[key: it['name'], label: it['displayName']] | ||
} | ||
} | ||
|
||
void addRelyingPartyOverridesToJson(Object json) { | ||
def properties = [:] | ||
customPropertiesConfiguration.getOverrides().each { | ||
def property | ||
if (it['displayType'] == 'list' | ||
|| it['displayType'] == 'set') { | ||
property = [$ref: '#/definitions/' + it['name']] | ||
} else { | ||
property = | ||
[title : it['displayName'], | ||
description: it['helpText'], | ||
type : it['displayType'], | ||
default : it['defaultValue']] | ||
} | ||
properties[(String) it['name']] = property | ||
} | ||
json['properties'] = properties | ||
} | ||
|
||
void addRelyingPartyOverridesCollectionDefinitionsToJson(Object json) { | ||
customPropertiesConfiguration.getOverrides().stream().filter { | ||
it -> it['displayType'] && (it['displayType'] == 'list' || it['displayType'] == 'set') | ||
}.each { | ||
def definition = [title : it['displayName'], | ||
description: it['helpText'], | ||
type : 'array', | ||
default : null] | ||
if (it['displayType'] == 'set') { | ||
definition['uniqueItems'] = true | ||
} else if (it['displayType'] == 'list') { | ||
definition['uniqueItems'] = false | ||
} | ||
def items = [type : 'string', | ||
minLength: '1', // TODO: should this be configurable? | ||
maxLength: '255'] //TODO: or this? | ||
items.widget = [id: 'datalist', data: it['defaultValues']] | ||
|
||
definition['items'] = items | ||
json[(String) it['name']] = definition | ||
} | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,5 +222,7 @@ | |
"attributeRelease" | ||
] | ||
} | ||
] | ||
], | ||
"definitions": { | ||
} | ||
} |
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
Oops, something went wrong.