-
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.
- Loading branch information
Showing
13 changed files
with
241 additions
and
73 deletions.
There are no files selected for viewing
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
50 changes: 50 additions & 0 deletions
50
...u/internet2/tier/shibboleth/admin/ui/configuration/JsonSchemaComponentsConfiguration.java
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,50 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.configuration; | ||
|
||
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 lombok.Setter; | ||
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.ShemaType.ENTITY_ATTRIBUTES_FILTERS; | ||
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.ShemaType.METADATA_SOURCES; | ||
|
||
/** | ||
* @author Dmitriy Kopylenko | ||
*/ | ||
@Configuration | ||
@ConfigurationProperties("shibui") | ||
public class JsonSchemaComponentsConfiguration { | ||
|
||
//Configured via @ConfigurationProperties (using setter method) with 'shibui.metadata-sources-ui-schema-location' property and default | ||
//value set here if that property is not explicitly set in application.properties | ||
@Setter | ||
private String metadataSourcesUiSchemaLocation = "classpath:metadata-sources-ui-schema.json"; | ||
|
||
//Configured via @ConfigurationProperties (using setter method) with 'shibui.entity-attributes-filters-ui-schema-location' property and | ||
// default value set here if that property is not explicitly set in application.properties | ||
@Setter | ||
private String entityAttributesFiltersUiSchemaLocation = "classpath:entity-attributes-filters-ui-schema.json"; | ||
|
||
@Bean | ||
public JsonSchemaResourceLocationRegistry jsonSchemaResourceLocationRegistry(ResourceLoader resourceLoader, ObjectMapper jacksonMapper) { | ||
return JsonSchemaResourceLocationRegistry.inMemory() | ||
.register(METADATA_SOURCES, JsonSchemaLocationBuilder.with() | ||
.jsonSchemaLocation(metadataSourcesUiSchemaLocation) | ||
.resourceLoader(resourceLoader) | ||
.jacksonMapper(jacksonMapper) | ||
.detectMalformedJson(true) | ||
.build()) | ||
.register(ENTITY_ATTRIBUTES_FILTERS, JsonSchemaLocationBuilder.with() | ||
.jsonSchemaLocation(entityAttributesFiltersUiSchemaLocation) | ||
.resourceLoader(resourceLoader) | ||
.jacksonMapper(jacksonMapper) | ||
.detectMalformedJson(true) | ||
.build()); | ||
|
||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
...2/tier/shibboleth/admin/ui/configuration/JsonSchemaValidationComponentsConfiguration.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
...rnet2/tier/shibboleth/admin/ui/jsonschema/InMemoryJsonSchemaResourceLocationRegistry.java
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,31 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.jsonschema; | ||
|
||
import java.util.EnumMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Default implementation of {@link JsonSchemaResourceLocationRegistry}. | ||
* <p> | ||
* This class has package private visibility as creation of it is delegated to public static factory method | ||
* on the registry interface itself. | ||
* | ||
* @author Dmitriy Kopylenko | ||
*/ | ||
class InMemoryJsonSchemaResourceLocationRegistry implements JsonSchemaResourceLocationRegistry { | ||
|
||
private Map<JsonSchemaResourceLocation.ShemaType, JsonSchemaResourceLocation> schemaLocations = | ||
new EnumMap<>(JsonSchemaResourceLocation.ShemaType.class); | ||
|
||
|
||
@Override | ||
public JsonSchemaResourceLocationRegistry register(JsonSchemaResourceLocation.ShemaType type, JsonSchemaResourceLocation location) { | ||
this.schemaLocations.put(type, location); | ||
return this; | ||
} | ||
|
||
@Override | ||
public Optional<JsonSchemaResourceLocation> lookup(JsonSchemaResourceLocation.ShemaType type) { | ||
return Optional.ofNullable(this.schemaLocations.get(type)); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...main/java/edu/internet2/tier/shibboleth/admin/ui/jsonschema/JsonSchemaLocationLookup.java
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,24 @@ | ||
package edu.internet2.tier.shibboleth.admin.ui.jsonschema; | ||
|
||
import static edu.internet2.tier.shibboleth.admin.ui.jsonschema.JsonSchemaResourceLocation.ShemaType.METADATA_SOURCES; | ||
|
||
/** | ||
* Utility methods for common JSON schema types lookups. | ||
* | ||
* @author Dmitriy Kopylenko | ||
*/ | ||
public abstract class JsonSchemaLocationLookup { | ||
|
||
/** | ||
* Searches metadata sources JSON schema resource location object in the given location registry. | ||
* | ||
* @param resourceLocationRegistry | ||
* @return metadata sources JSON schema resource location object | ||
* @throws IllegalStateException if schema is not found in the given registry | ||
*/ | ||
public static JsonSchemaResourceLocation metadataSourcesSchema(JsonSchemaResourceLocationRegistry resourceLocationRegistry) { | ||
return resourceLocationRegistry | ||
.lookup(METADATA_SOURCES) | ||
.orElseThrow(() -> new IllegalStateException("JSON schema resource location for metadata sources is not registered.")); | ||
} | ||
} |
Oops, something went wrong.