Skip to content

Commit

Permalink
SHIBUI-2268
Browse files Browse the repository at this point in the history
UI needed bits
  • Loading branch information
chasegawa committed Aug 9, 2022
1 parent 2f1326c commit c3d99fa
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController

import javax.annotation.PostConstruct

import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaLocationLookup.algorithmFilterSchema
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR

/**
Expand Down Expand Up @@ -51,6 +52,6 @@ class AlgorithmFilterUiDefinitionController {

@PostConstruct
void init() {
// this.jsonSchemaLocation = algorithmFilterSchema(this.jsonSchemaResourceLocationRegistry)
this.jsonSchemaLocation = algorithmFilterSchema(this.jsonSchemaResourceLocationRegistry)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocationRegistry;
import edu.internet2.tier.shibboleth.admin.ui.security.repository.UserRepository;
import edu.internet2.tier.shibboleth.admin.ui.security.service.UserService;
import edu.internet2.tier.shibboleth.admin.ui.service.JsonSchemaBuilderService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;

import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.*;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.JsonSchemaLocationBuilder;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.ALGORITHM_FILTER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.ENTITY_ATTRIBUTES_FILTERS;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.EXTERNAL_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.METADATA_SOURCES;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.FILESYSTEM_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.LOCAL_DYNAMIC_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.METADATA_SOURCES;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.NAME_ID_FORMAT_FILTER;

/**
Expand Down Expand Up @@ -58,8 +57,16 @@ public class JsonSchemaComponentsConfiguration {
@Setter
private String nameIdFormatFilterUiSchemaLocation = "classpath:nameid-filter.schema.json";

//Configured via @ConfigurationProperties (using setter method) with 'shibui.external-metadata-resolver-ui-schema-location' property and
// default value set here if that property is not explicitly set in application.properties
@Setter
private String externalMetadataResolverUiSchemaLocation = "classpath:external.schema.json";

//Configured via @ConfigurationProperties (using setter method) with 'shibui.algorithm-filter-ui-schema-location' property and
// default value set here if that property is not explicitly set in application.properties
@Setter
private String algorithmFilterUiSchemaLocation = "classpath:algorithm-filter.schema.json";

@Bean
public JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry(ResourceLoader resourceLoader, ObjectMapper jacksonMapper) {
return JsonSchemaResourceLocationRegistry.inMemory()
Expand Down Expand Up @@ -104,6 +111,12 @@ public JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry(Res
.resourceLoader(resourceLoader)
.jacksonMapper(jacksonMapper)
.detectMalformedJson(true)
.build())
.register(ALGORITHM_FILTER, JsonSchemaLocationBuilder.with()
.jsonSchemaLocation(algorithmFilterUiSchemaLocation)
.resourceLoader(resourceLoader)
.jacksonMapper(jacksonMapper)
.detectMalformedJson(true)
.build());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package edu.internet2.tier.shibboleth.admin.ui.jsonschema;

import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.ALGORITHM_FILTER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.ENTITY_ATTRIBUTES_FILTERS;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.EXTERNAL_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.METADATA_SOURCES;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.FILESYSTEM_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.LOCAL_DYNAMIC_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.METADATA_SOURCES;
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.NAME_ID_FORMAT_FILTER;

/**
Expand Down Expand Up @@ -106,15 +107,15 @@ public static JsonSchemaResourceLocation nameIdFormatFilterSchema(JsonSchemaReso
.orElseThrow(() -> new IllegalStateException("JSON schema resource location for name id format filter is not registered."));
}

// /**
// * Searches algorithm filter JSON schema resource location object in the given location registry.
// *
// * @param resourceLocationRegistry
// * @return algorithm filter JSON schema resource location object
// * @throws IllegalStateException if schema is not found in the given registry
// */
// public static JsonSchemaResourceLocation algorithmFilterSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) {
// return resourceLocationRegistry.lookup(ALGORITHM_FILTER)
// .orElseThrow(() -> new IllegalStateException("JSON schema resource location for algorithm filter is not registered."));
// }
/**
* Searches algorithm filter JSON schema resource location object in the given location registry.
*
* @param resourceLocationRegistry
* @return algorithm filter JSON schema resource location object
* @throws IllegalStateException if schema is not found in the given registry
*/
public static JsonSchemaResourceLocation algorithmFilterSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) {
return resourceLocationRegistry.lookup(ALGORITHM_FILTER)
.orElseThrow(() -> new IllegalStateException("JSON schema resource location for algorithm filter is not registered."));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public enum SchemaType {
// filter types
ENTITY_ATTRIBUTES_FILTERS("EntityAttributesFilters"),
NAME_ID_FORMAT_FILTER("NameIdFormatFilter"),
ALGORITHM_FILTER("AlgorithmFilter"),

// resolver types
FILE_BACKED_HTTP_METADATA_RESOLVER("FileBackedHttpMetadataResolver"),
Expand Down
50 changes: 41 additions & 9 deletions backend/src/main/resources/algorithm-filter.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
"name"
],
"properties": {
"@type": {
"type": "string",
"default": "Algorithm"
},
"name": {
"title": "label.filter-algorithm",
"description": "tooltip.filter-algorithm",
"title": "label.filter-name",
"description": "tooltip.filter-name",
"type": "string"
},
"filterEnabled": {
Expand All @@ -19,14 +15,50 @@
"type": "boolean",
"default": false
},
"AlgorithmFilterTarget": {
"title": "label.search-criteria",
"description": "tooltip.search-criteria",
"type": "object",
"properties": {
"nameIdFormatFilterTargetType": {
"title": "label.filter-target-type",
"type": "string",
"default": "ENTITY",
"enum": [
"ENTITY",
"CONDITION_REF",
"CONDITION_SCRIPT"
],
"enumNames": [
"value.entity-id",
"value.reference",
"value.script"
]
},
"value": {
"title": "label.filter-target-value",
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "string"
}
}
},
"required": [
"value",
"algorithmFilterTargetType"
]
},
"@type": {
"type": "string",
"default": "Algorithm"
},
"version": {
"type": "integer"
},
"resourceId": {
"type": "string"
},
"unknownXMLObjects": {

}
},
"definitions": {}
Expand Down
1 change: 1 addition & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ value.false=false
value.regex=Regex
value.script=Script
value.entity-id=Entity ID
value.reference=Condition Ref

value.support=Support
value.technical=Technical
Expand Down
1 change: 1 addition & 0 deletions backend/src/main/resources/i18n/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ value.false=false
value.regex=Regex
value.script=Script
value.entity-id=Entity ID
value.reference=Condition Ref

value.support=Support
value.technical=Technical
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.springframework.test.context.ActiveProfiles
import spock.lang.Specification

import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.*
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.ALGORITHM_FILTER
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.DYNAMIC_HTTP_METADATA_RESOLVER
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.ENTITY_ATTRIBUTES_FILTERS
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.SchemaType.FILESYSTEM_METADATA_RESOLVER
Expand Down Expand Up @@ -87,6 +88,12 @@ class BadJSONMetadataSourcesUiDefinitionControllerIntegrationTests extends Speci
.jacksonMapper(jacksonMapper)
.detectMalformedJson(false)
.build())
.register(ALGORITHM_FILTER, JsonSchemaLocationBuilder.with()
.jsonSchemaLocation('classpath:algorithm-filter.schema.json')
.resourceLoader(resourceLoader)
.jacksonMapper(jacksonMapper)
.detectMalformedJson(false)
.build())

}
}
Expand Down

0 comments on commit c3d99fa

Please sign in to comment.